//Color Picker Colour OnColour Changed Method private void ColorPicker_ColorChanged(object sender, Windows.UI.Color color) { Windows.UI.Text.ITextSelection selectedText = editBox.Document.Selection; if (selectedText != null) { Windows.UI.Text.ITextCharacterFormat charFormatting = selectedText.CharacterFormat; charFormatting.ForegroundColor = color; } }
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 SetFontSize(int size) { Windows.UI.Text.ITextSelection selectedText = editor.Document.Selection; if (selectedText != null) { Windows.UI.Text.ITextCharacterFormat charFormatting = selectedText.CharacterFormat; charFormatting.Size = size; selectedText.CharacterFormat = charFormatting; } }
private void SubScriptClicked(object sender, PointerRoutedEventArgs e) { Windows.UI.Text.ITextSelection selectedText = TxtArea.Document.Selection; if (selectedText != null) { Windows.UI.Text.ITextCharacterFormat charFormatting = selectedText.CharacterFormat; charFormatting.Subscript = Windows.UI.Text.FormatEffect.Toggle; selectedText.CharacterFormat = charFormatting; } }
private void ItalicButton_Click(object sender, RoutedEventArgs e) { Windows.UI.Text.ITextSelection selectedText = editor.Document.Selection; //check for selected text, either highlighted or a point if (selectedText != null) //should be != null in most cases { Windows.UI.Text.ITextCharacterFormat charFormatting = selectedText.CharacterFormat; charFormatting.Italic = Windows.UI.Text.FormatEffect.Toggle;//toggle italics selectedText.CharacterFormat = charFormatting; } }
private void ChangeColor() { // Apply the color to the selected text in a RichEditBox. Windows.UI.Text.ITextSelection selectedText = richEdit.Document.Selection; if (selectedText != null) { Windows.UI.Text.ITextCharacterFormat charFormatting = selectedText.CharacterFormat; charFormatting.ForegroundColor = _currentColorBrush.Color; selectedText.CharacterFormat = charFormatting; } }
/// <summary> /// Underlines the specified selected text. /// </summary> /// <param name="selectedText">The selected text.</param> public void Underline(Windows.UI.Text.ITextSelection selectedText) { 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 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; } }
//ALLCAPS Button private void allCapsbtn_Click(object sender, RoutedEventArgs e) { Windows.UI.Text.ITextSelection selectedText = editBox.Document.Selection; if (selectedText != null) { Windows.UI.Text.ITextCharacterFormat charFormatting = selectedText.CharacterFormat; if (charFormatting.AllCaps == Windows.UI.Text.FormatEffect.Off) { charFormatting.AllCaps = Windows.UI.Text.FormatEffect.On; } else { charFormatting.AllCaps = Windows.UI.Text.FormatEffect.Off; } selectedText.CharacterFormat = charFormatting; } }
private void HighlightButton_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.BackgroundColor == Windows.UI.Colors.White) //Check if unhighlighted { charFormatting.BackgroundColor = Windows.UI.Colors.Yellow; //highlight } else //oh but it was already highlight { charFormatting.BackgroundColor = Windows.UI.Colors.White; //too bad so sad } selectedText.CharacterFormat = charFormatting; } }
/// <summary> /// Italics the text selected. /// </summary> /// <param name="selectedText">The selected text.</param> public void ItalicBtnClicked(Windows.UI.Text.ITextSelection selectedText) { Windows.UI.Text.ITextCharacterFormat charFormatting = selectedText.CharacterFormat; charFormatting.Italic = Windows.UI.Text.FormatEffect.Toggle; selectedText.CharacterFormat = charFormatting; }