private void SearchNext_Click(object sender, System.EventArgs e) { MdiChild thisMdiChild = (ActiveMdiChild as MdiChild); findDialog.Direction = FindReplace.FindDirection.Down; findDialog.FindString(thisMdiChild.TextInput); }
private void ToggleWordWrap(short mode) { // Cast the active MDI child form as the template, // for access to the controls inside it. MdiChild thisMdiChild = (ActiveMdiChild as MdiChild); // Toggle word wrap in the text box. if (ActiveMdiChild != null) { if (thisMdiChild.TextInput.WordWrap == false) { if (mode == 1) { thisMdiChild.TextInput.WordWrap = true; EditWordWrap.Checked = true; } else if (mode == 0) { EditWordWrap.Checked = false; } } else { if (mode == 1) { thisMdiChild.TextInput.WordWrap = false; EditWordWrap.Checked = false; } else if (mode == 0) { EditWordWrap.Checked = true; } } } }
private void EditCut_Click(object sender, EventArgs e) { MdiChild thisMdiChild = (ActiveMdiChild as MdiChild); Clipboard.SetText(thisMdiChild.TextInput.SelectedText); thisMdiChild.TextInput.Text = thisMdiChild.TextInput.Text.Remove(thisMdiChild.TextInput.SelectionStart, thisMdiChild.TextInput.SelectedText.Length); }
private void EditUndo_Click(object sender, System.EventArgs e) { // Cast the active MDI child form as the template, // for access to the controls inside it. MdiChild thisMdiChild = (ActiveMdiChild as MdiChild); thisMdiChild.TextInput.Undo(); }
private void FileNew_Click(object sender, System.EventArgs e) { MdiChild newMdiChild = new MdiChild(); newMdiChild.Text = "Untitled"; newMdiChild.MdiParent = this; newMdiChild.Show(); }
private void findDialog_FindNextClick() { MdiChild thisMdiChild = (ActiveMdiChild as MdiChild); try { findDialog.FindString(thisMdiChild.TextInput); } catch { } }
private void SaveFile(object sender, CancelEventArgs e) { MdiChild thisMdiChild = (ActiveMdiChild as MdiChild); string safeName = Path.GetFileName(saveDialog.FileName); using (StreamWriter writer = new StreamWriter(saveDialog.FileName)) { writer.Write(thisMdiChild.TextInput.Text); } thisMdiChild.Text = safeName; thisMdiChild.openedFilePath = saveDialog.FileName; thisMdiChild.TextInput.Modified = false; }
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(); }
private void FileSave_Click(object sender, System.EventArgs e) { MdiChild thisMdiChild = (ActiveMdiChild as MdiChild); if (thisMdiChild.openedFilePath != "Untitled") { string safeName = Path.GetFileName(thisMdiChild.openedFilePath); using (StreamWriter writer = new StreamWriter(thisMdiChild.openedFilePath)) { writer.Write(thisMdiChild.TextInput.Text); } thisMdiChild.TextInput.Modified = false; thisMdiChild.Text = safeName; } else { saveDialog.ShowDialog(); } }
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(); } }
private void EditCopy_Click(object sender, EventArgs e) { MdiChild thisMdiChild = (ActiveMdiChild as MdiChild); Clipboard.SetText(thisMdiChild.TextInput.SelectedText); }
private void EditPaste_Click(object sender, System.EventArgs e) { MdiChild thisMdiChild = (ActiveMdiChild as MdiChild); thisMdiChild.TextInput.Text += Clipboard.GetText(); }