/[RomCheater]/trunk/Win32/libWin32/Win32/UI/MaskedHexBox.cs
ViewVC logotype

Diff of /trunk/Win32/libWin32/Win32/UI/MaskedHexBox.cs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

--- trunk/Win32/libWin32/Win32/UI/MaskedHexBox.cs	2014/09/17 06:43:30	902
+++ trunk/Win32/libWin32/Win32/UI/MaskedHexBox.cs	2014/09/17 12:44:22	903
@@ -30,6 +30,8 @@
             txtMaskedHexBox.InsertKeyMode = InsertKeyMode.Overwrite;
             this.AutoSize = true;
             OnAutoSizeChanged(new EventArgs());
+            //this.TextLength = 8;
+            //CreateTypeSize<ulong>();
         }
         [Browsable(true)]
         [Category("Property Changed")]
@@ -43,7 +45,7 @@
         [Browsable(true)]
         [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
         [EditorBrowsable(EditorBrowsableState.Always)]
-        public override bool AutoSize { get { return base.AutoSize; } set { if (base.AutoSize != value) { base.AutoSize = value; OnAutoSizeChanged(new EventArgs()); } } }
+        public override bool AutoSize { get { return base.AutoSize; } set { base.AutoSize = value; OnAutoSizeChanged(new EventArgs()); } }
 
         protected override void OnAutoSizeChanged(EventArgs e)
         {
@@ -131,7 +133,8 @@
                     case 7:
                     case 8: this.Text = string.Format("0x{0:x8}", value); break;
                     default: this.Text = string.Format("0x{0:x" + this.TextLength + "}", value); break;
-                }               
+                }
+                DoResize();
             }
         }
         private bool _isAddressMask;
@@ -154,6 +157,7 @@
             int size = Marshal.SizeOf(type) * 2;
             this.MaxLength = size;
             this.TextLength = this.MaxLength;
+            DoResize();
         }
 
         private int _MaxLength;
@@ -232,11 +236,11 @@
             DoResize();
         }
 
-        protected override void OnResize(EventArgs e)
-        {
-            base.OnResize(e);
-            DoResize();
-        }
+        //protected override void OnResize(EventArgs e)
+        //{
+        //    base.OnResize(e);
+        //    DoResize();
+        //}
 
         private void DoResize()
         {
@@ -264,19 +268,29 @@
             {
                 var size = g.MeasureString(t, this.Font).ToSize();
                 int width = size.Width; // the minimum size of the textbox
-                double growth = (double)size.Width / 0.5;
+                double growth = (double)size.Width;
 
+                //switch (this.TextLength)
+                //{
+                //    case 2: this.Width = (int)growth + 25; break;
+                //    case 4: this.Width = (int)growth + 15; break;
+                //    case 8: goto default;
+                //    case 16: this.Width = (int)growth - 70; break;
+                //    default:
+                //        this.Width = (int)growth - 15; break;
+                //}
                 switch (this.TextLength)
                 {
-                    case 2: this.Width = (int)growth + 25; break;
-                    case 4: this.Width = (int)growth + 15; break;
+                    case 2: width = (int)growth; break;
+                    case 4: width = (int)growth; break;
                     case 8: goto default;
-                    case 16: this.Width = (int)growth - 70; break;
+                    case 16: width = (int)growth; break;
                     default:
-                        this.Width = (int)growth - 15; break;
+                        width = (int)growth; break;
                 }
 
-                
+                txtMaskedHexBox.Width = width + 5;
+                this.Width = width;
             }
         }
 

 

  ViewVC Help
Powered by ViewVC 1.1.22