Esempio n. 1
0
 public FontStyleData(string name, FontStyle fontStyle, FontWeight fontWeight, TextDecorationLocation? textDecoration, FontVariants fontVariant, FontCapitals fontCapitals, double fontSize)
 {
     _name = name;
     _fontStyle = fontStyle;
     _fontWeight = fontWeight;
     _textDecoration = textDecoration;
     _fontVariant = fontVariant;
     _fontCapitals = fontCapitals;
     _fontSize = fontSize;
 }
Esempio n. 2
0
 public FontChoice(DependencyObject dependencyObject)
 {
     _family                 = dependencyObject.GetValue(TextElement.FontFamilyProperty)  as FontFamily;
     _style                  = (FontStyle)dependencyObject.GetValue(TextElement.FontStyleProperty);
     _weight                 = (FontWeight)dependencyObject.GetValue(TextElement.FontWeightProperty);
     _stretch                = (FontStretch)dependencyObject.GetValue(TextElement.FontStretchProperty);
     _size                   = (double)dependencyObject.GetValue(TextElement.FontSizeProperty);
     _decoration             = dependencyObject.GetValue(Inline.TextDecorationsProperty)  as TextDecorationCollection;
     _brush                  = dependencyObject.GetValue(TextElement.ForegroundProperty)  as Brush;
     _annotationAlternates   = (int)dependencyObject.GetValue(Typography.AnnotationAlternatesProperty);
     _capitals               = (FontCapitals)dependencyObject.GetValue(Typography.CapitalsProperty);
     _capitalSpacing         = (bool)dependencyObject.GetValue(Typography.CapitalSpacingProperty);
     _caseSensitiveForms     = (bool)dependencyObject.GetValue(Typography.CaseSensitiveFormsProperty);
     _contextualAlternates   = (bool)dependencyObject.GetValue(Typography.ContextualAlternatesProperty);
     _contextualLigatures    = (bool)dependencyObject.GetValue(Typography.ContextualLigaturesProperty);
     _contextualSwashes      = (int)dependencyObject.GetValue(Typography.ContextualSwashesProperty);
     _discretionaryLigatures = (bool)dependencyObject.GetValue(Typography.DiscretionaryLigaturesProperty);
     _eastAsianExpertForms   = (bool)dependencyObject.GetValue(Typography.EastAsianExpertFormsProperty);
     _eastAsianLanguage      = (FontEastAsianLanguage)dependencyObject.GetValue(Typography.EastAsianLanguageProperty);
     _eastAsianWidths        = (FontEastAsianWidths)dependencyObject.GetValue(Typography.EastAsianWidthsProperty);
     _fraction               = (FontFraction)dependencyObject.GetValue(Typography.FractionProperty);
     _historicalForms        = (bool)dependencyObject.GetValue(Typography.HistoricalFormsProperty);
     _historicalLigatures    = (bool)dependencyObject.GetValue(Typography.HistoricalLigaturesProperty);
     _kerning                = (bool)dependencyObject.GetValue(Typography.KerningProperty);
     _mathematicalGreek      = (bool)dependencyObject.GetValue(Typography.MathematicalGreekProperty);
     _numeralAlignment       = (FontNumeralAlignment)dependencyObject.GetValue(Typography.NumeralAlignmentProperty);
     _numeralStyle           = (FontNumeralStyle)dependencyObject.GetValue(Typography.NumeralStyleProperty);
     _slashedZero            = (bool)dependencyObject.GetValue(Typography.SlashedZeroProperty);
     _standardLigatures      = (bool)dependencyObject.GetValue(Typography.StandardLigaturesProperty);
     _standardSwashes        = (int)dependencyObject.GetValue(Typography.StandardSwashesProperty);
     _stylisticAlternates    = (int)dependencyObject.GetValue(Typography.StylisticAlternatesProperty);
     _stylisticSet1          = (bool)dependencyObject.GetValue(Typography.StylisticSet1Property);
     _stylisticSet2          = (bool)dependencyObject.GetValue(Typography.StylisticSet2Property);
     _stylisticSet3          = (bool)dependencyObject.GetValue(Typography.StylisticSet3Property);
     _stylisticSet4          = (bool)dependencyObject.GetValue(Typography.StylisticSet4Property);
     _stylisticSet5          = (bool)dependencyObject.GetValue(Typography.StylisticSet5Property);
     _stylisticSet6          = (bool)dependencyObject.GetValue(Typography.StylisticSet6Property);
     _stylisticSet7          = (bool)dependencyObject.GetValue(Typography.StylisticSet7Property);
     _stylisticSet8          = (bool)dependencyObject.GetValue(Typography.StylisticSet8Property);
     _stylisticSet9          = (bool)dependencyObject.GetValue(Typography.StylisticSet9Property);
     _stylisticSet10         = (bool)dependencyObject.GetValue(Typography.StylisticSet10Property);
     _stylisticSet11         = (bool)dependencyObject.GetValue(Typography.StylisticSet11Property);
     _stylisticSet12         = (bool)dependencyObject.GetValue(Typography.StylisticSet12Property);
     _stylisticSet13         = (bool)dependencyObject.GetValue(Typography.StylisticSet13Property);
     _stylisticSet14         = (bool)dependencyObject.GetValue(Typography.StylisticSet14Property);
     _stylisticSet15         = (bool)dependencyObject.GetValue(Typography.StylisticSet15Property);
     _stylisticSet16         = (bool)dependencyObject.GetValue(Typography.StylisticSet16Property);
     _stylisticSet17         = (bool)dependencyObject.GetValue(Typography.StylisticSet17Property);
     _stylisticSet18         = (bool)dependencyObject.GetValue(Typography.StylisticSet18Property);
     _stylisticSet19         = (bool)dependencyObject.GetValue(Typography.StylisticSet19Property);
     _stylisticSet20         = (bool)dependencyObject.GetValue(Typography.StylisticSet20Property);
     _variants               = (FontVariants)dependencyObject.GetValue(Typography.VariantsProperty);
 }
