Esempio n. 1
0
        protected override void  Dispose(bool disposing)
        {
            if (disposing)
            {
                try
                {
                    Microsoft.Win32.SystemEvents.TimeChanged -= new EventHandler(SystemEvents_TimeChanged);

                    if (this.components != null)
                    {
                        this.components.Dispose();
                    }

                    if (this.mainForm != null)
                    {
                        if (this.mainForm.OnOffButton != null)
                        {
                            this.mainForm.OnOffButton.Switched -= new Growl.UI.OnOffSwitchedEventHandler(OnOffButton_Switched);
                        }

                        this.mainForm.FormClosed -= new FormClosedEventHandler(mainForm_FormClosed);
                        this.mainForm.Dispose();
                        this.mainForm = null;
                    }

                    if (this.settingsToolStripMenuItem != null)
                    {
                        this.settingsToolStripMenuItem.Click -= new System.EventHandler(this.settingsToolStripMenuItem_Click);
                        this.settingsToolStripMenuItem.Dispose();
                        this.settingsToolStripMenuItem = null;
                    }

                    if (this.pauseGrowlToolStripMenuItem != null)
                    {
                        this.pauseGrowlToolStripMenuItem.Click -= new System.EventHandler(this.pauseGrowlToolStripMenuItem_Click);
                        this.pauseGrowlToolStripMenuItem.Dispose();
                        this.pauseGrowlToolStripMenuItem = null;
                    }

                    if (this.unpauseGrowlToolStripMenuItem != null)
                    {
                        this.unpauseGrowlToolStripMenuItem.Click -= new System.EventHandler(this.unpauseGrowlToolStripMenuItem_Click);
                        this.unpauseGrowlToolStripMenuItem.Dispose();
                        this.unpauseGrowlToolStripMenuItem = null;
                    }

                    if (this.muteToolStripMenuItem != null)
                    {
                        this.muteToolStripMenuItem.Click -= new System.EventHandler(this.muteToolStripMenuItem_Click);
                        this.muteToolStripMenuItem.Dispose();
                        this.muteToolStripMenuItem = null;
                    }

                    if (this.unmuteToolStripMenuItem != null)
                    {
                        this.unmuteToolStripMenuItem.Click -= new System.EventHandler(this.unmuteToolStripMenuItem_Click);
                        this.unmuteToolStripMenuItem.Dispose();
                        this.unmuteToolStripMenuItem = null;
                    }

                    if (this.checkForUpdatesToolStripMenuItem != null)
                    {
                        this.checkForUpdatesToolStripMenuItem.Click -= new System.EventHandler(this.checkForUpdatesToolStripMenuItem_Click);
                        this.checkForUpdatesToolStripMenuItem.Dispose();
                        this.checkForUpdatesToolStripMenuItem = null;
                    }

                    if (this.exitToolStripMenuItem != null)
                    {
                        this.exitToolStripMenuItem.Click -= new System.EventHandler(this.exitToolStripMenuItem_Click);
                        this.exitToolStripMenuItem.Dispose();
                        this.exitToolStripMenuItem = null;
                    }

                    if (this.toolStripSeparator1 != null)
                    {
                        this.toolStripSeparator1.Dispose();
                        this.toolStripSeparator1 = null;
                    }

                    if (this.contextMenu != null)
                    {
                        this.contextMenu.Close();
                        this.contextMenu.Dispose();
                        this.contextMenu = null;
                    }

                    if (this.notifyIcon != null)
                    {
                        this.notifyIcon.DoubleClick -= new System.EventHandler(this.notifyIcon_DoubleClick);
                        this.notifyIcon.Dispose();
                        this.notifyIcon = null;
                    }

                    if (this.updateForm != null)
                    {
                        this.updateForm.Close();
                        this.updateForm.Dispose();
                        this.updateForm = null;
                    }

                    if (this.updater != null)
                    {
                        this.updater.CheckForUpdateComplete -= new CheckForUpdateCompleteEventHandler(updater_CheckForUpdateComplete);
                        this.updater.Dispose();
                        this.updater = null;
                    }

                    if (this.controller != null)
                    {
                        this.controller.FailedToStart          -= new EventHandler <PortConflictEventArgs>(controller_FailedToStart);
                        this.controller.FailedToStartUDPLegacy -= new EventHandler <PortConflictEventArgs>(controller_FailedToStartUDPLegacy);
                        this.controller.Dispose();
                        this.controller = null;
                    }

                    if (this.autoUpdateTimer != null)
                    {
                        this.autoUpdateTimer.Tick -= new EventHandler(autoUpdateTimer_Tick);
                        this.autoUpdateTimer.Dispose();
                        this.autoUpdateTimer = null;
                    }

                    UnregisterHotKeys();

                    if (this.wpr != null)
                    {
                        this.wpr.DestroyHandle();
                        this.wpr = null;
                    }
                }
                catch
                {
                    // suppress
                }
            }
            base.Dispose(disposing);
        }
