Пример #1
0
        /// <summary>
        /// Creates a new text editor child window.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FileNew(object sender, EventArgs e)
        {
            formTextEditor textEditorInstance = new formTextEditor();

            textEditorInstance.MdiParent = this;
            textEditorInstance.Show();
        }
Пример #2
0
        /// <summary>
        /// Opens a saved text editor document.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void FileOpen(object sender, EventArgs e)
        {
            // If there is an active window:
            if (this.MdiChildren.Length > 0)
            {
                // If a text editor window is the currently active window...
                if (this.ActiveMdiChild.GetType() == typeof(formTextEditor))
                {
                    // ...call the text editor's Open event handler.
                    formTextEditor textEditorInstance =
                        (formTextEditor)this.ActiveMdiChild;
                    textEditorInstance.FileOpen(sender, e);
                }
                // If a text editor is not the active window:
                else
                {
                    // Create a new text editor window.
                    formTextEditor textEditorInstance = new formTextEditor();
                    textEditorInstance.MdiParent = this;
                    textEditorInstance.Show();

                    // Set focus to the new window and call the Open event handler.
                    textEditorInstance.Focus();
                    textEditorInstance.FileOpen(sender, e);
                }
            }
            // If there are no active windows:
            else
            {
                // Create a new text editor window.
                formTextEditor textEditorInstance = new formTextEditor();
                textEditorInstance.MdiParent = this;
                textEditorInstance.Show();

                // Set focus to the new window and call the Open event handler.
                textEditorInstance.Focus();
                textEditorInstance.FileOpen(sender, e);
            }
        }