private void btnCompFont_Click(object sender, EventArgs e) { frmCompFont fCompFont = new frmCompFont(); fCompFont.CompFHelper = CFHelper; DialogResult Ans = fCompFont.ShowDialog(); if (Ans == DialogResult.Cancel) { return; } CFHelper = fCompFont.CompFHelper; CompFontFlag = true; for (int i = 0; i < 256; i++) { int c = TableItems[i].Code; Font fnt = CFHelper.GetFont(c); TableItems[i].SymFont = fnt;; } PosTableItems(StartX, StartY); this.Location = new Point((Screen.PrimaryScreen.Bounds.Width - this.Width) / 2, (Screen.PrimaryScreen.Bounds.Height - this.Height) / 2); }
private void SaveCompFont() { CompFHelper = new CompFontHelper(); for (int i = 0; i < grdCompFont.Rows.Count; i++) { CompFont cf = new CompFont(); cf.Start = (int)grdCompFont.Rows[i].Cells["clStart"].Value; cf.End = (int)grdCompFont.Rows[i].Cells["clEnd"].Value; cf.Style = ((System.Drawing.Font)grdCompFont.Rows[i].Cells["clFontOptions"].Value).Style; cf.Size = ((System.Drawing.Font)grdCompFont.Rows[i].Cells["clFontOptions"].Value).Size; object fontfilename = grdCompFont.Rows[i].Cells["clFile"].Value; if (fontfilename != null) { cf.InFile = true; cf.FileName = (string)fontfilename; } else { cf.FamilyName = (string)grdCompFont.Rows[i].Cells["clFont"].Value; } CompFHelper.Add(cf); } }
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 btnLoad_Click(object sender, EventArgs e) { dlgOpen.InitialDirectory = CompFontHelper.FontFolder; dlgOpen.Filter = "Composite font (*.cf)|*.cf"; DialogResult Ans = dlgOpen.ShowDialog(); if (Ans == DialogResult.Cancel) { return; } CompFHelper = new CompFontHelper(); if (!CompFHelper.LoadCompFontData(dlgOpen.FileName)) { lblInfo.ForeColor = ErrColor; lblInfo.Text = "Load file error!"; return; } LoadCompFont(); }
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; } }