public static void ApplyFontStyle(FontStyle Style, FileFont fileFont)
        {
            Dictionary <string, bool> styleparse = ParseFontStyle(Style);

            fileFont.Regular   = styleparse["Regular"];
            fileFont.Bold      = styleparse["Bold"];
            fileFont.Italic    = styleparse["Italic"];
            fileFont.Strikeout = styleparse["Strikeout"];
            fileFont.Underline = styleparse["Underline"];
        }
        private void btnFontFile_Click(object sender, EventArgs e)
        {
            if (!CompFontHelper.CheckFontFolder())
            {
                MessageBox.Show("Font directory " + CompFontHelper.FontFolder + " creating error",
                                "Error");
                return;
            }

            dlgOpen.InitialDirectory = CompFontHelper.FontFolder;
            dlgOpen.Filter           = "TTF files|*.ttf";
            DialogResult Ans = dlgOpen.ShowDialog();

            if (Ans == DialogResult.Cancel)
            {
                return;
            }

            FileFont ff = new FileFont(dlgOpen.FileName);

            frmFontSettings fFontSettings = new frmFontSettings();

            fFontSettings.fileFont = ff;
            Ans = fFontSettings.ShowDialog();
            if (Ans == DialogResult.Cancel)
            {
                return;
            }
            ff = fFontSettings.fileFont;

            for (int i = 0; i < 256; i++)
            {
                TableItems[i].SymFont = ff.Font;
            }

            PosTableItems(StartX, StartY);

            this.Location = new Point((Screen.PrimaryScreen.Bounds.Width - this.Width) / 2,
                                      (Screen.PrimaryScreen.Bounds.Height - this.Height) / 2);

            CompFontFlag = false;
        }
        private void grdCompFont_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            string           name = grdCompFont.Columns[e.ColumnIndex].Name;
            DataGridViewCell c    = grdCompFont.Rows[grdCompFont.CurrentRow.Index].
                                    Cells[name];
            object v = c.Value;

            frmHexValue fHexVal = new frmHexValue();

            switch (name)
            {
            case "clStart":
            {
                object max = grdCompFont.Rows[grdCompFont.CurrentRow.Index].
                             Cells["clEnd"].Value;
                if (max == null)
                {
                    max = 0x10FFFF;
                }
                fHexVal.Min = 0;
                fHexVal.Max = (int)max;
                if (v == null)
                {
                    v = 0;
                }
                fHexVal.Value = (int)v;
                DialogResult Ans = fHexVal.ShowDialog();
                if (Ans == DialogResult.Cancel)
                {
                    return;
                }
                c.Value = fHexVal.Value;
            }; break;

            case "clEnd":
            {
                object min = grdCompFont.Rows[grdCompFont.CurrentRow.Index].
                             Cells["clStart"].Value;
                if (min == null)
                {
                    min = 0;
                }

                fHexVal.Min = (int)min;
                fHexVal.Max = 0x10FFFF;
                if (v == null)
                {
                    v = 0;
                }
                fHexVal.Value = (int)v;
                DialogResult Ans = fHexVal.ShowDialog();
                if (Ans == DialogResult.Cancel)
                {
                    return;
                }
                c.Value = fHexVal.Value;
            }; break;

            case "clFont":
            {
                DialogResult Ans = dlgFont.ShowDialog();
                if (Ans == DialogResult.Cancel)
                {
                    return;
                }
                c.Value = dlgFont.Font.FontFamily.Name;
                grdCompFont.Rows[grdCompFont.CurrentRow.Index].
                Cells["clFontOptions"].Value
                    = dlgFont.Font;
                grdCompFont.Rows[grdCompFont.CurrentRow.Index].
                Cells["clFile"].Value
                    = null;
            }; break;

            case "clFile":
            {
                dlgOpen.InitialDirectory = CompFontHelper.FontFolder;
                dlgOpen.Filter           = "TTF files|*.ttf";
                DialogResult Ans = dlgOpen.ShowDialog();
                if (Ans == DialogResult.Cancel)
                {
                    return;
                }
                if (((string)c.Value) == dlgOpen.FileName)
                {
                    return;
                }
                c.Value = dlgOpen.FileName;
                FileFont ff = new FileFont((string)c.Value);
                grdCompFont.Rows[grdCompFont.CurrentRow.Index].
                Cells["clFontOptions"].Value
                    = ff.Font;
                grdCompFont.Rows[grdCompFont.CurrentRow.Index].
                Cells["clFont"].Value
                    = null;
            }; break;

            case "clFontOptions":
            {
                System.Drawing.Font fnt = null;

                object ofontfamily = grdCompFont.Rows[grdCompFont.CurrentRow.Index].
                                     Cells["clFont"].Value;
                object ofontfile = grdCompFont.Rows[grdCompFont.CurrentRow.Index].
                                   Cells["clFile"].Value;

                if (ofontfile == null)
                {
                    if (ofontfamily == null)
                    {
                        MessageBox.Show("No font or font file selected!", "Error");
                    }
                    else
                    {
                        if (v == null)
                        {
                            fnt = new Font((string)ofontfamily, 8, FontStyle.Regular);
                        }
                        else
                        {
                            fnt = (System.Drawing.Font)v;
                        }

                        DialogResult Ans = dlgFont.ShowDialog();
                        if (Ans == DialogResult.Cancel)
                        {
                            return;
                        }
                        c.Value = dlgFont.Font;
                        grdCompFont.Rows[grdCompFont.CurrentRow.Index].
                        Cells["clFont"].Value = dlgFont.Font.FontFamily.Name;
                    }
                }
                else
                {
                    FileFont ff = new FileFont((string)ofontfile);
                    if (v == null)
                    {
                        fnt = new Font(ff.Font.FontFamily, 8, FontStyle.Regular);
                    }
                    else
                    {
                        fnt = (Font)v;
                        Dictionary <string, bool> style =
                            CompFontHelper.ParseFontStyle(fnt.Style);
                        ff.Bold      = style["Bold"];
                        ff.Italic    = style["Italic"];
                        ff.Underline = style["Underline"];
                        ff.Strikeout = style["Strikeout"];
                        ff.Size      = fnt.Size;
                    }

                    frmFontSettings fFontSettings = new frmFontSettings();
                    fFontSettings.fileFont = ff;
                    DialogResult Ans = fFontSettings.ShowDialog();
                    if (Ans == DialogResult.Cancel)
                    {
                        return;
                    }
                    ff      = fFontSettings.fileFont;
                    c.Value = ff.Font;
                }
            }; break;
            }
        }