示例#1
0
        /*
         * Shows a notification asking the user if they are sure they would
         * like to exit the application when the Exit tray menu item has been
         * clicked, and cleanly closes the application if yes.
         */
        private void mnuExit_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show(this, "Closing this application will cause the Custom Mouse to operate only as a basic" +
                                                  " mouse without any additional features such as programmable hotkeys. Are you sure you would like to do this?", "Exiting Custom Mouse Controller",
                                                  MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2);

            if (result == DialogResult.Yes)
            {
                settings.SaveSettings();
                HardwareListener.Instance.Dispose();
                // the HardwareListener thread is exited from Program.cs after the UI thread to prevent
                // an issue where the stop signal is not sent to the Arduino
                Application.ExitThread();
            }
            else
            {
                if (Visible)
                {
                    Focus();
                }
            }
        }