public void Set(TextBlock textBlock)
 {
     this.fontFamily = textBlock.FontFamily;
     this.fontWeight = textBlock.FontWeight;
     this.fontStyle = textBlock.FontStyle;
     this.fontStretch = textBlock.FontStretch;
 }
示例#2
0
        LocalizationService()
        {
#if HAS_UNO
            m_language      = "en-US";
            m_flowDirection = FlowDirection.LeftToRight;
#else
            m_language      = ApplicationLanguages.Languages[0];
            m_flowDirection =
                ResourceContext.GetForCurrentView().QualifierValues["LayoutDirection"] != "LTR" ? FlowDirection.RightToLeft : FlowDirection.LeftToRight;
#endif

            var resourceLoader = AppResourceProvider.GetInstance();
            m_fontFamilyOverride = resourceLoader.GetResourceString("LocalizedFontFamilyOverride");

            string reserved = "RESERVED_FOR_FONTLOC";

            m_overrideFontApiValues = ((m_fontFamilyOverride != null) && (m_fontFamilyOverride != reserved));
            if (m_overrideFontApiValues)
            {
                string localizedUICaptionFontSizeFactorOverride = resourceLoader.GetResourceString("LocalizedUICaptionFontSizeFactorOverride");
                string localizedUITextFontSizeFactorOverride    = resourceLoader.GetResourceString("LocalizedUITextFontSizeFactorOverride");
                string localizedFontWeightOverride = resourceLoader.GetResourceString("LocalizedFontWeightOverride");

                // If any of the font overrides are modified then all of them need to be modified
                Debug.Assert(localizedFontWeightOverride != reserved);
                Debug.Assert(localizedUITextFontSizeFactorOverride != reserved);
                Debug.Assert(localizedUICaptionFontSizeFactorOverride != reserved);

                m_fontWeightOverride               = ParseFontWeight(localizedFontWeightOverride);
                m_uiTextFontScaleFactorOverride    = double.Parse(localizedUITextFontSizeFactorOverride);
                m_uiCaptionFontScaleFactorOverride = double.Parse(localizedUICaptionFontSizeFactorOverride);
            }

            m_fontGroup = new LanguageFontGroup(m_language);
        }
示例#3
0
        static FontAttributes ToAttributes(FWeight fontWeight)
        {
            if (fontWeight.Weight == FontWeights.Bold.Weight || fontWeight.Weight == FontWeights.SemiBold.Weight ||
                fontWeight.Weight == FontWeights.ExtraBold.Weight)
            {
                return(FontAttributes.Bold);
            }

            return(FontAttributes.None);
        }
 /// <summary>
 /// Outputs text with formating.
 /// </summary>
 /// <param name="target">The target <see cref="TextBlock"/>.</param>
 /// <param name="toOutput">String to output.</param>
 /// <param name="fontStyle">The font style.</param>
 /// <param name="fontWeight">The font weight.</param>
 /// <param name="fontColor">Color of the font.</param>
 public static void OutputWithFormat(this TextBlock target, string toOutput,
     FontStyle fontStyle = FontStyle.Normal,
     FontWeight fontWeight = default(FontWeight),
     Color fontColor = default(Color))
 {
     var formatted = new Run
     {
         Text = toOutput,
         FontStyle = fontStyle,
         FontWeight = fontWeight.Equals(default(FontWeight)) ? FontWeights.Normal : fontWeight,
         Foreground = fontColor.Equals(default(Color)) ? new SolidColorBrush(Colors.Black) : new SolidColorBrush(fontColor)
     };
     target.Inlines.Add(formatted);
 }
示例#5
0
 internal static string GetFontWeightString(Windows.UI.Text.FontWeight fontWeight)
 {
     if (infos == null)
     {
         // hdt
         infos = typeof(FontWeights).GetRuntimeProperties().ToArray <PropertyInfo>();
     }
     for (int i = 0; i < infos.Length; i++)
     {
         object obj2 = infos[i].GetValue(null);
         if ((obj2 != null) && (((Windows.UI.Text.FontWeight)obj2).Weight == fontWeight.Weight))
         {
             return(infos[i].Name);
         }
     }
     return("Normal");
 }
