/// <summary>
        /// Close the current active child form or if no children close the parent form
        /// </summary>
        private void ClickClose(object sender, EventArgs e)
        {
            // Check for any children
            if (this.MdiChildren.Length > 0)
            {
                // Check if the active child is a TextEditor
                if (this.ActiveMdiChild.GetType() == typeof(formTextEditor))
                {
                    // Copy the instance of the child
                    formTextEditor textEditor = (formTextEditor)this.ActiveMdiChild;

                    // Call the exit event of Text Editor to close the TextEditor
                    textEditor.ExitClick(sender, e);
                }
                else
                {
                    // Close the active child
                    this.ActiveMdiChild.Close();
                }
            }
            else
            {
                // Close the parent form
                Close();
            }
        }
        /// <summary>
        /// Prompt user to select a text file to open and open it in a new TextEditor instance
        /// </summary>
        private void ClickOpenFile(object sender, EventArgs e)
        {
            // Create a new open dialoge
            OpenFileDialog openFile = new OpenFileDialog();

            // Set the file filters
            openFile.Filter = "Text files (*.txt)|*.txt|All files(*.*)|*.*";

            // When OK is pressed
            if (openFile.ShowDialog() == DialogResult.OK)
            {
                // Create a new instance of TextEditor
                CreateTextEditor();

                // Copy the instance of newly created Texteditor
                formTextEditor textEditor = (formTextEditor)this.ActiveMdiChild;

                string filePath = openFile.FileName;

                textEditor.UpdateTitle(filePath);

                // Create the file and read streams
                FileStream   fileToAccess = new FileStream(filePath, FileMode.Open, FileAccess.Read);
                StreamReader reader       = new StreamReader(fileToAccess);

                // Fill the textbox with the files contents
                textEditor.textboxInput.Text = reader.ReadToEnd();

                // Close the read stream
                reader.Close();
            }
        }
        /// <summary>
        /// Create a new TextEditor and display it
        /// </summary>
        public void CreateTextEditor()
        {
            // Create a new instance of the text editor form
            formTextEditor textEditor = new formTextEditor();

            // Assign it's MDI parent to be the form this event was called in
            textEditor.MdiParent = this;

            // Dispaly the form and set it as focus
            textEditor.Show();
            textEditor.Focus();
        }
        private void ClickSaveAs(object sender, EventArgs e)
        {
            // Check to see if the active child is a TextEditor form.
            if (this.MdiChildren.Length > 0 && this.ActiveMdiChild.GetType() == typeof(formTextEditor))
            {
                // Create an instance of the child
                formTextEditor textEditor = (formTextEditor)this.ActiveMdiChild;

                // Call the Paste event of Text Editor forms
                textEditor.SaveAsClick(sender, e);
            }
        }
        /// <summary>
        /// Run the cut event of TextEditor form when one is the active child form
        /// </summary>
        private void ClickCut(object sender, EventArgs e)
        {
            // Check to see if the active child is a TextEditor form.
            if (this.ActiveMdiChild.GetType() == typeof(formTextEditor))
            {
                // Create an instance of the child
                formTextEditor textEditor = (formTextEditor)this.ActiveMdiChild;

                // Call the Cut event of Text Editor forms
                textEditor.CutClick(sender, e);
            }
        }