Exemple #1
0
        /// <summary>
        /// On closing, we unsubscribe the global events to help the GC.
        /// </summary>
        /// <param name="e"></param>
        protected override void OnFormClosing(FormClosingEventArgs e)
        {
            base.OnFormClosing(e);

            // Unsubscribe global events
            EveMonClient.PlanNameChanged   -= EveMonClient_PlanNameChanged;
            EveMonClient.SettingsChanged   -= EveMonClient_SettingsChanged;
            EveMonClient.ItemPricesUpdated -= EveMonClient_ItemPricesUpdated;

            // Save settings if this one is the last activated and up-to-date
            if (s_lastActivated == this)
            {
                if (tabControl.TabPages.Contains(tpPlanEditor))
                {
                    Settings.UI.PlanWindow.Columns.Clear();
                    Settings.UI.PlanWindow.Columns.AddRange(planEditor.ExportColumnSettings());
                }
                s_lastActivated = null;
            }

            Settings.Save();

            // We're closing down
            if (e.CloseReason != CloseReason.ApplicationExitCall && // and Application.Exit() was not called
                e.CloseReason != CloseReason.TaskManagerClosing &&
                // and the user isn't trying to shut the program down for some reason
                e.CloseReason != CloseReason.WindowsShutDown) // and Windows is not shutting down
            {
                // Tell the loadout importation window we're closing down
                WindowsFactory.GetAndCloseByTag <LoadoutImportationWindow, Character>(m_character);

                // Tell the ship loadout window we're closing down
                WindowsFactory.GetAndCloseByTag <ShipLoadoutSelectWindow, Character>(m_character);

                // Tell the skill explorer we're closing down
                WindowsFactory.GetAndCloseByTag <SkillExplorerWindow, Character>(m_character);

                // Tell the attributes optimization window we're closing down
                WindowsFactory.GetAndCloseByTag <AttributesOptimizerOptionsWindow, PlanEditorControl>(planEditor);
                WindowsFactory.GetAndCloseByTag <AttributesOptimizerWindow, PlanEditorControl>(planEditor);

                // Tell the implant window we're closing down
                WindowsFactory.GetAndCloseByTag <ImplantCalculatorWindow, PlanEditorControl>(planEditor);
            }
        }