private void 打开OCtrlOToolStripMenuItem_Click(object sender, EventArgs e) { try { if (openFileDialog.ShowDialog() == DialogResult.OK) { RichTextBoxStreamType fileType = TrunFileType(openFileDialog.FilterIndex); fileCount++; file = new FormChild(fileType, openFileDialog.FileName, openFileDialog.FilterIndex); file.MdiParent = this; file.Show(); listFormChild.Add(file); } } catch (Exception ex) { return; } string str = openFileDialog.FileName; string[] sArray = str.Split('\\'); file.Text = sArray[sArray.Length - 1]; file.WindowState = FormWindowState.Maximized; }
public void SaveFile(FormChild df) //保存文件 { SaveFileDialog sfd = new SaveFileDialog(); sfd.Filter = "文本文件(*.txt)|*.txt|RTF文件|*.rtf|所有文件(*.*)|*.*"; if (sfd.ShowDialog() == DialogResult.OK) { RichTextBoxStreamType fileType = TrunFileType(sfd.FilterIndex); file.SetFileTypeIndex(sfd.FilterIndex); file.SetFilePath(saveFileDialog.InitialDirectory); df.Sourse.SaveFile(sfd.FileName, fileType); df.SetFilePath(sfd.FileName); oldFile = fileType; } string str = df.GetFilePath(); string[] sArray = str.Split('\\'); fileName = sArray[sArray.Length - 1]; for (int i = 0; i < sArray.Length - 1; i++) { filePath += sArray[i]; } }
private void 查找ToolStripMenuItem_Click(object sender, EventArgs e) { fileSend = (FormChild)this.ActiveMdiChild; FormFind find = new FormFind(); find.Show(); }
private void 新建NCtrlNToolStripMenuItem_Click(object sender, EventArgs e) { file = new FormChild(); //新建一个子窗体 file.MdiParent = this; //定义此窗体的父窗体,使之成为MDI窗体 ++ChildFormCount; file.Text = "子窗体" + ChildFormCount.ToString(); file.Show(); }
private void 全选CtrlAToolStripMenuItem_Click(object sender, EventArgs e) { try { FormChild df = (FormChild)this.ActiveMdiChild; df.Sourse.SelectAll(); } catch (Exception ex) { return; } }
private void 时间日期ToolStripMenuItem_Click(object sender, EventArgs e) { try { FormChild df = (FormChild)this.ActiveMdiChild; Clipboard.SetText(DateTime.Now.ToString()); df.Sourse.Paste(); } catch (Exception ex) { return; } }
private void 颜色CToolStripMenuItem_Click(object sender, EventArgs e) { try { if (colorDialog.ShowDialog() == DialogResult.OK && file != null) { FormChild df = (FormChild)this.ActiveMdiChild; df.Sourse.SelectionColor = colorDialog.Color; } } catch (Exception ex) { return; } }
private void 另存为ToolStripMenuItem_Click(object sender, EventArgs e) { FormChild df = (FormChild)this.ActiveMdiChild; try { SaveFile(df); filePath = df.GetFilePath(); MessageBox.Show("保存成功", "温馨提示"); } catch (Exception ex) { return; } }
private void 自动换行WToolStripMenuItem_Click(object sender, EventArgs e) { try { if (自动换行WToolStripMenuItem.CheckState == CheckState.Checked) { 自动换行WToolStripMenuItem.CheckState = CheckState.Unchecked; FormChild df = (FormChild)this.ActiveMdiChild; df.Sourse.WordWrap = false; } else { 自动换行WToolStripMenuItem.CheckState = CheckState.Checked; FormChild df = (FormChild)this.ActiveMdiChild; df.Sourse.WordWrap = true; } } catch (Exception ex) { return; } }
private void 保存SCtrlSToolStripMenuItem_Click(object sender, EventArgs e) { FormChild df = (FormChild)this.ActiveMdiChild; try { if (df.GetFilePath() == "") { SaveFile(df); MessageBox.Show("保存成功", "温馨提示"); } else { RichTextBoxStreamType fileType = TrunFileType(df.GetFileTypeIndex()); df.Sourse.SaveFile(df.GetFilePath(), fileType); MessageBox.Show("保存成功", "温馨提示"); } } catch (Exception ex) { MessageBox.Show("保存失败,请重新保存!", "温馨提示"); } }
private void FormChild_Load(object sender, EventArgs e) { this.file = (FormChild)FormMain.GetDocTrun(); }
private void FormFind_Load(object sender, EventArgs e) { this.file = FormMain.GetDocTrun(); }