Esempio n. 2
0
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                try
                {
                    Microsoft.Win32.SystemEvents.TimeChanged -= new EventHandler(SystemEvents_TimeChanged);

                    if (this.components != null)
                    {
                        this.components.Dispose();
                    }

                    if (this.mainForm != null)
                    {
                        if (this.mainForm.OnOffButton != null)
                        {
                            this.mainForm.OnOffButton.Switched -= new Growl.UI.OnOffSwitchedEventHandler(OnOffButton_Switched);
                        }

                        this.mainForm.FormClosed -= new FormClosedEventHandler(mainForm_FormClosed);
                        this.mainForm.Dispose();
                        this.mainForm = null;
                    }

                    if (this.settingsToolStripMenuItem != null)
                    {
                        this.settingsToolStripMenuItem.Click -= new System.EventHandler(this.settingsToolStripMenuItem_Click);
                        this.settingsToolStripMenuItem.Dispose();
                        this.settingsToolStripMenuItem = null;
                    }

                    if (this.pauseGrowlToolStripMenuItem != null)
                    {
                        this.pauseGrowlToolStripMenuItem.Click -= new System.EventHandler(this.pauseGrowlToolStripMenuItem_Click);
                        this.pauseGrowlToolStripMenuItem.Dispose();
                        this.pauseGrowlToolStripMenuItem = null;
                    }

                    if (this.unpauseGrowlToolStripMenuItem != null)
                    {
                        this.unpauseGrowlToolStripMenuItem.Click -= new System.EventHandler(this.unpauseGrowlToolStripMenuItem_Click);
                        this.unpauseGrowlToolStripMenuItem.Dispose();
                        this.unpauseGrowlToolStripMenuItem = null;
                    }

                    if (this.muteToolStripMenuItem != null)
                    {
                        this.muteToolStripMenuItem.Click -= new System.EventHandler(this.muteToolStripMenuItem_Click);
                        this.muteToolStripMenuItem.Dispose();
                        this.muteToolStripMenuItem = null;
                    }

                    if (this.unmuteToolStripMenuItem != null)
                    {
                        this.unmuteToolStripMenuItem.Click -= new System.EventHandler(this.unmuteToolStripMenuItem_Click);
                        this.unmuteToolStripMenuItem.Dispose();
                        this.unmuteToolStripMenuItem = null;
                    }

                    if (this.checkForUpdatesToolStripMenuItem != null)
                    {
                        this.checkForUpdatesToolStripMenuItem.Click -= new System.EventHandler(this.checkForUpdatesToolStripMenuItem_Click);
                        this.checkForUpdatesToolStripMenuItem.Dispose();
                        this.checkForUpdatesToolStripMenuItem = null;
                    }

                    if (this.exitToolStripMenuItem != null)
                    {
                        this.exitToolStripMenuItem.Click -= new System.EventHandler(this.exitToolStripMenuItem_Click);
                        this.exitToolStripMenuItem.Dispose();
                        this.exitToolStripMenuItem = null;
                    }

                    if (this.toolStripSeparator1 != null)
                    {
                        this.toolStripSeparator1.Dispose();
                        this.toolStripSeparator1 = null;
                    }

                    if (this.contextMenu != null)
                    {
                        this.contextMenu.Close();
                        this.contextMenu.Dispose();
                        this.contextMenu = null;
                    }

                    if (this.notifyIcon != null)
                    {
                        this.notifyIcon.DoubleClick -= new System.EventHandler(this.notifyIcon_DoubleClick);
                        this.notifyIcon.Dispose();
                        this.notifyIcon = null;
                    }

                    if (this.updateForm != null)
                    {
                        this.updateForm.Close();
                        this.updateForm.Dispose();
                        this.updateForm = null;
                    }

                    if (this.updater != null)
                    {
                        this.updater.CheckForUpdateComplete -= new CheckForUpdateCompleteEventHandler(updater_CheckForUpdateComplete);
                        this.updater.Dispose();
                        this.updater = null;
                    }

                    if (this.controller != null)
                    {
                        this.controller.FailedToStart -= new EventHandler<PortConflictEventArgs>(controller_FailedToStart);
                        this.controller.FailedToStartUDPLegacy -= new EventHandler<PortConflictEventArgs>(controller_FailedToStartUDPLegacy);
                        this.controller.Dispose();
                        this.controller = null;
                    }

                    if (this.autoUpdateTimer != null)
                    {
                        this.autoUpdateTimer.Tick -= new EventHandler(autoUpdateTimer_Tick);
                        this.autoUpdateTimer.Dispose();
                        this.autoUpdateTimer = null;
                    }

                    UnregisterHotKeys();

                    if (this.wpr != null)
                    {
                        this.wpr.DestroyHandle();
                        this.wpr = null;
                    }
                }
                catch
                {
                    // suppress
                }
            }
            base.Dispose(disposing);
        }
