Exemple #1
0
        /// <summary>
        /// Close all Opend Simulation Windows
        /// </summary>
        private void CloseAllSimulationUi()
        {
            // Stop the Simulation
            if (simUi.Count > 0)
            {
                // Copy the objects to an Array. Otherwise we will erase the Objects during the ForEach Loop
                Simulation_UI[] currentUiObjects = new Simulation_UI[simUi.Count];
                simUi.CopyTo(currentUiObjects);

                // Try to close all the Simulation Objects
                try
                {
                    // Try to Close all the Simulation UI Objects
                    for (int i = 0; i < currentUiObjects.Length; i++)
                    {
                        currentUiObjects[i].Close();
                    }
                }
                catch
                {
                    // OK Not all of the Objects could be closed.... we are going on anyway..
                }
            }

            // Disable the MenuItem for cloasing all SimUi's...
            this.menuItemCloseAllSimulations.IsEnabled = false;
        }
Exemple #2
0
        /// <summary>
        /// SImulation Object Close Event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SimulationWindowClosedEvent(object sender, EventArgs e)
        {
            // Get the Simulation Object from the Sender Object
            Simulation_UI simulationUiObject = sender as Simulation_UI;

            // Remove the Object from the List of Simulations
            simUi.Remove(simulationUiObject);

            // Remove the Item in the MenuBar
            menuSimulation.Items.Remove(simMenuBarItems.Last.Value);

            // Remove the Menu Item from the local List of Menuitems
            simMenuBarItems.RemoveLast();

            // If the last Simulation UI is closed disable the MenuItem for Closing all Simu UI's....
            if (simUi.Count <= 0)
            {
                this.menuItemCloseAllSimulations.IsEnabled = false;
            }

            // set the Title to the Simulation Window
            UpdateSimulationWindowTitle();
        }