Example #1
0
        void MainWindow_Closing(object sender, CancelEventArgs e)
        {
            // if anything has been added, edit'd or delete'd, ask if a save to the registry should be performed
            if (!ArrayHelpers.IsEquals(m_savedRegistryBytes, m_currentRegistryBytes))
            {
                var dlgRes = ShowDialog("You have made changes to the list of key mappings.\n\nDo you want to update the registry now?", "SharpKeys", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Stop, MessageBoxDefaultButton.Button3);
                switch (dlgRes)
                {
                case DialogResult.Cancel:
                    e.Cancel = true;
                    return;

                case DialogResult.Yes:
                    SetWaitState();
                    MainWindowController.Save(this);
                    SetReadyState();
                    UserMessage("Key Mappings have been successfully stored to the registry.\n\nPlease logout or reboot for these changes to take effect!", "SharpKeys");
                    break;
                }
            }

            // Only save the window position info on close; user is prompted to save mappings elsewhere
            PersistentOptions.SetWindowState(new PersistentOptions()
            {
                WindowState = WindowState, DesktopBounds = DesktopBounds, ShowWarning = m_windowOptions.ShowWarning
            });
        }
Example #2
0
 void LoadWindowDesktopBounds()
 {
     // First load the window positions from registry
     m_windowOptions = PersistentOptions.GetWindowState();
     if (m_windowOptions.ShowWarning == 0)
     {
         UserMessage("Welcome to SharpKeys!\n\nThis application will add one key to your registry that allows you\nto change how certain keys on your keyboard will work.\n\nYou must be running Windows 7/8/10 for this to be supported and\nyou'll be using SharpKeys at your own risk!\n\nEnjoy!\nexperimentalcommunity.org", "SharpKeys");
     }
 }
Example #3
0
        public static void SetWindowState(PersistentOptions windowOpitons)
        {
            var regKey = Registry.CurrentUser.CreateSubKey(m_strRegKey);

            if (regKey != null)
            {
                // Save Window Pos
                regKey.SetValue("MainWinState", (int)windowOpitons.WindowState);
                regKey.SetValue("MainX", windowOpitons.DesktopBounds.X);
                regKey.SetValue("MainY", windowOpitons.DesktopBounds.Y);
                regKey.SetValue("MainCX", windowOpitons.DesktopBounds.Width);
                regKey.SetValue("MainCY", windowOpitons.DesktopBounds.Height);
                regKey.SetValue("ShowWarning", 1);
                regKey.Close();
            }
        }
Example #4
0
        public static PersistentOptions GetWindowState()
        {
            var windowOptions = new PersistentOptions();
            var regKey        = Registry.CurrentUser.OpenSubKey(m_strRegKey);

            if (regKey != null)
            {
                // Load Window Pos
                windowOptions.WindowState          = (FormWindowState)regKey.GetValue("MainWinState", windowOptions.WindowState);
                windowOptions.DesktopBounds.X      = (int)regKey.GetValue("MainX", windowOptions.DesktopBounds.X);
                windowOptions.DesktopBounds.Y      = (int)regKey.GetValue("MainY", windowOptions.DesktopBounds.Y);
                windowOptions.DesktopBounds.Width  = (int)regKey.GetValue("MainCX", windowOptions.DesktopBounds.Width);
                windowOptions.DesktopBounds.Height = (int)regKey.GetValue("MainCY", windowOptions.DesktopBounds.Height);
                windowOptions.ShowWarning          = (int)regKey.GetValue("ShowWarning", windowOptions.ShowWarning);
                regKey.Close();
            }
            return(windowOptions);
        }