using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using NBarcode.Writing.WindowsForms;
namespace CSBarcodeWindowsForms
{
partial class BarcodeBuilder : Form
{
public BarcodeBuilder()
{
InitializeComponent();
this.propertyGrid1.SelectedObject = barcodeWinControl1.BarcodeStyle;
}
private void btnApply_Click(object sender, EventArgs e)
{
BarcodeType btype = BarcodeType.FromString(this.cmboBarcodeType.SelectedText);
if (!btype.IsUnknown())
{
System.Diagnostics.Debug.WriteLine("Selected BarcodeType:" + btype.ToString());
this.barcodeWinControl1.BarcodeType = btype;
}
this.barcodeWinControl1.Code = this.txtBarcodeCode.Text;
this.Invalidate(barcodeWinControl1.Region);
}
private void BarcodeCustomReportItemBuilder_Load(object sender, EventArgs e)
{
this.txtBarcodeCode.Text = barcodeWinControl1.Code;
string[] barcodeTypeNames = Enum.GetNames(typeof(BarcodeTypeEnum));
this.cmboBarcodeType.Items.Add("...");
this.cmboBarcodeType.Items.AddRange(barcodeTypeNames);
this.cmboBarcodeType.SelectedIndex = Array.IndexOf(barcodeTypeNames, barcodeWinControl1.BarcodeType.Value.ToString()) + 1;
this.Invalidate(barcodeWinControl1.Region);
}
private void cmboBarcodeType_SelectedIndexChanged(object sender, EventArgs e)
{
if (this.cmboBarcodeType.SelectedItem != null)
{
BarcodeType btype = BarcodeType.FromString((string)this.cmboBarcodeType.SelectedItem);
if (!btype.IsUnknown())
{
System.Diagnostics.Debug.WriteLine("Selected BarcodeType:" + btype.ToString());
this.barcodeWinControl1.BarcodeType = btype;
this.Invalidate(barcodeWinControl1.Region);
}
}
}
private void btnSave_Click(object sender, EventArgs e)
{
SaveFileDialog dialog = new SaveFileDialog();
if (dialog.ShowDialog() == DialogResult.OK)
{
barcodeWinControl1.Barcode.SaveToXml(dialog.FileName);
}
}
private void btnClose_Click(object sender, EventArgs e)
{
this.Close();
}
}
}