コード例 #1
0
ファイル: MainWindow.cs プロジェクト: jsj2008/gui-vm
        //------------------------------ MENU OPTIONS-----------------------------//

        /// <summary>
        ///  Click listener for "Open" menu button
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DialogResult result = openFileDialog.ShowDialog(); // Show the dialog.

            if (result == DialogResult.OK)                     // Test result.
            {
                string file = openFileDialog.FileName;
                try
                {
                    string text = File.ReadAllText(file);
                    if (fileForm == null)
                    {
                        fileForm = new FileForm(text, messages, mainMemory);
                        // Set the parent form of the child window.
                        fileForm.MdiParent = this;
                        // Display the new form.
                        fileForm.Text         = Path.GetFileName(openFileDialog.FileName);
                        fileForm.Name         = openFileDialog.FileName;
                        fileForm.FormClosing += Close_FormFile;
                    }

                    fileForm.Show();
                }
                catch (IOException)
                {
                }
            }
        }
コード例 #2
0
ファイル: MainWindow.cs プロジェクト: jsj2008/gui-vm
 public void Close_FormFile(object sender, EventArgs e)
 {
     fileForm = null;
 }