コード例 #1
0
        /// <summary>
        /// By clicking Open you can select any text file to open.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void FileOpen(object sender, EventArgs e)
        {
            OpenFileDialog openDialog = new OpenFileDialog();

            openDialog.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*";

            if (openDialog.ShowDialog() == DialogResult.OK)
            {
                formTextEditor textEditorInstance = new formTextEditor();
                textEditorInstance = this;
                textEditorInstance.Show();
                textEditorInstance.Focus();
                StreamReader read = new StreamReader(File.OpenRead(openDialog.FileName));

                textBoxEditor.Text = read.ReadToEnd();
                read.Dispose();

                filepath    = openDialog.FileName;
                isUnchanged = true;
                UpdateTitle();
            }
            else
            {
                // If user cancels the open operation, refer to the open instance and close it.
                formTextEditor textEditorInstance = (formTextEditor)this.ActiveMdiChild;
                textEditorInstance = this;
                textEditorInstance.Show();
                textEditorInstance.Close();
            }
        }
コード例 #2
0
 /// <summary>
 /// Prints information about the current application.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Help(object sender, EventArgs e)
 {
     if (this.MdiChildren.Length > 0)
     {
         if (this.ActiveMdiChild.GetType() == typeof(formTextEditor))
         {
             formTextEditor textEditorInstance = (formTextEditor)this.ActiveMdiChild;
             textEditorInstance.HelpAbout(sender, e);
         }
         else if (this.ActiveMdiChild.GetType() == typeof(AverageUnitsShipped))
         {
             AverageUnitsShipped averageUnitsShippedInstance = (AverageUnitsShipped)this.ActiveMdiChild;
             averageUnitsShippedInstance.AverageUnitsShippedHelp();
         }
         else if (this.ActiveMdiChild.GetType() == typeof(formAwesomeness))
         {
             formAwesomeness awesomenessInstance = (formAwesomeness)this.ActiveMdiChild;
             awesomenessInstance.AwesomenessHelp();
         }
         else if (this.ActiveMdiChild.GetType() == typeof(CarInventory))
         {
             CarInventory carHelpInstance = (CarInventory)this.ActiveMdiChild;
             carHelpInstance.CarHelp();
         }
         else
         {
             MessageBox.Show("The Help operation is not supported by the current selected window.");
         }
     }
     else
     {
         MessageBox.Show("Final Project\n" + "By Nimsith Fernandopulle and Gaelen Rhoads\n\n" + "For NETD 2202" +
                         "\n" + "April 2021", "About this Application");
     }
 }
コード例 #3
0
 /// <summary>
 /// Saves a file to the users computer for the first time.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void FileSaveAs(object sender, EventArgs e)
 {
     if (this.MdiChildren.Length > 0)
     {
         if (this.ActiveMdiChild.GetType() == typeof(formTextEditor))
         {
             formTextEditor textEditorInstance = (formTextEditor)this.ActiveMdiChild;
             textEditorInstance.FileSaveAs(sender, e);
         }
         else if (this.ActiveMdiChild.GetType() == typeof(AverageUnitsShipped))
         {
             AverageUnitsShipped UnitsShippedInstance = (AverageUnitsShipped)
                                                        this.ActiveMdiChild;
             MessageBox.Show("This application doesn’t support that functionality");
         }
         else if (this.ActiveMdiChild.GetType() == typeof(CarInventory))
         {
             CarInventory UnitsShippedInstance = (CarInventory)
                                                 this.ActiveMdiChild;
             MessageBox.Show("This application doesn’t support that functionality");
         }
         else if (this.ActiveMdiChild.GetType() == typeof(formAwesomeness))
         {
             formAwesomeness UnitsShippedInstance = (formAwesomeness)
                                                    this.ActiveMdiChild;
             MessageBox.Show("This application doesn’t support that functionality");
         }
     }
 }
コード例 #4
0
        /// <summary>
        /// Opens the text editor.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void WindowNewTextEditor(object sender, EventArgs e)
        {
            formTextEditor textInstance = new formTextEditor();

            textInstance.MdiParent = this;
            textInstance.Show();
            textInstance.Focus();
        }
コード例 #5
0
 /// <summary>
 /// After copying something to the clipboard you can paste it using this
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void EditPaste(object sender, EventArgs e)
 {
     if (this.ActiveMdiChild != null)
     {
         if (this.ActiveMdiChild.GetType() == typeof(formTextEditor))
         {
             formTextEditor textEditorInstance = (formTextEditor)this.ActiveMdiChild;
             textEditorInstance.EditPaste(sender, e);
         }
         else
         {
             MessageBox.Show("The Paste operation is not supported by the current selected window.");
         }
     }
     else
     {
         MessageBox.Show("The paste operation is not supported with no windows open.");
     }
 }
コード例 #6
0
        /// <summary>
        /// Creates instance of text editor and calls the FileOpen event handler from the text editor CS file.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void FileOpen(object sender, EventArgs e)
        {
            // Make a new instance of a text editor
            formTextEditor textEditorInstance = new formTextEditor();

            textEditorInstance.MdiParent = this;
            textEditorInstance.Show();
            textEditorInstance.Focus();
            // Call the open event handler
            textEditorInstance.FileOpen(sender, e);

            //if (this.MdiChildren.Length > 0)
            //{
            //    if (this.ActiveMdiChild.GetType() == typeof(formTextEditor))
            //    {
            //        formTextEditor textEditorInstance = (formTextEditor)this.ActiveMdiChild;
            //        textEditorInstance.MdiParent = this;
            //        textEditorInstance.Show();
            //        textEditorInstance.Focus();
            //        textEditorInstance.FileOpen(sender, e);
            //    }
            //    else
            //    {
            //        formTextEditor textEditorInstance = new formTextEditor();
            //        textEditorInstance.MdiParent = this;
            //        textEditorInstance.Show();
            //        textEditorInstance.Focus();
            //        textEditorInstance.FileOpen(sender, e);
            //    }
            //}
            //else
            //{
            //    formTextEditor textEditorInstance = new formTextEditor();
            //    textEditorInstance.MdiParent = this;
            //    textEditorInstance.Show();
            //    textEditorInstance.Focus();
            //    textEditorInstance.FileOpen(sender, e);
            //}
        }