Exemplo n.º 1
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;
     }
 }
Exemplo n.º 2
0
 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;
     }
 }
Exemplo n.º 3
0
 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;
     }
 }
Exemplo n.º 4
0
 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;
     }
 }
Exemplo n.º 5
0
 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;
     }
 }
Exemplo n.º 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;
     }
 }
Exemplo n.º 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");
     }
 }
Exemplo n.º 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;
            }
        }
Exemplo n.º 9
0
 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;
 }
Exemplo n.º 10
0
        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;
                }
            }
        }
Exemplo n.º 11
0
 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;
     }
 }
Exemplo n.º 12
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;
     }
 }
Exemplo n.º 13
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;
     }
 }
Exemplo n.º 14
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;
         }
     }
 }
Exemplo n.º 15
0
        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;
                }
            }
        }