示例#6
0
        public static FontStyle Convert(wut.FontStyle fontStyle, wut.FontWeight fontWeight)
        {
            var style = FontStyle.None;

            if (fontStyle == wut.FontStyle.Italic)
            {
                style |= FontStyle.Italic;
            }
            if (fontStyle == wut.FontStyle.Oblique)
            {
                style |= FontStyle.Italic;
            }
            if (ReferenceEquals(fontWeight, wut.FontWeights.Bold))
            {
                style |= FontStyle.Bold;
            }
            return(style);
        }
示例#7
0
 void Init()
 {
     this._fontTheme                 = null;
     this._fontFamily                = null;
     this._fontSize                  = -1.0;
     this._fontStretch               = Windows.UI.Text.FontStretch.Normal;
     this._fontStyle                 = Windows.UI.Text.FontStyle.Normal;
     this._fontWeight                = FontWeights.Normal;
     this._fill                      = null;
     this._fillThemeColor            = null;
     this._foreground                = null;
     this._foregroundThemeColor      = null;
     this._strokeThickness           = 1.0;
     this._stroke                    = null;
     this._strokeDashType            = Dt.Cells.Data.StrokeDashType.None;
     this._strokeThemeColor          = null;
     this._cornerRadius              = -1.0;
     this._themeContext              = null;
     this._cornerRadiusSet           = false;
     this._fillSet                   = false;
     this._fillThemeColorSet         = false;
     this._fontFamilySet             = false;
     this._fontSizeSet               = false;
     this._fontStretchSet            = false;
     this._fontStyleSet              = false;
     this._fontThemeSet              = false;
     this._fontWeightSet             = false;
     this._foregroundSet             = false;
     this._foregroundThemeColorSet   = false;
     this._strokeDashTypeSet         = false;
     this._strokeSet                 = false;
     this._strokeThemeColorSet       = false;
     this._strokeThicknessSet        = false;
     this._formatter                 = null;
     this._formatterSet              = false;
     this._lineCapType               = PenLineCap.Flat;
     this._lineCapTypeSet            = false;
     this._lineJoinType              = PenLineJoin.Round;
     this._lineJoinTypeSet           = false;
     this._lineBeginArrowSettings    = null;
     this._lineBeginArrowSettingsSet = false;
     this._lineEndArrowSettings      = null;
     this._lineEndArrowSettingsSet   = false;
 }
示例#8
0
        //const double lineHeightToFontSizeRatio = 1.4;
        //const double roundToNearest = 1;

        public static SharpDX.DirectWrite.FontWeight ToDxFontWeight(this Windows.UI.Text.FontWeight fontWeight)
        => DxFontWeight(fontWeight.Weight);
