Namespace MicrosoftNamespace Microsoft.Samples ' Base class for the LineControls PublicMustInheritClass LineBaseClass LineBase Inherits Control Private ThicknessValue AsInteger Private IsAntiAliasValue AsBoolean Protected pen As pen PublicSub New()SubNew() InitializeComponent() SetStyle(ControlStyles.SupportsTransparentBackColor Or ControlStyles.ResizeRedraw, True) SetStyle(ControlStyles.Selectable, False) ThicknessValue =1 IsAntiAliasValue =True BackColor = Color.Transparent End Sub ProtectedOverloadsOverridesSub Dispose()Sub Dispose(ByVal disposing AsBoolean) If disposing AndNot (pen IsNothing) Then pen.Dispose() EndIf MyBase.Dispose(disposing) End Sub PublicProperty AntiAlias()Property AntiAlias() AsBoolean Get Return IsAntiAliasValue EndGet Set(ByVal Value AsBoolean) IsAntiAliasValue = Value Invalidate() EndSet End Property PublicProperty Thickness()Property Thickness() AsInteger Get Return ThicknessValue EndGet Set(ByVal Value AsInteger) ThicknessValue = Value Invalidate() EndSet End Property PrivateSub InitializeComponent()Sub InitializeComponent() Me.Name ="LineBase" End Sub ProtectedMustOverrideSub LineBase_Paint()Sub LineBase_Paint(ByVal sender AsObject, ByVal e As System.Windows.Forms.PaintEventArgs) HandlesMyBase.Paint ' End Class End Namespace
2、StraightLine
Imports System.Drawing.Drawing2D Namespace MicrosoftNamespace Microsoft.Samples ' StraightLine Control PublicClass StraightLineClass StraightLine Inherits LineBase Private myLineType As StraightLineTypes PublicSub New()SubNew() LineType = StraightLineTypes.Horizontal End Sub PublicProperty LineType()Property LineType() As StraightLineTypes Get Return myLineType EndGet Set(ByVal Value As StraightLineTypes) myLineType = Value Invalidate() EndSet End Property ProtectedOverloadsOverridesSub LineBase_Paint()Sub LineBase_Paint(ByVal sender AsObject, ByVal e As System.Windows.Forms.PaintEventArgs) Pen =New Pen(ForeColor, Thickness) If AntiAlias Then e.Graphics.SmoothingMode = SmoothingMode.AntiAlias EndIf SelectCase LineType Case StraightLineTypes.Horizontal DrawCenteredHorizontalLine(e.Graphics) Case StraightLineTypes.Vertical DrawCenteredVerticalLine(e.Graphics) Case StraightLineTypes.DiagonalAscending DrawCenteredDiagonalAscendingLine(e.Graphics) Case StraightLineTypes.DiagonalDescending DrawCenteredDiagonalDescendingLine(e.Graphics) CaseElse EndSelect End Sub PrivateSub DrawCenteredHorizontalLine()Sub DrawCenteredHorizontalLine(ByVal g As Graphics) Dim i AsInteger= Height /2 g.DrawLine(Pen, 0, i, Width, i) End Sub PrivateSub DrawCenteredVerticalLine()Sub DrawCenteredVerticalLine(ByVal g As Graphics) Dim i AsInteger= Width /2 g.DrawLine(Pen, i, 0, i, Height) End Sub PrivateSub DrawCenteredDiagonalAscendingLine()Sub DrawCenteredDiagonalAscendingLine(ByVal g As Graphics) g.DrawLine(Pen, 0, Height, Width, 0) End Sub PrivateSub DrawCenteredDiagonalDescendingLine()Sub DrawCenteredDiagonalDescendingLine(ByVal g As Graphics) g.DrawLine(Pen, 0, 0, Width, Height) End Sub End Class End Namespace
3、StraightLineTypeEditor
Imports System.Runtime.InteropServices Imports System.ComponentModel Imports System.ComponentModel.Design Imports System.Drawing.Design Imports System.Windows.Forms.Design Namespace MicrosoftNamespace Microsoft.Samples <Editor("LineControls.Microsoft.Samples.StraightLineTypeEditor", GetType(UITypeEditor))> _ PublicEnum StraightLineTypesEnum StraightLineTypes Horizontal Vertical DiagonalDescending DiagonalAscending End Enum ' Class used to provided the custom UITypeEditor PublicClass StraightLineTypeEditorClass StraightLineTypeEditor Inherits UITypeEditor Private lineTypeUI As StraightLineTypeUI PublicOverloadsOverridesFunction EditValue()Function EditValue(ByVal context As ITypeDescriptorContext, ByVal provider As IServiceProvider, ByVal value AsObject) AsObject Dim returnValue AsObject= value IfNot (provider IsNothing) Then Dim edSvc As IWindowsFormsEditorService =CType(provider.GetService(GetType(IWindowsFormsEditorService)), IWindowsFormsEditorService) IfNot (edSvc IsNothing) Then If lineTypeUI IsNothingThen lineTypeUI =New StraightLineTypeUI(Me) EndIf lineTypeUI.Start(edSvc, value) edSvc.DropDownControl(lineTypeUI) value = lineTypeUI.MyValue lineTypeUI.MyEnd() EndIf EndIf Return value End Function PublicOverloadsOverridesFunction GetEditStyle()Function GetEditStyle(ByVal context As ITypeDescriptorContext) As UITypeEditorEditStyle Return UITypeEditorEditStyle.DropDown End Function PrivateClass StraightLineTypeUIClass StraightLineTypeUI Inherits Control Private edSvc As IWindowsFormsEditorService Private editor As StraightLineTypeEditor =Nothing Private oldLineType As StraightLineTypes Private value AsObject PublicSub New()SubNew(ByVal editor As StraightLineTypeEditor) Me.editor = editor InitializeComponent() End Sub PublicReadOnlyProperty MyValue()Property MyValue() AsObject Get Return value EndGet End Property PublicSub MyEnd()Sub MyEnd() value =Nothing edSvc =Nothing End Sub PublicSub Start()Sub Start(ByVal edSvc As IWindowsFormsEditorService, ByVal value AsObject) Me.edSvc = edSvc Me.value = value Me.oldLineType =CType(value, StraightLineTypes) Dim panel As Panel Dim c As Control ForEach c In Controls panel = c IfNot (c IsNothing) Then c.BackColor = SystemColors.Control c.ForeColor = SystemColors.ControlText EndIf panel =Nothing Next c SelectCaseCType(value, StraightLineTypes) Case StraightLineTypes.Horizontal Me.horizontalPanel.BackColor = SystemColors.ControlText Me.horizontalPanel.ForeColor = SystemColors.Control Case StraightLineTypes.Vertical Me.verticalPanel.BackColor = SystemColors.ControlText Me.verticalPanel.ForeColor = SystemColors.Control Case StraightLineTypes.DiagonalAscending Me.diagonalAscendingPanel.BackColor = SystemColors.ControlText Me.diagonalAscendingPanel.ForeColor = SystemColors.Control Case StraightLineTypes.DiagonalDescending Me.diagonalDescendingPanel.BackColor = SystemColors.ControlText Me.diagonalDescendingPanel.ForeColor = SystemColors.Control CaseElse EndSelect End Sub PrivateSub Teardown()Sub Teardown(ByVal save AsBoolean) IfNot save Then value = oldLineType EndIf edSvc.CloseDropDown() End Sub FriendWithEvents horizontalPanel As System.Windows.Forms.Panel FriendWithEvents verticalPanel As System.Windows.Forms.Panel FriendWithEvents diagonalDescendingPanel As System.Windows.Forms.Panel FriendWithEvents diagonalAscendingPanel As System.Windows.Forms.Panel FriendWithEvents horizontalLine As Microsoft.Samples.StraightLine FriendWithEvents verticalLine As Microsoft.Samples.StraightLine FriendWithEvents diagonalDescendingLine As Microsoft.Samples.StraightLine FriendWithEvents diagonalAscendingLine As Microsoft.Samples.StraightLine FriendSub InitializeComponent()Sub InitializeComponent() Me.horizontalPanel =New System.Windows.Forms.Panel() Me.verticalPanel =New System.Windows.Forms.Panel() Me.diagonalDescendingPanel =New System.Windows.Forms.Panel() Me.diagonalAscendingPanel =New System.Windows.Forms.Panel() Me.horizontalLine =New Microsoft.Samples.StraightLine() Me.verticalLine =New Microsoft.Samples.StraightLine() Me.diagonalDescendingLine =New Microsoft.Samples.StraightLine() Me.diagonalAscendingLine =New Microsoft.Samples.StraightLine() Me.horizontalPanel.SuspendLayout() Me.verticalPanel.SuspendLayout() Me.diagonalDescendingPanel.SuspendLayout() Me.diagonalAscendingPanel.SuspendLayout() Me.SuspendLayout() ' ' horizontalPanel ' Me.horizontalPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle Me.horizontalPanel.Controls.AddRange(New System.Windows.Forms.Control() {Me.horizontalLine}) Me.horizontalPanel.Location =New System.Drawing.Point(2, 2) Me.horizontalPanel.Name ="horizontalPanel" Me.horizontalPanel.Size =New System.Drawing.Size(40, 40) Me.horizontalPanel.TabIndex =0 ' ' verticalPanel ' Me.verticalPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle Me.verticalPanel.Controls.AddRange(New System.Windows.Forms.Control() {Me.verticalLine}) Me.verticalPanel.Location =New System.Drawing.Point(44, 2) Me.verticalPanel.Name ="verticalPanel" Me.verticalPanel.Size =New System.Drawing.Size(40, 40) Me.verticalPanel.TabIndex =1 ' ' diagonalDescendingPanel ' Me.diagonalDescendingPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle Me.diagonalDescendingPanel.Controls.AddRange(New System.Windows.Forms.Control() {Me.diagonalDescendingLine}) Me.diagonalDescendingPanel.Location =New System.Drawing.Point(86, 2) Me.diagonalDescendingPanel.Name ="diagonalDescendingPanel" Me.diagonalDescendingPanel.Size =New System.Drawing.Size(40, 40) Me.diagonalDescendingPanel.TabIndex =2 ' ' diagonalAscendingPanel ' Me.diagonalAscendingPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle Me.diagonalAscendingPanel.Controls.AddRange(New System.Windows.Forms.Control() {Me.diagonalAscendingLine}) Me.diagonalAscendingPanel.Location =New System.Drawing.Point(128, 2) Me.diagonalAscendingPanel.Name ="diagonalAscendingPanel" Me.diagonalAscendingPanel.Size =New System.Drawing.Size(40, 40) Me.diagonalAscendingPanel.TabIndex =3 ' ' horizontalLine ' Me.horizontalLine.Dock = System.Windows.Forms.DockStyle.Fill Me.horizontalLine.LineType = Microsoft.Samples.StraightLineTypes.Horizontal Me.horizontalLine.Name ="horizontalLine" Me.horizontalLine.Size =New System.Drawing.Size(38, 38) Me.horizontalLine.TabIndex =0 Me.horizontalLine.Text ="straightLine1" ' ' verticalLine ' Me.verticalLine.Dock = System.Windows.Forms.DockStyle.Fill Me.verticalLine.LineType = Microsoft.Samples.StraightLineTypes.Vertical Me.verticalLine.Name ="verticalLine" Me.verticalLine.Size =New System.Drawing.Size(38, 38) Me.verticalLine.TabIndex =0 Me.verticalLine.Text ="straightLine2" ' ' diagonalDescendingLine ' Me.diagonalDescendingLine.Dock = System.Windows.Forms.DockStyle.Fill Me.diagonalDescendingLine.LineType = Microsoft.Samples.StraightLineTypes.DiagonalDescending Me.diagonalDescendingLine.Name ="diagonalDescendingLine" Me.diagonalDescendingLine.Size =New System.Drawing.Size(38, 38) Me.diagonalDescendingLine.TabIndex =0 Me.diagonalDescendingLine.Text ="straightLine3" ' ' diagonalAscendingLine ' Me.diagonalAscendingLine.Dock = System.Windows.Forms.DockStyle.Fill Me.diagonalAscendingLine.LineType = Microsoft.Samples.StraightLineTypes.DiagonalAscending Me.diagonalAscendingLine.Name ="diagonalAscendingLine" Me.diagonalAscendingLine.Size =New System.Drawing.Size(38, 38) Me.diagonalAscendingLine.TabIndex =0 Me.diagonalAscendingLine.Text ="straightLine4" ' ' UserControl1 ' Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.diagonalAscendingPanel, Me.diagonalDescendingPanel, Me.verticalPanel, Me.horizontalPanel}) Me.Name ="UserControl1" Me.Size =New System.Drawing.Size(164, 44) Me.BackColor = System.Drawing.SystemColors.InactiveBorder Me.horizontalPanel.ResumeLayout(False) Me.verticalPanel.ResumeLayout(False) Me.diagonalDescendingPanel.ResumeLayout(False) Me.diagonalAscendingPanel.ResumeLayout(False) Me.ResumeLayout(False) End Sub PrivateSub button_Click()Sub button_Click(ByVal sender AsObject, ByVal e As System.EventArgs) Handles horizontalLine.Click, verticalLine.Click, diagonalDescendingLine.Click, diagonalAscendingLine.Click ' Dim line As StraightLine = sender IfNot (line IsNothing) Then Me.value = line.LineType Teardown(True) EndIf End Sub End Class End Class End Namespace
4、CurvedLine
Imports System.Drawing.Drawing2D Namespace MicrosoftNamespace Microsoft.Samples ' CurvedLine Control PublicClass CurvedLineClass CurvedLine Inherits LineBase Private curveTypeTemp As CurvedLineTypes PublicSub New()SubNew() CurveType = CurvedLineTypes.LowerRightQuarterCircle End Sub PublicProperty CurveType()Property CurveType() As CurvedLineTypes Get Return curveTypeTemp EndGet Set(ByVal Value As CurvedLineTypes) curveTypeTemp = Value Invalidate() EndSet End Property ProtectedOverridesSub LineBase_Paint()Sub LineBase_Paint(ByVal sender AsObject, ByVal e As System.Windows.Forms.PaintEventArgs) Dim doubleWidth AsInteger= Width *2 Dim doubleHeight AsInteger= Height *2 Dim bounds AsNew Rectangle(0, 0, Width *2, Height *2) bounds.Inflate(-Thickness /2, -Thickness /2) Pen =New Pen(ForeColor, Thickness) If AntiAlias Then e.Graphics.SmoothingMode = SmoothingMode.AntiAlias EndIf SelectCase CurveType Case CurvedLineTypes.UpperLeftQuarterCircle e.Graphics.DrawArc(Pen, bounds, 180.0F, 90.0F) Case CurvedLineTypes.UpperRightQuarterCircle bounds.Offset(-Width, 0) e.Graphics.DrawArc(Pen, bounds, 270.0F, 90.0F) Case CurvedLineTypes.LowerLeftQuarterCircle bounds.Offset(0, -Height) e.Graphics.DrawArc(Pen, bounds, 90.0F, 90.0F) Case CurvedLineTypes.LowerRightQuarterCircle bounds.Offset(-Width, -Height) e.Graphics.DrawArc(Pen, bounds, 0, 90) CaseElse EndSelect End Sub End Class End Namespace
5、CurvedLineTypeEditor
Imports System.Runtime.InteropServices Imports System.ComponentModel Imports System.ComponentModel.Design Imports System.Drawing.Design Imports System.Windows.Forms.Design Namespace MicrosoftNamespace Microsoft.Samples <Editor("LineControls.Microsoft.Samples.CurvedLineTypeEditor", GetType(UITypeEditor))> _ PublicEnum CurvedLineTypesEnum CurvedLineTypes LowerLeftQuarterCircle LowerRightQuarterCircle UpperLeftQuarterCircle UpperRightQuarterCircle End Enum ' Class used to provided the custom UITypeEditor PublicClass CurvedLineTypeEditorClass CurvedLineTypeEditor Inherits UITypeEditor Private lineTypeUI As CurvedLineTypeUI PublicOverloadsOverridesFunction EditValue()Function EditValue(ByVal context As ITypeDescriptorContext, ByVal provider As IServiceProvider, ByVal value AsObject) AsObject Dim returnValue AsObject= value IfNot (provider IsNothing) Then Dim edSvc As IWindowsFormsEditorService =CType(provider.GetService(GetType(IWindowsFormsEditorService)), IWindowsFormsEditorService) IfNot (edSvc IsNothing) Then If lineTypeUI IsNothingThen lineTypeUI =New CurvedLineTypeUI(Me) EndIf lineTypeUI.Start(edSvc, value) edSvc.DropDownControl(lineTypeUI) value = lineTypeUI.MyValue lineTypeUI.MyEnd() EndIf EndIf Return value End Function PublicOverloadsOverridesFunction GetEditStyle()Function GetEditStyle(ByVal context As ITypeDescriptorContext) As UITypeEditorEditStyle Return UITypeEditorEditStyle.DropDown End Function PrivateClass CurvedLineTypeUIClass CurvedLineTypeUI Inherits Control Private edSvc As IWindowsFormsEditorService Private editor As CurvedLineTypeEditor =Nothing Private oldLineType As CurvedLineTypes Private value AsObject PublicSub New()SubNew(ByVal editor As CurvedLineTypeEditor) Me.editor = editor InitializeComponent() End Sub PublicReadOnlyProperty MyValue()Property MyValue() AsObject Get Return value EndGet End Property PublicSub MyEnd()Sub MyEnd() value =Nothing edSvc =Nothing End Sub PublicSub Start()Sub Start(ByVal edSvc As IWindowsFormsEditorService, ByVal value AsObject) Me.edSvc = edSvc Me.value = value Me.oldLineType =CType(value, CurvedLineTypes) Dim panel As Panel Dim c As Control ForEach c In Controls panel = c IfNot (c IsNothing) Then c.BackColor = SystemColors.Control c.ForeColor = SystemColors.ControlText EndIf panel =Nothing Next c SelectCaseCType(value, CurvedLineTypes) Case CurvedLineTypes.UpperLeftQuarterCircle Me.upperLeftPanel.BackColor = SystemColors.ControlText Me.upperLeftPanel.ForeColor = SystemColors.Control Case CurvedLineTypes.UpperRightQuarterCircle Me.upperRightPanel.BackColor = SystemColors.ControlText Me.upperRightPanel.ForeColor = SystemColors.Control Case CurvedLineTypes.LowerLeftQuarterCircle Me.lowerLeftPanel.BackColor = SystemColors.ControlText Me.lowerLeftPanel.ForeColor = SystemColors.Control Case CurvedLineTypes.LowerRightQuarterCircle Me.lowerRightPanel.BackColor = SystemColors.ControlText Me.lowerRightPanel.ForeColor = SystemColors.Control CaseElse EndSelect End Sub PrivateSub Teardown()Sub Teardown(ByVal save AsBoolean) IfNot save Then value = oldLineType EndIf edSvc.CloseDropDown() End Sub FriendWithEvents upperLeftPanel As System.Windows.Forms.Panel FriendWithEvents upperRightPanel As System.Windows.Forms.Panel FriendWithEvents lowerLeftPanel As System.Windows.Forms.Panel FriendWithEvents lowerRightPanel As System.Windows.Forms.Panel FriendWithEvents upperLeftLine As Microsoft.Samples.CurvedLine FriendWithEvents upperRightLine As Microsoft.Samples.CurvedLine FriendWithEvents lowerLeftLine As Microsoft.Samples.CurvedLine FriendWithEvents lowerRighttLine As Microsoft.Samples.CurvedLine FriendSub InitializeComponent()Sub InitializeComponent() Me.upperLeftPanel =New System.Windows.Forms.Panel() Me.upperRightPanel =New System.Windows.Forms.Panel() Me.lowerLeftPanel =New System.Windows.Forms.Panel() Me.lowerRightPanel =New System.Windows.Forms.Panel() Me.upperLeftLine =New Microsoft.Samples.CurvedLine() Me.upperRightLine =New Microsoft.Samples.CurvedLine() Me.lowerLeftLine =New Microsoft.Samples.CurvedLine() Me.lowerRighttLine =New Microsoft.Samples.CurvedLine() Me.upperLeftPanel.SuspendLayout() Me.upperRightPanel.SuspendLayout() Me.lowerLeftPanel.SuspendLayout() Me.lowerRightPanel.SuspendLayout() Me.SuspendLayout() ' ' upperLeftPanel ' Me.upperLeftPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle Me.upperLeftPanel.Controls.AddRange(New System.Windows.Forms.Control() {Me.upperLeftLine}) Me.upperLeftPanel.Location =New System.Drawing.Point(2, 2) Me.upperLeftPanel.Name ="upperLeftPanel" Me.upperLeftPanel.Size =New System.Drawing.Size(40, 40) Me.upperLeftPanel.TabIndex =0 ' ' upperRightPanel ' Me.upperRightPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle Me.upperRightPanel.Controls.AddRange(New System.Windows.Forms.Control() {Me.upperRightLine}) Me.upperRightPanel.Location =New System.Drawing.Point(44, 2) Me.upperRightPanel.Name ="upperRightPanel" Me.upperRightPanel.Size =New System.Drawing.Size(40, 40) Me.upperRightPanel.TabIndex =1 ' ' lowerLeftPanel ' Me.lowerLeftPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle Me.lowerLeftPanel.Controls.AddRange(New System.Windows.Forms.Control() {Me.lowerLeftLine}) Me.lowerLeftPanel.Location =New System.Drawing.Point(86, 2) Me.lowerLeftPanel.Name ="lowerLeftPanel" Me.lowerLeftPanel.Size =New System.Drawing.Size(40, 40) Me.lowerLeftPanel.TabIndex =2 ' ' lowerRightPanel ' Me.lowerRightPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle Me.lowerRightPanel.Controls.AddRange(New System.Windows.Forms.Control() {Me.lowerRighttLine}) Me.lowerRightPanel.Location =New System.Drawing.Point(128, 2) Me.lowerRightPanel.Name ="lowerRightPanel" Me.lowerRightPanel.Size =New System.Drawing.Size(40, 40) Me.lowerRightPanel.TabIndex =3 ' ' upperLeftLine ' Me.upperLeftLine.Dock = System.Windows.Forms.DockStyle.Fill Me.upperLeftLine.CurveType = Microsoft.Samples.CurvedLineTypes.UpperLeftQuarterCircle Me.upperLeftLine.Name ="upperLeftLine" Me.upperLeftLine.Size =New System.Drawing.Size(38, 38) Me.upperLeftLine.TabIndex =0 Me.upperLeftLine.Text ="CurvedLine1" ' ' upperRightLine ' Me.upperRightLine.Dock = System.Windows.Forms.DockStyle.Fill Me.upperRightLine.CurveType = Microsoft.Samples.CurvedLineTypes.UpperRightQuarterCircle Me.upperRightLine.Name ="upperRightLine" Me.upperRightLine.Size =New System.Drawing.Size(38, 38) Me.upperRightLine.TabIndex =0 Me.upperRightLine.Text ="CurvedLine2" ' ' lowerLeftLine ' Me.lowerLeftLine.Dock = System.Windows.Forms.DockStyle.Fill Me.lowerLeftLine.CurveType = Microsoft.Samples.CurvedLineTypes.LowerLeftQuarterCircle Me.lowerLeftLine.Name ="lowerLeftLine" Me.lowerLeftLine.Size =New System.Drawing.Size(38, 38) Me.lowerLeftLine.TabIndex =0 Me.lowerLeftLine.Text ="CurvedLine3" ' ' lowerRighttLine ' Me.lowerRighttLine.Dock = System.Windows.Forms.DockStyle.Fill Me.lowerRighttLine.CurveType = Microsoft.Samples.CurvedLineTypes.LowerRightQuarterCircle Me.lowerRighttLine.Name ="lowerRighttLine" Me.lowerRighttLine.Size =New System.Drawing.Size(38, 38) Me.lowerRighttLine.TabIndex =0 Me.lowerRighttLine.Text ="CurvedLine4" ' ' UserControl1 ' Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.lowerRightPanel, Me.lowerLeftPanel, Me.upperRightPanel, Me.upperLeftPanel}) Me.Name ="UserControl1" Me.Size =New System.Drawing.Size(164, 44) Me.BackColor = System.Drawing.SystemColors.InactiveBorder Me.upperLeftPanel.ResumeLayout(False) Me.upperRightPanel.ResumeLayout(False) Me.lowerLeftPanel.ResumeLayout(False) Me.lowerRightPanel.ResumeLayout(False) Me.ResumeLayout(False) End Sub PrivateSub button_Click()Sub button_Click(ByVal sender AsObject, ByVal e As System.EventArgs) Handles upperLeftLine.Click, upperRightLine.Click, lowerLeftLine.Click, lowerRighttLine.Click ' Dim line As CurvedLine = sender IfNot (line IsNothing) Then Me.value = line.CurveType Teardown(True) EndIf End Sub End Class End Class End Namespace