Example #1
0
 //字体变小
 private void text_smaller_button_Click(object sender, RoutedEventArgs e)
 {
     Windows.UI.Text.ITextSelection selectedText = editor.Document.Selection;
     if (selectedText != null)
     {
         Windows.UI.Text.ITextCharacterFormat charFormatting = selectedText.CharacterFormat;
         try
         {
             if (charFormatting.Size >= 7)
             {
                 //selectedText.CharacterFormat.BackgroundColor = Colors.Blue;
                 charFormatting.Size--;
                 selectedText.CharacterFormat = charFormatting;
             }
         }
         catch (Exception)
         {
             selectedText.CharacterFormat.BackgroundColor = Colors.Red;
         }
     }
     else
     {
         if (editor.FontSize >= 7)
         {
             editor.FontSize--;
         }
     }
 }
        private void FontsizeComboBox_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 fontsize = item.Content.ToString();
                Windows.UI.Text.ITextCharacterFormat charFormatting = selectedText.CharacterFormat;
                if (fontsize == "8")
                {
                    charFormatting.Size = 8;
                }
                else if (fontsize == "10")
                {
                    charFormatting.Size = 10;
                }
                else if (fontsize == "12")
                {
                    charFormatting.Size = 12;
                }
                else if (fontsize == "14")
                {
                    charFormatting.Size = 14;
                }
                else if (fontsize == "16")
                {
                    charFormatting.Size = 16;
                }

                selectedText.CharacterFormat = charFormatting;
            }
        }
Example #3
0
 private void AppBarButton_Click_5(object sender, RoutedEventArgs e)
 {
     Windows.UI.Text.ITextSelection selectedText = NoteContent.Document.Selection;
     if (selectedText != null)
     {
         Windows.UI.Text.ITextCharacterFormat charFormatting = selectedText.CharacterFormat;
         charFormatting.Bold          = Windows.UI.Text.FormatEffect.Toggle;
         selectedText.CharacterFormat = charFormatting;
     }
 }
Example #4
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;
     }
 }
 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;
     }
 }
Example #6
0
 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;
     }
 }
Example #7
0
 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");
     }
 }
Example #8
0
        //**************************************************************
        // 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 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;
     }
 }
Example #10
0
 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;
     }
 }
Example #11
0
 //字体变大
 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;
                }
            }
        }