Exemplo n.º 1
0
        /// <summary>
        /// Turn into font wieght.
        /// </summary>
        /// <param name="fontWeight"> The source font wieght. </param>
        /// <returns> The product font wieght. </returns>
        public static FontWeight ToFontWeight(this FontWeight2 fontWeight)
        {
            switch (fontWeight)
            {
            case FontWeight2.Black: return(FontWeights.Black);

            case FontWeight2.Bold: return(FontWeights.Bold);

            case FontWeight2.ExtraBlack: return(FontWeights.ExtraBlack);

            case FontWeight2.ExtraBold: return(FontWeights.ExtraBold);

            case FontWeight2.ExtraLight: return(FontWeights.ExtraLight);

            case FontWeight2.Light: return(FontWeights.Light);

            case FontWeight2.Medium: return(FontWeights.Medium);

            case FontWeight2.Normal: return(FontWeights.Normal);

            case FontWeight2.SemiBold: return(FontWeights.SemiBold);

            case FontWeight2.SemiLight: return(FontWeights.SemiLight);

            case FontWeight2.Thin: return(FontWeights.Thin);

            default: return(FontWeights.Normal);
            }
        }
Exemplo n.º 2
0
        public void MethodSetFontWeight()
        {
            bool        isBold     = this.FontWeightConverter(this.FontWeight);
            FontWeight2 fontWeight = isBold ? FontWeight2.Normal : FontWeight2.Bold;

            this.MethodSetFontWeight(fontWeight);
        }
Exemplo n.º 3
0
        public void MethodSetFontWeight(FontWeight2 fontWeight)
        {
            this.FontWeight = fontWeight;
            this.ITextLayerChanged <FontWeight2>
            (
                set: (textLayer) => textLayer.FontWeight = fontWeight,

                type: HistoryType.LayersProperty_SetFontWeight,
                getUndo: (textLayer) => textLayer.FontWeight,
                setUndo: (textLayer, previous) => textLayer.FontWeight = previous
            );
        }
Exemplo n.º 4
0
        /// <summary>
        /// Load the entire <see cref="ILayer"/> form a XElement.
        /// </summary>
        /// <param name="element"> The destination XElement. </param>
        public override void Load(XElement element)
        {
            if (element.Element("Text") is XElement text)
            {
                this.FontText = text.Value;
            }
            if (element.Element("FontSize") is XElement fontSize)
            {
                this.FontSize = (float)fontSize;
            }
            if (element.Element("FontFamily") is XElement fontFamily)
            {
                this.FontFamily = fontFamily.Value;
            }

            if (element.Element("HorizontalAlignment") is XElement horizontalAlignment)
            {
                try
                {
                    this.HorizontalAlignment = (CanvasHorizontalAlignment)Enum.Parse(typeof(CanvasHorizontalAlignment), horizontalAlignment.Value);
                }
                catch (Exception) { }
            }
            if (element.Element("Direction") is XElement direction)
            {
                try
                {
                    this.Direction = (CanvasTextDirection)Enum.Parse(typeof(CanvasTextDirection), direction.Value);
                }
                catch (Exception) { }
            }

            if (element.Element("Underline") is XElement underline)
            {
                this.Underline = (bool)underline;
            }
            if (element.Element("FontStyle") is XElement fontStyle)
            {
                try
                {
                    this.FontStyle = (FontStyle)Enum.Parse(typeof(FontStyle), fontStyle.Value);
                }
                catch (Exception) { }
            }
            if (element.Element("FontWeight") is XElement fontWeight)
            {
                try
                {
                    this.FontWeight = (FontWeight2)Enum.Parse(typeof(FontWeight2), fontWeight.Value);
                }
                catch (Exception) { }
            }
        }
Exemplo n.º 5
0
        //@Converter
        /// <summary>
        /// Convert font weight to boolean
        /// </summary>
        /// <param name="fontWeight"> The font weight. </param>
        /// <returns> Is Bold ? ""Normal"" : ""Bold"" </returns>
        public bool FontWeightConverter(FontWeight2 fontWeight)
        {
            switch (fontWeight)
            {
            case FontWeight2.Black:
            case FontWeight2.Bold:
            case FontWeight2.ExtraBlack:
            case FontWeight2.ExtraBold:
            case FontWeight2.SemiBold:
                return(true);

            default:
                return(false);
            }
        }
 private bool FontWeightConverter(FontWeight2 fontWeight) => this.MethodViewModel.FontWeightConverter(fontWeight);