Esempio n. 3
0
 public FontChoice(FontChoice choice)
 {
     _family                 = choice._family;
     _style                  = choice._style;
     _weight                 = choice._weight;
     _stretch                = choice._stretch;
     _size                   = choice._size;
     _decoration             = choice._decoration;
     _brush                  = choice._brush;
     _annotationAlternates   = choice._annotationAlternates;
     _capitals               = choice._capitals;
     _capitalSpacing         = choice._capitalSpacing;
     _caseSensitiveForms     = choice._caseSensitiveForms;
     _contextualAlternates   = choice._contextualAlternates;
     _contextualLigatures    = choice._contextualLigatures;
     _contextualSwashes      = choice._contextualSwashes;
     _discretionaryLigatures = choice._discretionaryLigatures;
     _eastAsianExpertForms   = choice._eastAsianExpertForms;
     _eastAsianLanguage      = choice._eastAsianLanguage;
     _eastAsianWidths        = choice._eastAsianWidths;
     _fraction               = choice._fraction;
     _historicalForms        = choice._historicalForms;
     _historicalLigatures    = choice._historicalLigatures;
     _kerning                = choice._kerning;
     _mathematicalGreek      = choice._mathematicalGreek;
     _numeralAlignment       = choice._numeralAlignment;
     _numeralStyle           = choice._numeralStyle;
     _slashedZero            = choice._slashedZero;
     _standardLigatures      = choice._standardLigatures;
     _standardSwashes        = choice._standardSwashes;
     _stylisticAlternates    = choice._stylisticAlternates;
     _stylisticSet1          = choice._stylisticSet1;
     _stylisticSet2          = choice._stylisticSet2;
     _stylisticSet3          = choice._stylisticSet3;
     _stylisticSet4          = choice._stylisticSet4;
     _stylisticSet5          = choice._stylisticSet5;
     _stylisticSet6          = choice._stylisticSet6;
     _stylisticSet7          = choice._stylisticSet7;
     _stylisticSet8          = choice._stylisticSet8;
     _stylisticSet9          = choice._stylisticSet9;
     _stylisticSet10         = choice._stylisticSet10;
     _stylisticSet11         = choice._stylisticSet11;
     _stylisticSet12         = choice._stylisticSet12;
     _stylisticSet13         = choice._stylisticSet13;
     _stylisticSet14         = choice._stylisticSet14;
     _stylisticSet15         = choice._stylisticSet15;
     _stylisticSet16         = choice._stylisticSet16;
     _stylisticSet17         = choice._stylisticSet17;
     _stylisticSet18         = choice._stylisticSet18;
     _stylisticSet19         = choice._stylisticSet19;
     _stylisticSet20         = choice._stylisticSet20;
     _variants               = choice._variants;
 }
        // Token: 0x0600383B RID: 14395 RVA: 0x000FAD64 File Offset: 0x000F8F64
        private static void OnToggleSuperscript(object sender, ExecutedRoutedEventArgs args)
        {
            TextEditor textEditor = TextEditor._GetTextEditor(sender);

            if (textEditor == null || !textEditor._IsEnabled || textEditor.IsReadOnly || !textEditor.AcceptsRichContent || !(textEditor.Selection is TextSelection))
            {
                return;
            }
            TextEditorTyping._FlushPendingInputItems(textEditor);
            FontVariants fontVariants = (FontVariants)((TextSelection)textEditor.Selection).GetCurrentValue(Typography.VariantsProperty);

            fontVariants = ((fontVariants == FontVariants.Superscript) ? FontVariants.Normal : FontVariants.Superscript);
            TextEditorCharacters._OnApplyProperty(textEditor, Typography.VariantsProperty, fontVariants);
        }
