From c878077bc971b2731e7b957be77fe748f939c735 Mon Sep 17 00:00:00 2001 From: liuwf Date: Tue, 12 Nov 2024 14:04:28 +0800 Subject: [PATCH] =?UTF-8?q?add-=E6=89=93=E5=8D=B0=E6=9C=BA=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E6=B7=BB=E5=8A=A0=E7=A9=BA=E7=99=BD=E9=A1=B5=E5=8F=82?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PrintBarCode/Helper/DebugConfig.cs | 10 ++++++ PrintBarCode/Helper/PrintHelper.cs | 4 +++ PrintBarCode/MainForm.Designer.cs | 49 ++++++++++++++++++++++++++++-- PrintBarCode/MainForm.cs | 13 +++++--- PrintBarCode/MessageClient.cs | 3 +- PrintBarCode/PrintBarCode.csproj | 1 + 6 files changed, 71 insertions(+), 9 deletions(-) diff --git a/PrintBarCode/Helper/DebugConfig.cs b/PrintBarCode/Helper/DebugConfig.cs index 4f21434..58325c8 100644 --- a/PrintBarCode/Helper/DebugConfig.cs +++ b/PrintBarCode/Helper/DebugConfig.cs @@ -48,6 +48,16 @@ namespace PrintBarCode.Helper + /// + //是否打印空白页,1打印,0不打印 + /// + public string BlankFlag + { + get { return iniHelper.IniReadValue("system", "BlankFlag"); } + set { iniHelper.IniWriteValue("system", "BlankFlag", value); } + } + + } } diff --git a/PrintBarCode/Helper/PrintHelper.cs b/PrintBarCode/Helper/PrintHelper.cs index eed8185..17f8319 100644 --- a/PrintBarCode/Helper/PrintHelper.cs +++ b/PrintBarCode/Helper/PrintHelper.cs @@ -141,6 +141,10 @@ namespace PrintBarCode.Helper private string ZPLStr(string data, string name, float Size = 9f) { + if(Size <=15f) + { + Size = 15f; + } Bitmap bitmap = CreateImage(data, new Font("黑体", Size, FontStyle.Bold)); string text = ((bitmap.Size.Width / 8 + ((bitmap.Size.Width % 8 != 0) ? 1 : 0)) * bitmap.Size.Height).ToString(); string text2 = (bitmap.Size.Width / 8 + ((bitmap.Size.Width % 8 != 0) ? 1 : 0)).ToString(); diff --git a/PrintBarCode/MainForm.Designer.cs b/PrintBarCode/MainForm.Designer.cs index b34c1e3..31750f8 100644 --- a/PrintBarCode/MainForm.Designer.cs +++ b/PrintBarCode/MainForm.Designer.cs @@ -31,6 +31,9 @@ label1 = new Label(); logList = new ListBox(); label2 = new Label(); + button1 = new Button(); + label3 = new Label(); + BlankFlag = new Label(); SuspendLayout(); // // label1 @@ -47,7 +50,7 @@ // logList // logList.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; - logList.BackColor = SystemColors.InactiveCaption; + logList.BackColor = Color.Gainsboro; logList.Font = new Font("Microsoft YaHei UI", 14.25F, FontStyle.Bold, GraphicsUnit.Point); logList.ForeColor = Color.ForestGreen; logList.FormattingEnabled = true; @@ -55,7 +58,7 @@ logList.ItemHeight = 26; logList.Location = new Point(0, 157); logList.Name = "logList"; - logList.Size = new Size(1454, 654); + logList.Size = new Size(1454, 680); logList.TabIndex = 1; // // label2 @@ -69,12 +72,49 @@ label2.TabIndex = 2; label2.Text = "打印日志:"; // + // button1 + // + button1.BackColor = Color.MediumAquamarine; + button1.Font = new Font("Microsoft YaHei UI", 12F, FontStyle.Regular, GraphicsUnit.Point); + button1.Location = new Point(1257, 113); + button1.Name = "button1"; + button1.Size = new Size(83, 38); + button1.TabIndex = 3; + button1.Text = "修 改"; + button1.UseVisualStyleBackColor = false; + button1.Click += button1_Click; + // + // label3 + // + label3.AutoSize = true; + label3.BackColor = SystemColors.ActiveCaption; + label3.Font = new Font("Microsoft YaHei UI", 15F, FontStyle.Bold, GraphicsUnit.Point); + label3.ForeColor = Color.Green; + label3.Location = new Point(1006, 118); + label3.Name = "label3"; + label3.Size = new Size(198, 27); + label3.TabIndex = 4; + label3.Text = "结束是否打印空白页:"; + // + // BlankFlag + // + BlankFlag.AutoSize = true; + BlankFlag.Font = new Font("Microsoft YaHei UI", 14.25F, FontStyle.Regular, GraphicsUnit.Point); + BlankFlag.ForeColor = Color.Blue; + BlankFlag.Location = new Point(1210, 119); + BlankFlag.Name = "BlankFlag"; + BlankFlag.Size = new Size(0, 25); + BlankFlag.TabIndex = 5; + // // MainForm // AutoScaleDimensions = new SizeF(7F, 17F); AutoScaleMode = AutoScaleMode.Font; BackColor = SystemColors.ActiveCaption; - ClientSize = new Size(1454, 811); + ClientSize = new Size(1454, 837); + Controls.Add(BlankFlag); + Controls.Add(label3); + Controls.Add(button1); Controls.Add(label2); Controls.Add(logList); Controls.Add(label1); @@ -92,5 +132,8 @@ private Label label1; private ListBox logList; private Label label2; + private Button button1; + private Label label3; + private Label BlankFlag; } } \ No newline at end of file diff --git a/PrintBarCode/MainForm.cs b/PrintBarCode/MainForm.cs index 8daccda..5b6accd 100644 --- a/PrintBarCode/MainForm.cs +++ b/PrintBarCode/MainForm.cs @@ -9,7 +9,7 @@ namespace PrintBarCode { public partial class MainForm : Form { - + private DebugConfig debugConfig = DebugConfig.Instance; public MainForm() { @@ -18,6 +18,7 @@ namespace PrintBarCode addLog("ӡɹ......"); + BlankFlag.Text = debugConfig.BlankFlag=="1"?"":""; } @@ -50,11 +51,13 @@ namespace PrintBarCode e.Cancel = true; // ״̬ΪС this.WindowState = FormWindowState.Minimized; - - } - - + } + private void button1_Click(object sender, EventArgs e) + { + debugConfig.BlankFlag = debugConfig.BlankFlag == "1" ? "0" : "1"; + BlankFlag.Text = debugConfig.BlankFlag == "1" ? "" : ""; + } } } \ No newline at end of file diff --git a/PrintBarCode/MessageClient.cs b/PrintBarCode/MessageClient.cs index 8794c70..237a15a 100644 --- a/PrintBarCode/MessageClient.cs +++ b/PrintBarCode/MessageClient.cs @@ -124,7 +124,7 @@ namespace PrintBarCode } else { - if(IsPrintBlank == 1) + if(IsPrintBlank == 1 && debugConfig.BlankFlag=="1") { printBusiness.PrintBlankPage(); IsPrintBlank = 0; @@ -135,6 +135,7 @@ namespace PrintBarCode catch (Exception ex) { Console.WriteLine("处理消息时发生错误"); + IsPrintBlank = 0; } } }); diff --git a/PrintBarCode/PrintBarCode.csproj b/PrintBarCode/PrintBarCode.csproj index a479b7f..389c34d 100644 --- a/PrintBarCode/PrintBarCode.csproj +++ b/PrintBarCode/PrintBarCode.csproj @@ -20,6 +20,7 @@ +