Esempio n. 3
0
        public void Run()
        {
            if (!this.running)
            {
                this.running = true;

                InitializeComponent();

                // SUPER IMPORTANT - since we are using the contextMenu as the synchronizing object, its .Handle must be created first
                // this will force creation of the handle without showing the menu
                Utility.WriteDebugInfo("ContextMenu Handle: {0}", this.contextMenu.Handle);

                // scaling factor
                float currentDPI = 0;
                using (Graphics g = this.contextMenu.CreateGraphics())
                {
                    currentDPI = g.DpiX;
                }
                ApplicationMain.ScalingFactor = currentDPI / 96;

                // configure the controller
                this.controller = Controller.GetController();
                this.controller.FailedToStart          += new EventHandler <PortConflictEventArgs>(controller_FailedToStart);
                this.controller.FailedToStartUDPLegacy += new EventHandler <PortConflictEventArgs>(controller_FailedToStartUDPLegacy);
                this.controller.Initialize(Application.ExecutablePath, this.contextMenu);

                this.wpr = new WndProcReader(WndProc);

                StartGrowl();

                OnProgramRunning(this, EventArgs.Empty);

                HandleSystemNotifications();

                // signal the ProgramLoadedResetEvent so anybody that was waiting on it can start their work
                ProgramLoadedResetEvent.Set();

                // Normally we shouldnt ever explicitly call GC.Collect(), but since many of the prefs
                // are read from files on disk, they usually end up on the Large Object Heap. LOH objects
                // only get collected in Gen2 collections, so we want to do this here before the app
                // really gets going to clean up our initialization process.
                Utility.WriteDebugInfo("Program loaded. Force GC to clean up LOH");
                ApplicationMain.ForceGC();

                // auto updater
                this.updater = new Updater(Application.StartupPath);
                this.updater.CheckForUpdateComplete += new CheckForUpdateCompleteEventHandler(updater_CheckForUpdateComplete);
                this.autoUpdateTimer.Interval        = 20 * 1000;
                this.autoUpdateTimer.Tick           += new EventHandler(autoUpdateTimer_Tick);
                this.autoUpdateTimer.Start();

                // while it may seem strange to call the Detector to see if we are installed, it is the best way
                // to ensure that plugins/displays see the same values that we do
                Growl.CoreLibrary.Detector detector = new Growl.CoreLibrary.Detector();
                if (!detector.IsInstalled)
                {
                    // something is not right with the registry setting, so lets fix it now
                    Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(Growl.CoreLibrary.Detector.REGISTRY_KEY, true);
                    if (key == null)
                    {
                        key = Microsoft.Win32.Registry.CurrentUser.CreateSubKey(Growl.CoreLibrary.Detector.REGISTRY_KEY);
                    }
                    using (key)
                    {
                        key.SetValue(null, Application.ExecutablePath);
                    }
                }
            }
        }
