优化了示例工程

This commit is contained in:
fengjiayi
2024-09-28 23:55:19 +08:00
parent 51bdbab4d1
commit 10e5d172c6
56 changed files with 9920 additions and 455 deletions

View File

@@ -29,33 +29,35 @@
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.textBox1 = new System.Windows.Forms.TextBox();
this.textBoxPlcInfo = new System.Windows.Forms.TextBox();
this.button2 = new System.Windows.Forms.Button();
this.listBox1 = new System.Windows.Forms.ListBox();
this.textBoxSpaceNum = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(187, 22);
this.button1.Location = new System.Drawing.Point(220, 56);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(98, 23);
this.button1.Size = new System.Drawing.Size(65, 23);
this.button1.TabIndex = 0;
this.button1.Text = "查看状态";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// textBox1
// textBoxPlcInfo
//
this.textBox1.Location = new System.Drawing.Point(35, 24);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(137, 21);
this.textBox1.TabIndex = 1;
this.textBoxPlcInfo.Location = new System.Drawing.Point(35, 24);
this.textBoxPlcInfo.Name = "textBoxPlcInfo";
this.textBoxPlcInfo.ReadOnly = true;
this.textBoxPlcInfo.Size = new System.Drawing.Size(250, 21);
this.textBoxPlcInfo.TabIndex = 1;
//
// button2
//
this.button2.Location = new System.Drawing.Point(178, 179);
this.button2.Location = new System.Drawing.Point(205, 181);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(107, 23);
this.button2.Size = new System.Drawing.Size(80, 23);
this.button2.TabIndex = 2;
this.button2.Text = "触发";
this.button2.UseVisualStyleBackColor = true;
@@ -70,14 +72,23 @@
this.listBox1.Size = new System.Drawing.Size(250, 88);
this.listBox1.TabIndex = 6;
//
// textBoxSpaceNum
//
this.textBoxSpaceNum.Location = new System.Drawing.Point(35, 183);
this.textBoxSpaceNum.Name = "textBoxSpaceNum";
this.textBoxSpaceNum.Size = new System.Drawing.Size(106, 21);
this.textBoxSpaceNum.TabIndex = 7;
this.textBoxSpaceNum.Text = "104";
//
// FromWorkBenchView
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(341, 251);
this.Controls.Add(this.textBoxSpaceNum);
this.Controls.Add(this.listBox1);
this.Controls.Add(this.button2);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.textBoxPlcInfo);
this.Controls.Add(this.button1);
this.Name = "FromWorkBenchView";
this.Text = "Form1";
@@ -89,8 +100,9 @@
#endregion
private System.Windows.Forms.Button button1;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.TextBox textBoxPlcInfo;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.ListBox listBox1;
private System.Windows.Forms.TextBox textBoxSpaceNum;
}
}

View File

@@ -31,17 +31,21 @@ namespace Net461DllTest
private void button1_Click(object sender, EventArgs e)
{
textBox1.Text = ViewModel.GetDeviceInfo();
textBoxPlcInfo.Text = ViewModel.GetDeviceInfo();
}
private void button2_Click(object sender, EventArgs e)
{
if(listBox1.SelectedItem is null)
{
return;
}
string type = listBox1.SelectedItem.ToString();
if (Enum.TryParse(type, out OrderSignal signal) && Enum.IsDefined(typeof(OrderSignal), signal))
if (!string.IsNullOrEmpty(type) && Enum.TryParse(type, out OrderSignal signal) && Enum.IsDefined(typeof(OrderSignal), signal))
{
Console.WriteLine($"Trigger : {type}");
ViewModel.Trigger(signal);
ViewModel.Trigger(signal,textBoxSpaceNum.Text);
}
}

View File

@@ -1,33 +0,0 @@
using Net461DllTest.Data;
using Net461DllTest.Signal;
using Serein.Library.Attributes;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
namespace Net461DllTest.View
{
public partial class TeseFormView : Form
{
[AutoInjection]
public MyData MyData { get; set; }
public TeseFormView()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
MyData.Count = 0;
}
}
}

View File

@@ -1,6 +1,8 @@
namespace Net461DllTest.View
using System;
namespace Net461DllTest.View
{
partial class TeseFormView
partial class TestFormView
{
/// <summary>
/// Required designer variable.
@@ -37,17 +39,17 @@
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 0;
this.button1.Text = "清空";
this.button1.Text = "测试";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// TeseFormView
// TestFormView
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(254, 118);
this.Controls.Add(this.button1);
this.Name = "TeseFormView";
this.Name = "TestFormView";
this.Text = "TeseForm";
this.ResumeLayout(false);

View File

@@ -0,0 +1,19 @@
using System;
using System.Windows.Forms;
namespace Net461DllTest.View
{
public partial class TestFormView : Form
{
public TestFormView()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
}
}
}