From 9b5a866d16ca2b7a68d3af5bac8ea29c4626902f Mon Sep 17 00:00:00 2001 From: xcd <834800634@qq.com> Date: 星期三, 08 七月 2020 18:06:32 +0800 Subject: [PATCH] 添加快捷操作界面 --- src/Bro.M071.Process/UI/M071_MainForm.cs | 12 + src/Bro.UI.Config/AdvancedPwdFrm.cs | 6 + src/Bro.M071.Process/UI/M071_ShortcutFrm.Designer.cs | 93 +++++++++++++++ src/Bro.M071.Process/UI/M071_ShortcutFrm.cs | 76 ++++++++++++ src/Bro.M071.Process/UI/M071_ShortcutFrm.resx | 120 ++++++++++++++++++++ src/Bro.UI.Config/AdvancedPwdFrm.designer.cs | 23 +++ src/Bro.M071.Process/Bro.M071.Process.csproj | 3 src/Bro.UI.Config/MainFrm.cs | 2 src/Bro.UI.Model.Winform/UI/DockContent/MenuFrmBase.cs | 2 9 files changed, 325 insertions(+), 12 deletions(-) diff --git a/src/Bro.M071.Process/Bro.M071.Process.csproj b/src/Bro.M071.Process/Bro.M071.Process.csproj index c81ab99..eb681d3 100644 --- a/src/Bro.M071.Process/Bro.M071.Process.csproj +++ b/src/Bro.M071.Process/Bro.M071.Process.csproj @@ -152,6 +152,9 @@ <EmbeddedResource Include="UI\M071_MainForm.resx"> <DependentUpon>M071_MainForm.cs</DependentUpon> </EmbeddedResource> + <EmbeddedResource Include="UI\M071_ShortcutFrm.resx"> + <DependentUpon>M071_ShortcutFrm.cs</DependentUpon> + </EmbeddedResource> <None Include="App.config"> <SubType>Designer</SubType> <CopyToOutputDirectory>Always</CopyToOutputDirectory> diff --git a/src/Bro.M071.Process/UI/M071_MainForm.cs b/src/Bro.M071.Process/UI/M071_MainForm.cs index 37bcccb..df918c4 100644 --- a/src/Bro.M071.Process/UI/M071_MainForm.cs +++ b/src/Bro.M071.Process/UI/M071_MainForm.cs @@ -33,10 +33,12 @@ tscEditLocation.Visible = tsmiShowEditor.Checked = false; - this.Load += (s, e) => - { - cvImage.SetScreenSize(); - }; + this.Load += async (s, e) => + { + await Task.Delay(300); + + cvImage.SetScreenSize(); + }; } public override void OnProcessUpdated() @@ -52,7 +54,7 @@ try { Bitmap image = (Bitmap)Image.FromFile(Config.BackgroundImagePath); - cvImage.LoadImage(image); + cvImage.LoadImage(image); cvImage.SetScreenSize(); } catch (Exception ex) diff --git a/src/Bro.M071.Process/UI/M071_ShortcutFrm.Designer.cs b/src/Bro.M071.Process/UI/M071_ShortcutFrm.Designer.cs index 6ed449b..eca6a77 100644 --- a/src/Bro.M071.Process/UI/M071_ShortcutFrm.Designer.cs +++ b/src/Bro.M071.Process/UI/M071_ShortcutFrm.Designer.cs @@ -28,12 +28,103 @@ /// </summary> private void InitializeComponent() { - this.components = new System.ComponentModel.Container(); + this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); + this.chkBlockSaftyDoor = new System.Windows.Forms.CheckBox(); + this.chkBlockSafetyBeam = new System.Windows.Forms.CheckBox(); + this.chkBlockBeep = new System.Windows.Forms.CheckBox(); + this.chkManualInputForbidden = new System.Windows.Forms.CheckBox(); + this.btnLightSwitch = new System.Windows.Forms.Button(); + this.flowLayoutPanel1.SuspendLayout(); + this.SuspendLayout(); + // + // flowLayoutPanel1 + // + this.flowLayoutPanel1.Controls.Add(this.chkBlockSaftyDoor); + this.flowLayoutPanel1.Controls.Add(this.chkBlockSafetyBeam); + this.flowLayoutPanel1.Controls.Add(this.chkBlockBeep); + this.flowLayoutPanel1.Controls.Add(this.chkManualInputForbidden); + this.flowLayoutPanel1.Controls.Add(this.btnLightSwitch); + this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 0); + this.flowLayoutPanel1.Name = "flowLayoutPanel1"; + this.flowLayoutPanel1.Size = new System.Drawing.Size(800, 450); + this.flowLayoutPanel1.TabIndex = 0; + // + // chkBlockSaftyDoor + // + this.chkBlockSaftyDoor.AutoSize = true; + this.chkBlockSaftyDoor.Location = new System.Drawing.Point(3, 3); + this.chkBlockSaftyDoor.Name = "chkBlockSaftyDoor"; + this.chkBlockSaftyDoor.Size = new System.Drawing.Size(86, 17); + this.chkBlockSaftyDoor.TabIndex = 0; + this.chkBlockSaftyDoor.Text = "灞忚斀瀹夊叏闂�"; + this.chkBlockSaftyDoor.UseVisualStyleBackColor = true; + this.chkBlockSaftyDoor.CheckedChanged += new System.EventHandler(this.chkBlockSaftyDoor_CheckedChanged); + // + // chkBlockSafetyBeam + // + this.chkBlockSafetyBeam.AutoSize = true; + this.chkBlockSafetyBeam.Location = new System.Drawing.Point(95, 3); + this.chkBlockSafetyBeam.Name = "chkBlockSafetyBeam"; + this.chkBlockSafetyBeam.Size = new System.Drawing.Size(98, 17); + this.chkBlockSafetyBeam.TabIndex = 1; + this.chkBlockSafetyBeam.Text = "灞忚斀瀹夊叏鍏夌嚎"; + this.chkBlockSafetyBeam.UseVisualStyleBackColor = true; + this.chkBlockSafetyBeam.CheckedChanged += new System.EventHandler(this.chkBlockSafetyBeam_CheckedChanged); + // + // chkBlockBeep + // + this.chkBlockBeep.AutoSize = true; + this.chkBlockBeep.Location = new System.Drawing.Point(199, 3); + this.chkBlockBeep.Name = "chkBlockBeep"; + this.chkBlockBeep.Size = new System.Drawing.Size(86, 17); + this.chkBlockBeep.TabIndex = 2; + this.chkBlockBeep.Text = "灞忚斀铚傞福鍣�"; + this.chkBlockBeep.UseVisualStyleBackColor = true; + this.chkBlockBeep.CheckedChanged += new System.EventHandler(this.chkBlockBeep_CheckedChanged); + // + // chkManualInputForbidden + // + this.chkManualInputForbidden.AutoSize = true; + this.chkManualInputForbidden.Location = new System.Drawing.Point(291, 3); + this.chkManualInputForbidden.Name = "chkManualInputForbidden"; + this.chkManualInputForbidden.Size = new System.Drawing.Size(122, 17); + this.chkManualInputForbidden.TabIndex = 4; + this.chkManualInputForbidden.Text = "绂佹鎵嬪姩杈撳叆鏉$爜"; + this.chkManualInputForbidden.UseVisualStyleBackColor = true; + this.chkManualInputForbidden.CheckedChanged += new System.EventHandler(this.chkManualInputForbidden_CheckedChanged); + // + // btnLightSwitch + // + this.btnLightSwitch.Location = new System.Drawing.Point(419, 3); + this.btnLightSwitch.Name = "btnLightSwitch"; + this.btnLightSwitch.Size = new System.Drawing.Size(75, 36); + this.btnLightSwitch.TabIndex = 5; + this.btnLightSwitch.Text = "鏃ュ厜鐏紑鍏�"; + this.btnLightSwitch.UseVisualStyleBackColor = true; + this.btnLightSwitch.Click += new System.EventHandler(this.btnLightSwitch_Click); + // + // M071_ShortcutFrm + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(800, 450); + this.Controls.Add(this.flowLayoutPanel1); + this.Name = "M071_ShortcutFrm"; this.Text = "M071_ShortcutFrm"; + this.flowLayoutPanel1.ResumeLayout(false); + this.flowLayoutPanel1.PerformLayout(); + this.ResumeLayout(false); + } #endregion + + private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1; + private System.Windows.Forms.CheckBox chkBlockSaftyDoor; + private System.Windows.Forms.CheckBox chkBlockSafetyBeam; + private System.Windows.Forms.CheckBox chkBlockBeep; + private System.Windows.Forms.CheckBox chkManualInputForbidden; + private System.Windows.Forms.Button btnLightSwitch; } } \ No newline at end of file diff --git a/src/Bro.M071.Process/UI/M071_ShortcutFrm.cs b/src/Bro.M071.Process/UI/M071_ShortcutFrm.cs index 245d16d..d5961a9 100644 --- a/src/Bro.M071.Process/UI/M071_ShortcutFrm.cs +++ b/src/Bro.M071.Process/UI/M071_ShortcutFrm.cs @@ -6,6 +6,7 @@ using System.Drawing; using System.Linq; using System.Text; +using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; @@ -17,6 +18,81 @@ public M071_ShortcutFrm() { InitializeComponent(); + + this.Load += (s, e) => + { + loadHandle.Set(); + }; + } + + ManualResetEventSlim loadHandle = new ManualResetEventSlim(false); + M071Config Config => Process?.IConfig as M071Config; + M071Process Process_M071 => Process as M071Process; + + protected override bool IsLogin + { + get => base.IsLogin; + set + { + base.IsLogin = value; + + Task.Run(() => + { + if (loadHandle.Wait(1000)) + { + this.Invoke(new Action(() => + { + chkBlockSafetyBeam.Enabled = chkBlockSaftyDoor.Enabled = IsLogin; + })); + } + }); + } + } + + public override void OnProcessUpdated() + { + base.OnProcessUpdated(); + + Task.Run(() => + { + if (loadHandle.Wait(1000)) + { + this.Invoke(new Action(() => + { + chkBlockBeep.Checked = Config.IsBeepBlocked; + chkBlockSafetyBeam.Checked = Config.IsSafetyBeamBlocked; + chkBlockSaftyDoor.Checked = Config.IsSafetyDoorBlocked; + chkManualInputForbidden.Checked = Config.IsBarcodeManulInputBlocked; + })); + } + }); + } + + private void chkBlockSaftyDoor_CheckedChanged(object sender, EventArgs e) + { + Config.IsSafetyDoorBlocked = chkBlockSaftyDoor.Checked; + } + + private void chkBlockSafetyBeam_CheckedChanged(object sender, EventArgs e) + { + Config.IsSafetyBeamBlocked = chkBlockSafetyBeam.Checked; + } + + private void chkBlockBeep_CheckedChanged(object sender, EventArgs e) + { + Config.IsBeepBlocked = chkBlockBeep.Checked; + } + + private void chkManualInputForbidden_CheckedChanged(object sender, EventArgs e) + { + Config.IsBarcodeManulInputBlocked = chkManualInputForbidden.Checked; + } + + bool isLightOn = false; + private void btnLightSwitch_Click(object sender, EventArgs e) + { + isLightOn = !isLightOn; + Process_M071.SwitchLight(isLightOn); } } } diff --git a/src/Bro.M071.Process/UI/M071_ShortcutFrm.resx b/src/Bro.M071.Process/UI/M071_ShortcutFrm.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/src/Bro.M071.Process/UI/M071_ShortcutFrm.resx @@ -0,0 +1,120 @@ +锘�<?xml version="1.0" encoding="utf-8"?> +<root> + <!-- + Microsoft ResX Schema + + Version 2.0 + + The primary goals of this format is to allow a simple XML format + that is mostly human readable. The generation and parsing of the + various data types are done through the TypeConverter classes + associated with the data types. + + Example: + + ... ado.net/XML headers & schema ... + <resheader name="resmimetype">text/microsoft-resx</resheader> + <resheader name="version">2.0</resheader> + <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> + <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> + <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> + <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> + <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> + <value>[base64 mime encoded serialized .NET Framework object]</value> + </data> + <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> + <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> + <comment>This is a comment</comment> + </data> + + There are any number of "resheader" rows that contain simple + name/value pairs. + + Each data row contains a name, and value. The row also contains a + type or mimetype. Type corresponds to a .NET class that support + text/value conversion through the TypeConverter architecture. + Classes that don't support this are serialized and stored with the + mimetype set. + + The mimetype is used for serialized objects, and tells the + ResXResourceReader how to depersist the object. This is currently not + extensible. For a given mimetype the value must be set accordingly: + + Note - application/x-microsoft.net.object.binary.base64 is the format + that the ResXResourceWriter will generate, however the reader can + read any of the formats listed below. + + mimetype: application/x-microsoft.net.object.binary.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.soap.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Soap.SoapFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.bytearray.base64 + value : The object must be serialized into a byte array + : using a System.ComponentModel.TypeConverter + : and then encoded with base64 encoding. + --> + <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> + <xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> + <xsd:element name="root" msdata:IsDataSet="true"> + <xsd:complexType> + <xsd:choice maxOccurs="unbounded"> + <xsd:element name="metadata"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" /> + </xsd:sequence> + <xsd:attribute name="name" use="required" type="xsd:string" /> + <xsd:attribute name="type" type="xsd:string" /> + <xsd:attribute name="mimetype" type="xsd:string" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="assembly"> + <xsd:complexType> + <xsd:attribute name="alias" type="xsd:string" /> + <xsd:attribute name="name" type="xsd:string" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="data"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> + <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> + <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="resheader"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" /> + </xsd:complexType> + </xsd:element> + </xsd:choice> + </xsd:complexType> + </xsd:element> + </xsd:schema> + <resheader name="resmimetype"> + <value>text/microsoft-resx</value> + </resheader> + <resheader name="version"> + <value>2.0</value> + </resheader> + <resheader name="reader"> + <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <resheader name="writer"> + <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> +</root> \ No newline at end of file diff --git a/src/Bro.UI.Config/AdvancedPwdFrm.cs b/src/Bro.UI.Config/AdvancedPwdFrm.cs index f710f0b..275c534 100644 --- a/src/Bro.UI.Config/AdvancedPwdFrm.cs +++ b/src/Bro.UI.Config/AdvancedPwdFrm.cs @@ -76,5 +76,11 @@ CheckInputPassword(); } } + + private void btnExitLogin_Click(object sender, EventArgs e) + { + OnLoginOK?.Invoke(false); + this.DialogResult = DialogResult.Abort; + } } } diff --git a/src/Bro.UI.Config/AdvancedPwdFrm.designer.cs b/src/Bro.UI.Config/AdvancedPwdFrm.designer.cs index 8c385ef..bf7e6b6 100644 --- a/src/Bro.UI.Config/AdvancedPwdFrm.designer.cs +++ b/src/Bro.UI.Config/AdvancedPwdFrm.designer.cs @@ -32,11 +32,12 @@ this.label1 = new System.Windows.Forms.Label(); this.btnCancel = new System.Windows.Forms.Button(); this.btnOK = new System.Windows.Forms.Button(); + this.btnExitLogin = new System.Windows.Forms.Button(); this.SuspendLayout(); // // txtPwd // - this.txtPwd.Font = new System.Drawing.Font("SimSun", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.txtPwd.Font = new System.Drawing.Font("瀹嬩綋", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.txtPwd.Location = new System.Drawing.Point(126, 28); this.txtPwd.Name = "txtPwd"; this.txtPwd.PasswordChar = '*'; @@ -47,7 +48,7 @@ // label1 // this.label1.AutoSize = true; - this.label1.Font = new System.Drawing.Font("SimSun", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.label1.Font = new System.Drawing.Font("瀹嬩綋", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.label1.Location = new System.Drawing.Point(32, 32); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(52, 14); @@ -57,7 +58,7 @@ // btnCancel // this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.btnCancel.Font = new System.Drawing.Font("SimSun", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.btnCancel.Font = new System.Drawing.Font("瀹嬩綋", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.btnCancel.Location = new System.Drawing.Point(208, 63); this.btnCancel.Name = "btnCancel"; this.btnCancel.Size = new System.Drawing.Size(75, 23); @@ -68,7 +69,7 @@ // // btnOK // - this.btnOK.Font = new System.Drawing.Font("SimSun", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.btnOK.Font = new System.Drawing.Font("瀹嬩綋", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.btnOK.Location = new System.Drawing.Point(289, 63); this.btnOK.Name = "btnOK"; this.btnOK.Size = new System.Drawing.Size(75, 23); @@ -76,6 +77,18 @@ this.btnOK.Text = "OK"; this.btnOK.UseVisualStyleBackColor = true; this.btnOK.Click += new System.EventHandler(this.button2_Click); + // + // btnExitLogin + // + this.btnExitLogin.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.btnExitLogin.Font = new System.Drawing.Font("瀹嬩綋", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.btnExitLogin.Location = new System.Drawing.Point(12, 63); + this.btnExitLogin.Name = "btnExitLogin"; + this.btnExitLogin.Size = new System.Drawing.Size(75, 23); + this.btnExitLogin.TabIndex = 2; + this.btnExitLogin.Text = "閫�鍑虹櫥褰�"; + this.btnExitLogin.UseVisualStyleBackColor = true; + this.btnExitLogin.Click += new System.EventHandler(this.btnExitLogin_Click); // // AdvancedPwdFrm // @@ -85,6 +98,7 @@ this.ClientSize = new System.Drawing.Size(388, 98); this.ControlBox = false; this.Controls.Add(this.btnOK); + this.Controls.Add(this.btnExitLogin); this.Controls.Add(this.btnCancel); this.Controls.Add(this.label1); this.Controls.Add(this.txtPwd); @@ -103,5 +117,6 @@ private System.Windows.Forms.Label label1; private System.Windows.Forms.Button btnCancel; private System.Windows.Forms.Button btnOK; + private System.Windows.Forms.Button btnExitLogin; } } \ No newline at end of file diff --git a/src/Bro.UI.Config/MainFrm.cs b/src/Bro.UI.Config/MainFrm.cs index f35297d..39c483d 100644 --- a/src/Bro.UI.Config/MainFrm.cs +++ b/src/Bro.UI.Config/MainFrm.cs @@ -317,7 +317,7 @@ private void OnLoginOK(bool isLogin) { - IsLogin = true; + IsLogin = isLogin; } #endregion diff --git a/src/Bro.UI.Model.Winform/UI/DockContent/MenuFrmBase.cs b/src/Bro.UI.Model.Winform/UI/DockContent/MenuFrmBase.cs index 90420b4..007a6db 100644 --- a/src/Bro.UI.Model.Winform/UI/DockContent/MenuFrmBase.cs +++ b/src/Bro.UI.Model.Winform/UI/DockContent/MenuFrmBase.cs @@ -81,7 +81,7 @@ #endregion #region Login - protected bool IsLogin { get; set; } + protected virtual bool IsLogin { get; set; } public virtual void SetLoginStatus(bool isLogin) { -- Gitblit v1.8.0