Пример #1
0
 private void DeleteButtonClicked(object sender, PointerRoutedEventArgs e)
 {
     Windows.UI.Text.ITextSelection selectedText = TxtArea.Document.Selection;
     if (selectedText != null)
     {
         selectedText.Cut();
     }
 }
Пример #2
0
        private void SelectAllButtonClicked(object sender, PointerRoutedEventArgs e)
        {
            Windows.UI.Text.ITextSelection selection = TxtArea.Document.Selection;
            selection.StartPosition = 0;
            int end = TxtArea.Document.ToString().Length;

            selection.EndPosition = end;
        }
Пример #3
0
 private void ApplyListStyle(string listStyle)
 {
     Windows.UI.Text.ITextSelection selectedText = richEdit.Document.Selection;
     if (selectedText != null)
     {
         selectedText.ParagraphFormat.ListType = _listStyles[listStyle ?? "none"];
     }
 }
Пример #4
0
 /// <summary>
 /// Handles the Click event of the UnderlineButton control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param>
 private void UnderlineButton_Click(object sender, RoutedEventArgs e)
 {
     Windows.UI.Text.ITextSelection selectedText = draftEditor.Document.Selection;
     if (selectedText != null)
     {
         ViewModel.Underline(selectedText);
     }
 }
 //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;
     }
 }
Пример #6
0
 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;
     }
 }
Пример #7
0
 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;
     }
 }
Пример #8
0
 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;
     }
 }
Пример #9
0
 private void ListButton_Click(object sender, RoutedEventArgs e)
 {
     Windows.UI.Text.ITextSelection selectedText = Editor.Document.Selection;
     if (selectedText != null)
     {
         Windows.UI.Text.ITextParagraphFormat paragraphFormatting = selectedText.ParagraphFormat;
         paragraphFormatting.ListType = Windows.UI.Text.MarkerType.Bullet;
         selectedText.ParagraphFormat = paragraphFormatting;
     }
 }
Пример #10
0
 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;
     }
 }
Пример #11
0
 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;
     }
 }
Пример #12
0
 /// <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;
 }
Пример #13
0
 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;
     }
 }
 //Right Align Button
 private void rightbtn_Click(object sender, RoutedEventArgs e)
 {
     Windows.UI.Text.ITextSelection selectedText = editBox.Document.Selection;
     if (selectedText != null)
     {
         Windows.UI.Text.ITextParagraphFormat charFormatting = selectedText.ParagraphFormat;
         if (charFormatting.Alignment != Windows.UI.Text.ParagraphAlignment.Right)
         {
             charFormatting.Alignment = Windows.UI.Text.ParagraphAlignment.Right;
         }
         else
         {
             //charFormatting.Alignment = Windows.UI.Text.ParagraphAlignment.Right;
         }
         selectedText.ParagraphFormat = charFormatting;
     }
 }
Пример #16
0
 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;
     }
 }
Пример #17
0
        private void ColorText_DropDownClosed(object sender, object e)
        {
            Windows.UI.Text.ITextSelection select = Edit.Document.Selection;

            switch ((sender as ComboBox).SelectedIndex)
            {
            case 0:
            {
                Edit.Document.Selection.CharacterFormat.ForegroundColor = Windows.UI.Colors.Black;
                break;
            }

            case 1:
            {
                Edit.Document.Selection.CharacterFormat.ForegroundColor = Windows.UI.Colors.White;
                break;
            }

            case 2:
            {
                Edit.Document.Selection.CharacterFormat.ForegroundColor = Windows.UI.Colors.Red;
                break;
            }

            case 3:
            {
                Edit.Document.Selection.CharacterFormat.ForegroundColor = Windows.UI.Colors.Green;
                break;
            }

            case 4:
            {
                Edit.TextDocument.Selection.CharacterFormat.ForegroundColor = Windows.UI.Colors.Blue;
                break;
            }

            case 5:
            {
                Edit.Document.Selection.CharacterFormat.ForegroundColor = Windows.UI.Colors.Yellow;
                break;
            }
            }
            Edit.Focus(FocusState.Programmatic);
        }
Пример #18
0
 /// <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;
 }