//字体斜体 private void italicButton_Click(object sender, RoutedEventArgs e) { Windows.UI.Text.ITextSelection selectedText = editor.Document.Selection; if (selectedText != null) { Windows.UI.Text.ITextCharacterFormat charFormatting = selectedText.CharacterFormat; charFormatting.Italic = Windows.UI.Text.FormatEffect.Toggle; selectedText.CharacterFormat = charFormatting; } }
private void BoldButton_Click(object sender, RoutedEventArgs e) { Windows.UI.Text.ITextSelection selectedText = WritingRichEditBox.Document.Selection; if (selectedText != null) { Windows.UI.Text.ITextCharacterFormat charFormatting = selectedText.CharacterFormat; charFormatting.Bold = Windows.UI.Text.FormatEffect.Toggle; selectedText.CharacterFormat = charFormatting; } }
private void mnuItmNone_Click(object sender, RoutedEventArgs e) { // No Bullet List Windows.UI.Text.ITextSelection selectedText = editor.Document.Selection; if (selectedText != null) { Windows.UI.Text.ITextParagraphFormat paraFormatting = selectedText.ParagraphFormat; paraFormatting.ListType = Windows.UI.Text.MarkerType.None; selectedText.ParagraphFormat = paraFormatting; } }
private void mnuItmLowerRomanNumeral_Click(object sender, RoutedEventArgs e) { // Lowercase Roman Numeral List - Ex: i), ii), iii)... Windows.UI.Text.ITextSelection selectedText = editor.Document.Selection; if (selectedText != null) { Windows.UI.Text.ITextParagraphFormat paraFormatting = selectedText.ParagraphFormat; paraFormatting.ListType = Windows.UI.Text.MarkerType.LowercaseRoman; selectedText.ParagraphFormat = paraFormatting; } }
private void mnuItmLowerEngLetter_Click(object sender, RoutedEventArgs e) { // Lowercase English Letter List - Ex: a), b), c)... Windows.UI.Text.ITextSelection selectedText = editor.Document.Selection; if (selectedText != null) { Windows.UI.Text.ITextParagraphFormat paraFormatting = selectedText.ParagraphFormat; paraFormatting.ListType = Windows.UI.Text.MarkerType.LowercaseEnglishLetter; selectedText.ParagraphFormat = paraFormatting; } }
private void btnItalic_Unchecked(object sender, RoutedEventArgs e) { // Disable Italic Text Windows.UI.Text.ITextSelection selectedText = editor.Document.Selection; if (selectedText != null) { Windows.UI.Text.ITextCharacterFormat charFormatting = selectedText.CharacterFormat; charFormatting.Italic = Windows.UI.Text.FormatEffect.Toggle; selectedText.CharacterFormat = charFormatting; } }
private void BoldButton_Click(object sender, RoutedEventArgs e) { Windows.UI.Text.ITextSelection selectedText = editor.Document.Selection; if (selectedText != null) { Windows.UI.Text.ITextCharacterFormat charFormatting = selectedText.CharacterFormat; charFormatting.Bold = Windows.UI.Text.FormatEffect.Toggle; selectedText.CharacterFormat = charFormatting; Debug.WriteLine("Triggered"); } }
//************************************************************** // RichEditBox Font Style AppBarToggleButton Checked Events //************************************************************** private void btnBold_Checked(object sender, RoutedEventArgs e) { // Enable Bold Text Windows.UI.Text.ITextSelection selectedText = editor.Document.Selection; if (selectedText != null) { Windows.UI.Text.ITextCharacterFormat charFormatting = selectedText.CharacterFormat; charFormatting.Bold = Windows.UI.Text.FormatEffect.Toggle; selectedText.CharacterFormat = charFormatting; } }
private void btnAlignRight_Checked(object sender, RoutedEventArgs e) { // Enable Right Align Text Windows.UI.Text.ITextSelection selectedText = editor.Document.Selection; if (selectedText != null) { Windows.UI.Text.ITextParagraphFormat paraFormatting = selectedText.ParagraphFormat; paraFormatting.Alignment = Windows.UI.Text.ParagraphAlignment.Right; selectedText.ParagraphFormat = paraFormatting; } btnAlignLeft.IsChecked = false; btnAlignCenter.IsChecked = false; }
private void btnAlignCenter_Unchecked(object sender, RoutedEventArgs e) { // Disable Center Align Text //Windows.UI.Text.ITextSelection selectedText = editor.Document.Selection; //if (selectedText != null) //{ // Windows.UI.Text.ITextParagraphFormat paraFormatting = selectedText.ParagraphFormat; // paraFormatting.Alignment = Windows.UI.Text.ParagraphAlignment.Left; // selectedText.ParagraphFormat = paraFormatting; //} //btnAlignLeft.IsChecked = false; //btnAlignCenter.IsChecked = false; if (btnAlignRight.IsChecked == true) { Windows.UI.Text.ITextSelection selectedText = editor.Document.Selection; if (selectedText != null) { Windows.UI.Text.ITextParagraphFormat paraFormatting = selectedText.ParagraphFormat; paraFormatting.Alignment = Windows.UI.Text.ParagraphAlignment.Right; selectedText.ParagraphFormat = paraFormatting; } btnAlignLeft.IsChecked = false; btnAlignCenter.IsChecked = false; } else if (btnAlignLeft.IsChecked == true) { Windows.UI.Text.ITextSelection selectedText = editor.Document.Selection; if (selectedText != null) { Windows.UI.Text.ITextParagraphFormat paraFormatting = selectedText.ParagraphFormat; paraFormatting.Alignment = Windows.UI.Text.ParagraphAlignment.Left; selectedText.ParagraphFormat = paraFormatting; } btnAlignCenter.IsChecked = false; btnAlignRight.IsChecked = false; } else { // Disable Center Align Text Windows.UI.Text.ITextSelection selectedText = editor.Document.Selection; if (selectedText != null) { Windows.UI.Text.ITextParagraphFormat paraFormatting = selectedText.ParagraphFormat; paraFormatting.Alignment = Windows.UI.Text.ParagraphAlignment.Left; selectedText.ParagraphFormat = paraFormatting; } } }
private void fontStyle_SelectionChanged(object sender, SelectionChangedEventArgs e) { Windows.UI.Text.ITextSelection selectedText = editor.Document.Selection; if (selectedText != null) { //var family = fontStyle.SelectedItem; //string a = "Oblique"; var family = fontStyle.SelectedItem.ToString(); //Windows.UI.Text.ITextCharacterFormat charFormatting1 = selectedText.CharacterFormat; //if (fontStyle.SelectedItem.ToString() == a) //charFormatting1.FontStyle.ToString() = fontStyle.SelectedItem.ToString(); // charFormatting1.FontStyle = Windows.UI.Text.FontStyle. selectedText.CharacterFormat.Name = family; } }
private void UnderlineButton_Click(object sender, RoutedEventArgs e) { Windows.UI.Text.ITextSelection selectedText = editor.Document.Selection; if (selectedText != null) { Windows.UI.Text.ITextCharacterFormat charFormatting = selectedText.CharacterFormat; if (charFormatting.Underline == Windows.UI.Text.UnderlineType.None) { charFormatting.Underline = Windows.UI.Text.UnderlineType.Single; } else { charFormatting.Underline = Windows.UI.Text.UnderlineType.None; } selectedText.CharacterFormat = charFormatting; } }
private void btnUnderline_Unchecked(object sender, RoutedEventArgs e) { // Disable Underlined Text Windows.UI.Text.ITextSelection selectedText = editor.Document.Selection; if (selectedText != null) { Windows.UI.Text.ITextCharacterFormat charFormatting = selectedText.CharacterFormat; if (charFormatting.Underline == Windows.UI.Text.UnderlineType.None) { charFormatting.Underline = Windows.UI.Text.UnderlineType.Single; } else { charFormatting.Underline = Windows.UI.Text.UnderlineType.None; } selectedText.CharacterFormat = charFormatting; } }
//字体变大 private void text_bigger_button_Click(object sender, RoutedEventArgs e) { //ConsoleColor[] colors = (ConsoleColor[])ConsoleColor.GetValues(typeof(ConsoleColor)); Windows.UI.Text.ITextSelection selectedText = editor.Document.Selection; if (selectedText != null) { Windows.UI.Text.ITextCharacterFormat charFormatting = selectedText.CharacterFormat; try { //charFormatting.BackgroundColor = colors[0]; //var color = colors[1]; //selectedText.CharacterFormat.BackgroundColor = color; //ITextSelection selectedText = reb.Document.Selection; if (charFormatting.Size <= 30) { //selectedText.CharacterFormat.BackgroundColor = Colors.Blue; charFormatting.Size++; selectedText.CharacterFormat = charFormatting; } } catch (Exception) { selectedText.CharacterFormat.BackgroundColor = Colors.Red; } } else { try { if (editor.FontSize <= 30) { //selectedText.CharacterFormat.BackgroundColor = Colors.Blue; editor.FontSize++; } } catch (Exception) { //editor.Background = Colors.Red; } } }
private void Fontcolor_SelectionChanged(object sender, SelectionChangedEventArgs e) { Windows.UI.Text.ITextSelection selectedText = editor.Document.Selection; if (selectedText != null) { var combo = (ComboBox)sender; var item = (ComboBoxItem)combo.SelectedItem; var fontcolor = item.Content.ToString(); Windows.UI.Text.ITextCharacterFormat charFormatting = selectedText.CharacterFormat; if (fontcolor == "red") { Color c = Color.Red; charFormatting.ForegroundColor = Windows.UI.Colors.Red; } if (fontcolor == "yellow") { Color c = Color.Red; charFormatting.ForegroundColor = Windows.UI.Colors.Yellow; } if (fontcolor == "blue") { Color c = Color.Red; charFormatting.ForegroundColor = Windows.UI.Colors.Blue; } if (fontcolor == "black") { Color c = Color.Red; charFormatting.ForegroundColor = Windows.UI.Colors.Black; } if (fontcolor == "pink") { Color c = Color.Red; charFormatting.ForegroundColor = Windows.UI.Colors.Pink; } } }