-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- `Card` command has been renamed to` Switch` - `Card` command now searches for the specified video card (or displays the entire list) - `Help` command has been improved
- Loading branch information
1 parent
06e7a1f
commit 5ea850a
Showing
13 changed files
with
146 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using CommandLine; | ||
|
||
namespace FYA.Options | ||
{ | ||
public class SwitchOptions | ||
{ | ||
#region Var | ||
[Option('i', "id", Required = true, SetName = "cardID", HelpText = "Video card's instance id")] | ||
public string ID { get; } | ||
|
||
[Option('n', "name", Required = true, SetName = "cardName", HelpText = "Video card's name")] | ||
public string Name { get; } | ||
|
||
[Option('d', "disable", HelpText = "Indicates turn on or off the specified video card")] | ||
public bool Disable { get; } | ||
#endregion | ||
|
||
#region Init | ||
public SwitchOptions(string ID, string Name, bool Disable) | ||
{ | ||
this.ID = ID ?? string.Empty; | ||
this.Name = Name ?? string.Empty; | ||
this.Disable = Disable; | ||
} | ||
#endregion | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,38 @@ | ||
using System; | ||
using FYA.Models; | ||
using FYA.Options; | ||
using FYA.PInvoke; | ||
using System.Linq; | ||
|
||
namespace FYA.Programs | ||
{ | ||
public class CardProgram : BaseProgram<CardOptions> | ||
{ | ||
public override string Usage => "fya card -d --name Intel"; | ||
public override string Description => "Enables or disables the specified video card"; | ||
public override string Usage => "fya card --name Intel"; | ||
public override string Description => "Searches for a specified video card or displays all"; | ||
|
||
public override void Run(CardOptions Options) | ||
{ | ||
string id = Options.ID.ToLower(); | ||
string name = Options.Name.ToLower(); | ||
|
||
Func<VideoCard, bool> predicate = string.IsNullOrEmpty(id) | ||
? new Func<VideoCard, bool>(x => x.Name.ToLower().Contains(name)) | ||
: x => x.ID.ToLower().Contains(id) || id.Contains(x.ID.ToLower()); | ||
Func<VideoCard, bool> predicate = !string.IsNullOrEmpty(name) | ||
? x => x.Name.ToLower().Contains(name) | ||
: !string.IsNullOrEmpty(id) | ||
? x => x.ID.ToLower().Contains(id) || id.Contains(x.ID.ToLower()) | ||
: new Func<VideoCard, bool>(x => true); | ||
|
||
VideoCard card = VideoCard.EnumerateVideoCards().FirstOrDefault(predicate); | ||
if (card is null) | ||
Console.WriteLine(); | ||
foreach (VideoCard card in VideoCard.EnumerateVideoCards().Where(predicate)) | ||
{ | ||
if (!string.IsNullOrEmpty(Options.ID)) | ||
try | ||
{ | ||
SetupAPI.ChangeDeviceState(VideoCard.VideoAdaptersClass, Options.ID, !Options.Disable); | ||
return; | ||
} catch { } | ||
PrintException("The specified video card was not found"); | ||
} | ||
else | ||
{ | ||
try | ||
{ | ||
if (Options.Disable) | ||
card.Disable(); | ||
else | ||
card.Enable(); | ||
} | ||
catch (Exception e) | ||
{ | ||
PrintException(e); | ||
} | ||
Console.ForegroundColor = ConsoleColor.White; | ||
Console.WriteLine("{0}:", card.Name); | ||
Console.ResetColor(); | ||
Console.WriteLine("ID: {0}", card.ID); | ||
Console.WriteLine("State: {0}", card.StateFlags); | ||
Console.WriteLine("Devices: {0}", string.Join(", ", card.Devices.Select(x => $"\"{x}\""))); | ||
Console.WriteLine("Keys: {0}", string.Join(", ", card.RegistryKeys.Select(x => $"\"{x}\""))); | ||
Console.WriteLine(); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using System; | ||
using FYA.Models; | ||
using FYA.Options; | ||
using FYA.PInvoke; | ||
using System.Linq; | ||
|
||
namespace FYA.Programs | ||
{ | ||
public class SwitchProgram : BaseProgram<SwitchOptions> | ||
{ | ||
public override string Usage => "fya switch --name Intel -d"; | ||
public override string Description => "Enables or disables the specified video card"; | ||
|
||
public override void Run(SwitchOptions Options) | ||
{ | ||
string id = Options.ID.ToLower(); | ||
string name = Options.Name.ToLower(); | ||
|
||
Func<VideoCard, bool> predicate = string.IsNullOrEmpty(id) | ||
? new Func<VideoCard, bool>(x => x.Name.ToLower().Contains(name)) | ||
: x => x.ID.ToLower().Contains(id) || id.Contains(x.ID.ToLower()); | ||
|
||
VideoCard card = VideoCard.EnumerateVideoCards().FirstOrDefault(predicate); | ||
if (card is null) | ||
{ | ||
if (!string.IsNullOrEmpty(Options.ID)) | ||
try | ||
{ | ||
SetupAPI.ChangeDeviceState(VideoCard.VideoAdaptersClass, Options.ID, !Options.Disable); | ||
return; | ||
} catch { } | ||
PrintException("The specified video card was not found"); | ||
} | ||
else | ||
{ | ||
try | ||
{ | ||
if (Options.Disable) | ||
card.Disable(); | ||
else | ||
card.Enable(); | ||
} | ||
catch (Exception e) | ||
{ | ||
PrintException(e); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,16 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
[assembly: AssemblyTitle("FYA")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("FYA")] | ||
[assembly: AssemblyCompany("Kir_Antipov")] | ||
[assembly: AssemblyTrademark("Kir_Antipov")] | ||
[assembly: AssemblyCopyright("Copyright © 2019")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
[assembly: AssemblyDescription("F*CK YOU ADOBE (a.k.a. FYA)")] | ||
|
||
// Setting ComVisible to false makes the types in this assembly not visible | ||
// to COM components. If you need to access a type in this assembly from | ||
// COM, set the ComVisible attribute to true on that type. | ||
[assembly: ComVisible(false)] | ||
|
||
// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
[assembly: Guid("91743895-7b0a-423f-a302-f029210412e3")] | ||
|
||
// Version information for an assembly consists of the following four values: | ||
// | ||
// Major Version | ||
// Minor Version | ||
// Build Number | ||
// Revision | ||
// | ||
// You can specify all the values or you can default the Build and Revision Numbers | ||
// by using the '*' as shown below: | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] | ||
[assembly: AssemblyVersion("1.1.0.0")] | ||
[assembly: AssemblyFileVersion("1.1.0.0")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
{ | ||
"profiles": { | ||
"FYA": { | ||
"commandName": "Project", | ||
"commandLineArgs": "shortcut" | ||
"commandName": "Project" | ||
} | ||
} | ||
} |