| 1: | using System; | |
| 2: | using System.Collections; | |
| 3: | using System.ComponentModel; | |
| 4: | using System.Data; | |
| 5: | using System.Drawing; | |
| 6: | using System.Web; | |
| 7: | using System.Web.SessionState; | |
| 8: | using System.Web.UI; | |
| 9: | using System.Web.UI.WebControls; | |
| 10: | using System.Web.UI.HtmlControls; | |
| 11: | using BarcodeNETWorkShop.Core; | |
| 12: | namespace WebFeaturesDemoCS | |
| 13: | { | |
| 14: | /// <summary> | |
| 15: | /// Summary description for WebForm2. | |
| 16: | /// </summary> | |
| 17: | public class ImageDynamicDemo : System.Web.UI.Page | |
| 18: | { | |
| 19: | protected System.Web.UI.WebControls.TextBox BarHieght; | |
| 20: | protected System.Web.UI.WebControls.TextBox CustomText; | |
| 21: | protected System.Web.UI.WebControls.TextBox BarcodeText; | |
| 22: | protected System.Web.UI.WebControls.TextBox BarWidth; | |
| 23: | protected System.Web.UI.WebControls.Button Button2; | |
| 24: | protected System.Web.UI.WebControls.TextBox SupplementalText; | |
| 25: | protected BarcodeNETWorkShop.BarcodeNETImage BarcodeNETImage1; | |
| 26: | protected System.Web.UI.WebControls.Label lblErrMsg; | |
| 27: | protected System.Web.UI.WebControls.DropDownList BarcodeType; | |
| 28: | protected System.Web.UI.WebControls.DropDownList BarcodeColor; | |
| 29: | protected System.Web.UI.WebControls.DropDownList TextColor; | |
| 30: | protected System.Web.UI.WebControls.DropDownList FileFormat; | |
| 31: | protected System.Web.UI.WebControls.DropDownList RotateAngle; | |
| 32: | protected System.Web.UI.WebControls.DropDownList TextFontName; | |
| 33: | protected System.Web.UI.WebControls.DropDownList ExceptionType; | |
| 34: | protected System.Web.UI.WebControls.DropDownList SupplementalTexStyle; | |
| 35: | protected System.Web.UI.WebControls.CheckBox ShowBarcodeText; | |
| 36: | protected System.Web.UI.WebControls.CheckBox SilentMode; | |
| 37: | protected System.Web.UI.WebControls.CheckBox ShowBorder; | |
| 38: | protected System.Web.UI.WebControls.CheckBox IncludeCheckSumDigit; | |
| 39: | protected System.Web.UI.WebControls.CheckBox AntiAlias; | |
| 40: | protected System.Web.UI.WebControls.CheckBox IsRounded; | |
| 41: | protected System.Web.UI.WebControls.DropDownList BgColor; | |
| 42: | protected System.Web.UI.WebControls.DropDownList TextFontSize; | |
| 43: | protected System.Web.UI.WebControls.DropDownList MarginBoundLeft; | |
| 44: | protected System.Web.UI.WebControls.DropDownList MarginBoundRight; | |
| 45: | protected System.Web.UI.WebControls.DropDownList MarginBoundTop; | |
| 46: | protected System.Web.UI.WebControls.DropDownList MarginBoundDown; | |
| 47: | protected System.Web.UI.WebControls.DropDownList TextGapLeft; | |
| 48: | protected System.Web.UI.WebControls.TextBox TopText; | |
| 49: | protected System.Web.UI.WebControls.DropDownList TextGapRight; | |
| 50: | protected System.Web.UI.WebControls.DropDownList TextGapTop; | |
| 51: | protected System.Web.UI.WebControls.DropDownList TextGapDown; | |
| 52: | protected System.Web.UI.WebControls.Button Button1; | |
| 53: | ||
| 54: | private void Page_Load(object sender, System.EventArgs e) | |
| 55: | { | |
| 56: | // Put user code to initialize the page here | |
| 57: | if (!this.IsPostBack) | |
| 58: | { | |
| 59: | string[] SupplementalTextStyleList=Enum.GetNames(typeof(SUPPLEMENTAL_TEXT_STYLE)); | |
| 60: | SupplementalTexStyle.DataSource=SupplementalTextStyleList; | |
| 61: | SupplementalTexStyle.DataBind(); | |
| 62: | ||
| 63: | string[] BarcodeTypeList=Enum.GetNames(typeof(BARCODE_TYPE)); | |
| 64: | BarcodeType.DataSource=BarcodeTypeList; | |
| 65: | BarcodeType.DataBind(); | |
| 66: | BarcodeType_SelectedIndexChanged(BarcodeType, null); | |
| 67: | ||
| 68: | string[] ColorList= Enum.GetNames (typeof(KnownColor)); | |
| 69: | BarcodeColor.DataSource =ColorList; | |
| 70: | BarcodeColor.DataBind (); | |
| 71: | BarcodeColor.Items.FindByText("Black").Selected =true; | |
| 72: | ||
| 73: | ||
| 74: | TextColor.DataSource =ColorList; | |
| 75: | TextColor.DataBind(); | |
| 76: | TextColor.Items.FindByText("Black").Selected =true; | |
| 77: | ||
| 78: | BgColor.DataSource =ColorList; | |
| 79: | BgColor.DataBind(); | |
| 80: | BgColor.Items.FindByText("White").Selected =true; | |
| 81: | ||
| 82: | string[] ExceptionTypeList=Enum.GetNames(typeof(EXCEPTION_TYPE)); | |
| 83: | ExceptionType.DataSource=ExceptionTypeList; | |
| 84: | ExceptionType.DataBind(); | |
| 85: | ||
| 86: | string[] FileFormatList=Enum.GetNames(typeof(FILE_FORMAT)); | |
| 87: | FileFormat.DataSource=FileFormatList; | |
| 88: | FileFormat.DataBind(); | |
| 89: | FileFormat.Items.FindByText("PNG").Selected =true; | |
| 90: | ||
| 91: | string[] RotateAngleList=Enum.GetNames(typeof(ROTATE_ANGLE)); | |
| 92: | RotateAngle.DataSource=RotateAngleList; | |
| 93: | RotateAngle.DataBind(); | |
| 94: | ||
| 95: | foreach (FontFamily ff in System.Drawing.FontFamily.Families ) | |
| 96: | { | |
| 97: | TextFontName.Items.Add (ff.GetName (0)); | |
| 98: | } | |
| 99: | ||
| 100: | SetValue(); | |
| 101: | } | |
| 102: | else | |
| 103: | { | |
| 104: | SetValue(); | |
| 105: | } | |
| 106: | } | |
| 107: | ||
| 108: | ||
| 109: | private void SetValue() | |
| 110: | { | |
| 111: | try | |
| 112: | { | |
| 113: | BarcodeNETImage1.BarcodeType=(BARCODE_TYPE)TypeDescriptor.GetConverter(typeof(BARCODE_TYPE)).ConvertFromString(BarcodeType.SelectedItem.ToString()); | |
| 114: | BarcodeNETImage1.ShowBarcodeText=this.ShowBarcodeText.Checked; | |
| 115: | BarcodeNETImage1.SilentMode=this.SilentMode.Checked; | |
| 116: | BarcodeNETImage1.IncludeChecksumDigit=this.IncludeCheckSumDigit.Checked; | |
| 117: | BarcodeNETImage1.ShowBorder=this.ShowBorder.Checked; | |
| 118: | BarcodeNETImage1.BarcodeText=this.BarcodeText.Text; | |
| 119: | BarcodeNETImage1.TopText =this.TopText.Text ; | |
| 120: | BarcodeNETImage1.CustomText=this.CustomText.Text; | |
| 121: | BarcodeNETImage1.BarHeight=Convert.ToInt32(this.BarHieght.Text); | |
| 122: | BarcodeNETImage1.BarcodeColor=Color.FromName(this.BarcodeColor.SelectedValue.ToString()); | |
| 123: | BarcodeNETImage1.BgColor=Color.FromName(this.BgColor.SelectedValue.ToString()); | |
| 124: | BarcodeNETImage1.TextColor=Color.FromName(this.TextColor.SelectedValue.ToString()); | |
| 125: | BarcodeNETImage1.ExceptionType=(EXCEPTION_TYPE)TypeDescriptor.GetConverter(typeof(EXCEPTION_TYPE)).ConvertFromString(ExceptionType.SelectedItem.ToString()); | |
| 126: | BarcodeNETImage1.FileFormat=(FILE_FORMAT)TypeDescriptor.GetConverter(typeof(FILE_FORMAT)).ConvertFromString(FileFormat.SelectedItem.ToString()); | |
| 127: | BarcodeNETImage1.RotateAngle=(ROTATE_ANGLE)TypeDescriptor.GetConverter(typeof(ROTATE_ANGLE)).ConvertFromString(RotateAngle.SelectedItem.ToString()); | |
| 128: | BarcodeNETImage1.TextFont= new Font(TextFontName.SelectedItem.Text,(float)Convert.ToDecimal(TextFontSize.SelectedItem.Text)); | |
| 129: | BarcodeNETImage1.BarWidth=Convert.ToInt32(BarWidth.Text); | |
| 130: | BarcodeNETImage1.SupplementalText=this.SupplementalText.Text; | |
| 131: | BarcodeNETImage1.SupplementalTextStyle=(SUPPLEMENTAL_TEXT_STYLE)TypeDescriptor.GetConverter(typeof(SUPPLEMENTAL_TEXT_STYLE)).ConvertFromString(SupplementalTexStyle.SelectedItem.ToString()); | |
| 132: | BarcodeNETImage1.AntiAlias =this.AntiAlias.Checked; | |
| 133: | BarcodeNETImage1.IsRounded =this.IsRounded .Checked ; | |
| 134: | BarcodeNETImage1.BarcodeMargins.Top =Convert.ToInt32 (this.MarginBoundTop.SelectedValue); | |
| 135: | BarcodeNETImage1.BarcodeMargins.Bottom =Convert.ToInt32 (this.MarginBoundDown.SelectedValue); | |
| 136: | BarcodeNETImage1.BarcodeMargins.Left =Convert.ToInt32 (this.MarginBoundLeft.SelectedValue); | |
| 137: | BarcodeNETImage1.BarcodeMargins.Right =Convert.ToInt32 (this.MarginBoundRight.SelectedValue); | |
| 138: | BarcodeNETImage1.BarcodeGap.Top =Convert.ToInt32 (this.TextGapTop.SelectedValue); | |
| 139: | BarcodeNETImage1.BarcodeGap.Bottom =Convert.ToInt32 (this.TextGapDown.SelectedValue); | |
| 140: | BarcodeNETImage1.BarcodeGap.Left =Convert.ToInt32 (this.TextGapLeft.SelectedValue); | |
| 141: | BarcodeNETImage1.BarcodeGap.Right =Convert.ToInt32 (this.TextGapRight.SelectedValue); | |
| 142: | lblErrMsg.Text=""; | |
| 143: | } | |
| 144: | catch | |
| 145: | { | |
| 146: | ||
| 147: | } | |
| 148: | } | |
| 149: | ||
| 150: | private void BarcodeType_SelectedIndexChanged(object sender, System.EventArgs e) | |
| 151: | { | |
| 152: | BARCODE_TYPE SelectedBarcodeType=(BARCODE_TYPE)TypeDescriptor.GetConverter(typeof(BARCODE_TYPE)).ConvertFromString(((DropDownList)sender).SelectedItem.ToString()); | |
| 153: | this.BarcodeText.Text=BarcodeNETImage1.BarcodeText=BarcodeNETImage1.GetDefaultBarcodeText(SelectedBarcodeType); | |
| 154: | this.SupplementalText.Text=BarcodeNETImage1.SupplementalText=BarcodeNETImage1.GetDefaultSupplementalText(SelectedBarcodeType); | |
| 155: | SetValue(); | |
| 156: | } | |
| 157: | ||
| 158: | #region Web Form Designer generated code | |
| 159: | override protected void OnInit(EventArgs e) | |
| 160: | { | |
| 161: | // | |
| 162: | // CODEGEN: This call is required by the ASP.NET Web Form Designer. | |
| 163: | // | |
| 164: | InitializeComponent(); | |
| 165: | base.OnInit(e); | |
| 166: | } | |
| 167: | ||
| 168: | /// <summary> | |
| 169: | /// Required method for Designer support - do not modify | |
| 170: | /// the contents of this method with the code editor. | |
| 171: | /// </summary> | |
| 172: | private void InitializeComponent() | |
| 173: | { | |
| 174: | this.BarcodeType.SelectedIndexChanged += new System.EventHandler(this.BarcodeType_SelectedIndexChanged); | |
| 175: | this.Button1.Click += new System.EventHandler(this.Button1_Click); | |
| 176: | this.Button2.Click += new System.EventHandler(this.Button2_Click); | |
| 177: | this.Load += new System.EventHandler(this.Page_Load); | |
| 178: | ||
| 179: | } | |
| 180: | #endregion | |
| 181: | ||
| 182: | private void Button1_Click(object sender, System.EventArgs e) | |
| 183: | { | |
| 184: | SetValue(); | |
| 185: | } | |
| 186: | ||
| 187: | private void Button2_Click(object sender, System.EventArgs e) | |
| 188: | { | |
| 189: | try | |
| 190: | { | |
| 191: | SetValue(); | |
| 192: | ||
| 193: | BarcodeNETImage1.SaveToFile(Server.MapPath(Request.ApplicationPath)+"\\"+"test.bmp",FILE_FORMAT.BMP); | |
| 194: | BarcodeNETImage1.SaveToFile(Server.MapPath(Request.ApplicationPath)+"\\"+"test.jpg",FILE_FORMAT.JPG); | |
| 195: | BarcodeNETImage1.SaveToFile(Server.MapPath(Request.ApplicationPath)+"\\"+"test.png",FILE_FORMAT.PNG); | |
| 196: | BarcodeNETImage1.SaveToFile(Server.MapPath(Request.ApplicationPath)+"\\"+"test2.gif"); | |
| 197: | lblErrMsg.Text="Success save to current directory"; | |
| 198: | } | |
| 199: | catch | |
| 200: | { | |
| 201: | lblErrMsg.Text="Error saving files"; | |
| 202: | } | |
| 203: | } | |
| 204: | ||
| 205: | ||
| 206: | ||
| 207: | ||
| 208: | } | |
| 209: | } |
This page was automatically generated by SharpDevelop.