diff --git a/DNSD_Controls/HslTable.cs b/DNSD_Controls/HslTable.cs index c0e272e..eead9e8 100644 --- a/DNSD_Controls/HslTable.cs +++ b/DNSD_Controls/HslTable.cs @@ -230,8 +230,8 @@ namespace DNSD_Controls } set { - bool flag = this.rowsTotalCount > 0; - if (flag) + //bool flag = this.rowsTotalCount > 0; + //if (flag) { this.rowsTotalCount = value; base.Invalidate(); diff --git a/NDSD-Screwdriver/FormUtils.cs b/NDSD-Screwdriver/FormUtils.cs new file mode 100644 index 0000000..4ee2068 --- /dev/null +++ b/NDSD-Screwdriver/FormUtils.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace NDSD_Screwdriver +{ + public class FormUtils + { + public static Random r = new Random(); + + public static Brush TestRamColor() + { + int i = r.Next(0, 4); + if (i == 1) + { + return Brushes.Green; + } + else if (i == 2) + { + return Brushes.Yellow; + } + else return Brushes.Red; + } + } +} diff --git a/NDSD-Screwdriver/MainForm.Designer.cs b/NDSD-Screwdriver/MainForm.Designer.cs index 8a15f92..4dee2d1 100644 --- a/NDSD-Screwdriver/MainForm.Designer.cs +++ b/NDSD-Screwdriver/MainForm.Designer.cs @@ -31,13 +31,17 @@ this.DOTest = new System.Windows.Forms.Button(); this.dataGridView1 = new System.Windows.Forms.DataGridView(); this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.ScrewdriverMonitor = new DNSD_Controls.HslTable(); + this.TestButton1 = new System.Windows.Forms.Button(); + this.TestButton2 = new System.Windows.Forms.Button(); + this.TestButton3 = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit(); this.groupBox1.SuspendLayout(); this.SuspendLayout(); // // DOTest // - this.DOTest.Location = new System.Drawing.Point(673, 31); + this.DOTest.Location = new System.Drawing.Point(673, 12); this.DOTest.Name = "DOTest"; this.DOTest.Size = new System.Drawing.Size(75, 23); this.DOTest.TabIndex = 0; @@ -53,25 +57,88 @@ this.dataGridView1.Name = "dataGridView1"; this.dataGridView1.RowHeadersWidth = 51; this.dataGridView1.RowTemplate.Height = 27; - this.dataGridView1.Size = new System.Drawing.Size(370, 826); + this.dataGridView1.Size = new System.Drawing.Size(388, 826); this.dataGridView1.TabIndex = 1; // // groupBox1 // this.groupBox1.Controls.Add(this.dataGridView1); this.groupBox1.Dock = System.Windows.Forms.DockStyle.Right; - this.groupBox1.Location = new System.Drawing.Point(772, 0); + this.groupBox1.Location = new System.Drawing.Point(754, 0); this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(376, 850); + this.groupBox1.Size = new System.Drawing.Size(394, 850); this.groupBox1.TabIndex = 2; this.groupBox1.TabStop = false; this.groupBox1.Text = "日志"; // + // ScrewdriverMonitor + // + this.ScrewdriverMonitor.AssistHeaderText = ""; + this.ScrewdriverMonitor.BorderColor = System.Drawing.Color.Black; + this.ScrewdriverMonitor.ColumnHeader = new string[] { + "工作标识", + "RFID", + "信号指示"}; + this.ScrewdriverMonitor.ColumnWidth = new float[] { + 0F, + 0.1F, + 0.9F, + 1F}; + this.ScrewdriverMonitor.Dock = System.Windows.Forms.DockStyle.Left; + this.ScrewdriverMonitor.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.ScrewdriverMonitor.ForeColor = System.Drawing.Color.Black; + this.ScrewdriverMonitor.HeaderColor = System.Drawing.Color.Black; + this.ScrewdriverMonitor.Location = new System.Drawing.Point(0, 0); + this.ScrewdriverMonitor.Name = "ScrewdriverMonitor"; + this.ScrewdriverMonitor.RowsTotalCount = 13; + this.ScrewdriverMonitor.Size = new System.Drawing.Size(667, 850); + this.ScrewdriverMonitor.TabIndex = 3; + this.ScrewdriverMonitor.Text = "hslTable1"; + this.ScrewdriverMonitor.TopHeaderColor = System.Drawing.Color.Black; + this.ScrewdriverMonitor.TopHeaderHeight = 0.05F; + this.ScrewdriverMonitor.TopHeaderText = "螺丝刀监控"; + this.ScrewdriverMonitor.TopHeaderTextSize = 18F; + this.ScrewdriverMonitor.OnDrawCellTextEvent += new DNSD_Controls.HslTable.DrawCellTextDelegate(this.ScrewdriverMonitor_OnDrawCellTextEvent); + // + // TestButton1 + // + this.TestButton1.Location = new System.Drawing.Point(673, 41); + this.TestButton1.Name = "TestButton1"; + this.TestButton1.Size = new System.Drawing.Size(75, 23); + this.TestButton1.TabIndex = 4; + this.TestButton1.Text = "测试1"; + this.TestButton1.UseVisualStyleBackColor = true; + this.TestButton1.Click += new System.EventHandler(this.TestButton1_Click); + // + // TestButton2 + // + this.TestButton2.Location = new System.Drawing.Point(673, 70); + this.TestButton2.Name = "TestButton2"; + this.TestButton2.Size = new System.Drawing.Size(75, 23); + this.TestButton2.TabIndex = 5; + this.TestButton2.Text = "测试2"; + this.TestButton2.UseVisualStyleBackColor = true; + this.TestButton2.Click += new System.EventHandler(this.TestButton2_Click); + // + // TestButton3 + // + this.TestButton3.Location = new System.Drawing.Point(673, 99); + this.TestButton3.Name = "TestButton3"; + this.TestButton3.Size = new System.Drawing.Size(75, 23); + this.TestButton3.TabIndex = 6; + this.TestButton3.Text = "测试3"; + this.TestButton3.UseVisualStyleBackColor = true; + this.TestButton3.Click += new System.EventHandler(this.TestButton3_Click); + // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(1148, 850); + this.Controls.Add(this.TestButton3); + this.Controls.Add(this.TestButton2); + this.Controls.Add(this.TestButton1); + this.Controls.Add(this.ScrewdriverMonitor); this.Controls.Add(this.groupBox1); this.Controls.Add(this.DOTest); this.Name = "MainForm"; @@ -88,5 +155,9 @@ private System.Windows.Forms.Button DOTest; private System.Windows.Forms.DataGridView dataGridView1; private System.Windows.Forms.GroupBox groupBox1; + private DNSD_Controls.HslTable ScrewdriverMonitor; + private System.Windows.Forms.Button TestButton1; + private System.Windows.Forms.Button TestButton2; + private System.Windows.Forms.Button TestButton3; } } \ No newline at end of file diff --git a/NDSD-Screwdriver/MainForm.cs b/NDSD-Screwdriver/MainForm.cs index ab60879..909985b 100644 --- a/NDSD-Screwdriver/MainForm.cs +++ b/NDSD-Screwdriver/MainForm.cs @@ -17,6 +17,10 @@ namespace NDSD_Screwdriver TcpServer server = TcpServer.Instance; + List monitorEntities; + + Random rand = new Random(); + public MainForm() { InitializeComponent(); @@ -25,6 +29,84 @@ namespace NDSD_Screwdriver { MessageBox.Show("服务端打开失败!"); } + monitorEntities = new List() + { + new MonitorEntity() + { + RowEneieys = new List() + { + new RowEneiey() + { + ColumnIndex = 0, + Color = Brushes.Transparent + }, + + new RowEneiey() + { + ColumnIndex = 1, + Value = "11111111", + Color = Brushes.Transparent + }, + + new RowEneiey() + { + ColumnIndex = 2, + }, + }, + RowIndex = 0, + }, + + new MonitorEntity() + { + RowEneieys = new List() + { + new RowEneiey() + { + ColumnIndex = 0, + Color = Brushes.Transparent + }, + + new RowEneiey() + { + ColumnIndex = 1, + Value = "22222222", + Color = Brushes.Transparent + }, + + new RowEneiey() + { + ColumnIndex = 2, + }, + }, + RowIndex = 1, + }, + + new MonitorEntity() + { + RowEneieys = new List() + { + new RowEneiey() + { + ColumnIndex = 0, + Color = Brushes.Transparent + }, + + new RowEneiey() + { + ColumnIndex = 1, + Value = "33333333", + Color = Brushes.Transparent + }, + + new RowEneiey() + { + ColumnIndex = 2, + }, + }, + RowIndex = 2, + }, + + }; } private void DOTest_Click(object sender, EventArgs e) @@ -35,7 +117,7 @@ namespace NDSD_Screwdriver private void MainForm_FormClosed(object sender, FormClosedEventArgs e) { - if (server != null) + if (server != null) { if (!server.ServerStop()) { @@ -45,8 +127,61 @@ namespace NDSD_Screwdriver { MessageBox.Show("服务端释放失败!"); } - + + } + } + + private void ScrewdriverMonitor_OnDrawCellTextEvent(Graphics g, int rowIndex, int colIndex, RectangleF rectangle, string value, StringFormat sf) + { + foreach (MonitorEntity entity in monitorEntities) + { + if (rowIndex == entity.RowIndex) + { + foreach (RowEneiey rowEneiey in entity.RowEneieys) + { + if (colIndex == rowEneiey.ColumnIndex) + { + if (colIndex == 2) + { + g.FillRectangle(FormUtils.TestRamColor(), rectangle); + g.DrawString(rowEneiey.Value, this.ScrewdriverMonitor.Font, Brushes.Black, rectangle, sf); + } + else + { + g.FillRectangle(rowEneiey.Color, rectangle); + g.DrawString(rowEneiey.Value, this.ScrewdriverMonitor.Font, Brushes.Black, rectangle, sf); + } + } + } + } + } + + } + private void TestButton1_Click(object sender, EventArgs e) + { + RefreshRoll(); + } + + private void TestButton2_Click(object sender, EventArgs e) + { + RefreshRoll(); + } + + private void TestButton3_Click(object sender, EventArgs e) + { + RefreshRoll(); + } + + private void RefreshRoll() + { + for (int i = 0; i < 5; i++) + { + ScrewdriverMonitor.AddRowTop(new string[]{ + "", + "", + "" + }); } } } diff --git a/NDSD-Screwdriver/MonitorEntity.cs b/NDSD-Screwdriver/MonitorEntity.cs new file mode 100644 index 0000000..96ba86c --- /dev/null +++ b/NDSD-Screwdriver/MonitorEntity.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace NDSD_Screwdriver +{ + public class MonitorEntity + { + public List RowEneieys { get; set; } + + public int RowIndex { get; set; } + } + + public class RowEneiey + { + public int ColumnIndex { get; set; } + + public Brush Color { get; set; } = Brushes.Transparent; + + public string Value { get; set; } = ""; + } +} diff --git a/NDSD-Screwdriver/NDSD_Screwdriver.csproj b/NDSD-Screwdriver/NDSD_Screwdriver.csproj index 560216f..d8b0225 100644 --- a/NDSD-Screwdriver/NDSD_Screwdriver.csproj +++ b/NDSD-Screwdriver/NDSD_Screwdriver.csproj @@ -75,6 +75,7 @@ MainForm.cs + @@ -83,6 +84,7 @@ ScrewdriverTest.cs + MainForm.cs diff --git a/NDSD-Screwdriver/ScrewdriverTest.Designer.cs b/NDSD-Screwdriver/ScrewdriverTest.Designer.cs index 43e3a03..16e7870 100644 --- a/NDSD-Screwdriver/ScrewdriverTest.Designer.cs +++ b/NDSD-Screwdriver/ScrewdriverTest.Designer.cs @@ -44,10 +44,9 @@ // // DOpenButton // - this.DOpenButton.Location = new System.Drawing.Point(73, 58); - this.DOpenButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.DOpenButton.Location = new System.Drawing.Point(65, 48); this.DOpenButton.Name = "DOpenButton"; - this.DOpenButton.Size = new System.Drawing.Size(112, 36); + this.DOpenButton.Size = new System.Drawing.Size(100, 30); this.DOpenButton.TabIndex = 0; this.DOpenButton.Text = "开启"; this.DOpenButton.UseVisualStyleBackColor = true; @@ -55,10 +54,9 @@ // // DCloseButton // - this.DCloseButton.Location = new System.Drawing.Point(73, 101); - this.DCloseButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.DCloseButton.Location = new System.Drawing.Point(65, 84); this.DCloseButton.Name = "DCloseButton"; - this.DCloseButton.Size = new System.Drawing.Size(112, 36); + this.DCloseButton.Size = new System.Drawing.Size(100, 30); this.DCloseButton.TabIndex = 1; this.DCloseButton.Text = "关闭"; this.DCloseButton.UseVisualStyleBackColor = true; @@ -66,19 +64,17 @@ // // DNoTextBox // - this.DNoTextBox.Location = new System.Drawing.Point(73, 20); - this.DNoTextBox.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.DNoTextBox.Location = new System.Drawing.Point(65, 17); this.DNoTextBox.Name = "DNoTextBox"; - this.DNoTextBox.Size = new System.Drawing.Size(112, 28); + this.DNoTextBox.Size = new System.Drawing.Size(100, 25); this.DNoTextBox.TabIndex = 2; this.DNoTextBox.Text = "1"; // // DOpenAll // - this.DOpenAll.Location = new System.Drawing.Point(73, 144); - this.DOpenAll.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.DOpenAll.Location = new System.Drawing.Point(65, 120); this.DOpenAll.Name = "DOpenAll"; - this.DOpenAll.Size = new System.Drawing.Size(112, 36); + this.DOpenAll.Size = new System.Drawing.Size(100, 30); this.DOpenAll.TabIndex = 3; this.DOpenAll.Text = "全部开启"; this.DOpenAll.UseVisualStyleBackColor = true; @@ -86,10 +82,9 @@ // // DCloseAll // - this.DCloseAll.Location = new System.Drawing.Point(73, 187); - this.DCloseAll.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.DCloseAll.Location = new System.Drawing.Point(65, 156); this.DCloseAll.Name = "DCloseAll"; - this.DCloseAll.Size = new System.Drawing.Size(112, 36); + this.DCloseAll.Size = new System.Drawing.Size(100, 30); this.DCloseAll.TabIndex = 4; this.DCloseAll.Text = "全部关闭"; this.DCloseAll.UseVisualStyleBackColor = true; @@ -97,19 +92,17 @@ // // DelayTimeTextBox // - this.DelayTimeTextBox.Location = new System.Drawing.Point(270, 20); - this.DelayTimeTextBox.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.DelayTimeTextBox.Location = new System.Drawing.Point(240, 17); this.DelayTimeTextBox.Name = "DelayTimeTextBox"; - this.DelayTimeTextBox.Size = new System.Drawing.Size(112, 28); + this.DelayTimeTextBox.Size = new System.Drawing.Size(100, 25); this.DelayTimeTextBox.TabIndex = 7; this.DelayTimeTextBox.Text = "1"; // // DelayButton // - this.DelayButton.Location = new System.Drawing.Point(270, 58); - this.DelayButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.DelayButton.Location = new System.Drawing.Point(240, 48); this.DelayButton.Name = "DelayButton"; - this.DelayButton.Size = new System.Drawing.Size(112, 36); + this.DelayButton.Size = new System.Drawing.Size(100, 30); this.DelayButton.TabIndex = 5; this.DelayButton.Text = "计时开启"; this.DelayButton.UseVisualStyleBackColor = true; @@ -118,27 +111,26 @@ // label1 // this.label1.AutoSize = true; - this.label1.Location = new System.Drawing.Point(14, 24); + this.label1.Location = new System.Drawing.Point(12, 20); this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(53, 18); + this.label1.Size = new System.Drawing.Size(47, 15); this.label1.TabIndex = 9; this.label1.Text = "DO No"; // // label3 // this.label3.AutoSize = true; - this.label3.Location = new System.Drawing.Point(192, 24); + this.label3.Location = new System.Drawing.Point(171, 20); this.label3.Name = "label3"; - this.label3.Size = new System.Drawing.Size(71, 18); + this.label3.Size = new System.Drawing.Size(63, 15); this.label3.TabIndex = 11; this.label3.Text = "DO Time"; // // AllTimeButton // - this.AllTimeButton.Location = new System.Drawing.Point(270, 101); - this.AllTimeButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.AllTimeButton.Location = new System.Drawing.Point(240, 84); this.AllTimeButton.Name = "AllTimeButton"; - this.AllTimeButton.Size = new System.Drawing.Size(112, 36); + this.AllTimeButton.Size = new System.Drawing.Size(100, 30); this.AllTimeButton.TabIndex = 12; this.AllTimeButton.Text = "全部计时开"; this.AllTimeButton.UseVisualStyleBackColor = true; @@ -146,27 +138,26 @@ // // DelaySpanTextBox // - this.DelaySpanTextBox.Location = new System.Drawing.Point(270, 193); - this.DelaySpanTextBox.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); + this.DelaySpanTextBox.Location = new System.Drawing.Point(240, 161); this.DelaySpanTextBox.Name = "DelaySpanTextBox"; - this.DelaySpanTextBox.Size = new System.Drawing.Size(112, 28); + this.DelaySpanTextBox.Size = new System.Drawing.Size(100, 25); this.DelaySpanTextBox.TabIndex = 13; this.DelaySpanTextBox.Text = "100"; // // label2 // this.label2.AutoSize = true; - this.label2.Location = new System.Drawing.Point(256, 172); + this.label2.Location = new System.Drawing.Point(228, 143); this.label2.Name = "label2"; - this.label2.Size = new System.Drawing.Size(152, 18); + this.label2.Size = new System.Drawing.Size(129, 15); this.label2.TabIndex = 14; this.label2.Text = "全启间隔时间(ms)"; // // ScrewdriverTest // - this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 18F); + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(433, 407); + this.ClientSize = new System.Drawing.Size(385, 216); this.Controls.Add(this.label2); this.Controls.Add(this.DelaySpanTextBox); this.Controls.Add(this.AllTimeButton); @@ -179,7 +170,6 @@ this.Controls.Add(this.DNoTextBox); this.Controls.Add(this.DCloseButton); this.Controls.Add(this.DOpenButton); - this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.Name = "ScrewdriverTest"; this.Text = "螺丝刀测试"; this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.ScrewdriverTest_FormClosed);