Exemplo n.º 1
0
        private void FileNew_Click(object sender, System.EventArgs e)
        {
            MdiChild newMdiChild = new MdiChild();

            newMdiChild.Text      = "Untitled";
            newMdiChild.MdiParent = this;
            newMdiChild.Show();
        }
Exemplo n.º 2
0
        private void OpenFile(object sender, CancelEventArgs e)
        {
            MdiChild newMdiChild = new MdiChild();

            newMdiChild.MdiParent = this;
            using (StreamReader reader = new StreamReader(openDialog.FileName))
            {
                newMdiChild.TextInput.Text = reader.ReadToEnd();
            }
            newMdiChild.Text           = openDialog.SafeFileName;
            newMdiChild.openedFilePath = openDialog.FileName;
            newMdiChild.Show();
        }
Exemplo n.º 3
0
        private void MainForm_Load(object sender, System.EventArgs e)
        {
            MdiChild newMdiChild = new MdiChild();

            newMdiChild.MdiParent   = this;
            newMdiChild.Text        = "Untitled";
            newMdiChild.WindowState = FormWindowState.Maximized;
            try
            {
                if (Environment.GetCommandLineArgs().GetValue(1).ToString() != string.Empty)
                {
                    newMdiChild.openedFilePath = Environment.GetCommandLineArgs().GetValue(1).ToString();
                    if (File.Exists(newMdiChild.openedFilePath))
                    {
                        newMdiChild.Text           = Path.GetFileName(newMdiChild.openedFilePath);
                        newMdiChild.TextInput.Text = File.ReadAllText(newMdiChild.openedFilePath);
                        newMdiChild.TextInput.DeselectAll();
                    }
                    else
                    {
                        switch (MessageBox.Show("Cannot find the " + newMdiChild.openedFilePath + " file." + (char)10 + "Do you want to create a new file?", "Multipad .NET", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation))
                        {
                        case DialogResult.Yes:
                            File.CreateText(newMdiChild.openedFilePath);
                            newMdiChild.Text           = Path.GetFileName(newMdiChild.openedFilePath);
                            newMdiChild.TextInput.Text = File.ReadAllText(newMdiChild.openedFilePath);
                            return;

                        case DialogResult.No:
                            return;
                        }
                    }
                }
            }
            catch { return; }
            finally { newMdiChild.Show(); }
        }