Beispiel #1
0
        /// <summary>
        /// Closes the currently selected text editor window.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FileClose(object sender, EventArgs e)
        {
            // If there is an active window:
            if (this.MdiChildren.Length > 0)
            {
                // If the text editor window is the currently active window...
                if (this.ActiveMdiChild.GetType() == typeof(formTextEditor))
                {
                    // ...call the text editor's close event handler.
                    formTextEditor textEditorInstance =
                        (formTextEditor)this.ActiveMdiChild;
                    textEditorInstance.FileClose(sender, e);
                }

                // If the Car Inventory window is the currently active window...
                else if (this.ActiveMdiChild.GetType() == typeof(formCarInventory))
                {
                    // ...call the window's close event handler.
                    formCarInventory carInventoryInstance =
                        (formCarInventory)this.ActiveMdiChild;
                    carInventoryInstance.ButtonCloseClick(sender, e);
                }

                // If the Average Units Shipped window is the currently active window...
                else if (this.ActiveMdiChild.GetType() == typeof(formAverageUnitsShipped))
                {
                    // ...call the window's close event handler.
                    formAverageUnitsShipped unitsShippedInstance =
                        (formAverageUnitsShipped)this.ActiveMdiChild;
                    unitsShippedInstance.ButtonCloseClick(sender, e);
                }

                // If the Weekly Temperature window is the currently active window...
                else if (this.ActiveMdiChild.GetType() == typeof(formWeeklyTemperature))
                {
                    // ...call the Car Inventory's close event handler.
                    formWeeklyTemperature temperatureInstance =
                        (formWeeklyTemperature)this.ActiveMdiChild;
                    temperatureInstance.ButtonCloseClick(sender, e);
                }

                // If any window specified above is not the active window...
                else
                {
                    // ...display an appropriate message.
                    MessageBox.Show("The Close operation is not supported by the " +
                                    "currently selected window.", "Operation Not Supported");
                }
            }
            else
            {
                MessageBox.Show("To Close a window, a window must first be open.",
                                "Operation Not Supported");
            }
        }
Beispiel #2
0
        /// <summary>
        /// Create and display a Car Inventory instance as an MDI child.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void WindowCarList(object sender, EventArgs e)
        {
            // Create/call Car Inventory Form instance called listInstance.
            formCarInventory listInstance = formCarInventory.Instance;

            // Set it as an MDI child.
            listInstance.MdiParent = this;

            // Display the window.
            listInstance.Show();

            // Set focus to the new window.
            listInstance.Focus();
        }
 /// <summary>
 /// Upon the CarInventory instance closing, the contents of the instance
 /// variable is destroyed.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void CarInventoryClosing(object sender, FormClosingEventArgs e)
 {
     instance = null;
 }