Esempio n. 4
0
        public void Run()
        {
            if (!this.running)
            {
                this.running = true;

                InitializeComponent();

                // SUPER IMPORTANT - since we are using the contextMenu as the synchronizing object, its .Handle must be created first
                // this will force creation of the handle without showing the menu
                Utility.WriteDebugInfo("ContextMenu Handle: {0}", this.contextMenu.Handle);

                // scaling factor
                float currentDPI = 0;
                using (Graphics g = this.contextMenu.CreateGraphics())
                {
                    currentDPI = g.DpiX;
                }
                ApplicationMain.ScalingFactor = currentDPI / 96;

                // configure the controller
                this.controller = Controller.GetController();
                this.controller.FailedToStart += new EventHandler<PortConflictEventArgs>(controller_FailedToStart);
                this.controller.FailedToStartUDPLegacy += new EventHandler<PortConflictEventArgs>(controller_FailedToStartUDPLegacy);
                this.controller.Initialize(Application.ExecutablePath, this.contextMenu);

                this.wpr = new WndProcReader(WndProc);

                StartGrowl();

                OnProgramRunning(this, EventArgs.Empty);

                HandleSystemNotifications();

                // signal the ProgramLoadedResetEvent so anybody that was waiting on it can start their work
                ProgramLoadedResetEvent.Set();

                // Normally we shouldnt ever explicitly call GC.Collect(), but since many of the prefs
                // are read from files on disk, they usually end up on the Large Object Heap. LOH objects
                // only get collected in Gen2 collections, so we want to do this here before the app
                // really gets going to clean up our initialization process.
                Utility.WriteDebugInfo("Program loaded. Force GC to clean up LOH");
                ApplicationMain.ForceGC();

                // auto updater
                this.updater = new Updater(Application.StartupPath);
                this.updater.CheckForUpdateComplete += new CheckForUpdateCompleteEventHandler(updater_CheckForUpdateComplete);
                this.autoUpdateTimer.Interval = 20 * 1000;
                this.autoUpdateTimer.Tick += new EventHandler(autoUpdateTimer_Tick);
                this.autoUpdateTimer.Start();

                // while it may seem strange to call the Detector to see if we are installed, it is the best way
                // to ensure that plugins/displays see the same values that we do
                Growl.CoreLibrary.Detector detector = new Growl.CoreLibrary.Detector();
                if (!detector.IsInstalled)
                {
                    // something is not right with the registry setting, so lets fix it now
                    Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(Growl.CoreLibrary.Detector.REGISTRY_KEY, true);
                    if (key == null)
                        key = Microsoft.Win32.Registry.CurrentUser.CreateSubKey(Growl.CoreLibrary.Detector.REGISTRY_KEY);
                    using (key)
                    {
                        key.SetValue(null, Application.ExecutablePath);
                    }
                }
            }
        }