1:   Imports System
2:   Imports System.Collections
3:   Imports System.ComponentModel
4:   Imports System.Data
5:   Imports System.Drawing
6:   Imports System.Web
7:   Imports System.Web.SessionState
8:   Imports System.Web.UI
9:   Imports System.Web.UI.WebControls
10:   Imports System.Web.UI.HtmlControls
11:   Imports BarcodeNETWorkShop.Core
12:   Public Class ImageDynamicDemo
13:       Inherits System.Web.UI.Page
14:  
15:   #Region " Web Form Designer Generated Code "
16:  
17:       'This call is required by the Web Form Designer.
18:       <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
19:  
20:       End Sub
21:       Protected WithEvents TextGapDown As System.Web.UI.WebControls.DropDownList
22:       Protected WithEvents TextGapTop As System.Web.UI.WebControls.DropDownList
23:       Protected WithEvents TextGapRight As System.Web.UI.WebControls.DropDownList
24:       Protected WithEvents TextGapLeft As System.Web.UI.WebControls.DropDownList
25:       Protected WithEvents MarginBoundDown As System.Web.UI.WebControls.DropDownList
26:       Protected WithEvents MarginBoundTop As System.Web.UI.WebControls.DropDownList
27:       Protected WithEvents MarginBoundRight As System.Web.UI.WebControls.DropDownList
28:       Protected WithEvents MarginBoundLeft As System.Web.UI.WebControls.DropDownList
29:       Protected WithEvents BarWidth As System.Web.UI.WebControls.TextBox
30:       Protected WithEvents BarHieght As System.Web.UI.WebControls.TextBox
31:       Protected WithEvents SupplementalText As System.Web.UI.WebControls.TextBox
32:       Protected WithEvents CustomText As System.Web.UI.WebControls.TextBox
33:       Protected WithEvents TopText As System.Web.UI.WebControls.TextBox
34:       Protected WithEvents BarcodeText As System.Web.UI.WebControls.TextBox
35:       Protected WithEvents IsRounded As System.Web.UI.WebControls.CheckBox
36:       Protected WithEvents AntiAlias As System.Web.UI.WebControls.CheckBox
37:       Protected WithEvents IncludeCheckSumDigit As System.Web.UI.WebControls.CheckBox
38:       Protected WithEvents ShowBorder As System.Web.UI.WebControls.CheckBox
39:       Protected WithEvents SilentMode As System.Web.UI.WebControls.CheckBox
40:       Protected WithEvents ShowBarcodeText As System.Web.UI.WebControls.CheckBox
41:       Protected WithEvents SupplementalTexStyle As System.Web.UI.WebControls.DropDownList
42:       Protected WithEvents ExceptionType As System.Web.UI.WebControls.DropDownList
43:       Protected WithEvents TextFontSize As System.Web.UI.WebControls.DropDownList
44:       Protected WithEvents TextFontName As System.Web.UI.WebControls.DropDownList
45:       Protected WithEvents RotateAngle As System.Web.UI.WebControls.DropDownList
46:       Protected WithEvents FileFormat As System.Web.UI.WebControls.DropDownList
47:       Protected WithEvents TextColor As System.Web.UI.WebControls.DropDownList
48:       Protected WithEvents BgColor As System.Web.UI.WebControls.DropDownList
49:       Protected WithEvents BarcodeColor As System.Web.UI.WebControls.DropDownList
50:       Protected WithEvents BarcodeType As System.Web.UI.WebControls.DropDownList
51:       Protected WithEvents lblErrMsg As System.Web.UI.WebControls.Label
52:       Protected WithEvents BarcodeNETImage1 As BarcodeNETWorkShop.BarcodeNETImage
53:       Protected WithEvents btnSubmit As System.Web.UI.WebControls.Button
54:       Protected WithEvents btnSave As System.Web.UI.WebControls.Button
55:  
56:       'NOTE: The following placeholder declaration is required by the Web Form Designer.
57:       'Do not delete or move it.
58:       Private designerPlaceholderDeclaration As System.Object
59:  
60:       Private Sub Page_Init(ByVal sender As System.ObjectByVal As System.EventArgs) Handles MyBase.Init
61:           'CODEGEN: This method call is required by the Web Form Designer
62:           'Do not modify it using the code editor.
63:           InitializeComponent()
64:       End Sub
65:  
66:   #End Region
67:  
68:       Private Sub Page_Load(ByVal sender As System.ObjectByVal As System.EventArgs) Handles MyBase.Load
69:           'Put user code to initialize the page here
70:           If Not Me.IsPostBack Then
71:               Dim SupplementalTextStyleList() As String = [Enum].GetNames(GetType(SUPPLEMENTAL_TEXT_STYLE))
72:               SupplementalTexStyle.DataSource = SupplementalTextStyleList
73:               SupplementalTexStyle.DataBind()
74:  
75:               Dim BarcodeTypeList() As String = [Enum].GetNames(GetType(BARCODE_TYPE))
76:               BarcodeType.DataSource = BarcodeTypeList
77:               BarcodeType.DataBind()
78:               BarcodeType_SelectedIndexChanged(BarcodeType, Nothing)
79:  
80:               Dim ColorList() As String = [Enum].GetNames(GetType(KnownColor))
81:               BarcodeColor.DataSource = ColorList
82:               BarcodeColor.DataBind()
83:               BarcodeColor.Items.FindByText("Black").Selected = True
84:  
85:  
86:               TextColor.DataSource = ColorList
87:               TextColor.DataBind()
88:               TextColor.Items.FindByText("Black").Selected = True
89:  
90:               BgColor.DataSource = ColorList
91:               BgColor.DataBind()
92:               BgColor.Items.FindByText("White").Selected = True
93:  
94:               Dim ExceptionTypeList() As String = [Enum].GetNames(GetType(EXCEPTION_TYPE))
95:               ExceptionType.DataSource = ExceptionTypeList
96:               ExceptionType.DataBind()
97:  
98:               Dim FileFormatList() As String = [Enum].GetNames(GetType(FILE_FORMAT))
99:               FileFormat.DataSource = FileFormatList
100:               FileFormat.DataBind()
101:               FileFormat.Items.FindByText("PNG").Selected = True
102:  
103:               Dim RotateAngleList() As String = [Enum].GetNames(GetType(ROTATE_ANGLE))
104:               RotateAngle.DataSource = RotateAngleList
105:               RotateAngle.DataBind()
106:  
107:               Dim ff As FontFamily
108:               For Each ff In System.Drawing.FontFamily.Families
109:                   TextFontName.Items.Add(ff.GetName(0))
110:               Next
111:  
112:               SetValue()
113:           Else
114:               SetValue()
115:           End If
116:       End Sub
117:       Private Sub SetValue()
118:           Try
119:               BarcodeNETImage1.BarcodeType = CType(TypeDescriptor.GetConverter(GetType(BARCODE_TYPE)).ConvertFromString(BarcodeType.SelectedItem.ToString()), BARCODE_TYPE)
120:               BarcodeNETImage1.ShowBarcodeText = Me.ShowBarcodeText.Checked
121:               BarcodeNETImage1.SilentMode = Me.SilentMode.Checked
122:               BarcodeNETImage1.IncludeChecksumDigit = Me.IncludeCheckSumDigit.Checked
123:               BarcodeNETImage1.ShowBorder = Me.ShowBorder.Checked
124:               BarcodeNETImage1.BarcodeText = Me.BarcodeText.Text
125:               BarcodeNETImage1.TopText = Me.TopText.Text
126:               BarcodeNETImage1.CustomText = Me.CustomText.Text
127:               BarcodeNETImage1.BarHeight = Convert.ToInt32(Me.BarHieght.Text)
128:               BarcodeNETImage1.BarcodeColor = Color.FromName(Me.BarcodeColor.SelectedValue.ToString())
129:               BarcodeNETImage1.BgColor = Color.FromName(Me.BgColor.SelectedValue.ToString())
130:               BarcodeNETImage1.TextColor = Color.FromName(Me.TextColor.SelectedValue.ToString())
131:               BarcodeNETImage1.ExceptionType = CType(TypeDescriptor.GetConverter(GetType(EXCEPTION_TYPE)).ConvertFromString(ExceptionType.SelectedItem.ToString()), EXCEPTION_TYPE)
132:               BarcodeNETImage1.FileFormat = CType(TypeDescriptor.GetConverter(GetType(FILE_FORMAT)).ConvertFromString(FileFormat.SelectedItem.ToString()), FILE_FORMAT)
133:               BarcodeNETImage1.RotateAngle = CType(TypeDescriptor.GetConverter(GetType(ROTATE_ANGLE)).ConvertFromString(RotateAngle.SelectedItem.ToString()), ROTATE_ANGLE)
134:               BarcodeNETImage1.TextFont = New Font(TextFontName.SelectedItem.TextCType(Convert.ToDecimal(TextFontSize.SelectedItem.Text), Single))
135:               BarcodeNETImage1.BarWidth = Convert.ToInt32(BarWidth.Text)
136:               BarcodeNETImage1.SupplementalText = Me.SupplementalText.Text
137:               BarcodeNETImage1.SupplementalTextStyle = CType(TypeDescriptor.GetConverter(GetType(SUPPLEMENTAL_TEXT_STYLE)).ConvertFromString(SupplementalTexStyle.SelectedItem.ToString()), SUPPLEMENTAL_TEXT_STYLE)
138:               BarcodeNETImage1.AntiAlias = Me.AntiAlias.Checked
139:               BarcodeNETImage1.IsRounded = Me.IsRounded.Checked
140:               BarcodeNETImage1.BarcodeMargins.Top = Convert.ToInt32(Me.MarginBoundTop.SelectedValue)
141:               BarcodeNETImage1.BarcodeMargins.Bottom = Convert.ToInt32(Me.MarginBoundDown.SelectedValue)
142:               BarcodeNETImage1.BarcodeMargins.Left = Convert.ToInt32(Me.MarginBoundLeft.SelectedValue)
143:               BarcodeNETImage1.BarcodeMargins.Right = Convert.ToInt32(Me.MarginBoundRight.SelectedValue)
144:               BarcodeNETImage1.BarcodeGap.Top = Convert.ToInt32(Me.TextGapTop.SelectedValue)
145:               BarcodeNETImage1.BarcodeGap.Bottom = Convert.ToInt32(Me.TextGapDown.SelectedValue)
146:               BarcodeNETImage1.BarcodeGap.Left = Convert.ToInt32(Me.TextGapLeft.SelectedValue)
147:               BarcodeNETImage1.BarcodeGap.Right = Convert.ToInt32(Me.TextGapRight.SelectedValue)
148:           Catch
149:           End Try
150:       End Sub
151:       Private Sub btnSubmit_Click(ByVal sender As System.ObjectByVal As System.EventArgs) Handles btnSubmit.Click
152:           SetValue()
153:       End Sub
154:  
155:       Private Sub btnSave_Click(ByVal sender As System.ObjectByVal As System.EventArgs) Handles btnSave.Click
156:           Try
157:               SetValue()
158:  
159:               BarcodeNETImage1.SaveToFile(Server.MapPath(Request.ApplicationPath) + "\\" "test.bmp", FILE_FORMAT.BMP)
160:               BarcodeNETImage1.SaveToFile(Server.MapPath(Request.ApplicationPath) + "\\" "test.jpg", FILE_FORMAT.JPG)
161:               BarcodeNETImage1.SaveToFile(Server.MapPath(Request.ApplicationPath) + "\\" "test.png", FILE_FORMAT.PNG)
162:               BarcodeNETImage1.SaveToFile(Server.MapPath(Request.ApplicationPath) + "\\" "test2.gif")
163:               lblErrMsg.Text "Success save to current directory"
164:           Catch
165:               lblErrMsg.Text "Error saving files"
166:           End Try
167:       End Sub
168:       Private Sub BarcodeType_SelectedIndexChanged(ByVal sender As System.ObjectByVal As System.EventArgs) Handles BarcodeType.SelectedIndexChanged
169:           Dim SelectedBarcodeType As BARCODE_TYPE = CType(TypeDescriptor.GetConverter(GetType(BARCODE_TYPE)).ConvertFromString((CType(sender, DropDownList)).SelectedItem.ToString()), BARCODE_TYPE)
170:           Me.BarcodeText.Text = BarcodeNETImage1.GetDefaultBarcodeText(SelectedBarcodeType)
171:           SupplementalText.Text = BarcodeNETImage1.GetDefaultSupplementalText(SelectedBarcodeType)
172:           BarcodeNETImage1.SupplementalText = SupplementalText.Text
173:           SetValue()
174:       End Sub
175:   End Class

This page was automatically generated by SharpDevelop.