示例#9
0
        /// <summary>
        /// Applies the DataTemplate to display on base of DisplayStyle and Alignment property values.
        /// </summary>
        private void ApplyContentTemplate()
        {
            if (_attachedElement == null || _applyingTemplate)
            {
                return;
            }

            _applyingTemplate = true;
            var root = TreeHelpers.GetRootPanel().Parent;
            var style = GetDisplayStyle(root);
            var sketchTemplateUri = new Uri("ms-appx:///Neumann.HelpFrame/SketchStyle.xaml", UriKind.Absolute);
            var popupTemplateUri = new Uri("ms-appx:///Neumann.HelpFrame/PopupStyle.xaml", UriKind.Absolute);

            var direction = (HelpFrameAlignment)_attachedElement.GetValue(AlignmentProperty);
            if (direction == HelpFrameAlignment.TopLeft ||
                direction == HelpFrameAlignment.TopRight ||
                direction == HelpFrameAlignment.TopCenter ||
                direction == HelpFrameAlignment.CenterCenter)
            {
                if (style == HelpFrameDisplayStyle.Sketch)
                {
                    this.ContentTemplate = ResourceHelpers.GetResourceFromDictionary<DataTemplate>(sketchTemplateUri, "TopSketchTemplate");
                }
                else if (style == HelpFrameDisplayStyle.Popup)
                {
                    this.ContentTemplate = ResourceHelpers.GetResourceFromDictionary<DataTemplate>(popupTemplateUri, "TopPopupTemplate");
                }
                else
                {
                    this.ContentTemplate = this.TopTemplate;
                }
            }
            else if (direction == HelpFrameAlignment.BottomLeft ||
                direction == HelpFrameAlignment.BottomRight ||
                direction == HelpFrameAlignment.BottomCenter)
            {
                if (style == HelpFrameDisplayStyle.Sketch)
                {
                    this.ContentTemplate = ResourceHelpers.GetResourceFromDictionary<DataTemplate>(sketchTemplateUri, "BottomSketchTemplate");
                }
                else if (style == HelpFrameDisplayStyle.Popup)
                {
                    this.ContentTemplate = ResourceHelpers.GetResourceFromDictionary<DataTemplate>(popupTemplateUri, "BottomPopupTemplate");
                }
                else
                {
                    this.ContentTemplate = this.BottomTemplate;
                }
            }
            else if (direction == HelpFrameAlignment.CenterLeft)
            {
                if (style == HelpFrameDisplayStyle.Sketch)
                {
                    this.ContentTemplate = ResourceHelpers.GetResourceFromDictionary<DataTemplate>(sketchTemplateUri, "LeftSketchTemplate");
                }
                else if (style == HelpFrameDisplayStyle.Popup)
                {
                    this.ContentTemplate = ResourceHelpers.GetResourceFromDictionary<DataTemplate>(popupTemplateUri, "LeftPopupTemplate");
                }
                else
                {
                    this.ContentTemplate = this.LeftTemplate;
                }
            }
            else if (direction == HelpFrameAlignment.CenterRight)
            {
                if (style == HelpFrameDisplayStyle.Sketch)
                {
                    this.ContentTemplate = ResourceHelpers.GetResourceFromDictionary<DataTemplate>(sketchTemplateUri, "RightSketchTemplate");
                }
                else if (style == HelpFrameDisplayStyle.Popup)
                {
                    this.ContentTemplate = ResourceHelpers.GetResourceFromDictionary<DataTemplate>(popupTemplateUri, "RightPopupTemplate");
                }
                else
                {
                    this.ContentTemplate = this.RightTemplate;
                }
            }

            if (style == HelpFrameDisplayStyle.Popup)
            {
                this.ContentHorizontalAlignment = HorizontalAlignment.Center;
                this.ContentVerticalAlignment = VerticalAlignment.Center;
            }
            else
            {
                this.ContentHorizontalAlignment = HorizontalAlignment.Left;
                this.ContentVerticalAlignment = VerticalAlignment.Bottom;
                if (style == HelpFrameDisplayStyle.Sketch)
                {
                    _originalFontFamily = this.FontFamily;
                    _originalFontSize = this.FontSize;
                    _originalFontWeight = this.FontWeight;
                    this.FontFamily = new FontFamily("Buxton Sketch");
                    this.FontSize = 24;
                    this.FontWeight = FontWeights.Normal;
                }
                else if (_originalFontFamily != null)
                {
                    this.FontFamily = _originalFontFamily;
                    this.FontSize = _originalFontSize;
                    this.FontWeight = _originalFontWeight;
                }
            }

            _applyingTemplate = false;
        }
示例#10
0
 internal void CopyFromInternal(object o, bool clone)
 {
     if ((o is FloatingObjectStyleInfo) && !object.ReferenceEquals(o, this))
     {
         FloatingObjectStyleInfo info = (FloatingObjectStyleInfo)o;
         this._fontTheme      = info._fontTheme;
         this._fontThemeSet   = info._fontThemeSet;
         this._fontFamily     = info._fontFamily;
         this._fontFamilySet  = info._fontFamilySet;
         this._fontSize       = info._fontSize;
         this._fontSizeSet    = info._fontSizeSet;
         this._fontStretch    = info._fontStretch;
         this._fontStretchSet = info._fontStretchSet;
         this._fontStyle      = info._fontStyle;
         this._fontStyleSet   = info._fontStyleSet;
         this._fontWeight     = info._fontWeight;
         this._fontWeightSet  = info._fontWeightSet;
         if (info._fillSet)
         {
             ICloneable cloneable = info._fill as ICloneable;
             if (cloneable != null)
             {
                 this._fill = cloneable.Clone() as Brush;
             }
             else
             {
                 this._fill = info._fill;
             }
             this._fillSet = true;
         }
         else
         {
             this._fill    = null;
             this._fillSet = false;
         }
         if (info._foregroundSet)
         {
             ICloneable cloneable2 = info._foreground as ICloneable;
             if (cloneable2 != null)
             {
                 this._foreground = cloneable2.Clone() as Brush;
             }
             else
             {
                 this._foreground = info._foreground;
             }
             this._foregroundSet = true;
         }
         else
         {
             this._foreground    = null;
             this._foregroundSet = false;
         }
         this._fillThemeColor          = info._fillThemeColor;
         this._fillThemeColorSet       = info._fillThemeColorSet;
         this._foregroundThemeColor    = info._foregroundThemeColor;
         this._foregroundThemeColorSet = info._foregroundThemeColorSet;
         if (info._strokeSet)
         {
             ICloneable cloneable3 = info._stroke as ICloneable;
             if (cloneable3 != null)
             {
                 this._stroke = cloneable3.Clone() as Brush;
             }
             else
             {
                 this._stroke = info._stroke;
             }
             this._strokeSet = true;
         }
         else
         {
             this._stroke    = null;
             this._strokeSet = false;
         }
         this._strokeDashType      = info._strokeDashType;
         this._strokeDashTypeSet   = info._strokeDashTypeSet;
         this._strokeThemeColor    = info._strokeThemeColor;
         this._strokeThemeColorSet = info._strokeThemeColorSet;
         this._strokeThickness     = info._strokeThickness;
         this._strokeThicknessSet  = info._strokeThicknessSet;
         this._cornerRadius        = info._cornerRadius;
         this._cornerRadiusSet     = info._cornerRadiusSet;
         this._themeContext        = info._themeContext;
         if (info._formatterSet)
         {
             ICloneable cloneable4 = info._formatter as ICloneable;
             if (cloneable4 != null)
             {
                 this._formatter = cloneable4.Clone() as IFormatter;
             }
             else
             {
                 this._formatter = info._formatter;
             }
             this._formatterSet = true;
         }
         else
         {
             this._formatter    = null;
             this._formatterSet = false;
         }
         this._lineCapType               = info._lineCapType;
         this._lineCapTypeSet            = info._lineCapTypeSet;
         this._lineJoinType              = info.LineJoinType;
         this._lineJoinTypeSet           = info._lineJoinTypeSet;
         this._lineBeginArrowSettings    = info._lineBeginArrowSettings;
         this._lineBeginArrowSettingsSet = info._lineBeginArrowSettingsSet;
         this._lineEndArrowSettings      = info._lineEndArrowSettings;
         this._lineEndArrowSettingsSet   = info._lineEndArrowSettingsSet;
     }
 }
