Browse Source

添加Icon的可见控制

章政 8 years ago
parent
commit
ff8023034d

+ 21 - 21
UAS-MES/CustomControl/TextBoxWithIcon/TextBoxGeneratePaCode.Designer.cs

@@ -32,25 +32,9 @@
             this.enterTextBox1 = new UAS_MES.CustomControl.TextBoxWithIcon.EnterTextBox();
             this.GeneratePaCode = new System.Windows.Forms.PictureBox();
             this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
-            this.enterTextBox1 = new UAS_MES.CustomControl.TextBoxWithIcon.EnterTextBox();
             ((System.ComponentModel.ISupportInitialize)(this.GeneratePaCode)).BeginInit();
             this.SuspendLayout();
             // 
-            // GeneratePaCode
-            // 
-            this.GeneratePaCode.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
-            this.GeneratePaCode.Cursor = System.Windows.Forms.Cursors.Hand;
-            this.GeneratePaCode.Dock = System.Windows.Forms.DockStyle.Right;
-            this.GeneratePaCode.Image = global::UAS_MES.Properties.Resources.box_code;
-            this.GeneratePaCode.Location = new System.Drawing.Point(204, 0);
-            this.GeneratePaCode.Margin = new System.Windows.Forms.Padding(4);
-            this.GeneratePaCode.Name = "GeneratePaCode";
-            this.GeneratePaCode.Size = new System.Drawing.Size(26, 28);
-            this.GeneratePaCode.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
-            this.GeneratePaCode.TabIndex = 1;
-            this.GeneratePaCode.TabStop = false;
-            this.GeneratePaCode.Click += new System.EventHandler(this.GeneratePaCode_Click);
-            // 
             // enterTextBox1
             // 
             this.enterTextBox1.AllPower = null;
@@ -58,10 +42,10 @@
             this.enterTextBox1.Dock = System.Windows.Forms.DockStyle.Left;
             this.enterTextBox1.ID = null;
             this.enterTextBox1.Location = new System.Drawing.Point(0, 0);
-            this.enterTextBox1.Margin = new System.Windows.Forms.Padding(4);
+            this.enterTextBox1.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
             this.enterTextBox1.Name = "enterTextBox1";
             this.enterTextBox1.Power = null;
-            this.enterTextBox1.Size = new System.Drawing.Size(190, 28);
+            this.enterTextBox1.Size = new System.Drawing.Size(169, 25);
             this.enterTextBox1.Str = null;
             this.enterTextBox1.Str1 = null;
             this.enterTextBox1.Str2 = null;
@@ -69,15 +53,31 @@
             this.enterTextBox1.TextChanged += new System.EventHandler(this.enterTextBox1_TextChanged);
             this.enterTextBox1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.enterTextBox1_KeyDown);
             // 
+            // GeneratePaCode
+            // 
+            this.GeneratePaCode.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
+            this.GeneratePaCode.Cursor = System.Windows.Forms.Cursors.Hand;
+            this.GeneratePaCode.Dock = System.Windows.Forms.DockStyle.Right;
+            this.GeneratePaCode.Image = global::UAS_MES.Properties.Resources.box_code;
+            this.GeneratePaCode.Location = new System.Drawing.Point(181, 0);
+            this.GeneratePaCode.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
+            this.GeneratePaCode.Name = "GeneratePaCode";
+            this.GeneratePaCode.Size = new System.Drawing.Size(23, 23);
+            this.GeneratePaCode.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
+            this.GeneratePaCode.TabIndex = 1;
+            this.GeneratePaCode.TabStop = false;
+            this.GeneratePaCode.Click += new System.EventHandler(this.GeneratePaCode_Click);
+            // 
             // TextBoxGeneratePaCode
             // 
-            this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 18F);
+            this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.Controls.Add(this.GeneratePaCode);
             this.Controls.Add(this.enterTextBox1);
-            this.Margin = new System.Windows.Forms.Padding(4);
+            this.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
             this.Name = "TextBoxGeneratePaCode";
-            this.Size = new System.Drawing.Size(230, 28);
+            this.Size = new System.Drawing.Size(204, 23);
+            this.Load += new System.EventHandler(this.TextBoxGeneratePaCode_Load);
             this.SizeChanged += new System.EventHandler(this.TextBoxGeneratePaCode_SizeChanged);
             ((System.ComponentModel.ISupportInitialize)(this.GeneratePaCode)).EndInit();
             this.ResumeLayout(false);

+ 23 - 0
UAS-MES/CustomControl/TextBoxWithIcon/TextBoxGeneratePaCode.cs

@@ -12,6 +12,8 @@ namespace UAS_MES.CustomControl.TextBoxWithIcon
             toolTip1.SetToolTip(GeneratePaCode, "自动生成箱号");
         }
 
+        private bool showClickIcon;
+
         //重写Text方法,用于接收或者传递值
         public override string Text
         {
@@ -82,6 +84,19 @@ namespace UAS_MES.CustomControl.TextBoxWithIcon
             }
         }
 
+        public bool ShowClickIcon
+        {
+            get
+            {
+                return showClickIcon;
+            }
+
+            set
+            {
+                showClickIcon = value;
+            }
+        }
+
         public void GeneratePaCode_Click(object sender, EventArgs e)
         {
             IconClick?.Invoke(sender, new EventArgs());
@@ -117,5 +132,13 @@ namespace UAS_MES.CustomControl.TextBoxWithIcon
         {
             enterTextBox1.Width = Width - GeneratePaCode.Width - 3;
         }
+
+        private void TextBoxGeneratePaCode_Load(object sender, EventArgs e)
+        {
+            if (!showClickIcon)
+            {
+                GeneratePaCode.Visible = false;
+            }
+        }
     }
 }