Esempio n. 5
0
        private void Txt_SelectionChanged(object sender, RoutedEventArgs e)
        {
            try
            {
                if (txt.Selection.GetPropertyValue(FontSizeProperty) == DependencyProperty.UnsetValue)
                {
                    ComboBox_FontSize.Text = "---";
                }
                else
                {
                    ComboBox_FontSize.Text = "" + txt.Selection.GetPropertyValue(FontSizeProperty);
                }

                ComboBox_FontName.Text = txt.Selection.GetPropertyValue(FontFamilyProperty).ToString();

                if (((FontWeight)txt.Selection.GetPropertyValue(TextElement.FontWeightProperty)) == FontWeights.Bold)
                {
                    SButton_Bold.SetChecked(true);
                }
                else
                {
                    SButton_Bold.SetChecked(false);
                }


                if (((System.Windows.FontStyle)txt.Selection.GetPropertyValue(TextElement.FontStyleProperty)) == FontStyles.Italic)
                {
                    SButton_Italic.SetChecked(true);
                }
                else
                {
                    SButton_Italic.SetChecked(false);
                }

                FontVariants fv = (FontVariants)txt.Selection.GetPropertyValue(Typography.VariantsProperty);

                if (fv == FontVariants.Subscript)
                {
                    SButton_SubScript.SetCheckedNoCall(true);
                    SButton_SuperScript.SetCheckedNoCall(false);
                }
                else if (fv == FontVariants.Superscript)
                {
                    SButton_SuperScript.SetCheckedNoCall(true);
                    SButton_SubScript.SetCheckedNoCall(false);
                }
                else
                {
                    SButton_SubScript.SetCheckedNoCall(false);
                    SButton_SuperScript.SetCheckedNoCall(false);
                }


                TextDecorationCollection td = (TextDecorationCollection)txt.Selection.GetPropertyValue(Inline.TextDecorationsProperty);

                if (td == TextDecorations.Underline)
                {
                    SButton_Underline.SetCheckedNoCall(true);
                    SButton_Strikeline.SetCheckedNoCall(false);
                }
                else if (td == TextDecorations.Strikethrough)
                {
                    SButton_Underline.SetCheckedNoCall(false);
                    SButton_Strikeline.SetCheckedNoCall(true);
                }
                else
                {
                    SButton_Underline.SetCheckedNoCall(false);
                    SButton_Strikeline.SetCheckedNoCall(false);
                }


                TextAlignment textalign = (TextAlignment)txt.Selection.GetPropertyValue(Paragraph.TextAlignmentProperty);

                Button_LeftAlign.SetCheckedNoCall(false);
                Button_RightAlign.SetCheckedNoCall(false);
                Button_CenterAlign.SetCheckedNoCall(false);
                Button_JustifyAlign.SetCheckedNoCall(false);

                if (textalign == TextAlignment.Left)
                {
                    Button_LeftAlign.SetCheckedNoCall(true);
                }
                else if (textalign == TextAlignment.Center)
                {
                    Button_CenterAlign.SetCheckedNoCall(true);
                }
                else if (textalign == TextAlignment.Right)
                {
                    Button_RightAlign.SetCheckedNoCall(true);
                }
                else if (textalign == TextAlignment.Justify)
                {
                    Button_JustifyAlign.SetCheckedNoCall(true);
                }



                BackColor.Fill = (SolidColorBrush)txt.Selection.GetPropertyValue(Inline.BackgroundProperty);
                ForColor.Fill  = (SolidColorBrush)txt.Selection.GetPropertyValue(Inline.ForegroundProperty);
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Selection Changed: " + ex);
            }
        }
 public void SetVariants(FontVariants value)
 {
     _variant = value;
     OnPropertiesChanged();
 }
