private void InitText()
        {
            try
            {
                var fwc = new FontWeightConverter();
                var fsc = new FontStyleConverter();

                if (Properties.Settings.Default.Plot_FG_Color != null)
                {
                    _fgBrush = new SolidColorBrush(
                        System.Windows.Media.Color.FromRgb(
                            Properties.Settings.Default.Plot_FG_Color.R,
                            Properties.Settings.Default.Plot_FG_Color.G,
                            Properties.Settings.Default.Plot_FG_Color.B));
                }

                // Overall graph text properties...
                LineGraph.FontFamily = new System.Windows.Media.FontFamily(Properties.Settings.Default.Plot_Font_Name);
                LineGraph.FontSize   = double.Parse(Properties.Settings.Default.Plot_Font_Size);
                LineGraph.FontWeight = (FontWeight)fwc.ConvertFromString(Properties.Settings.Default.Plot_Font_Weight);
                LineGraph.FontStyle  = (FontStyle)fsc.ConvertFromString(Properties.Settings.Default.Plot_Font_Style);
                LineGraph.Foreground = _fgBrush;
            }
            catch
            {
            }
        }
示例#2
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);
        }
        private void InitTextTitle()
        {
            try
            {
                var fwc = new FontWeightConverter();
                var fsc = new FontStyleConverter();

                if (Properties.Settings.Default.Plot_FG_Color_Title != null)
                {
                    _fgBrushTitle = new SolidColorBrush(
                        System.Windows.Media.Color.FromRgb(
                            Properties.Settings.Default.Plot_FG_Color_Title.R,
                            Properties.Settings.Default.Plot_FG_Color_Title.G,
                            Properties.Settings.Default.Plot_FG_Color_Title.B));
                }

                // Title...
                GraphTitle.FontFamily = new System.Windows.Media.FontFamily(Properties.Settings.Default.Plot_Font_Name_Title);
                GraphTitle.FontSize   = double.Parse(Properties.Settings.Default.Plot_Font_Size_Title);
                GraphTitle.FontWeight = (FontWeight)fwc.ConvertFromString(Properties.Settings.Default.Plot_Font_Weight_Title);
                GraphTitle.FontStyle  = (FontStyle)fsc.ConvertFromString(Properties.Settings.Default.Plot_Font_Style_Title);
                GraphTitle.Foreground = _fgBrushTitle;
            }
            catch
            {
            }
        }
示例#4
0
        private FontStyle GetFontStyle()
        {
            var fontStyleConverter = new FontStyleConverter();
            var fontStyle          = (FontStyle)fontStyleConverter.ConvertFromString(FontStyle);

            return(fontStyle);
        }
示例#5
0
        protected virtual void LoadRegistryInfo(RegistryKey regkey)
        {
            string selectedLanguagesText = (string)regkey.GetValue(strOcrLanguage, String.Empty);

            dataSource.SelectedLanguages = new ObservableCollection <string>(selectedLanguagesText.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(p => p.Trim()).Distinct().ToList());
            curLangCode = GetLangCodes(selectedLanguagesText);

            this.textBox1.TextWrapping = (TextWrapping)regkey.GetValue(strWordWrap, TextWrapping.NoWrap);
            this.textBox1.FontFamily   = new System.Windows.Media.FontFamily(regkey.GetValue(strFontFace, "Microsoft Sans Serif").ToString());
            this.textBox1.FontSize     = double.Parse((string)regkey.GetValue(strFontSize, "10"));
            var fsc = new FontStyleConverter();

            this.textBox1.FontStyle = (FontStyle)fsc.ConvertFromString((string)regkey.GetValue(strFontStyle, "Normal"));
            var bc = new BrushConverter();

            this.textBox1.Foreground = (Brush)bc.ConvertFromString((string)regkey.GetValue(strForeColor, "Black"));
            this.textBox1.Background = (Brush)bc.ConvertFromString((string)regkey.GetValue(strBackColor, "White"));
            filterIndex        = (int)regkey.GetValue(strFilterIndex, 1);
            selectedUILanguage = Thread.CurrentThread.CurrentUICulture.Name;

            this.segmentedRegionsToolStripMenuItem.IsChecked = Convert.ToBoolean((int)regkey.GetValue(strSegmentedRegions, Convert.ToInt32(false)));
            this.buttonSegmentedRegions.Visibility           = this.segmentedRegionsToolStripMenuItem.IsChecked ? Visibility.Visible : Visibility.Hidden;
            this.toolStripMenuItemPara.IsChecked             = Convert.ToBoolean((int)regkey.GetValue(strSegmentedRegionsPara, Convert.ToInt32(false)));
            this.toolStripMenuItemTextLine.IsChecked         = Convert.ToBoolean((int)regkey.GetValue(strSegmentedRegionsTextLine, Convert.ToInt32(false)));
            this.toolStripMenuItemSymbol.IsChecked           = Convert.ToBoolean((int)regkey.GetValue(strSegmentedRegionsSymbol, Convert.ToInt32(false)));
            this.toolStripMenuItemBlock.IsChecked            = Convert.ToBoolean((int)regkey.GetValue(strSegmentedRegionsBlock, Convert.ToInt32(false)));
            this.toolStripMenuItemWord.IsChecked             = Convert.ToBoolean((int)regkey.GetValue(strSegmentedRegionsWord, Convert.ToInt32(false)));
        }
