Exemple #1
0
 public MainForm()
 {
     InitializeComponent();
     rightSplitContainer.SplitterWidth = 12;
     var fc = new FontConverter();
     tbInfo.Font = fc.ConvertFromInvariantString(Settings.Default.InfoFont) as Font;
     _visualiser = new Visualiser(Settings.Default.VisualisationCellSize);
 }
        public Font GetFontEx(string name)
        {
            if (GdiCacheFonts.ContainsKey(name))
                return GdiCacheFonts[name];
            else
            {
                string fontName = name;
                string fontSize = "";
                if (name.IndexOf(',') != -1)
                {
                    fontName = name.Substring(0, name.IndexOf(',')).Trim();
                    fontSize = name.Substring(name.IndexOf(',') + 1).Trim();
                }

                double userBaseSize = Engine.Instance.Storage.GetFloat("gui.font.normal.size");
                if (userBaseSize == 0)
                {
                    string systemFont = Core.Platform.Instance.GetSystemFont();
                    int posSize = systemFont.IndexOf(",");

                    string strSize = systemFont.Substring(posSize + 1);
                    if (posSize != -1)
                        double.TryParse(strSize, out userBaseSize);

                    if (userBaseSize == 0)
                        userBaseSize = 10;
                }

                if ((fontName == "System") || (fontName == "SystemMonospace"))
                {
                    string systemFont = "";
                    if (fontName == "System")
                    {
                        if(Engine.Instance.Storage.Get("gui.font.normal.name") != "")
                            systemFont = Engine.Instance.Storage.Get("gui.font.normal.name");
                        else
                            systemFont = Core.Platform.Instance.GetSystemFont();
                    }

                    else if (fontName == "SystemMonospace")
                            systemFont = Core.Platform.Instance.GetSystemFontMonospace();
                    int posSize = systemFont.IndexOf(",");
                    if (posSize != -1)
                        systemFont = systemFont.Substring(0, posSize);
                    fontName = systemFont;
                }

                if (fontSize == "normal")
                    fontSize = userBaseSize.ToString(CultureInfo.InvariantCulture) + "pt";
                else if (fontSize == "big")
                    fontSize = (userBaseSize * 1.25).ToString(CultureInfo.InvariantCulture) + "pt";

                string name2 = fontName + "," + fontSize;

                FontConverter fontConverter = new FontConverter();
                Font f = fontConverter.ConvertFromInvariantString(name2) as Font;
                GdiCacheFonts[name] = f;

                return f;
            }
        }
 /// <summary>
 /// Gets the font.
 /// </summary>
 /// <returns></returns>
 public Font GetFont()
 {
     FontConverter converter = new FontConverter();
     return (Font)converter.ConvertFromInvariantString(_fontString);
 }