Hallo zusammen,
für ein CAD-Programm habe ich in einem VB.net Derivat (iLogic) einen Produktkonfigurator erstellt. Die Eingabemaske möchte ich nun zusätzlich in VB.net mittels WinForm umsetzen. Ziel ist es, dass andere Abteilungen Zugriff auf die Produktlogik erhalten, direkt sehen können welche Kombinationen möglich sind und im Idealfall eine Parameterausgabe zur Weitergabe erhalten welche ich gerne im CAD einlesen würde.
Momentan geht es mir erstmal um die reine Umsetzung der Eingabemaske mit abhängigen Auswahloptionen, welche bedingt durch die Auswahl anderer Option zur Verfügung stehen sollen.
Eine erste Machbarkeitsversion habe ich mir zurechtgewurschtelt und wollte nun, bevor ich die komplexeren Zusammenhänge einbringe, fragen ob sich jemand erbarmt über mein Machwerk einmal drüber zu schauen. Ich kann mir vorstellen dass dort einiges an Verbesserungspotential schlummert oder es komplett falsch aufgezogen ist. Vor allem da dies ein einfacherer Konfigurator ist und einer mit wesentlich mehr Abhängigkeiten umgesetzt werden soll.
Einmal der Code und einmal das vollständige Abhängikeitsmodell.
Spoiler anzeigen
Jetzt schon einmal vielen Dank für eure Mühen
Grüße
3D_CAD
für ein CAD-Programm habe ich in einem VB.net Derivat (iLogic) einen Produktkonfigurator erstellt. Die Eingabemaske möchte ich nun zusätzlich in VB.net mittels WinForm umsetzen. Ziel ist es, dass andere Abteilungen Zugriff auf die Produktlogik erhalten, direkt sehen können welche Kombinationen möglich sind und im Idealfall eine Parameterausgabe zur Weitergabe erhalten welche ich gerne im CAD einlesen würde.
Momentan geht es mir erstmal um die reine Umsetzung der Eingabemaske mit abhängigen Auswahloptionen, welche bedingt durch die Auswahl anderer Option zur Verfügung stehen sollen.
Eine erste Machbarkeitsversion habe ich mir zurechtgewurschtelt und wollte nun, bevor ich die komplexeren Zusammenhänge einbringe, fragen ob sich jemand erbarmt über mein Machwerk einmal drüber zu schauen. Ich kann mir vorstellen dass dort einiges an Verbesserungspotential schlummert oder es komplett falsch aufgezogen ist. Vor allem da dies ein einfacherer Konfigurator ist und einer mit wesentlich mehr Abhängigkeiten umgesetzt werden soll.
Einmal der Code und einmal das vollständige Abhängikeitsmodell.
VB.NET-Quellcode
- Option Strict On
- Option Explicit On
- Imports Microsoft.VisualBasic.ControlChars
- Public Class Form1
- Private Sub Konfigurator_Load(sender As Object, e As EventArgs) Handles MyBase.Load
- Call InitializeForm()
- End Sub
- #Region "Deklaration"
- Dim _Breite As String
- Dim _Version As String
- Dim _Anzahl As String
- Dim _Tiefe As String
- Private Const x01RadioButtons As Integer = 10
- Private Const y01RadioButtons As Integer = 20
- Private Const dyRadioButtons As Integer = 20
- Private rtb_Ausgabe As RichTextBox
- Private grb_Breite As GroupBox
- Private rb_Breite01 As RadioButton
- Private rb_Breite02 As RadioButton
- Private rb_Breite03 As RadioButton
- Private rb_Breite04 As RadioButton
- Private grb_Version As GroupBox
- Private rb_Version01 As RadioButton
- Private rb_Version02 As RadioButton
- Private grb_Tiefe As GroupBox
- Private rb_Tiefe01 As RadioButton
- Private rb_Tiefe02 As RadioButton
- Private rb_Tiefe03 As RadioButton
- Private rb_Tiefe04 As RadioButton
- Private rb_Tiefe05 As RadioButton
- Private rb_Tiefe06 As RadioButton
- Private grb_Anzahl As GroupBox
- Private rb_Anzahl06 As RadioButton
- Private rb_Anzahl07 As RadioButton
- Private rb_Anzahl08 As RadioButton
- Private rb_Anzahl09 As RadioButton
- Private rb_Anzahl10 As RadioButton
- Private rb_Anzahl11 As RadioButton
- Private rb_Anzahl12 As RadioButton
- #End Region
- Private Sub InitializeForm()
- grb_Breite = New System.Windows.Forms.GroupBox()
- rb_Breite01 = New System.Windows.Forms.RadioButton()
- rb_Breite02 = New System.Windows.Forms.RadioButton()
- rb_Breite03 = New System.Windows.Forms.RadioButton()
- rb_Breite04 = New System.Windows.Forms.RadioButton()
- grb_Version = New System.Windows.Forms.GroupBox()
- rb_Version01 = New System.Windows.Forms.RadioButton()
- rb_Version02 = New System.Windows.Forms.RadioButton()
- grb_Tiefe = New System.Windows.Forms.GroupBox()
- rtb_Ausgabe = New System.Windows.Forms.RichTextBox()
- Call FixeElemente()
- Call FixeAuswahl()
- Call VariableAuswahl()
- Call KonfiguratorForm()
- End Sub
- Private Sub FixeElemente()
- With rtb_Ausgabe
- .Location = New System.Drawing.Point(140, 17)
- .Name = "rtb_Ausgabe"
- .Size = New System.Drawing.Size(150, 200)
- .TabIndex = 7
- .Text = "Zusammenfassung"
- .ReadOnly = True
- End With
- End Sub
- Private Sub VariableAuswahl()
- Call AnzahlOptionen()
- Call TiefenOptionen()
- End Sub
- Private Sub FixeAuswahl()
- Call BreitenOptionen()
- Call VersionsOptionen()
- End Sub
- Private Sub BreitenOptionen()
- Dim IndexRadioButtons As Integer
- Dim y As Integer
- With grb_Breite
- .Location = New System.Drawing.Point(10, 10)
- .Size = New System.Drawing.Size(100, 105)
- .Text = "Breite"
- .Controls.Add(rb_Breite01)
- .Controls.Add(rb_Breite02)
- .Controls.Add(rb_Breite03)
- .Controls.Add(rb_Breite04)
- End With
- y = y01RadioButtons + IndexRadioButtons * dyRadioButtons
- With rb_Breite01
- .Location = New System.Drawing.Point(x01RadioButtons, y)
- .Name = "rb_Breite01"
- .Size = New System.Drawing.Size(67, 17)
- .Text = "Breite 01"
- AddHandler .CheckedChanged, AddressOf BreiteChanged
- End With
- IndexRadioButtons += 1
- y = y01RadioButtons + IndexRadioButtons * dyRadioButtons
- With rb_Breite02
- .Location = New System.Drawing.Point(x01RadioButtons, y)
- .Name = "rb_Breite02"
- .Size = New System.Drawing.Size(67, 17)
- .Text = "Breite 02"
- AddHandler .CheckedChanged, AddressOf BreiteChanged
- End With
- IndexRadioButtons += 1
- y = y01RadioButtons + IndexRadioButtons * dyRadioButtons
- With rb_Breite03
- .Location = New System.Drawing.Point(x01RadioButtons, y)
- .Name = "rb_Breite03"
- .Size = New System.Drawing.Size(67, 17)
- .Text = "Breite 03"
- AddHandler .CheckedChanged, AddressOf BreiteChanged
- End With
- IndexRadioButtons += 1
- y = y01RadioButtons + IndexRadioButtons * dyRadioButtons
- With rb_Breite04
- .Location = New System.Drawing.Point(x01RadioButtons, y)
- .Name = "rb_Breite04"
- .Size = New System.Drawing.Size(67, 17)
- .Text = "Breite 04"
- AddHandler .CheckedChanged, AddressOf BreiteChanged
- End With
- End Sub
- Private Sub VersionsOptionen()
- Dim IndexRadioButtons As Integer
- Dim y As Integer
- With grb_Version
- .Location = New System.Drawing.Point(10, 120)
- .Size = New System.Drawing.Size(100, 65)
- .Text = "Version"
- .Controls.Add(rb_Version01)
- .Controls.Add(rb_Version02)
- End With
- y = y01RadioButtons + IndexRadioButtons * dyRadioButtons
- With rb_Version01
- .Location = New System.Drawing.Point(x01RadioButtons, y)
- .Name = "rb_Version01"
- .Size = New System.Drawing.Size(75, 17)
- .Text = "Standard"
- AddHandler .Click, AddressOf VersionChanged
- End With
- IndexRadioButtons += 1
- y = y01RadioButtons + IndexRadioButtons * dyRadioButtons
- With rb_Version02
- .Location = New System.Drawing.Point(x01RadioButtons, y)
- .Name = "rb_Version02"
- .Size = New System.Drawing.Size(75, 17)
- .Text = "Hoch"
- AddHandler .Click, AddressOf VersionChanged
- End With
- End Sub
- Private Sub TiefenOptionen()
- Dim IndexRadioButtons, y As Integer
- rb_Tiefe01 = New System.Windows.Forms.RadioButton()
- rb_Tiefe02 = New System.Windows.Forms.RadioButton()
- rb_Tiefe03 = New System.Windows.Forms.RadioButton()
- rb_Tiefe04 = New System.Windows.Forms.RadioButton()
- rb_Tiefe05 = New System.Windows.Forms.RadioButton()
- rb_Tiefe06 = New System.Windows.Forms.RadioButton()
- y = y01RadioButtons + IndexRadioButtons * dyRadioButtons
- With rb_Tiefe01
- .Location = New System.Drawing.Point(x01RadioButtons, y)
- .Name = "rb_Tiefe01"
- .Size = New System.Drawing.Size(67, 17)
- .Text = "Tiefe 01"
- AddHandler .CheckedChanged, AddressOf TiefeChanged
- End With
- With rb_Tiefe03
- .Location = New System.Drawing.Point(x01RadioButtons, y)
- .Name = "rb_Tiefe03"
- .Size = New System.Drawing.Size(67, 17)
- .Text = "Tiefe 03"
- AddHandler .CheckedChanged, AddressOf TiefeChanged
- End With
- With rb_Tiefe05
- .Location = New System.Drawing.Point(x01RadioButtons, y)
- .Name = "rb_Tiefe05"
- .Size = New System.Drawing.Size(67, 17)
- .Text = "Tiefe 05"
- AddHandler .CheckedChanged, AddressOf TiefeChanged
- End With
- IndexRadioButtons += 1
- y = y01RadioButtons + IndexRadioButtons * dyRadioButtons
- With rb_Tiefe02
- .Location = New System.Drawing.Point(x01RadioButtons, y)
- .Name = "rb_Tiefe02"
- .Size = New System.Drawing.Size(67, 17)
- .Text = "Tiefe 02"
- AddHandler .CheckedChanged, AddressOf TiefeChanged
- End With
- With rb_Tiefe04
- .Location = New System.Drawing.Point(x01RadioButtons, y)
- .Name = "rb_Tiefe04"
- .Size = New System.Drawing.Size(67, 17)
- .Text = "Tiefe 04"
- AddHandler .CheckedChanged, AddressOf TiefeChanged
- End With
- With rb_Tiefe06
- .Location = New System.Drawing.Point(x01RadioButtons, y)
- .Name = "rb_Tiefe06"
- .Size = New System.Drawing.Size(67, 17)
- .Text = "Tiefe 06"
- AddHandler rb_Tiefe06.CheckedChanged, AddressOf TiefeChanged
- End With
- Select Case _Breite
- Case "Breite 01"
- SetTiefenOptionen({rb_Tiefe01, rb_Tiefe02})
- If Not rb_Tiefe02.Checked Then rb_Tiefe01.Checked = True
- Case "Breite 02"
- SetTiefenOptionen({rb_Tiefe03, rb_Tiefe04})
- If Not rb_Tiefe04.Checked Then rb_Tiefe03.Checked = True
- Case "Breite 03"
- SetTiefenOptionen({rb_Tiefe01, rb_Tiefe02})
- If Not rb_Tiefe02.Checked Then rb_Tiefe01.Checked = True
- Case "Breite 04"
- SetTiefenOptionen({rb_Tiefe05, rb_Tiefe06})
- If Not rb_Tiefe06.Checked Then rb_Tiefe05.Checked = True
- Case Else
- SetTiefenOptionen({rb_Tiefe01, rb_Tiefe02})
- End Select
- Controls.Add(grb_Tiefe)
- End Sub
- Private Sub SetTiefenOptionen(BtnsToAdd() As RadioButton)
- grb_Tiefe.AutoSize = False
- grb_Tiefe.Controls.Clear()
- For i As Integer = 1 To BtnsToAdd.GetUpperBound(0) + 1
- grb_Tiefe.Controls.Add(BtnsToAdd(i - 1))
- Next
- With grb_Tiefe
- .Location = New System.Drawing.Point(10, 190)
- .Size = New System.Drawing.Size(100, 65)
- .Name = "grb_Tiefe"
- .Text = "Tiefe"
- End With
- End Sub
- Private Sub AnzahlOptionen()
- End Sub
- Private Sub KonfiguratorForm()
- ClientSize = New System.Drawing.Size(310, 410)
- Controls.Add(grb_Breite)
- Controls.Add(grb_Version)
- Controls.Add(grb_Tiefe)
- Controls.Add(rtb_Ausgabe)
- End Sub
- Private Sub BreiteChanged(ByVal sender As Object, ByVal e As EventArgs)
- If rb_Breite01.Checked Then
- _Breite = "Breite 01"
- ElseIf rb_Breite02.Checked Then
- _Breite = "Breite 02"
- ElseIf rb_Breite03.Checked Then
- _Breite = "Breite 03"
- ElseIf rb_Breite04.Checked Then
- _Breite = "Breite 04"
- End If
- Call TiefenOptionen()
- Call Ausgabe()
- End Sub
- Private Sub VersionChanged(ByVal sender As Object, ByVal e As EventArgs)
- If rb_Version01.Checked Then
- _Version = "Standard"
- ElseIf rb_Version02.Checked Then
- _Version = "Hoch"
- End If
- Call Ausgabe()
- End Sub
- Private Sub TiefeChanged(ByVal sender As Object, ByVal e As EventArgs)
- If rb_Tiefe01.Checked Then
- _Tiefe = "Tiefe 01"
- ElseIf rb_Tiefe02.Checked Then
- _Tiefe = "Tiefe 02"
- ElseIf rb_Tiefe03.Checked Then
- _Tiefe = "Tiefe 03"
- ElseIf rb_Tiefe04.Checked Then
- _Tiefe = "Tiefe 04"
- ElseIf rb_Tiefe05.Checked Then
- _Tiefe = "Tiefe 05"
- ElseIf rb_Tiefe06.Checked Then
- _Tiefe = "Tiefe 06"
- Else
- _Tiefe = " "
- End If
- Call Ausgabe()
- End Sub
- Private Sub Ausgabe()
- Const unitLength As String = " mm"
- Const unitArea As String = " m²"
- Const unitUnitless As String = " "
- Const unitLengthTc As String = "[mm]"
- Const unitAreaTc As String = "[m²]"
- Const unitUnitlessTc As String = "[-] "
- rtb_Ausgabe.Text = "Zusammenfassung" & Lf & Lf &
- "Breite:" & Tab & _Breite & unitLength & Lf &
- "Version:" & Tab & _Version & Lf &
- "Tiefe:" & Tab & _Tiefe & unitLength
- End Sub
- End Class
Jetzt schon einmal vielen Dank für eure Mühen
Grüße
3D_CAD