示例#11
0
        /// <summary>
        /// Generates an object from its XML representation.
        /// </summary>
        /// <param name="reader">The <see cref="T:System.Xml.XmlReader" /> stream from which the object is deserialized.</param>
        void IXmlSerializable.ReadXml(XmlReader reader)
        {
            Serializer.InitReader(reader);
            this.Reset();
            while (reader.Read())
            {
                if (reader.NodeType == ((XmlNodeType)((int)XmlNodeType.Element)))
                {
                    switch (reader.Name)
                    {
                    case "FontTheme":
                        this._fontTheme    = (string)(Serializer.DeserializeObj(typeof(string), reader) as string);
                        this._fontThemeSet = true;
                        break;

                    case "FontFamily":
                        if (!(Serializer.ReadAttribute("value", reader) == Serializer.Format(null)))
                        {
                            goto Label_0239;
                        }
                        this._fontFamily = null;
                        goto Label_0279;

                    case "FontSize":
                        this._fontSize    = (float)Serializer.DeserializeObj(typeof(float), reader);
                        this._fontSizeSet = true;
                        break;

                    case "FontStretch":
                    {
                        Windows.UI.Text.FontStretch?stretch = null;
                        string str  = (string)(Serializer.DeserializeObj(typeof(string), reader) as string);
                        object obj2 = Serializer.DeserializeEnum(this.FontStretch.GetType(), str);
                        if (obj2 != null)
                        {
                            stretch = new Windows.UI.Text.FontStretch?((Windows.UI.Text.FontStretch)obj2);
                        }
                        if (stretch.HasValue)
                        {
                            this._fontStretch    = stretch.Value;
                            this._fontStretchSet = true;
                        }
                        break;
                    }

                    case "FontStyle":
                    {
                        Windows.UI.Text.FontStyle?style = null;
                        string str  = (string)(Serializer.DeserializeObj(typeof(string), reader) as string);
                        object obj2 = Serializer.DeserializeEnum(this.FontStyle.GetType(), str);
                        if (obj2 != null)
                        {
                            style = new Windows.UI.Text.FontStyle?((Windows.UI.Text.FontStyle)obj2);
                        }
                        if (style.HasValue)
                        {
                            this._fontStyle    = style.Value;
                            this._fontStyleSet = true;
                        }
                        break;
                    }

                    case "FontWeight":
                    {
                        string result = (string)(Serializer.DeserializeObj(typeof(string), reader) as string);
                        Windows.UI.Text.FontWeight?weight = Serializer.FindStaticDefinationStruct <Windows.UI.Text.FontWeight>(typeof(FontWeights), result);
                        if (weight.HasValue)
                        {
                            this._fontWeight    = weight.Value;
                            this._fontWeightSet = true;
                        }
                        break;
                    }

                    case "Fill":
                        goto Label_03E3;

                    case "Foreground":
                        goto Label_0409;

                    case "FillTheme":
                        this._fillThemeColor    = (string)(Serializer.DeserializeObj(typeof(string), reader) as string);
                        this._fillThemeColorSet = true;
                        break;

                    case "ForegroundTheme":
                        this._foregroundThemeColor    = (string)(Serializer.DeserializeObj(typeof(string), reader) as string);
                        this._foregroundThemeColorSet = true;
                        break;

                    case "Formatter":
                        if (!(Serializer.ReadAttribute("value", reader) == Serializer.Format(null)))
                        {
                            goto Label_04B4;
                        }
                        this._formatter = null;
                        goto Label_04E2;

                    case "Stroke":
                        goto Label_04EE;

                    case "StrokeTheme":
                        this._strokeThemeColor    = (string)(Serializer.DeserializeObj(typeof(string), reader) as string);
                        this._strokeThemeColorSet = true;
                        break;

                    case "StrokeThickness":
                        this._strokeThickness    = (double)((double)Serializer.DeserializeObj(typeof(double), reader));
                        this._strokeThicknessSet = true;
                        break;

                    case "CornerRadius":
                        this._cornerRadius    = (double)((double)Serializer.DeserializeObj(typeof(double), reader));
                        this._cornerRadiusSet = true;
                        break;

                    case "StrokeDashes":
                        this._strokeDashType    = (Dt.Cells.Data.StrokeDashType)Serializer.DeserializeObj(typeof(Dt.Cells.Data.StrokeDashType), reader);
                        this._strokeDashTypeSet = true;
                        break;

                    case "LineCapType":
                        this._lineCapType    = (PenLineCap)Serializer.DeserializeObj(typeof(PenLineCap), reader);
                        this._lineCapTypeSet = true;
                        break;

                    case "LineJoinType":
                        this._lineJoinType    = (PenLineJoin)Serializer.DeserializeObj(typeof(PenLineJoin), reader);
                        this._lineJoinTypeSet = true;
                        break;

                    case "LineBeginArrowSettings":
                        this._lineBeginArrowSettings    = (ArrowSettings)Serializer.DeserializeObj(typeof(ArrowSettings), reader);
                        this._lineBeginArrowSettingsSet = true;
                        break;

                    case "LineEndArrowSettings":
                        this._lineEndArrowSettings    = (ArrowSettings)Serializer.DeserializeObj(typeof(ArrowSettings), reader);
                        this._lineEndArrowSettingsSet = true;
                        break;
                    }
                }
                continue;
Label_0239:
                _fontFamily = new FontFamily(Serializer.DeserializeObj(typeof(string), reader) as string);
Label_0279:
                this._fontFamilySet = true;
                continue;
Label_03E3:
                _fill         = Serializer.DeserializeObj(typeof(Brush), reader) as Brush;
                this._fillSet = true;
                continue;
Label_0409:
                _foreground         = Serializer.DeserializeObj(typeof(Brush), reader) as Brush;
                this._foregroundSet = true;
                continue;
Label_04B4:
                string str3 = (string)(Serializer.DeserializeObj(typeof(string), reader) as string);
                if (str3 != null)
                {
                    this._formatter = new GeneralFormatter(str3);
                }
Label_04E2:
                this._formatterSet = true;
                continue;
Label_04EE:
                _stroke         = Serializer.DeserializeObj(typeof(Brush), reader) as Brush;
                this._strokeSet = true;
            }
        }
示例#12
0
 public void ResetFontWeight()
 {
     this._fontWeight    = FontWeights.Normal;
     this._fontWeightSet = false;
     this.RaisePropertyChanged("FontWeight");
 }
示例#13
0
 private async Task getMessages()
 {
     while (true)
     {
         if (currentfileName != "") {
             
             String lastname = "";
             HttpWebRequest req = WebRequest.CreateHttp("http://jmex.altervista.org/" + currentfileName);
             req.Method = "GET";
             HttpWebResponse resp = (HttpWebResponse)await req.GetResponseAsync();
             String x = new StreamReader(resp.GetResponseStream()).ReadToEnd();
             JsonObject array = JsonObject.Parse(x);
             JsonArray msgArray = array["messages"].GetArray();
             if (msgArray.Count != lastMsgNumb || currentfileName != lastFileName)
             {
                 messagesPanel.Children.Clear();
                 lastMsgNumb = msgArray.Count;
                 lastFileName = currentfileName;
                 for (uint i = 0; i < msgArray.Count; i++)
                 {
                     TextBlock txtB = new TextBlock();
                     txtB.HorizontalAlignment = HorizontalAlignment.Stretch;
                     JsonObject obj = msgArray.GetObjectAt(i);
                     String user = obj["user"].GetString();
                     String msg = obj["text"].GetString();
                     Span msgContainer = new Span();
                     txtB.Margin = new Thickness(0);
                     if (user != lastname)
                     {
                         
                         Run name = new Run();
                         
                         name.Text =user + Environment.NewLine;
                         name.Foreground = (SolidColorBrush)Application.Current.Resources["SystemControlBackgroundAccentBrush"];
                         if(user == this.user)
                         {
                             FontWeight wh = new FontWeight();
                             wh.Weight = 800;
                             name.FontWeight = wh;
                             
                         }
                         txtB.Margin = new Thickness(0, 8, 0, 0);
                         txtB.Inlines.Add(name);
                         lastname = user;
                     }
                     Run text = new Run();
                     text.Text = msg;
                     txtB.Inlines.Add(text );
                    
                     if(user == this.user)
                     {
                         txtB.TextAlignment = TextAlignment.Right;
                         
                     }
                     messagesPanel.Children.Add(txtB);
                 }
             }
         }
         await Task.Delay(100);
     }
     
 }
 public NamedFontWeight(string name, FontWeight fontWeight)
 {
     Name = name;
     FontWeight = fontWeight;
 }
示例#15
0
 public PInfoWrapper( string Name, FontWeight F )
 {
     Weight = F;
     this.Name = Name;
 }
 private TextBlock New_TextBlock(int p, string content)
 {
     TextBlock tb = new TextBlock();
     switch (p)
     {
         case 1: //较重标题
             {
                 tb.Text = content.Substring(1, (content.LastIndexOf('】') - content.IndexOf('【') - 1));
                 //tb.Foreground = App.APPTheme.Content_Header_Color_Brush;
                 tb.FontSize = 16;
                 tb.Margin = new Thickness(0, 3, 0, 8);
             }; break;
         case 2: //普通内容
             {
                 tb.Text = content;
                 FontWeight weight = new FontWeight();
                 weight.Weight = 10;
                 tb.FontWeight = weight;
                 //tb.Foreground = App.APPTheme.Gary_Color_Brush;
                 tb.FontSize = 15;
                 tb.LineHeight = 26;
             }; break;
     }
     tb.CharacterSpacing = 100;
     tb.TextWrapping = TextWrapping.Wrap;
     return tb;
 }