/* * Method name: newTSMI_Click * Version: #1.0 * Author: Michael Fesser * Description: This method creates a new child form and passes the date if the datepicker is already * active. * Outputs: None. * Returns: None. * Change History: None. */ private void newTSMI_Click(object sender, EventArgs e) { // Try to make a new file try { // Instantiate new child form childForm = new textEditorFrom(); // Make the MDI form the parent of the child form. childForm.MdiParent = this; // Increment the number of the child form in the title childForm.Text = "Window " + childFormNumber++; // Show the child form childForm.Show(); // If the datepicker is active pass that value to any new child forms. if (datepickerTSMI.Enabled == true) { childForm.date = dateTimePicker.Value.ToString(); } // Enable the datepicker menu option datepickerTSMI.Enabled = true; } catch (Exception io) { MessageBox.Show("The file could not be created."); } }
/* * Method name: openTSMI_Click * Version: #1.0 * Author: Michael Fesser * Description: This method creates a new child form, passes the date if the datepicker is already * active and opens a file in the new child form. * Outputs: None. * Returns: None. * Change History: None. */ private void openTSMI_Click(object sender, EventArgs e) { // Try to open a file try { // Instantiate and new object OpenFileDialog openFileDialog = new OpenFileDialog(); // Goto default user path openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal); // Set file types to text openFileDialog.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*"; if (openFileDialog.ShowDialog(this) == DialogResult.OK) { // Set the filename to the path string filename = openFileDialog.FileName; // Instantiate new child form and pass the file in a constructor from John Wu www.github.com childForm = new textEditorFrom(filename); // Make the MDI form the parent of the child form. childForm.MdiParent = this; // Increment the number of the child form in the title childForm = new textEditorFrom(filename); // Show the child form childForm.Show(); // If the datepicker is active pass that value to any new child forms. if (datepickerTSMI.Enabled == true) { childForm.date = dateTimePicker.Value.ToString(); } // Enable the datepicker menu option datepickerTSMI.Enabled = true; } } catch (Exception io) { MessageBox.Show("The file could not be opened."); } }