/// <summary> /// Combined Event Handler for Formatting a PARAGRAPH except Indentation (DONE in Rich Text Viewer Form) when pressed from the TOP MENU. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void setParagraphFormat_ToolStripMenuItem_Click(object sender, EventArgs e) { if (this.ActiveMdiChild != null) { Text_Viewer text_View = (Text_Viewer)this.ActiveMdiChild; Paragraph_Format para_Format = new Paragraph_Format((Text_Viewer)this.ActiveMdiChild); para_Format.set_Dialog_State(text_View.selected_Alignment, text_View.selected_Bullets); para_Format.ShowDialog(); if (para_Format.DialogResult == DialogResult.OK) { text_View.format_Paragraph(para_Format.curr_Para_Aligment, para_Format.is_Bullets_Applied); } } }
/// <summary> /// Combined event handler for handling all the buttons on tool strip. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void format_Text_Click(object sender, EventArgs e) { try { ToolStripButton pressed_Btn = (ToolStripButton)sender; //For BOLD, ITALIC, UNDERLINE, STRIKE THROUGH. if (pressed_Btn == tsb_Bold || pressed_Btn == tsb_Italic || pressed_Btn == tsb_UnderLine || pressed_Btn == tsb_StrikeThrough) { if (this.ActiveMdiChild != null) { Text_Viewer textView = (Text_Viewer)this.ActiveMdiChild; Font temp_Font = textView.selected_Font_Settings; if (pressed_Btn == tsb_Bold) { if (temp_Font.Bold) { FontStyle style = FontStyle.Regular; if (temp_Font.Italic) { style = style | FontStyle.Italic; } if (temp_Font.Underline) { style = style | FontStyle.Underline; } if (temp_Font.Strikeout) { style = style | FontStyle.Strikeout; } textView.format_Font(new Font(temp_Font.FontFamily, temp_Font.Size, style), textView.selected_BackColor, textView.selected_ForeColor); } else { textView.format_Font(new Font(temp_Font.FontFamily, temp_Font.Size, temp_Font.Style | FontStyle.Bold), textView.selected_BackColor, textView.selected_ForeColor); } } if (pressed_Btn == tsb_Italic) { if (temp_Font.Italic) { FontStyle style = FontStyle.Regular; if (temp_Font.Bold) { style = style | FontStyle.Bold; } if (temp_Font.Underline) { style = style | FontStyle.Underline; } if (temp_Font.Strikeout) { style = style | FontStyle.Strikeout; } textView.format_Font(new Font(temp_Font.FontFamily, temp_Font.Size, style), textView.selected_BackColor, textView.selected_ForeColor); } else { textView.format_Font(new Font(temp_Font.FontFamily, temp_Font.Size, temp_Font.Style | FontStyle.Italic), textView.selected_BackColor, textView.selected_ForeColor); } } if (pressed_Btn == tsb_UnderLine) { if (temp_Font.Underline) { FontStyle style = FontStyle.Regular; if (temp_Font.Bold) { style = style | FontStyle.Bold; } if (temp_Font.Italic) { style = style | FontStyle.Italic; } if (temp_Font.Strikeout) { style = style | FontStyle.Strikeout; } textView.format_Font(new Font(temp_Font.FontFamily, temp_Font.Size, style), textView.selected_BackColor, textView.selected_ForeColor); } else { textView.format_Font(new Font(temp_Font.FontFamily, temp_Font.Size, temp_Font.Style | FontStyle.Underline), textView.selected_BackColor, textView.selected_ForeColor); } } if (pressed_Btn == tsb_StrikeThrough) { if (temp_Font.Strikeout) { FontStyle style = FontStyle.Regular; if (temp_Font.Bold) { style = style | FontStyle.Bold; } if (temp_Font.Underline) { style = style | FontStyle.Underline; } if (temp_Font.Italic) { style = style | FontStyle.Italic; } textView.format_Font(new Font(temp_Font.FontFamily, temp_Font.Size, style), textView.selected_BackColor, textView.selected_ForeColor); } else { textView.format_Font(new Font(temp_Font.FontFamily, temp_Font.Size, temp_Font.Style | FontStyle.Strikeout), textView.selected_BackColor, textView.selected_ForeColor); } } } } else if (pressed_Btn == tsb_AlignLeft || pressed_Btn == tsb_AlignCenter || pressed_Btn == tsb_AlignRight) {//For ALIGN LEFT, ALIGN CENTER, ALIGN RIGHT. if (this.ActiveMdiChild != null) { Text_Viewer text_view = (Text_Viewer)this.ActiveMdiChild; text_view.format_Paragraph(pressed_Btn.Text, text_view.selected_Bullets); } } else if (pressed_Btn == tsb_IncreaseIndent || pressed_Btn == tsb_DecreaseIndent) {//For INCREASE DECREASE INDENT. if (this.ActiveMdiChild != null) { Text_Viewer text_view = (Text_Viewer)this.ActiveMdiChild; if (pressed_Btn == tsb_IncreaseIndent) { text_view.increase_decrease_Indent(true); } else { text_view.increase_decrease_Indent(false); } } } else if (pressed_Btn == tsb_Bullet) {//For ENABLING/DISABLING BULLETS. if (this.ActiveMdiChild != null) { Text_Viewer text_view = (Text_Viewer)this.ActiveMdiChild; if (text_view.selected_Bullets) { text_view.format_Paragraph(text_view.selected_Alignment.ToString(), false); } else { text_view.format_Paragraph(text_view.selected_Alignment.ToString(), true); } } } } catch (Exception) { MessageBox.Show("Error: Cannot Handle Multiple Fonts and Size"); } }