示例#6
0
        /// <summary>
        /// Internal API for loading text. Sets a text block's font style.
        /// </summary>
        /// <param name="FBlockToSet">The Block to set the font style of.</param>
        /// <param name="FontStyle">The font family in string form to set the Block's font style to.</param>
        /// <returns>A Block with the font style set.</returns>
        internal Block FMXAML_TextAPI_SetFontStyle(Block FBlockToSet, string FontStyle) // Sets the font style.
        {
            FontStyleConverter _FontStyleConverter = new FontStyleConverter();
            FontStyle          _FinalFontStyle     = (FontStyle)_FontStyleConverter.ConvertFromString(FontStyle);

            FBlockToSet.FontStyle = _FinalFontStyle;
            return(FBlockToSet);
        }
示例#7
0
 static FontStyle?ParseFontStyle(string fontStyle)
 {
     if (string.IsNullOrEmpty(fontStyle))
     {
         return(null);
     }
     return(FontStyleConverter.ConvertFromString(fontStyle));
 }
示例#8
0
        /// <summary>
        /// 转换
        /// </summary>
        /// <param name="attribute">属性</param>
        /// <returns>是否转化成果</returns>
        public override bool Parse(SVGAttribute attribute)
        {
            SVGFontStyle result = new SVGFontStyle();

            result.Value = (FontStyle)Converter.ConvertFromString(attribute.Value);

            attribute.Data = result;

            return(true);
        }
        private void InitSeries1()
        {
            var fwc = new FontWeightConverter();
            var fsc = new FontStyleConverter();

            ((LegendItem)LineGraph.LegendItems[0]).FontFamily = new System.Windows.Media.FontFamily(Properties.Settings.Default.Plot_Font_Name);
            ((LegendItem)LineGraph.LegendItems[0]).FontSize   = double.Parse(Properties.Settings.Default.Plot_Font_Size);
            ((LegendItem)LineGraph.LegendItems[0]).FontWeight = (FontWeight)fwc.ConvertFromString(Properties.Settings.Default.Plot_Font_Weight);
            ((LegendItem)LineGraph.LegendItems[0]).FontStyle  = (FontStyle)fsc.ConvertFromString(Properties.Settings.Default.Plot_Font_Style);
            ((LegendItem)LineGraph.LegendItems[0]).Foreground = _fgBrush;
        }
 public static bool CanParseFontStyle(string fontStyleName)
 {
     try
     {
         FontStyleConverter converter = new FontStyleConverter();
         converter.ConvertFromString(fontStyleName);
         return(true);
     }
     catch
     {
         return(false);
     }
 }
示例#11
0
        public static FontStyle ParseStyle(string styleString)
        {
            FontStyle          style     = FontStyles.Normal;
            FontStyleConverter converter = new FontStyleConverter();

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

            return(style);
        }
示例#12
0
        private void ComboBoxStyleTitleSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (ComboBoxStyleTitle.SelectedValue == null)
            {
                return;
            }

            var fontStyle = (string)ComboBoxStyleTitle.SelectedValue;
            var fsc       = new FontStyleConverter();

            PlotFontStyleTitle = (FontStyle)fsc.ConvertFromString(fontStyle);
            TextBlockExampleTitle.FontStyle = PlotFontStyleTitle;
            Properties.Settings.Default.Plot_Font_Style_Title = fontStyle;
            GraphUc.UpdateStyles();
        }
示例#13
0
 /// <summary>
 /// Internal API for loading text. Sets a text block's font style. (INLINE OVERLOAD)
 /// </summary>
 /// <param name="FBlockToSet">The Block to set the font style of.</param>
 /// <param name="FontStyle">The font family in string form to set the Block's font style to.</param>
 /// <returns>An Inline with the font style set.</returns>
 internal Inline FMXAML_TextAPI_SetFontStyle(Inline FBlockToSet, string FontStyle) // Sets the font style.
 {
     try
     {
         FontStyleConverter _FontStyleConverter = new FontStyleConverter();
         FontStyle          _FinalFontStyle     = (FontStyle)_FontStyleConverter.ConvertFromString(FontStyle);
         FBlockToSet.FontStyle = _FinalFontStyle;
         return(FBlockToSet);
     }
     catch (FormatException err)
     {
         FError.ThrowError(15, "An invalid string was supplied.", FErrorSeverity.FatalError, err);
         return(null);
     }
 }
