示例#1
0
        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);
                }
            }
        }
示例#2
0
 public void Disable() => SetupAPI.ChangeDeviceState(VideoAdaptersClass, ID, false);
示例#3
0
 public void Enable() => SetupAPI.ChangeDeviceState(VideoAdaptersClass, ID, true);