Esempio n. 1
0
        protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
        {
            //clean up notifyicon (would otherwise stay open until application finishes)
            MainNotifyIcon.Dispose();

            base.OnClosing(e);
        }
Esempio n. 2
0
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                _tray?.Dispose();
                _container?.Dispose();
                _coreInvoker?.Dispose();
            }

            base.Dispose(disposing);
        }
Esempio n. 3
0
        protected override void OnFormClosing(FormClosingEventArgs e)
        {
            if (e.CloseReason == CloseReason.UserClosing)
            {
                e.Cancel    = true;
                WindowState = FormWindowState.Minimized;
                Hide();
            }
            else
            {
                MainNotifyIcon.Dispose( );

                base.OnFormClosing(e);
            }
        }
Esempio n. 4
0
        public MainForm()
        {
            InitializeComponent();
            try
            {
                XInputObj = new XInputManager();
                vJoyObj   = new vJoyManager();
                RefreshDeviceList();

                Application.ApplicationExit += new EventHandler(delegate(Object o, EventArgs a)
                {
                    StopThread();

                    // Bug or something but the notify icon lingers after exiting unless we explicitely dispose it
                    if (MainNotifyIcon != null)
                    {
                        MainNotifyIcon.Icon = null;
                        MainNotifyIcon.Dispose();
                        MainNotifyIcon = null;
                    }
                });

                string[] cmds = Environment.GetCommandLineArgs();
                HandleArguments(cmds);
            }
            catch (System.IO.FileNotFoundException e)
            {
                MessageBox.Show("FileNotFoundException: " + e.FileName + ". This may occur because of missing DLLs. Make sure to include everything! Application will exit..", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Environment.Exit(-1);
            }
            catch (Exception e)
            {
                MessageBox.Show("Error: " + e.Message + ". This may occur because of missing DLLs. Make sure to include everything! Application will exit..", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Environment.Exit(-1);
            }
        }