Esempio n. 7
0
        private static IEnumerable <Inline> Parse(IEnumerable <XNode> nodes, FontFamily fontFamily, Brush fontColor, FontWeight fontWeight, FontStyle fontStyle, TextDecorations textDecoration, FontVariants fontVariants)
        {
            foreach (var current in nodes)
            {
                switch (current)
                {
                case XText xText:
                    var run = new Run()
                    {
                        Text = xText.Value, FontWeight = fontWeight, FontStyle = fontStyle, TextDecorations = textDecoration
                    };
                    if (fontFamily != null)
                    {
                        run.FontFamily = fontFamily;
                    }
                    if (fontColor != null)
                    {
                        run.Foreground = fontColor;
                    }
                    Typography.SetVariants(run, fontVariants);
                    yield return(run);

                    break;

                case XElement xElement:
                {
                    switch (xElement.Name.LocalName.ToLower())
                    {
                    case "b":
                    case "strong":
                    {
                        FontWeight newFontWeight = FontWeights.Bold;
                        var        weight        = xElement.Attribute("weight")?.Value;
                        if (!string.IsNullOrEmpty(weight))
                        {
                            switch (weight.ToLower())
                            {
                            case "950":
                            case "extrablack":
                                newFontWeight = FontWeights.ExtraBlack;
                                break;

                            case "900":
                            case "black":
                                newFontWeight = FontWeights.Black;
                                break;

                            case "800":
                            case "extrabold":
                                newFontWeight = FontWeights.ExtraBold;
                                break;

                            case "700":
                            case "bold":
                                newFontWeight = FontWeights.Bold;
                                break;

                            case "600":
                            case "semibold":
                                newFontWeight = FontWeights.SemiBold;
                                break;

                            case "500":
                            case "medium":
                                newFontWeight = FontWeights.Medium;
                                break;

                            case "400":
                            case "normal":
                                newFontWeight = FontWeights.Normal;
                                break;

                            case "350":
                            case "semilight":
                                newFontWeight = FontWeights.SemiLight;
                                break;

                            case "300":
                            case "light":
                                newFontWeight = FontWeights.Light;
                                break;

                            case "200":
                            case "extralight":
                                newFontWeight = FontWeights.ExtraLight;
                                break;

                            case "100":
                            case "thin":
                                newFontWeight = FontWeights.Thin;
                                break;
                            }
                        }
                        foreach (var item in Parse(xElement.Nodes(), fontFamily, fontColor, newFontWeight, fontStyle, textDecoration, fontVariants))
                        {
                            yield return(item);
                        }
                        break;
                    }

                    case "em":
                    case "i":
                    case "cite":
                    case "dfn":
                        foreach (var item in Parse(xElement.Nodes(), fontFamily, fontColor, fontWeight, FontStyle.Italic, textDecoration, fontVariants))
                        {
                            yield return(item);
                        }
                        break;

                    case "u":
                        foreach (var item in Parse(xElement.Nodes(), fontFamily, fontColor, fontWeight, fontStyle, TextDecorations.Underline, fontVariants))
                        {
                            yield return(item);
                        }
                        break;

                    case "s":
                    case "strike":
                    case "del":
                        foreach (var item in Parse(xElement.Nodes(), fontFamily, fontColor, fontWeight, fontStyle, TextDecorations.Strikethrough, fontVariants))
                        {
                            yield return(item);
                        }
                        break;

                    case "font":
                    {
                        Brush      newFontColor  = null;
                        FontFamily newFontFamily = null;

                        var colorStr = xElement.Attribute("color")?.Value;
                        if (!string.IsNullOrEmpty(colorStr))
                        {
                            try
                            {
                                var color = XamlBindingHelper.ConvertValue(typeof(Windows.UI.Color), colorStr) as Color?;
                                if (color.HasValue)
                                {
                                    newFontColor = new SolidColorBrush()
                                    {
                                        Color = color.Value
                                    };
                                }
                            }
                            catch { }
                        }

                        var faceStr = xElement.Attribute("face")?.Value;
                        if (!string.IsNullOrEmpty(faceStr))
                        {
                            newFontFamily = new FontFamily(faceStr);
                        }

                        foreach (var item in Parse(xElement.Nodes(), newFontFamily ?? fontFamily, newFontColor ?? fontColor, fontWeight, fontStyle, textDecoration, fontVariants))
                        {
                            yield return(item);
                        }
                    }
                    break;

                    case "tt":
                    {
                        foreach (var item in Parse(xElement.Nodes(), new FontFamily("Consolas"), fontColor, fontWeight, fontStyle, textDecoration, fontVariants))
                        {
                            yield return(item);
                        }
                    }
                    break;

                    case "sup":
                    {
                        foreach (var item in Parse(xElement.Nodes(), fontFamily, fontColor, fontWeight, fontStyle, textDecoration, FontVariants.Superscript))
                        {
                            yield return(item);
                        }
                    }
                    break;

                    case "sub":
                    {
                        foreach (var item in Parse(xElement.Nodes(), fontFamily, fontColor, fontWeight, fontStyle, textDecoration, FontVariants.Subscript))
                        {
                            yield return(item);
                        }
                    }
                    break;

                    case "br":
                    {
                        yield return(new LineBreak());
                    }
                    break;

                    case "a":
                    {
                        var href = xElement.Attribute("href")?.Value;
                        if (!string.IsNullOrEmpty(href))
                        {
                            var hyperlink = new Hyperlink()
                            {
                                NavigateUri    = new Uri(href),
                                UnderlineStyle = UnderlineStyle.None
                            };
                            foreach (var item in Parse(xElement.Nodes(), fontFamily, fontColor, fontWeight, fontStyle, textDecoration, fontVariants))
                            {
                                hyperlink.Inlines.Add(item);
                            }
                            yield return(hyperlink);
                        }
                        else
                        {
                            //ignore the hyperlink
                            foreach (var item in Parse(xElement.Nodes(), fontFamily, fontColor, fontWeight, fontStyle, textDecoration, fontVariants))
                            {
                                yield return(item);
                            }
                        }
                    }
                    break;

                    default:
                        //ignore the element
                        foreach (var item in Parse(xElement.Nodes(), fontFamily, fontColor, fontWeight, fontStyle, textDecoration, fontVariants))
                        {
                            yield return(item);
                        }
                        break;
                    }
                }
                break;
                }
            }
        }
Esempio n. 8
0
 public static void SetVariants(DependencyObject element, FontVariants value)
 {
     SetTypographyValue(element, VariantsProperty, value);
 }
Esempio n. 9
0
        /// <summary>
        /// Writes the attached property Variants to the given element.
        /// </summary>
        /// <param name="element">The element to which to write the attached property.</param>
        /// <param name="value">The property value to set</param>
        /// <seealso cref="Typography.VariantsProperty" />
        public static void SetVariants(DependencyObject element, FontVariants value)
        {
            if (element == null)
            {
                throw new ArgumentNullException("element");
            }

            element.SetValue(VariantsProperty, value);
        }
 // Token: 0x060066F1 RID: 26353 RVA: 0x001CD2B3 File Offset: 0x001CB4B3
 public void SetVariants(FontVariants value)
 {
     this._variant = value;
     base.OnPropertiesChanged();
 }
 public void SetVariants(FontVariants value)
 {
     _variant = value;
     OnPropertiesChanged();
 }