Example #1
0
 static void DisableRestoreAtLogon(string[] args)
 {
     if (RegistryHandler.DeregisterCurrentVersionRun())
     {
         Console.WriteLine("Profile has been deregistered.");
     }
     else
     {
         Console.WriteLine("No profile has been registered, no action needed.");
     }
 }
Example #2
0
        static void ListRegistryResolutionProfiles(string[] args)
        {
            List <string> profiles = RegistryHandler.getAllDefinedProfiles();

            if (profiles.Count > 0)
            {
                Console.WriteLine("Listing defined Profiles:");
                foreach (string profile in profiles)
                {
                    Console.WriteLine("  " + profile);
                }
            }
            else
            {
                Console.WriteLine("No profile have been defined.");
            }
        }
Example #3
0
        static void DeleteRegistryResolutionProfile(string[] args)
        {
            string    profileName = null;
            OptionSet p           = new OptionSet()
            {
                {
                    "p|profile=", "the {PROFILENAME} of the screen resolution. (\"Default\" is the default profile.)",
                    v => profileName = RegistryHandler.sanitizeProfileName(v)
                }
            };
            List <string> extra;

            try
            {
                extra = p.Parse(args);
            }
            catch (OptionException e)
            {
                Console.WriteLine("ERROR: " + e.Message);
                return;
            }

            if (profileName == null)
            {
                Console.WriteLine("ERROR: No profile name has not been specified.");
                return;
            }

            if (RegistryHandler.hasProfile(profileName))
            {
                Console.WriteLine("Deleting the profile " + profileName);
                RegistryHandler.deleteProfile(profileName);
            }
            else
            {
                Console.WriteLine("The profile " + profileName + " does not exist.");
            }
        }
Example #4
0
        static void RestoreCurrentResolution(string[] args)
        {
            string    profileName = "Default";
            bool      silent      = false;
            OptionSet p           = new OptionSet()
            {
                {
                    "p|profile=", "the {PROFILENAME} of the screen resolution. (\"Default\" is the default profile.)",
                    v => profileName = RegistryHandler.sanitizeProfileName(v)
                },
                {
                    "q|quiet", "be quiet",
                    v => silent = v != null
                }
            };
            List <string> extra;

            try
            {
                extra = p.Parse(args);
            }
            catch (OptionException e)
            {
                if (!silent)
                {
                    Console.WriteLine("ERROR: " + e.Message);
                }
                return;
            }

            foreach (RegistryProfileDeviceSettings rpds in RegistryHandler.getProfile(profileName))
            {
                try
                {
                    if (!silent)
                    {
                        Console.WriteLine("Restoring Screen resolution: " + rpds);
                    }
                    DISPLAY_DEVICE d = ScreenDevice.GetDesktopDeviceByName(rpds.DeviceName);
                    if (rpds.Frequency > 0 && rpds.Bits > 0)
                    {
                        try
                        {
                            ScreenDevice.ChangeResolution(ref d, rpds.Width, rpds.Height, rpds.Bits, rpds.Frequency);
                        }
                        catch (User32Exception)
                        {
                            rpds.Frequency = 0;
                            if (!silent)
                            {
                                Console.WriteLine("Failed to change resolution, restoring without frequency: " + rpds);
                            }
                            ScreenDevice.ChangeResolution(ref d, rpds.Width, rpds.Height, rpds.Bits);
                        }
                    }
                    else if (rpds.Bits > 0)
                    {
                        ScreenDevice.ChangeResolution(ref d, rpds.Width, rpds.Height, rpds.Bits);
                    }
                    else
                    {
                        ScreenDevice.ChangeResolution(ref d, rpds.Width, rpds.Height);
                    }
                }
                catch (Exception e)
                {
                    if (!silent)
                    {
                        Console.WriteLine("ERROR: " + e.Message);
                    }
                }
            }
            if (!silent)
            {
                Console.WriteLine("Screen resolution has been restored from profile \"" + profileName + "\".");
            }
        }