コード例 #1
0
ファイル: Form1.cs プロジェクト: Soldier-B/SoldierB.TrueType
        private void OpenMenuItem_Click(object sender, EventArgs e)
        {
            if (FontDialog.ShowDialog() == DialogResult.OK)
            {
                Stopwatch timer = new Stopwatch();
                foreach (string fontFile in FontDialog.FileNames)
                {
                    string          fontFileName  = Path.GetFileName(fontFile);
                    FontInformation info          = null;
                    Exception       fontException = null;

                    timer.Restart();

                    try
                    {
                        info = FontInformation.Read(fontFile);
                    }
                    catch (Exception ex)
                    {
                        fontException = ex;
                    }

                    timer.Stop();

                    if (info != null)
                    {
                        OutputList.Items.Add($"{timer.Elapsed.TotalMilliseconds}ms {fontFileName} > {info.FamilyName} {info.Style}");
                    }
                    else
                    {
                        OutputList.Items.Add($"{timer.Elapsed.TotalMilliseconds}ms {fontFileName} > {fontException.Message}");
                    }
                }
            }
        }
コード例 #2
0
        public FreeFontsViewModel()
        {
            Title = "Free";

            var fonts = FontInformation.FontAwesomeFree();

            Fonts = fonts.ToObservableCollection();
        }
コード例 #3
0
        public ProFontsViewModel()
        {
            Title = "Pro";

            var fonts = FontInformation.FontAwesomePro();

            Fonts = fonts.ToObservableCollection();
        }
コード例 #4
0
        public static string ReadUserStringValue(FontInformation information)
        {
            RegistryKey hkcu = Registry.CurrentUser; //HKCU Registry

            var key = hkcu.OpenSubKey(information.Path);

            var keyvalue = key.GetValue("CaptionFont");

            return(null);
        }
コード例 #5
0
        public static void ReadFontSizeValue(FontInformation information)
        {
            RegistryKey hkcu = Registry.CurrentUser; //HKCU Registry

            var pathkey = hkcu.OpenSubKey(information.Path);

            var keyvalue = pathkey.GetValue(information.Key);

            if (keyvalue != null && keyvalue is byte[] values)
            {
                var fontsize = values[0];
                information.Size = fontsize;
            }
        }
コード例 #6
0
        private void Initialize()
        {
            CaptionFontInformation       = new FontInformation("Captions", "Title bar and Caption buttons", 9);
            SecondarytitlebarInformation = new FontInformation("Secondary caption bar", "Small captions", 9);
            MenuInformation       = new FontInformation("Menu bar", "Menu and Ribbons", 9);
            MessageBoxInformation = new FontInformation("Messagebox bar", "Messagebox and contextmenu", 9);
            IconInformation       = new FontInformation("Icon Caption", "Icon and explorer descriptions", 9);
            StatusbarInformation  = new FontInformation("Status bar", "For status bar", 9);
            BorderInformation     = new IntegerInformation("Border", "Window Padding", 1);

            if (!WPFService.IsDesignMode())
            {
                InitializeSystemValues();
            }
        }
コード例 #7
0
        public static void WriteFontSizeValue(FontInformation information)
        {
            RegistryKey hkcu = Registry.CurrentUser; //HKCU Registry

            var pathkey = hkcu.OpenSubKey(information.Path, true);

            var keyvalue = pathkey.GetValue(information.Key);

            if (keyvalue != null && keyvalue is byte[] values &&
                information.Size <= byte.MaxValue &&
                information.Size >= byte.MinValue)
            {
                values[0] = (byte)information.Size;

                try
                {
                    pathkey.SetValue(information.Key, values);
                }
                catch (Exception ex)
                {
                    string k = "";
                }
            }
        }