示例#14
0
 /// <summary>
 /// Deserializes a HighlightingColor.
 /// </summary>
 protected HighlightingColor(SerializationInfo info, StreamingContext context)
 {
     if (info == null)
     {
         throw new ArgumentNullException("info");
     }
     this.Name = info.GetString("Name");
     if (info.GetBoolean("HasWeight"))
     {
         this.FontWeight = TextAddin.FontWeight.FromOpenTypeWeight(info.GetInt32("Weight"));
     }
     if (info.GetBoolean("HasStyle"))
     {
         this.FontStyle = FontStyleConverter.ConvertFromString(info.GetString("Style"));
     }
     this.Foreground = (Color)info.GetValue("Foreground", typeof(Color));
     this.Background = (Color)info.GetValue("Background", typeof(Color));
 }
示例#15
0
        internal static Typeface CreateTypeFace(string fontFamily, string fontStyle, string fontWeight, string fontStretch, string fallbackFontFamily)
        {
            if ((fontFamily == null) || (fontStyle == null) || (fontWeight == null) || (fontStretch == null))
            {
                return(null);
            }

            FontFamily  family  = new FontFamily(fontFamily);
            FontStyle   style   = (FontStyle)styleConverter.ConvertFromString(fontStyle);
            FontWeight  weight  = (FontWeight)weightConverter.ConvertFromString(fontWeight);
            FontStretch stretch = (FontStretch)stretchConverter.ConvertFromString(fontStretch);

            if (fallbackFontFamily == null)
            {
                return(new Typeface(family, style, weight, stretch));
            }
            else
            {
                return(new Typeface(family, style, weight, stretch, new FontFamily(fallbackFontFamily)));
            }
        }
        public static FontStyle ParseFontStyle(string fontStyleName)
        {
            FontStyleConverter converter = new FontStyleConverter();

            return((FontStyle)converter.ConvertFromString(fontStyleName));
        }
示例#17
0
        private void InitText()
        {
            var fwc = new FontWeightConverter();
            var fsc = new FontStyleConverter();

            FontSelector.ItemsSource = Fonts.SystemFontFamilies;
            var fontIndex = -1;

            // Font name...
            if (string.IsNullOrEmpty(Properties.Settings.Default.Plot_Font_Name))
            {
                var g = new Graph(null, null);
                _fontName = g.FontFamily.Source;
                Properties.Settings.Default.Plot_Font_Name = _fontName;
            }
            else
            {
                _fontName = Properties.Settings.Default.Plot_Font_Name;
            }

            // Font size...
            if (string.IsNullOrEmpty(Properties.Settings.Default.Plot_Font_Size))
            {
                PlotFontSize = 12;
            }
            else
            {
                try
                {
                    PlotFontSize = double.Parse(Properties.Settings.Default.Plot_Font_Size);
                }
                catch
                {
                }
            }

            // Font weight...
            if (string.IsNullOrEmpty(Properties.Settings.Default.Plot_Font_Weight))
            {
                PlotFontWeight = (FontWeight)fwc.ConvertFromString("Normal");
            }
            else
            {
                PlotFontWeight = (FontWeight)fwc.ConvertFromString(Properties.Settings.Default.Plot_Font_Weight);
            }

            // Font style...
            if (string.IsNullOrEmpty(Properties.Settings.Default.Plot_Font_Style))
            {
                PlotFontStyle = (FontStyle)fsc.ConvertFromString("Normal");
            }
            else
            {
                PlotFontStyle = (FontStyle)fsc.ConvertFromString(Properties.Settings.Default.Plot_Font_Style);
            }

            foreach (System.Windows.Media.FontFamily ff in FontSelector.Items)
            {
                fontIndex++;
                if (System.String.Compare(ff.Source, _fontName, System.StringComparison.Ordinal) == 0)
                {
                    _fontFamily = ff;
                    break;
                }
            }

            // Font FG color
            if (Properties.Settings.Default.Plot_FG_Color != null)
            {
                _fgBrush = new SolidColorBrush(
                    System.Windows.Media.Color.FromRgb(
                        Properties.Settings.Default.Plot_FG_Color.R,
                        Properties.Settings.Default.Plot_FG_Color.G,
                        Properties.Settings.Default.Plot_FG_Color.B));
            }

            // Init the controls
            FontSelector.SelectedIndex   = fontIndex;
            ComboBoxStyle.SelectedValue  = fsc.ConvertToString(PlotFontStyle);
            ComboBoxWeight.SelectedValue = fwc.ConvertToString(PlotFontWeight);
            SliderFontSize.DataContext   = this;
        }
示例#18
0
        /// <summary>
        /// Deserializes the font style.
        /// </summary>
        /// <param name="fontStyle">The font style.</param>
        /// <returns>The deserialized font style.</returns>
        public static FontStyle DeserializeFontStyle(string fontStyle)
        {
            var converter = new FontStyleConverter();

            return((FontStyle)converter.ConvertFromString(fontStyle));
        }