'// A simple code generation "device"
'// When the relatively large database is operated, there is a lot of variables, attributes, and similar reproducibility of repeatability of the field.
'// If one is overwritten, it is indeed irritating, so I have made a small program for this part.
Public Class frMpropertycode
Inherits System.Windows.Forms.form
#Region "Windows Form Designer Generated Code"
Public Sub New ()
Mybase.new ()
'This call is required for the Windows Form Designer.
InitializeComponent ()
'Add any initialization after INITIALIZECOMPONENT ()
Initialize ()
End Sub
'Form rewriting Dispose to clean up the list of components.
Protected Overloads Overrides Sub Dispose (Byval Disposing as Boolean)
IF Disposing then
IF not (Components Is Nothing) THEN
Components.dispose ()
END IF
END IF
Mybase.dispose (Disposing)
End Sub
'Windows Form Designer
Private Components as System.comPonentModel.icontainer
'Note: The following process is necessary for the Windows Form Designer.
'You can modify this process using the Windows Form Designer.
'Don't modify it using the code editor.
Friend Withevents VariabletextBox as system.windows.Forms.TextBox
Friend Withemoth CodeTextBox As System.Windows.Forms.TextBox
Friend Withevents PropertyCombox as system.windows.Forms.comBobox
Friend Withevents PropertyTextBox as system.windows.Forms.TextBox
Friend Withevents SavePropertyButton as System.Windows.Forms.Button
Friend Withevents BuildcodeButton as System.Windows.Forms.Button
Friend Withevents Label1 As System.Windows.Forms.Label
Friend Withevents Label2 As System.Windows.Forms.Label
Friend Withevents Label3 As System.Windows.Forms.label
Friend Withevents Label4 As System.Windows.Forms.Label
Dim Resources as system.resources.resourceManager = new system.resources.resourceManager (gettype (frmpropertycode))
Me.VariabletextBox = new system.windows.Forms.TextBox
Me.codetextbox = new system.windows.Forms.TextBox
Me.propertycomboBOX = new system.windows.Forms.comBoboxme.PropertyTextBox = new system.windows.Forms.TextBox
Me.SavePropertyButton = new system.windows.Forms.Button
Me.buildcodebutton = new system.windows.Forms.Button
Me.label1 = new system.windows.forms.label
Me.Label2 = new system.windows.forms.label
Me.label3 = new system.windows.Forms.Label
Me.label4 = new system.windows.forms.label
Me.suspendlayout ()
'
'VariableTextBox
'
Me.VariabletextBox.Anchor = ctype ((System.Windows.Forms.Anchorstyles.top or system.windows.forms.Anchorstyles.bottom) _
Or System.Windows.Forms.Anchorstyles.left, System.Windows.Forms.Anchorstyles
Me.VariabletextBox.Location = new system.drawing.point (8, 48)
Me.variabletextBox.Multiline = true
Me.VariabletextBox.Name = "VariabletextBox"
Me.variabletextBox.Scrollbars = System.Windows.Forms.Scrollbars.both
Me.variabletextBox.size = new system.drawing.size (168, 176)
Me.VariableTextBox.tabindex = 0
Me.variabletextBox.text = ""
'
'CodeTextBox
'
Me.codetextBox.Anchor = ctype (((System.Windows.Forms.Anchorstyles.top or system.windows.forms.Anchorstyles.bottom) _
OR system.windows.forms.Anchorstyles.left)
Or System.Windows.Forms.Anchorstyles.right, System.Windows.Forms.Anchorstyles
Me.codetextBox.BackColor = system.drawing.systemcolors.info
Me.codetextBox.location = new system.drawing.point (192, 48)
Me.codetextbox.multiline = true
Me.codetextBox.Name = "CodeTextBox"
Me.codetextbox.scrollbars = system.windows.Forms.Scrollbars.both
Me.codetextBox.size = new system.drawing.size (344, 176)
Me.codetextBox.tabindex = 1
Me.codetextBox.text = "" "
'PropertyComboBox
'
Me.PropertycomboBox.Anchor = ctype ((System.Windows.Forms.Anchorstyles.Bottom or System.Windows.Forms.Anchorstyles.left), System.Windows.Forms.Anchorstyles)
Me.PropertycomboBox.BackColor = system.drawing.systemcolors.info
Me.propertycomboBox.location = new system.drawing.point (88, 240)
Me.propertycomboBOX.NAME = "PropertyComboBox"
Me.PropertycomboBox.size = new system.drawing.size (224, 20)
Me.PropertycomboBox.tabindex = 2
'
'PropertyTextBox
'
Me.propertyTextBox.Anchor = ctype ((System.Windows.Forms.Anchorstyles.Bottom or System.Windows.Forms.Anchorstyles.left) _
Or System.Windows.Forms.Anchorstyles.right, System.Windows.Forms.Anchorstyles
Me.PropertyTextBox.BackColor = system.drawing.systemcolors.info
Me.PropertyTextBox.location = new system.drawing.point (8, 296)
Me.propertyTextBox.Multiline = TRUE
Me.PropertyTextBox.name = "PropertyTextBox"
Me.propertyTextBox.Scrollbars = System.Windows.Forms.Scrollbars.both
Me.PropertyTextBox.size = new system.drawing.size (536, 112)
Me.PropertyTextBox.TabINDEX = 3
Me.PropertyTextBox.Text = ""
'
'SavePropertyButton
'
Me.SavePropertyButton.Anchor = ctype ((System.Windows.Forms.Anchorstyles.Bottom or System.Windows.Forms.Anchorstyles.left), System.Windows.Forms.Anchorstyles)
Me.SavePropertyButton.FlatStyle = system.windows.forms.Flatstyle.FLLAT
Me.SavePropertyButton.Location = New System.drawing.Point (320, 240)
Me.SavePropertyButton.name = "SavePropertyButton"
Me.SavePropertyButton.size = new system.drawing.size (104, 32)
Me.SavePropertyButton.taBindex = 4Me.savePropertyButton.text = "Save Style"
'
'BuildCodeButton
'
Me.buildcodebutton.Anchor = ctype ((System.Windows.Forms.Anchorstyles.Bottom or System.Windows.Forms.Anchorstyles.right), System.Windows.Forms.Anchorseles
Me.buildcodebutton.flatstyle = system.windows.Forms.Flatstyle.FLAT
Me.buildcodebutton.location = new system.drawing.point (432, 240)
Me.buildcodebutton.name = "buildcodebutton"
Me.buildcodebutton.size = new system.drawing.size (104, 32)
Me.buildcodebutton.tabindex = 5
Me.buildcodebutton.text = "Generate Code"
'
'Label1
'
Me.label1.anchor = ctype ((System.Windows.Forms.Anchorstyles.Bottom or System.Windows.Forms.Anchorstyles.Left), System.Windows.Forms.Anchorstyles
Me.label1.location = new system.drawing.point (8, 240)
Me.Label1.name = "label1"
Me.label1.size = new system.drawing.size (80, 23)
Me.label1.tabindex = 6
Me.Label1.Text = "style selection:"
'
'Label2
'
Me.label2.location = new system.drawing.point (8, 16)
Me.Label2.name = "label2"
Me.label2.size = new system.drawing.size (88, 23)
Me.label2.tabindex = 7
Me.Label2.text = "Variable box:"
'
'Label3
'
Me.label3.Location = new system.drawing.point (192, 16)
Me.label3.name = "label3"
Me.label3.size = new system.drawing.size (96, 23)
Me.Label3.tabindex = 8
Me.Label3.Text = "code box:"
'
'Label4
'
Me.Label4.anchor = ctype ((System.Windows.Forms.Anchorstyles.Bottom or System.Windows.Forms.Anchorstyles.left), System.Windows.Forms.Anchorstyles
Me.label4.location = new system.drawing.point (8, 272)
Me.label4.name = "label4"
Me.label4.size = new system.drawing.size (96, 17)
Me.label4.tabindex = 9
Me.Label4.Text = "Style box:"
'
'FrMpropertycode
'
Me.autoscalebasesize = new system.drawing.size (6, 14)
Me.ClientSize = new system.drawing.size (552, 421)
Me.Controls.add (me.label4)
Me.Controls.add (me.label3)
Me.Controls.add (me.label2)
Me.Controls.add (me.label1)
Me.Controls.add (me.buildcodebutton)
Me.Controls.add (me.savepropertybutton)
Me.Controls.add (me.propertytextbox)
Me.Controls.add (me.codetextbox)
Me.Controls.add (me.variabletextbox)
Me.Controls.add (me.propertycomboBOX)
Me.icon = ctype (Resources.GetObject ("$ this.icon"), System.drawing.icon)
Me.Name = "frmpropertycode"
Me.Text = "Property Code Builder"
Me.ResumeLayout (false)
End Sub
#End region
'// The following is added to the code
Private ds as new dataset
'// The following two variables store the current record value, use to determine the relevant operation in the SavePropertyButton function
Private currentname as string = ""
Private CurrentText As String = ""
Private Withevents Manager As CurrencyManager
Private subinitialize ()
Application.doevents ()
'// read the XML architecture file
DS.Readxmlschema ("Property.xsd")
'// read the XML data file
DS.ReadXML ("Property.xml")
Me.PropertycomboBox.DataSource = ds.tables (0)
Me.propertycomboBox.displaymember = "name"
Me.PropertyTextBox.Databindings.add (New Binding ("Text", DS.Tables (0), "Text"))
Manager = ctype (me.bindingcontext (ds.tables (0)), CurrencyManager
End Sub
Private sub savepropertyButton_Click (Byval e as system.EventArgs) Handles SavePropertyButton.click
'// Remove the name
If Not Me.PropertyComboBox.Text.Equals (CurrentName) AndAlso Me.PropertyTextBox.Text.Equals (CurrentText) ThenCType (Manager.Current, DataRowView) .Row ( "Name") = Me.PropertyComboBox.Text
END IF
'// change content
If me.propertycomboBox.text.equals (currentname) Andalso Not Me.PropertyTextBox.Text.Equals (CurrentText) THEN
Ctype (Manager.current, DataRowView ).Row ("text") = me.propertytextBox.text
END IF
'// new
If not me.propertycombox.text.equals (currentname) Andalso Not Me.PropertyTextBox.Text.Equals (CurrentText) THEN
Ctype (Manager.current, DataRowView ).Row ("text") = currenttext
DIM ROW AS DATAROW = DS.TABLES (0) .newrow
Row ("name") = me.propertycomboBOX.Text
Row ("text") = me.propertytextbox.text
DS.TABLES (0) .Rows.Add (Row)
END IF
DS.TABLES (0) .acceptchanges ()
'//save data
DS.WRITEXML ("Property.xml")
Manager.refresh ()
Manager.position = ds.tables (0) .rows.count - 1
End Sub
Private sub position_changed (byval e AS Object, Byval E as Eventargs) Handles Manager.PositionChanged
CurrentName = me.propertycomboBox.text
CurrentText = Me.PropertyTextBox.text
End Sub
Private Sub BuildcodeButton_Click (Byval E AS System.Object, Byval E As System.EventArgs) Handles BuildcodeButton.click
Me.codetextBox.clear ()
DIM line As string
For each line in me.variabletextBox.Lines
Me.codetextBox.AppendText (String.Format (me.propertytextbox.text, line.split ("," c)))
Me.codeTextBox.AppendText (ControlChars.crlf)
NEXT
End Sub
END CLASS
'// The following is the architecture file Property.xsd content
XML Version = "1.0" encoding = "UTF-8"?>
xs: sequence>
xs: complexType>
xs: key>
xs: element>
xs: sequence>
xs: complexType>
xs: schema>
'// The following is the data file Property.xml content
XML Version = "1.0" encoding = "UTF-8"?>
Property>
Property>
Get
Return_ {0}
END GET
End Property text>
Property>
PropertyCollection>