コード例 #1
0
 private void miSave_Click(object sender, EventArgs e)
 {
     if (this.ActiveMdiChild != null)
     {
         frmDiary fd = this.ActiveMdiChild as frmDiary;
         if (string.IsNullOrEmpty(fd.FileName))
         {
             SaveFileDialog sfd = new SaveFileDialog();
             sfd.Filter = "文本文件(*.txt)|*.txt|富文本文件(*.rtf)|*.rtf";
             if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
             {
                 string fn = sfd.FileName;
                 if (fn.ToLower().EndsWith("txt") || fn.ToLower().EndsWith("rtf"))
                 {
                     fd.RichDiary.SaveFile(fn);
                     fd.FileName = fn;
                 }
                 else
                 {
                     MessageBox.Show("请填写正确的后缀名!");
                 }
             }
         }
         else
         {
             fd.RichDiary.SaveFile(fd.FileName);
         }
     }
 }
コード例 #2
0
        private void miNew_Click(object sender, EventArgs e)
        {
            frmDiary fd = new frmDiary();

            fd.Text      = DateTime.Now.ToLongDateString();
            fd.MdiParent = this;
            fd.Show();
        }
コード例 #3
0
 private void 重做RedoToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (this.ActiveMdiChild != null)
     {
         frmDiary fd = this.ActiveMdiChild as frmDiary;
         fd.RichDiary.Cut();
     }
 }
コード例 #4
0
        private void miBgColor_Click(object sender, EventArgs e)
        {
            frmDiary    currentForm = this.ActiveMdiChild as frmDiary;
            ColorDialog cd          = new ColorDialog();

            if (cd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                currentForm.RichDiary.BackColor = cd.Color;
            }
        }
コード例 #5
0
 private void miFont_Click(object sender, EventArgs e)
 {
     if (this.ActiveMdiChild != null)
     {
         frmDiary   fd   = this.ActiveMdiChild as frmDiary;
         FontDialog font = new FontDialog();
         font.ShowColor = true;
         if (font.ShowDialog() == System.Windows.Forms.DialogResult.OK)
         {
             fd.RichDiary.SelectionFont  = font.Font;
             fd.RichDiary.SelectionColor = font.Color;
         }
     }
 }
コード例 #6
0
        private void miOPen_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter = "文本文件(*.txt)|*.txt|富文本文件(*.rtf)|*.rtf";
            if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                string   fn = ofd.FileName;
                frmDiary fd = new frmDiary();
                fd.RichDiary.LoadFile(fn);
                fd.MdiParent = this;
                fd.Text      = Path.GetFileNameWithoutExtension(fn);
                fd.FileName  = fn;
                fd.Show();
            }
        }
コード例 #7
0
 private void btnQuery_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(tbSearch.Text))
     {
         if (this.ActiveMdiChild != null)
         {
             frmDiary fd = this.ActiveMdiChild as frmDiary;
             pos = fd.RichDiary.Text.IndexOf(tbSearch.Text, pos);
             if (pos >= 0)
             {
                 fd.RichDiary.SelectionStart  = pos;
                 fd.RichDiary.SelectionLength = tbSearch.Text.Length;
                 pos += tbSearch.Text.Length + 1;
             }
             else
             {
                 pos = 0;
             }
         }
     }
 }