📄 livewebdemo.aspx.cs
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using Bokai.Barcodes;
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DropDownList Generator;
protected System.Web.UI.WebControls.Button submitButton;
protected System.Web.UI.WebControls.HyperLink barcodeURL;
protected System.Web.UI.WebControls.DropDownList BarcodeType;
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.Label Label2;
protected System.Web.UI.WebControls.TextBox Data;
protected System.Web.UI.WebControls.Label Label3;
protected System.Web.UI.WebControls.TextBox AddOnData;
protected System.Web.UI.WebControls.Label Label4;
protected System.Web.UI.WebControls.DropDownList ImageFormat;
protected System.Web.UI.WebControls.Label Label5;
protected System.Web.UI.WebControls.TextBox BarWidth;
protected System.Web.UI.WebControls.Label Label6;
protected System.Web.UI.WebControls.Label Label7;
protected System.Web.UI.WebControls.TextBox Height;
protected System.Web.UI.WebControls.Label Label8;
protected System.Web.UI.WebControls.Label Label9;
protected System.Web.UI.WebControls.TextBox Caption;
protected System.Web.UI.WebControls.Label Label10;
protected System.Web.UI.WebControls.TextBox AddOnCaption;
protected System.Web.UI.WebControls.Label Label11;
protected System.Web.UI.WebControls.TextBox FontName;
protected System.Web.UI.WebControls.Label Label12;
protected System.Web.UI.WebControls.TextBox FontSize;
protected System.Web.UI.WebControls.Label Label13;
protected System.Web.UI.WebControls.ListBox FontStyle;
protected System.Web.UI.WebControls.Label Label14;
protected System.Web.UI.WebControls.DropDownList TextPosition;
protected System.Web.UI.WebControls.Label Label15;
protected System.Web.UI.WebControls.DropDownList AddOnTextPosition;
protected System.Web.UI.WebControls.Label Label16;
protected System.Web.UI.WebControls.DropDownList UniBarHeight;
protected System.Web.UI.WebControls.Label Label17;
protected System.Web.UI.WebControls.DropDownList StretchText;
protected System.Web.UI.WebControls.Label Label18;
protected System.Web.UI.WebControls.DropDownList ShowCode39StartStop;
protected System.Web.UI.WebControls.Label Label19;
protected System.Web.UI.WebControls.DropDownList RetainAspectRatio;
protected System.Web.UI.WebControls.Label Label20;
protected System.Web.UI.WebControls.DropDownList UpcSmallFont;
protected System.Web.UI.WebControls.Label Label21;
protected System.Web.UI.WebControls.TextBox BackColor;
protected System.Web.UI.WebControls.Label Label22;
protected System.Web.UI.WebControls.TextBox ForeColor;
protected System.Web.UI.WebControls.Label Label23;
protected System.Web.UI.WebControls.DropDownList InvalidDataAction;
protected BarcodeImage barcodeImage1;
protected System.Web.UI.WebControls.DropDownList Orientation;
protected System.Web.UI.WebControls.DropDownList Transparent;
protected System.Web.UI.HtmlControls.HtmlInputText barcodeUrlText;
protected System.Web.UI.HtmlControls.HtmlTextArea barcodeUrlArea;
protected System.Web.UI.WebControls.Label Debug;
protected System.Web.UI.WebControls.Button submitButton1;
protected System.Web.UI.HtmlControls.HtmlForm barcodeForm;
protected System.Web.UI.WebControls.Label Label24;
protected System.Web.UI.WebControls.Label ModuleCount;
private void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack)
{
string str = Request.Url.GetLeftPart(UriPartial.Authority).TrimEnd(new char[] { '/' });
barcodeUrlArea.Value = str + barcodeImage1.MakeImageUrlBase();
barcodeURL.NavigateUrl = barcodeUrlArea.Value;
ModuleCount.Text = barcodeImage1.ModuleCount.ToString();
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.submitButton1.Click += new System.EventHandler(this.submitButton1_Click);
this.submitButton.Click += new System.EventHandler(this.submitButton_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void Regenerate()
{
String text;
if (Generator.SelectedItem.Value == "handler")
barcodeImage1.ImageUrl = "BarcodeHandler.aspx";
else
barcodeImage1.ImageUrl = "Barcode.aspx";
// NOTE: some internal Barcode .Net functions are called just to
// take advantage of some parsing code; they are not indispensable
// and are not expected to be useful under normal circumstances
barcodeImage1.BarcodeType = BarcodeWeb.ParseBarcodeType(BarcodeType.SelectedItem.Value);
text = Data.Text;
if (text == "")
barcodeImage1.UseDefaultData();
else
barcodeImage1.Data = text;
text = AddOnData.Text;
if (text == "")
barcodeImage1.UseDefaultAddOnData();
else
barcodeImage1.AddOnData = text;
barcodeImage1.ImageFormat = BarcodeWeb.ParseImageFormat(ImageFormat.SelectedItem.Value);
BarcodeWeb.ProcessOrientation(barcodeImage1.Barcode, Orientation.SelectedItem.Value);
text = BarWidth.Text.Trim();
if (text != "") barcodeImage1.BarWidth = BarcodeWeb.ParseInt(text, 1);
text = Height.Text.Trim();
if (text != "") barcodeImage1.BarcodeHeight = BarcodeWeb.ParseInt(text, 40);
barcodeImage1.Transparent = BarcodeWeb.ParseBool(Transparent.SelectedItem.Value, false);
text = Caption.Text;
if (text != "") barcodeImage1.Caption = text;
text = AddOnCaption.Text;
if (text != "") barcodeImage1.AddOnCaption = text;
text = FontName.Text;
if (text != "") barcodeImage1.Font.Name = text;
text = FontName.Text;
if (text != "") barcodeImage1.Font.Name = text;
text = FontSize.Text.Trim();
if (text != "")
barcodeImage1.Font.Size = new FontUnit(new Unit(BarcodeWeb.ParseSingle(text, 9.0f), UnitType.Point));
// Default is already this:
//barcodeImage1.Font.Overline = false;
//barcodeImage1.Font.Underline = false;
//barcodeImage1.Font.Italic = false;
//barcodeImage1.Font.Bold = false;
//barcodeImage1.Font.Strikeout = false;
foreach (ListItem li in FontStyle.Items)
{
if (!li.Selected) continue;
switch (li.Text.ToLower())
{
case "bold":
barcodeImage1.Font.Bold = true;
break;
case "italic":
barcodeImage1.Font.Italic = true;
break;
case "underline":
barcodeImage1.Font.Underline = true;
break;
case "strikeout":
barcodeImage1.Font.Strikeout = true;
break;
case "regular":
default:
break;
}
}
barcodeImage1.TextPosition = BarcodeWeb.ParseTextPosition(TextPosition.SelectedItem.Value, BarcodeTextPosition.Below);
barcodeImage1.AddOnTextPosition = BarcodeWeb.ParseTextPosition(AddOnTextPosition.SelectedItem.Value, BarcodeTextPosition.Above);
barcodeImage1.UniBarHeight = BarcodeWeb.ParseBool(UniBarHeight.SelectedItem.Value, false);
barcodeImage1.StretchText = BarcodeWeb.ParseBool(StretchText.SelectedItem.Value, true);
barcodeImage1.ShowCode39StartStop = BarcodeWeb.ParseBool(ShowCode39StartStop.SelectedItem.Value, true);
barcodeImage1.RetainAspectRatio = BarcodeWeb.ParseBool(RetainAspectRatio.SelectedItem.Value, false);
barcodeImage1.UpcSmallFont = BarcodeWeb.ParseBool(UpcSmallFont.SelectedItem.Value, true);
text = BackColor.Text.Trim();
if (text != "")
barcodeImage1.BackColor = BarcodeWeb.ParseColor(text, System.Drawing.Color.White);
text = ForeColor.Text.Trim();
if (text != "")
barcodeImage1.ForeColor = BarcodeWeb.ParseColor(text, System.Drawing.Color.Black);
BarcodeWeb.ProcessInvalidDataAction(barcodeImage1.Barcode, InvalidDataAction.SelectedItem.Value);
string str = Request.Url.GetLeftPart(UriPartial.Authority).TrimEnd(new char[] { '/' });
barcodeUrlArea.Value = str + barcodeImage1.MakeFullImageUrl();
barcodeURL.NavigateUrl = barcodeUrlArea.Value;
ModuleCount.Text = barcodeImage1.ModuleCount.ToString();
}
private void submitButton_Click(object sender, System.EventArgs e)
{
Regenerate();
}
private void submitButton1_Click(object sender, System.EventArgs e)
{
Regenerate();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -