Esempio n. 1
0
        public override FontStyle Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
        {
            var fontStyleString = reader.GetString() ?? "Normal";
            var converter       = new System.Windows.FontStyleConverter();

            return((FontStyle)converter.ConvertFromString(fontStyleString));
        }
        public FontDefinition ToFontDefinition()
        {
            var styleConverter = new FontStyleConverter();
            var weightConverter = new FontWeightConverter();
            var stretchConverter = new FontStretchConverter();

            var style = (FontStyle?)styleConverter.ConvertFromString(FontStyle) ?? FontStyles.Normal;
            var weight = (FontWeight?)weightConverter.ConvertFromString(FontWeight) ?? FontWeights.Normal;
            var stretch = (FontStretch?)stretchConverter.ConvertFromString(FontStretch) ?? FontStretches.Normal;

            return new FontDefinition
            {
                FontFamily = new FontFamily(FontFamily),
                FontStyle = style,
                FontWeight = weight,
                FontStretch = stretch,
                FontSize = FontSize
            };
        }
Esempio n. 3
0
        /// <summary>
        /// Helper function that converts the values stored in the settings into the font values
        /// and then sets the tasklist font values.
        /// </summary>
		public void SetFont()
        {
            var family = new FontFamily(User.Default.TaskListFontFamily);

            double size = User.Default.TaskListFontSize;

            var styleConverter = new FontStyleConverter();

            FontStyle style = (FontStyle)styleConverter.ConvertFromString(User.Default.TaskListFontStyle);

            var stretchConverter = new FontStretchConverter();
            FontStretch stretch = (FontStretch)stretchConverter.ConvertFromString(User.Default.TaskListFontStretch);

            var weightConverter = new FontWeightConverter();
            FontWeight weight = (FontWeight)weightConverter.ConvertFromString(User.Default.TaskListFontWeight);

            Color color = (Color)ColorConverter.ConvertFromString(User.Default.TaskListFontBrushColor);

			lbTasks.FontFamily = family;
			lbTasks.FontSize = size;
			lbTasks.FontStyle = style;
			lbTasks.FontStretch = stretch;
			lbTasks.FontWeight = weight;
			lbTasks.Foreground = new SolidColorBrush(color);
        }
Esempio n. 4
0
 public static FontStyle ParseFontStyle(string fontStyleName)
 {
     var converter = new FontStyleConverter();
     return (FontStyle) converter.ConvertFromString(fontStyleName);
 }
Esempio n. 5
0
 public static bool CanParseFontStyle(string fontStyleName)
 {
     try
     {
         var converter = new FontStyleConverter();
         converter.ConvertFromString(fontStyleName);
         return true;
     }
     catch
     {
         return false;
     }
 }
Esempio n. 6
0
        public static FontStyle ParseStyle(string styleString)
        {
            FontStyle style = FontStyles.Normal;
            FontStyleConverter converter = new FontStyleConverter();

            try {
                style = (FontStyle)converter.ConvertFromString(styleString);
            }
            catch {
            }

            return style;
        }