@@ -55,15 +55,9 @@ public decimal Value
5555 _value = value ;
5656 valueText = value . ToString ( ) ;
5757 if ( changed )
58- {
5958 ValueChanged ( this , null ) ;
60- if ( ValueChangedCallback != null )
61- ValueChangedCallback . Invoke ( ValueChangedCallbackInfo ) ;
62- }
6359 }
6460 }
65- public CallbackDelegate ValueChangedCallback { get ; set ; }
66- public object ValueChangedCallbackInfo { get ; set ; }
6761
6862 public NumericUpDown ( ) : this ( true )
6963 {
@@ -114,27 +108,19 @@ public NumericUpDown(bool initButtons)
114108 Controls . Add ( ButtonDecrease ) ;
115109 }
116110
117- Resize += _UpdateButtonsLocation ;
118- LostFocus += ( s , a ) => { _ConfirmValue ( ) ; } ;
111+ Resize += UpdateButtonsLocation ;
112+ LostFocus += ( s , a ) => { ConfirmValue ( ) ; } ;
119113 }
120114
121- private void _ConfirmValue ( )
115+ public event EventHandler ValueChanged = delegate { } ;
116+
117+ protected void ConfirmValue ( )
122118 {
123119 decimal value = Value ;
124120 if ( decimal . TryParse ( valueText , out value ) )
125121 if ( Value != value )
126122 Value = value ;
127123 }
128- private void _UpdateButtonsLocation ( object sender , EventArgs e )
129- {
130- if ( ButtonIncrease != null )
131- ButtonIncrease . Location = new Point ( Width - 16 , Height / 2 - 8 ) ;
132- if ( ButtonDecrease != null )
133- ButtonDecrease . Location = new Point ( Width - 16 , Height / 2 ) ;
134- }
135-
136- public event EventHandler ValueChanged = delegate { } ;
137-
138124 public void HideButtons ( )
139125 {
140126 ButtonIncrease . Visible = false ;
@@ -151,7 +137,7 @@ protected override void OnKeyPress(KeyEventArgs e)
151137 base . OnKeyPress ( e ) ;
152138
153139 if ( e . KeyCode == UnityEngine . KeyCode . Return )
154- _ConfirmValue ( ) ;
140+ ConfirmValue ( ) ;
155141 }
156142 protected override void OnMouseWheel ( MouseEventArgs e )
157143 {
@@ -187,7 +173,12 @@ public void ShowButtons()
187173 ButtonIncrease . Visible = true ;
188174 ButtonDecrease . Visible = true ;
189175 }
190-
191- public delegate void CallbackDelegate ( object data ) ;
176+ protected void UpdateButtonsLocation ( object sender , EventArgs e )
177+ {
178+ if ( ButtonIncrease != null )
179+ ButtonIncrease . Location = new Point ( Width - 16 , Height / 2 - 8 ) ;
180+ if ( ButtonDecrease != null )
181+ ButtonDecrease . Location = new Point ( Width - 16 , Height / 2 ) ;
182+ }
192183 }
193184}
0 commit comments