diff --git a/Form1.vb b/Form1.vb index 16d795c..1536040 100644 --- a/Form1.vb +++ b/Form1.vb @@ -1,6 +1,7 @@ Imports System.IO Public Class Form1 + Public lineLightSeqDict As New Dictionary(Of Form3.Role, String()) Public drawState As Form3.Role = Form3.Role.NULL Public Sub New() @@ -24,25 +25,41 @@ Public Class Form1 ' Private frm2 As New Form2 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load frm2.Show() - frm2.WindowState = FormWindowState.Normal + frm2.WindowState = FormWindowState.Minimized '根据需求,form2表格想要一开始隐藏了,单击再弹出来 frm3.Show() frm3.WindowState = FormWindowState.Normal ' Dim test As Form4 = New Form4 ' test.Show() End Sub - Private Sub Form1_Click(sender As Object, e As EventArgs) Handles Me.Click - Me.TopMost = True - End Sub + '这个是置顶、、窗口默认是可以点哪个哪个就在最前端的 + ' Private Sub Form1_Click(sender As Object, e As EventArgs) Handles Me.Click + ' Me.TopMost = True + ' End Sub Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click - ' If frm2.WindowState = FormWindowState.Minimized Then - ' frm2.WindowState = FormWindowState.Normal - ' Else - ' frm2.WindowState = FormWindowState.Minimized ' cuz max button has been banned - ' End If - frm2.TopMost = Not frm2.TopMost + '使用代理(委托)的关键就是,代理本身是一个模子,所以方法签名一样的跨线程ui操作都可以复用同一个代理声明。 + '默认单线程,即所有的form都在一个线程里 + '然后在使用的时候只需要把自己实现的function或子过程的地址传给代理类型的变量即可,这就算对代理实例化了。 + 'Dim noArgDeleForm2 As Form2.no_arg_form2 = AddressOf flipForm2 + + 'Await Task.Run(New Action(Sub() + ''原理应该是反射 + ' End Sub)) + + flipForm2() + ' frm2.TopMost = Not frm2.TopMost + End Sub + '为了多线程载入form2,这里实例化form2里声明的代理 子过程,然后才可以跨线程操作(美其名曰 代理) + '注意private时不能跨文件访问 + Public Sub flipForm2() + If frm2.WindowState = FormWindowState.Minimized Then + frm2.WindowState = FormWindowState.Normal + Else + frm2.WindowState = FormWindowState.Minimized ' cuz max button has been banned + End If End Sub + Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click ' If frm3.WindowState = FormWindowState.Minimized Then ' frm3.WindowState = FormWindowState.Normal diff --git a/Form2.vb b/Form2.vb index 92ab586..a4d8fec 100644 --- a/Form2.vb +++ b/Form2.vb @@ -1,6 +1,7 @@ Imports System.ComponentModel Public Class Form2 + Public Delegate Sub no_arg_form2() '声明一个委托或者叫代理用于跨线程操作ui 'vb.net里()表示数组 Private consts_k() As String Public Sub New() @@ -124,6 +125,8 @@ Public Class Form2 lb.Dock = DockStyle.Fill Return lb End Function + + Private Function getAInput() Dim tb As New TextBox 'tb.Height = 1 diff --git a/Form3.Designer.vb b/Form3.Designer.vb index 50dab52..ba1328f 100644 --- a/Form3.Designer.vb +++ b/Form3.Designer.vb @@ -23,11 +23,8 @@ Partial Class Form3 Private Sub InitializeComponent() Me.SplitContainer1 = New System.Windows.Forms.SplitContainer() - Me.M = New System.Windows.Forms.Label() - Me.A = New System.Windows.Forms.Label() - Me.B = New System.Windows.Forms.Label() - Me.C = New System.Windows.Forms.Label() Me.ShapeContainer1 = New Microsoft.VisualBasic.PowerPacks.ShapeContainer() + Me.X_down1A = New Microsoft.VisualBasic.PowerPacks.LineShape() Me.X_down3 = New Microsoft.VisualBasic.PowerPacks.LineShape() Me.OvalShape_ME1 = New Microsoft.VisualBasic.PowerPacks.OvalShape() Me.OvalShape_ME2 = New Microsoft.VisualBasic.PowerPacks.OvalShape() @@ -50,7 +47,16 @@ Partial Class Form3 Me.Button2 = New System.Windows.Forms.Button() Me.Button1 = New System.Windows.Forms.Button() Me.CheckBox1 = New System.Windows.Forms.CheckBox() - Me.X_down1A = New Microsoft.VisualBasic.PowerPacks.LineShape() + Me.LineShape1 = New Microsoft.VisualBasic.PowerPacks.LineShape() + Me.LineShape2 = New Microsoft.VisualBasic.PowerPacks.LineShape() + Me.LineShape3 = New Microsoft.VisualBasic.PowerPacks.LineShape() + Me.XXX = New Microsoft.VisualBasic.PowerPacks.LineShape() + Me.XXXX = New Microsoft.VisualBasic.PowerPacks.LineShape() + Me.LineShape6 = New Microsoft.VisualBasic.PowerPacks.LineShape() + Me.XX = New Microsoft.VisualBasic.PowerPacks.LineShape() + Me.OvalShape1 = New Microsoft.VisualBasic.PowerPacks.OvalShape() + Me.OvalShape2 = New Microsoft.VisualBasic.PowerPacks.OvalShape() + Me.LineShape8 = New Microsoft.VisualBasic.PowerPacks.LineShape() CType(Me.SplitContainer1, System.ComponentModel.ISupportInitialize).BeginInit() Me.SplitContainer1.Panel1.SuspendLayout() Me.SplitContainer1.Panel2.SuspendLayout() @@ -68,66 +74,35 @@ Partial Class Form3 'SplitContainer1.Panel1 ' Me.SplitContainer1.Panel1.BackColor = System.Drawing.Color.FromArgb(CType(CType(229, Byte), Integer), CType(CType(229, Byte), Integer), CType(CType(229, Byte), Integer)) - Me.SplitContainer1.Panel1.Controls.Add(Me.M) - Me.SplitContainer1.Panel1.Controls.Add(Me.A) - Me.SplitContainer1.Panel1.Controls.Add(Me.B) - Me.SplitContainer1.Panel1.Controls.Add(Me.C) Me.SplitContainer1.Panel1.Controls.Add(Me.ShapeContainer1) Me.SplitContainer1.Panel1.Cursor = System.Windows.Forms.Cursors.Default ' 'SplitContainer1.Panel2 ' Me.SplitContainer1.Panel2.Controls.Add(Me.FlowLayoutPanel1) - Me.SplitContainer1.Size = New System.Drawing.Size(482, 203) - Me.SplitContainer1.SplitterDistance = 160 + Me.SplitContainer1.Size = New System.Drawing.Size(482, 268) + Me.SplitContainer1.SplitterDistance = 222 Me.SplitContainer1.TabIndex = 0 ' - 'M - ' - Me.M.Cursor = System.Windows.Forms.Cursors.Hand - Me.M.Location = New System.Drawing.Point(363, 76) - Me.M.Name = "M" - Me.M.Size = New System.Drawing.Size(26, 15) - Me.M.TabIndex = 4 - Me.M.Text = "ME" - ' - 'A - ' - Me.A.Cursor = System.Windows.Forms.Cursors.Hand - Me.A.Location = New System.Drawing.Point(137, 76) - Me.A.Name = "A" - Me.A.Size = New System.Drawing.Size(19, 15) - Me.A.TabIndex = 3 - Me.A.Text = "A" - ' - 'B - ' - Me.B.Cursor = System.Windows.Forms.Cursors.Hand - Me.B.Location = New System.Drawing.Point(59, 76) - Me.B.Name = "B" - Me.B.Size = New System.Drawing.Size(19, 15) - Me.B.TabIndex = 2 - Me.B.Text = "B" - ' - 'C - ' - Me.C.Cursor = System.Windows.Forms.Cursors.Hand - Me.C.Location = New System.Drawing.Point(154, 23) - Me.C.Name = "C" - Me.C.Size = New System.Drawing.Size(19, 15) - Me.C.TabIndex = 1 - Me.C.Text = "C" - ' 'ShapeContainer1 ' Me.ShapeContainer1.Location = New System.Drawing.Point(0, 0) Me.ShapeContainer1.Margin = New System.Windows.Forms.Padding(0) Me.ShapeContainer1.Name = "ShapeContainer1" - Me.ShapeContainer1.Shapes.AddRange(New Microsoft.VisualBasic.PowerPacks.Shape() {Me.X_down1A, Me.X_down3, Me.OvalShape_ME1, Me.OvalShape_ME2, Me.LineShape_ME, Me.X_down1, Me.LineShape_B, Me.LineShape_A, Me.X_up2, Me.X_up1, Me.LineShape_C, Me.OvalShape_C1, Me.OvalShape_C2, Me.OvalShape_B1, Me.OvalShape_B2, Me.OvalShape_A2, Me.OvalShape_A1, Me.X, Me.X_down2}) - Me.ShapeContainer1.Size = New System.Drawing.Size(482, 160) + Me.ShapeContainer1.Shapes.AddRange(New Microsoft.VisualBasic.PowerPacks.Shape() {Me.LineShape8, Me.OvalShape2, Me.OvalShape1, Me.XX, Me.LineShape6, Me.XXXX, Me.XXX, Me.LineShape3, Me.LineShape2, Me.LineShape1, Me.X_down1A, Me.X_down3, Me.OvalShape_ME1, Me.OvalShape_ME2, Me.LineShape_ME, Me.X_down1, Me.LineShape_B, Me.LineShape_A, Me.X_up2, Me.X_up1, Me.LineShape_C, Me.OvalShape_C1, Me.OvalShape_C2, Me.OvalShape_B1, Me.OvalShape_B2, Me.OvalShape_A2, Me.OvalShape_A1, Me.X, Me.X_down2}) + Me.ShapeContainer1.Size = New System.Drawing.Size(482, 222) Me.ShapeContainer1.TabIndex = 0 Me.ShapeContainer1.TabStop = False ' + 'X_down1A + ' + Me.X_down1A.BorderWidth = 4 + Me.X_down1A.Name = "X_down1A" + Me.X_down1A.X1 = 135 + Me.X_down1A.X2 = 239 + Me.X_down1A.Y1 = 113 + Me.X_down1A.Y2 = 113 + ' 'X_down3 ' Me.X_down3.BorderWidth = 4 @@ -293,7 +268,7 @@ Partial Class Form3 Me.FlowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill Me.FlowLayoutPanel1.Location = New System.Drawing.Point(0, 0) Me.FlowLayoutPanel1.Name = "FlowLayoutPanel1" - Me.FlowLayoutPanel1.Size = New System.Drawing.Size(482, 39) + Me.FlowLayoutPanel1.Size = New System.Drawing.Size(482, 42) Me.FlowLayoutPanel1.TabIndex = 0 ' 'Button2 @@ -339,20 +314,103 @@ Partial Class Form3 Me.CheckBox1.UseVisualStyleBackColor = True Me.CheckBox1.Visible = False ' - 'X_down1A - ' - Me.X_down1A.BorderWidth = 4 - Me.X_down1A.Name = "X_down1A" - Me.X_down1A.X1 = 135 - Me.X_down1A.X2 = 239 - Me.X_down1A.Y1 = 113 - Me.X_down1A.Y2 = 113 + 'LineShape1 + ' + Me.LineShape1.BorderWidth = 4 + Me.LineShape1.Name = "LineShape1" + Me.LineShape1.X1 = 177 + Me.LineShape1.X2 = 202 + Me.LineShape1.Y1 = 125 + Me.LineShape1.Y2 = 165 + ' + 'LineShape2 + ' + Me.LineShape2.BorderWidth = 4 + Me.LineShape2.Name = "LineShape2" + Me.LineShape2.X1 = 202 + Me.LineShape2.X2 = 305 + Me.LineShape2.Y1 = 164 + Me.LineShape2.Y2 = 164 + ' + 'LineShape3 + ' + Me.LineShape3.BorderWidth = 4 + Me.LineShape3.Name = "LineShape3" + Me.LineShape3.X1 = 327 + Me.LineShape3.X2 = 304 + Me.LineShape3.Y1 = 124 + Me.LineShape3.Y2 = 164 + ' + 'XXX + ' + Me.XXX.BorderColor = System.Drawing.Color.LimeGreen + Me.XXX.BorderWidth = 4 + Me.XXX.Name = "XXX" + Me.XXX.X1 = 163 + Me.XXX.X2 = 181 + Me.XXX.Y1 = 113 + Me.XXX.Y2 = 113 + ' + 'XXXX + ' + Me.XXXX.BorderColor = System.Drawing.Color.LimeGreen + Me.XXXX.BorderWidth = 4 + Me.XXXX.Name = "XXXX" + Me.XXXX.X1 = 317 + Me.XXXX.X2 = 339 + Me.XXXX.Y1 = 113 + Me.XXXX.Y2 = 113 + ' + 'LineShape6 + ' + Me.LineShape6.BorderWidth = 4 + Me.LineShape6.Name = "LineShape6" + Me.LineShape6.X1 = 126 + Me.LineShape6.X2 = 100 + Me.LineShape6.Y1 = 56 + Me.LineShape6.Y2 = 98 + ' + 'XX + ' + Me.XX.BorderColor = System.Drawing.Color.LimeGreen + Me.XX.BorderWidth = 4 + Me.XX.Name = "XX" + Me.XX.X1 = 92 + Me.XX.X2 = 110 + Me.XX.Y1 = 113 + Me.XX.Y2 = 113 + ' + 'OvalShape1 + ' + Me.OvalShape1.BackColor = System.Drawing.Color.Red + Me.OvalShape1.BackStyle = Microsoft.VisualBasic.PowerPacks.BackStyle.Opaque + Me.OvalShape1.Cursor = System.Windows.Forms.Cursors.Hand + Me.OvalShape1.Location = New System.Drawing.Point(235, 174) + Me.OvalShape1.Name = "OvalShape1" + Me.OvalShape1.Size = New System.Drawing.Size(9, 9) + ' + 'OvalShape2 + ' + Me.OvalShape2.BackColor = System.Drawing.SystemColors.Window + Me.OvalShape2.Cursor = System.Windows.Forms.Cursors.Hand + Me.OvalShape2.FillColor = System.Drawing.Color.Thistle + Me.OvalShape2.Location = New System.Drawing.Point(244, 174) + Me.OvalShape2.Name = "OvalShape2" + Me.OvalShape2.Size = New System.Drawing.Size(9, 9) + ' + 'LineShape8 + ' + Me.LineShape8.Name = "LineShape8" + Me.LineShape8.X1 = 235 + Me.LineShape8.X2 = 235 + Me.LineShape8.Y1 = 166 + Me.LineShape8.Y2 = 180 ' 'Form3 ' Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None Me.BackColor = System.Drawing.SystemColors.ButtonFace - Me.ClientSize = New System.Drawing.Size(482, 203) + Me.ClientSize = New System.Drawing.Size(482, 268) Me.Controls.Add(Me.SplitContainer1) Me.DoubleBuffered = True Me.MaximizeBox = False @@ -370,10 +428,6 @@ Partial Class Form3 End Sub Friend WithEvents SplitContainer1 As SplitContainer - Friend WithEvents M As Label - Friend WithEvents A As Label - Friend WithEvents B As Label - Friend WithEvents C As Label Friend WithEvents ShapeContainer1 As PowerPacks.ShapeContainer Friend WithEvents OvalShape_ME1 As PowerPacks.OvalShape Friend WithEvents OvalShape_ME2 As PowerPacks.OvalShape @@ -398,4 +452,14 @@ Partial Class Form3 Friend WithEvents X_down3 As PowerPacks.LineShape Friend WithEvents CheckBox1 As CheckBox Friend WithEvents X_down1A As PowerPacks.LineShape + Friend WithEvents LineShape8 As PowerPacks.LineShape + Friend WithEvents OvalShape2 As PowerPacks.OvalShape + Friend WithEvents OvalShape1 As PowerPacks.OvalShape + Friend WithEvents XX As PowerPacks.LineShape + Friend WithEvents LineShape6 As PowerPacks.LineShape + Friend WithEvents XXXX As PowerPacks.LineShape + Friend WithEvents XXX As PowerPacks.LineShape + Friend WithEvents LineShape3 As PowerPacks.LineShape + Friend WithEvents LineShape2 As PowerPacks.LineShape + Friend WithEvents LineShape1 As PowerPacks.LineShape End Class diff --git a/Form3.resx b/Form3.resx index 5ea6e4a..fc6786b 100644 --- a/Form3.resx +++ b/Form3.resx @@ -117,6 +117,78 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 235, 166, 0, 14 + + + 235, 166 + + + 0, 14 + + + 92, 113, 18, 0 + + + 92, 113 + + + 18, 0 + + + 100, 56, 26, 42 + + + 100, 56 + + + 26, 42 + + + 317, 113, 22, 0 + + + 317, 113 + + + 22, 0 + + + 163, 113, 18, 0 + + + 163, 113 + + + 18, 0 + + + 304, 124, 23, 40 + + + 304, 124 + + + 23, 40 + + + 202, 164, 103, 0 + + + 202, 164 + + + 103, 0 + + + 177, 125, 25, 40 + + + 177, 125 + + + 25, 40 + 135, 113, 104, 0 diff --git a/Form3.vb b/Form3.vb index fa9bd68..3eea620 100644 --- a/Form3.vb +++ b/Form3.vb @@ -63,7 +63,7 @@ cb.Visible = Not cb.Visible End Sub - Private Sub Me_Click(sender As Object, e As EventArgs) Handles OvalShape_ME1.Click, OvalShape_ME2.Click, M.Click + Private Sub Me_Click(sender As Object, e As EventArgs) Handles OvalShape_ME1.Click, OvalShape_ME2.Click, OvalShape2.Click, OvalShape1.Click Dim pre = Role.NULL If msgStack.Count > 0 Then pre = msgStack.Pop() @@ -119,7 +119,7 @@ msgStack.Push(Role.M) End Sub - Private Sub A_Click(sender As Object, e As EventArgs) Handles OvalShape_A1.Click, OvalShape_A2.Click, A.Click + Private Sub A_Click(sender As Object, e As EventArgs) Handles OvalShape_A1.Click, OvalShape_A2.Click Dim pre = Role.NULL If msgStack.Count > 0 Then pre = msgStack.Pop() @@ -160,7 +160,7 @@ msgStack.Push(Role.A) End Sub - Private Sub B_Click(sender As Object, e As EventArgs) Handles OvalShape_B1.Click, OvalShape_B2.Click, B.Click + Private Sub B_Click(sender As Object, e As EventArgs) Handles OvalShape_B1.Click, OvalShape_B2.Click Dim pre = Role.NULL If msgStack.Count > 0 Then pre = msgStack.Pop() @@ -201,7 +201,7 @@ msgStack.Push(Role.B) End Sub - Private Sub C_Click(sender As Object, e As EventArgs) Handles OvalShape_C1.Click, OvalShape_C2.Click, C.Click + Private Sub C_Click(sender As Object, e As EventArgs) Handles OvalShape_C1.Click, OvalShape_C2.Click Dim pre = Role.NULL If msgStack.Count > 0 Then pre = msgStack.Pop() @@ -304,7 +304,8 @@ Dim lines = shapes.OfType(Of PowerPacks.LineShape) For Each e In lines ' If e.Name <> "X" And e.Name <> "X_down3" Then '这里有bug 如果没有isChecked的时候,对b全线点亮也应该恢复X_down3 - If e.Name <> "X" Then + Dim flippers As ArrayList = New ArrayList({"X", "XX", "XXX", "XXXX"}) + If Not flippers.Contains(e.Name) Then If e.Name = "X_down3" AndAlso isChecked() Then Continue For End If