📄 form1.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Xml;
using System.Xml.Xsl;
using System.Xml.XPath;
using System.Globalization ;
namespace FontMaker
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class FontMaker : System.Windows.Forms.Form
{
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.ComboBox cmbFont;
private System.Windows.Forms.ComboBox cmbFSize;
private System.Windows.Forms.ColumnHeader columnHeader6;
private System.Windows.Forms.ImageList fontImgList;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.Button btnAdd;
private System.Windows.Forms.TextBox txtFonts;
private System.Windows.Forms.Button btnFont;
private System.Windows.Forms.Button btnAdjust;
private System.ComponentModel.IContainer components;
private System.Windows.Forms.TextBox txtSample;
private System.Windows.Forms.ListView listFontView;
private System.Windows.Forms.ComboBox cmbImgSizeW;
private System.Windows.Forms.ComboBox cmbImgSizeH;
private System.Windows.Forms.ComboBox cmbImgLarge;
private System.Windows.Forms.ListBox listFont;
private System.Windows.Forms.Button btnDelete;
private System.Windows.Forms.ComboBox cmbSampleLarge;
private System.Windows.Forms.HScrollBar hScrollBar;
private System.Windows.Forms.VScrollBar vScrollBar;
private System.Xml.XmlDocument xmlDoc;
private System.Windows.Forms.Button btnAdjustSure;
private System.Windows.Forms.Panel panelSample;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.Button btnCreateXML;
private System.Windows.Forms.Button btnInportXML;
private System.Windows.Forms.Button btnCreateLattice;
private System.Windows.Forms.Button btnInportXSL;
//the flag value
private bool bFontName=false;
private bool bFontSize=false;
private bool bImgSizeW=false;
private bool bImgSizeH=false;
private bool bTxtSample=false;
private bool bAdjust=false;
private string strXslFileName="";
public FontMaker()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
xmlDoc=new XmlDocument();
xmlDoc.LoadXml("<?xml version=\"1.0\" ?><Fonts></Fonts>");
cmbFont.Items.Clear();
cmbFSize.Items.Clear();
for(int i=0;i<System.Drawing.FontFamily.Families.GetLongLength(0);i++)
{
cmbFont.Items.Add(((System.Drawing.FontFamily )System.Drawing.FontFamily.Families.GetValue(i)).GetName(0));
}
for(int i=8 ;i<=72;i++)
{
cmbFSize.Items.Add(i.ToString());
}
cmbFont.SelectedIndex=cmbFont.FindString("Arial");
cmbFSize.SelectedIndex=cmbFSize.FindString("10");
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.label1 = new System.Windows.Forms.Label();
this.txtSample = new System.Windows.Forms.TextBox();
this.cmbSampleLarge = new System.Windows.Forms.ComboBox();
this.panelSample = new System.Windows.Forms.Panel();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.label6 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.listFontView = new System.Windows.Forms.ListView();
this.columnHeader6 = new System.Windows.Forms.ColumnHeader();
this.fontImgList = new System.Windows.Forms.ImageList(this.components);
this.cmbFont = new System.Windows.Forms.ComboBox();
this.cmbFSize = new System.Windows.Forms.ComboBox();
this.cmbImgSizeW = new System.Windows.Forms.ComboBox();
this.cmbImgSizeH = new System.Windows.Forms.ComboBox();
this.cmbImgLarge = new System.Windows.Forms.ComboBox();
this.hScrollBar = new System.Windows.Forms.HScrollBar();
this.vScrollBar = new System.Windows.Forms.VScrollBar();
this.btnAdjust = new System.Windows.Forms.Button();
this.btnAdd = new System.Windows.Forms.Button();
this.txtFonts = new System.Windows.Forms.TextBox();
this.listFont = new System.Windows.Forms.ListBox();
this.btnCreateXML = new System.Windows.Forms.Button();
this.btnFont = new System.Windows.Forms.Button();
this.btnDelete = new System.Windows.Forms.Button();
this.btnAdjustSure = new System.Windows.Forms.Button();
this.btnInportXML = new System.Windows.Forms.Button();
this.btnCreateLattice = new System.Windows.Forms.Button();
this.btnInportXSL = new System.Windows.Forms.Button();
this.groupBox2.SuspendLayout();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// groupBox2
//
this.groupBox2.Controls.Add(this.label1);
this.groupBox2.Controls.Add(this.txtSample);
this.groupBox2.Controls.Add(this.cmbSampleLarge);
this.groupBox2.Controls.Add(this.panelSample);
this.groupBox2.Location = new System.Drawing.Point(192, 200);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(536, 120);
this.groupBox2.TabIndex = 23;
this.groupBox2.TabStop = false;
//
// label1
//
this.label1.Location = new System.Drawing.Point(432, 24);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(32, 24);
this.label1.TabIndex = 25;
this.label1.Text = "倍数";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// txtSample
//
this.txtSample.Location = new System.Drawing.Point(8, 24);
this.txtSample.Name = "txtSample";
this.txtSample.Size = new System.Drawing.Size(416, 21);
this.txtSample.TabIndex = 16;
this.txtSample.Text = "Sample Text";
this.txtSample.TextChanged += new System.EventHandler(this.txtSample_TextChanged);
this.txtSample.Leave += new System.EventHandler(this.txtSample_Leave);
//
// cmbSampleLarge
//
this.cmbSampleLarge.Items.AddRange(new object[] {
"1",
"2",
"3",
"4"});
this.cmbSampleLarge.Location = new System.Drawing.Point(464, 24);
this.cmbSampleLarge.Name = "cmbSampleLarge";
this.cmbSampleLarge.Size = new System.Drawing.Size(64, 20);
this.cmbSampleLarge.TabIndex = 17;
this.cmbSampleLarge.Text = "1";
this.cmbSampleLarge.SelectedIndexChanged += new System.EventHandler(this.cmbSampleLarge_SelectedIndexChanged);
//
// panelSample
//
this.panelSample.Location = new System.Drawing.Point(8, 56);
this.panelSample.Name = "panelSample";
this.panelSample.Size = new System.Drawing.Size(520, 56);
this.panelSample.TabIndex = 18;
//
// groupBox1
//
this.groupBox1.Controls.Add(this.label6);
this.groupBox1.Controls.Add(this.label5);
this.groupBox1.Controls.Add(this.label4);
this.groupBox1.Controls.Add(this.label3);
this.groupBox1.Controls.Add(this.label2);
this.groupBox1.Controls.Add(this.listFontView);
this.groupBox1.Controls.Add(this.cmbFont);
this.groupBox1.Controls.Add(this.cmbFSize);
this.groupBox1.Controls.Add(this.cmbImgSizeW);
this.groupBox1.Controls.Add(this.cmbImgSizeH);
this.groupBox1.Controls.Add(this.cmbImgLarge);
this.groupBox1.Controls.Add(this.hScrollBar);
this.groupBox1.Controls.Add(this.vScrollBar);
this.groupBox1.Location = new System.Drawing.Point(192, 46);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(536, 154);
this.groupBox1.TabIndex = 25;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "字库调整";
//
// label6
//
this.label6.Location = new System.Drawing.Point(160, 16);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(32, 24);
this.label6.TabIndex = 30;
this.label6.Text = "大小";
this.label6.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label5
//
this.label5.Location = new System.Drawing.Point(8, 16);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(32, 24);
this.label5.TabIndex = 29;
this.label5.Text = "字体";
this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label4
//
this.label4.Location = new System.Drawing.Point(256, 16);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(32, 24);
this.label4.TabIndex = 28;
this.label4.Text = "宽度";
this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label3
//
this.label3.Location = new System.Drawing.Point(352, 16);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(32, 24);
this.label3.TabIndex = 27;
this.label3.Text = "长度";
this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// label2
//
this.label2.Location = new System.Drawing.Point(464, 16);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(32, 24);
this.label2.TabIndex = 26;
this.label2.Text = "倍数";
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// listFontView
//
this.listFontView.Activation = System.Windows.Forms.ItemActivation.TwoClick;
this.listFontView.BackColor = System.Drawing.SystemColors.InactiveCaptionText;
this.listFontView.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.listFontView.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader6});
this.listFontView.Cursor = System.Windows.Forms.Cursors.Cross;
this.listFontView.Font = new System.Drawing.Font("Arial", 6F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
this.listFontView.GridLines = true;
this.listFontView.HideSelection = false;
this.listFontView.HoverSelection = true;
this.listFontView.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.listFontView.Location = new System.Drawing.Point(32, 48);
this.listFontView.Name = "listFontView";
this.listFontView.Size = new System.Drawing.Size(496, 88);
this.listFontView.SmallImageList = this.fontImgList;
this.listFontView.Sorting = System.Windows.Forms.SortOrder.Ascending;
this.listFontView.TabIndex = 15;
this.listFontView.View = System.Windows.Forms.View.List;
this.listFontView.DoubleClick += new System.EventHandler(this.listFontView_DoubleClick);
this.listFontView.SelectedIndexChanged += new System.EventHandler(this.listFontView_SelectedIndexChanged);
//
// columnHeader6
//
this.columnHeader6.Text = "";
this.columnHeader6.Width = 95;
//
// fontImgList
//
this.fontImgList.ColorDepth = System.Windows.Forms.ColorDepth.Depth32Bit;
this.fontImgList.ImageSize = new System.Drawing.Size(64, 64);
this.fontImgList.TransparentColor = System.Drawing.Color.Silver;
//
// cmbFont
//
this.cmbFont.Location = new System.Drawing.Point(40, 16);
this.cmbFont.Name = "cmbFont";
this.cmbFont.Size = new System.Drawing.Size(121, 20);
this.cmbFont.TabIndex = 4;
this.cmbFont.Text = "font";
this.cmbFont.SelectedIndexChanged += new System.EventHandler(this.cmbFont_SelectedIndexChanged);
//
// cmbFSize
//
this.cmbFSize.Location = new System.Drawing.Point(192, 16);
this.cmbFSize.Name = "cmbFSize";
this.cmbFSize.Size = new System.Drawing.Size(64, 20);
this.cmbFSize.TabIndex = 5;
this.cmbFSize.Text = "10";
this.cmbFSize.SelectedIndexChanged += new System.EventHandler(this.cmbFSize_SelectedIndexChanged);
//
// cmbImgSizeW
//
this.cmbImgSizeW.Items.AddRange(new object[] {
"0",
"4",
"8",
"12",
"16",
"20",
"28",
"32"});
this.cmbImgSizeW.Location = new System.Drawing.Point(288, 16);
this.cmbImgSizeW.Name = "cmbImgSizeW";
this.cmbImgSizeW.Size = new System.Drawing.Size(64, 20);
this.cmbImgSizeW.TabIndex = 6;
this.cmbImgSizeW.Text = "0";
this.cmbImgSizeW.SelectedIndexChanged += new System.EventHandler(this.cmbImgSizeW_SelectedIndexChanged);
//
// cmbImgSizeH
//
this.cmbImgSizeH.Items.AddRange(new object[] {
"0",
"4",
"8",
"16",
"24",
"32"});
this.cmbImgSizeH.Location = new System.Drawing.Point(384, 16);
this.cmbImgSizeH.Name = "cmbImgSizeH";
this.cmbImgSizeH.Size = new System.Drawing.Size(72, 20);
this.cmbImgSizeH.TabIndex = 7;
this.cmbImgSizeH.Text = "0";
this.cmbImgSizeH.SelectedIndexChanged += new System.EventHandler(this.cmbImgSizeH_SelectedIndexChanged);
//
// cmbImgLarge
//
this.cmbImgLarge.Items.AddRange(new object[] {
"1",
"2",
"3",
"4"});
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -