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
            });
        }