📄 form1.cs
字号:
using System;
using System.Drawing;
using System.Drawing.Printing;
using System.Windows.Forms;
using System.Drawing.Imaging;
using Bokai.Barcodes;
namespace Bokai.Barcodes.Sample2
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label1;
private Bokai.Barcodes.BarcodeControl barcodeControl1;
private System.Windows.Forms.ListBox listboxProperties;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.TextBox editData;
private System.Windows.Forms.TextBox editAddOnData;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.LinkLabel linkFont;
private System.Windows.Forms.TextBox editFont;
private System.Windows.Forms.ComboBox comboBarcodeType;
private System.Windows.Forms.ComboBox comboRotation;
private System.Windows.Forms.Button buttonPrint;
private System.Windows.Forms.Button buttonSaveImage;
private System.Windows.Forms.ComboBox comboOrientation;
private System.ComponentModel.IContainer components = null;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.CheckBox checkHiliteMain;
private System.Windows.Forms.CheckBox checkHiliteAddOn;
private System.Windows.Forms.CheckBox checkHiliteWhole;
private BarcodeDrawFlags _drawFlags = 0;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
int i = 0;
BarcodeTypeEnumerator e = BarcodeControl.EnumerateBarcodeTypes();
while (e.MoveNext())
{
BarcodeTypeInfo barcodeTypeInfo = (BarcodeTypeInfo) e.Current;
comboBarcodeType.Items.Add(barcodeTypeInfo);
if (barcodeTypeInfo.BarcodeType == BarcodeType.CODE39) comboBarcodeType.SelectedIndex = i;
++i;
}
// item index corresponds to actual numeric value of BarcodeOrientation
comboOrientation.Items.Add("BottomFacing");
comboOrientation.SelectedIndex = 0;
comboOrientation.Items.Add("RightFacing");
comboOrientation.Items.Add("TopFacing");
comboOrientation.Items.Add("LeftFacing");
editFont.ForeColor = barcodeControl1.ForeColor;
editFont.Text = barcodeControl1.Font.Name;
comboRotation.SelectedIndex = 0;
_drawFlags = 0;
BarcodeDrawFlags drawFlagsFromProperties = barcodeControl1.DrawFlagsFromProperties;
Type type = typeof(BarcodeDrawFlags);
System.Reflection.FieldInfo[] afi = type.GetFields();
for (i = 0; i < afi.Length; i++)
{
if (afi[i].FieldType != type) continue;
BarcodeDrawFlags flag = (BarcodeDrawFlags) afi[i].GetValue(null);
switch (flag)
{
case BarcodeDrawFlags.WidthPerModule:
case BarcodeDrawFlags.NoRestoreGraphicsState:
break;
default:
listboxProperties.Items.Add(flag);
if ((flag & drawFlagsFromProperties) != 0)
listboxProperties.SetSelected(listboxProperties.Items.Count - 1, true);
break;
}
}
barcodeControl1.InvalidDataAction = InvalidDataAction.DisplayInvalid;
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.listboxProperties = new System.Windows.Forms.ListBox();
this.barcodeControl1 = new Bokai.Barcodes.BarcodeControl();
this.comboOrientation = new System.Windows.Forms.ComboBox();
this.label1 = new System.Windows.Forms.Label();
this.buttonPrint = new System.Windows.Forms.Button();
this.buttonSaveImage = new System.Windows.Forms.Button();
this.label2 = new System.Windows.Forms.Label();
this.comboBarcodeType = new System.Windows.Forms.ComboBox();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.editData = new System.Windows.Forms.TextBox();
this.editAddOnData = new System.Windows.Forms.TextBox();
this.label5 = new System.Windows.Forms.Label();
this.comboRotation = new System.Windows.Forms.ComboBox();
this.linkFont = new System.Windows.Forms.LinkLabel();
this.editFont = new System.Windows.Forms.TextBox();
this.checkHiliteMain = new System.Windows.Forms.CheckBox();
this.checkHiliteAddOn = new System.Windows.Forms.CheckBox();
this.checkHiliteWhole = new System.Windows.Forms.CheckBox();
this.label6 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// listboxProperties
//
this.listboxProperties.Location = new System.Drawing.Point(304, 48);
this.listboxProperties.Name = "listboxProperties";
this.listboxProperties.SelectionMode = System.Windows.Forms.SelectionMode.MultiSimple;
this.listboxProperties.Size = new System.Drawing.Size(168, 316);
this.listboxProperties.TabIndex = 0;
this.listboxProperties.SelectedIndexChanged += new System.EventHandler(this.listboxProperties_SelectedIndexChanged);
//
// barcodeControl1
//
this.barcodeControl1.AddOnCaption = null;
this.barcodeControl1.AddOnData = null;
this.barcodeControl1.BackColor = System.Drawing.Color.White;
this.barcodeControl1.Caption = null;
this.barcodeControl1.Data = "000000";
this.barcodeControl1.Font = new System.Drawing.Font("Arial", 9F);
this.barcodeControl1.ForeColor = System.Drawing.Color.Black;
this.barcodeControl1.Location = new System.Drawing.Point(32, 88);
this.barcodeControl1.LowerTopTextBy = 0F;
this.barcodeControl1.Name = "barcodeControl1";
this.barcodeControl1.RaiseBottomTextBy = 0F;
this.barcodeControl1.Size = new System.Drawing.Size(224, 112);
this.barcodeControl1.TabIndex = 1;
this.barcodeControl1.Visible = false;
//
// comboOrientation
//
this.comboOrientation.Location = new System.Drawing.Point(80, 320);
this.comboOrientation.Name = "comboOrientation";
this.comboOrientation.Size = new System.Drawing.Size(128, 21);
this.comboOrientation.TabIndex = 2;
this.comboOrientation.SelectedIndexChanged += new System.EventHandler(this.comboOrientation_SelectedIndexChanged);
//
// label1
//
this.label1.Location = new System.Drawing.Point(8, 320);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(64, 16);
this.label1.TabIndex = 3;
this.label1.Text = "Orientation:";
//
// buttonPrint
//
this.buttonPrint.Location = new System.Drawing.Point(304, 8);
this.buttonPrint.Name = "buttonPrint";
this.buttonPrint.TabIndex = 4;
this.buttonPrint.Text = "Print...";
this.buttonPrint.Click += new System.EventHandler(this.buttonPrint_Click);
//
// buttonSaveImage
//
this.buttonSaveImage.Location = new System.Drawing.Point(392, 8);
this.buttonSaveImage.Name = "buttonSaveImage";
this.buttonSaveImage.Size = new System.Drawing.Size(88, 23);
this.buttonSaveImage.TabIndex = 5;
this.buttonSaveImage.Text = "Save Image...";
this.buttonSaveImage.Click += new System.EventHandler(this.buttonSaveImage_Click);
//
// label2
//
this.label2.Location = new System.Drawing.Point(8, 224);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(80, 16);
this.label2.TabIndex = 6;
this.label2.Text = "BarcodeType:";
//
// comboBarcodeType
//
this.comboBarcodeType.Location = new System.Drawing.Point(96, 224);
this.comboBarcodeType.MaxDropDownItems = 30;
this.comboBarcodeType.Name = "comboBarcodeType";
this.comboBarcodeType.Size = new System.Drawing.Size(184, 21);
this.comboBarcodeType.TabIndex = 7;
this.comboBarcodeType.SelectedIndexChanged += new System.EventHandler(this.comboBarcodeType_SelectedIndexChanged);
//
// label3
//
this.label3.Location = new System.Drawing.Point(8, 288);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(72, 16);
this.label3.TabIndex = 8;
this.label3.Text = "AddOnData:";
//
// label4
//
this.label4.Location = new System.Drawing.Point(8, 256);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(32, 16);
this.label4.TabIndex = 9;
this.label4.Text = "Data:";
//
// editData
//
this.editData.Location = new System.Drawing.Point(48, 256);
this.editData.Name = "editData";
this.editData.Size = new System.Drawing.Size(232, 20);
this.editData.TabIndex = 10;
this.editData.Text = "";
this.editData.TextChanged += new System.EventHandler(this.editData_TextChanged);
//
// editAddOnData
//
this.editAddOnData.Location = new System.Drawing.Point(96, 288);
this.editAddOnData.Name = "editAddOnData";
this.editAddOnData.Size = new System.Drawing.Size(184, 20);
this.editAddOnData.TabIndex = 11;
this.editAddOnData.Text = "";
this.editAddOnData.TextChanged += new System.EventHandler(this.editAddOnData_TextChanged);
//
// label5
//
this.label5.Location = new System.Drawing.Point(8, 352);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(56, 16);
this.label5.TabIndex = 12;
this.label5.Text = "Rotation:";
//
// comboRotation
//
this.comboRotation.Items.AddRange(new object[] {
"0",
"30",
"45",
"135",
"225",
"315"});
this.comboRotation.Location = new System.Drawing.Point(64, 352);
this.comboRotation.Name = "comboRotation";
this.comboRotation.Size = new System.Drawing.Size(64, 21);
this.comboRotation.TabIndex = 13;
this.comboRotation.SelectedIndexChanged += new System.EventHandler(this.comboRotation_SelectedIndexChanged);
//
// linkFont
//
this.linkFont.Location = new System.Drawing.Point(144, 352);
this.linkFont.Name = "linkFont";
this.linkFont.Size = new System.Drawing.Size(32, 16);
this.linkFont.TabIndex = 14;
this.linkFont.TabStop = true;
this.linkFont.Text = "Font:";
this.linkFont.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkFont_LinkClicked);
//
// editFont
//
this.editFont.ForeColor = System.Drawing.SystemColors.WindowText;
this.editFont.Location = new System.Drawing.Point(184, 352);
this.editFont.Name = "editFont";
this.editFont.ReadOnly = true;
this.editFont.TabIndex = 15;
this.editFont.Text = "";
//
// checkHiliteMain
//
this.checkHiliteMain.Location = new System.Drawing.Point(136, 384);
this.checkHiliteMain.Name = "checkHiliteMain";
this.checkHiliteMain.Size = new System.Drawing.Size(96, 16);
this.checkHiliteMain.TabIndex = 16;
this.checkHiliteMain.Text = "Main Barcode";
this.checkHiliteMain.CheckedChanged += new System.EventHandler(this.checkHilite_CheckedChanged);
//
// checkHiliteAddOn
//
this.checkHiliteAddOn.Location = new System.Drawing.Point(264, 384);
this.checkHiliteAddOn.Name = "checkHiliteAddOn";
this.checkHiliteAddOn.Size = new System.Drawing.Size(64, 16);
this.checkHiliteAddOn.TabIndex = 17;
this.checkHiliteAddOn.Text = "Add-On";
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -