C# Visual Programming

Rich Text Box App

 

Following is the code related to the feature:

New Child and Open File
private void newToolStripMenuItem_Click(object sender, EventArgs e)
        {
           
            
                FromChild Ch = new FromChild();
                Ch.MdiParent = this;
                 Ch.Show();

        }

        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog1= new OpenFileDialog();
            openFileDialog1.Multiselect = true;
            openFileDialog1.Filter = ("rtf|*.rtf");
            openFileDialog1.FileName = "";

            DialogResult dr = openFileDialog1.ShowDialog();
            if (dr == System.Windows.Forms.DialogResult.OK)
            {

                foreach (string files in openFileDialog1.FileNames)
                {
                    try
                    {
                        int a = openFileDialog1.FileNames.Count();
                        if ((a > 1) && (GetRichTextBox().Text.Length > 0))
                        {

                            FromChild naya = new FromChild();
                            {
                                naya.Text = "New Form";
                                naya.Show();
                                naya.RTF.LoadFile(files, RichTextBoxStreamType.RichText);

                            }
                        }
                    }
                    catch{}
                }
            }

        }
private void closeToolStripMenuItem_Click_1(object sender, EventArgs e)
        {
            if(ActiveMdiChild!=null )
            {
                ActiveMdiChild.Close();
            }

        }
private void closeAllToolStripMenuItem_Click(object sender, EventArgs e)
        {
            foreach (Form form in this.MdiChildren)
            {
                form.Close();
            }
        }
Formatting Text
private void copyToolStripMenuItem_Click(object sender, EventArgs e)
        {
            GetRichTextBox().Copy();
        }

        private void cutToolStripMenuItem_Click(object sender, EventArgs e)
        {
            GetRichTextBox().Cut();

        }
        private void sellectAllToolStripMenuItem_Click(object sender, EventArgs e)
        {
            GetRichTextBox().SelectAll();
        }
        private void pasteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            GetRichTextBox().Paste();
        }

        private void toolStripButton3_Click(object sender, EventArgs e)
        {
            if(strik==false)
            {
                GetRichTextBox().SelectionFont = new Font(GetRichTextBox().SelectionFont, FontStyle.Strikeout);
                toolStripButton3.Font = new Font(toolStripButton3.Font, FontStyle.Strikeout);
                strik = true;
            }
            else
            {
                GetRichTextBox().SelectionFont = new Font(GetRichTextBox().SelectionFont, FontStyle.Regular);
                toolStripButton3.Font = new Font(toolStripButton3.Font, FontStyle.Regular);
                strik = false;
            }
        }

        private void toolStripButton4_Click(object sender, EventArgs e)
        {
            if (under == false)
            {
                GetRichTextBox().SelectionFont = new Font(GetRichTextBox().SelectionFont, FontStyle.Underline);
                toolStripButton4.Font = new Font(toolStripButton4.Font, FontStyle.Underline);
                under = true;
            }
            else
            {
                GetRichTextBox().SelectionFont = new Font(GetRichTextBox().SelectionFont, FontStyle.Regular);
                toolStripButton4.Font = new Font(toolStripButton4.Font, FontStyle.Regular);
                under = false;
            }
        }




Paragraph Alignment
private void toolStripButton5_Click(object sender, EventArgs e)
        {
            GetRichTextBox().SelectionAlignment = HorizontalAlignment.Left;
        }

        private void toolStripButton6_Click(object sender, EventArgs e)
        {
            GetRichTextBox().SelectionAlignment = HorizontalAlignment.Center;
        }

        private void toolStripButton7_Click(object sender, EventArgs e)
        {
            GetRichTextBox().SelectionAlignment = HorizontalAlignment.Right;
        }

Font Formatting
  private void fontToolStripMenuItem_Click(object sender, EventArgs e)
        {
            FontDialog fond = new FontDialog();
            fond.ShowColor = true;

            if ((fondd.ShowDialog() == DialogResult.OK) && (!String.IsNullOrEmpty(GetRichTextBox().Text)))
            {
                GetRichTextBox().SelectionFont = fond.Font;
                GetRichTextBox().SelectionColor = fondd.Color;


            }

}
private void toolStripButton8_Click(object sender, EventArgs e)
        {
            int size = int.Parse(toolComboBox1.Text);
            GetRichTextBox().BulletIndent = size;
  
            if (ind == true)
            {
                GetRichTextBox().SelectionBullet = true;
                ind = false;
            }
            else
            {
                GetRichTextBox().SelectionBullet = false;
                ind = true;
            }

        }

        private void toolStripComboBox1_TextChanged_1(object sender, EventArgs e)
        {
            toolStripComboBox1.Text = toolStripComboBox1.Text.ToString();
            try
            {
                int size = int.Parse(toolStripComboBox1.Text);
                GetRichTextBox().BulletIndent = size;


                {
                    GetRichTextBox().SelectionBullet = true;
                }
            }
            catch{}

        }

Comments