Skip to content

Commit

Permalink
- fixed wrong texture for ColorPicker (BrightnessSaturationPicker con…
Browse files Browse the repository at this point in the history
…trol);

- removed callbacks from NumericUpDown;
  • Loading branch information
Meragon committed Mar 1, 2017
1 parent ca529fc commit fc54e8c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 25 deletions.
2 changes: 1 addition & 1 deletion System/Windows/Forms/ColorPicker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ private void _UpdateImage()

for (int k = 0; k < _image.Height; k++)
{
luminosity = (float)k / _image.Height;
luminosity = 1f - (float)k / _image.Height;

// HSL to RGB convertion.
Color pixelColor = Color.FromHsb(hue, saturation, luminosity);
Expand Down
4 changes: 2 additions & 2 deletions System/Windows/Forms/Form.cs
Original file line number Diff line number Diff line change
Expand Up @@ -350,13 +350,13 @@ public void SetResize(ControlResizeTypes resize)
break;
}
}
public void Show(bool shouldFocus = true)
public void Show(bool fShouldFocus = true)
{
Visible = true;
int self = Owner.Forms.FindIndex(x => x == this);
if (self == -1)
Owner.Forms.Add(this);
if (shouldFocus)
if (fShouldFocus)
{
Focus();
_SelectFirstControl();
Expand Down
35 changes: 13 additions & 22 deletions System/Windows/Forms/NumericUpDown.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,9 @@ public decimal Value
_value = value;
valueText = value.ToString();
if (changed)
{
ValueChanged(this, null);
if (ValueChangedCallback != null)
ValueChangedCallback.Invoke(ValueChangedCallbackInfo);
}
}
}
public CallbackDelegate ValueChangedCallback { get; set; }
public object ValueChangedCallbackInfo { get; set; }

public NumericUpDown() : this(true)
{
Expand Down Expand Up @@ -114,27 +108,19 @@ public NumericUpDown(bool initButtons)
Controls.Add(ButtonDecrease);
}

Resize += _UpdateButtonsLocation;
LostFocus += (s, a) => { _ConfirmValue(); };
Resize += UpdateButtonsLocation;
LostFocus += (s, a) => { ConfirmValue(); };
}

private void _ConfirmValue()
public event EventHandler ValueChanged = delegate { };

protected void ConfirmValue()
{
decimal value = Value;
if (decimal.TryParse(valueText, out value))
if (Value != value)
Value = value;
}
private void _UpdateButtonsLocation(object sender, EventArgs e)
{
if (ButtonIncrease != null)
ButtonIncrease.Location = new Point(Width - 16, Height / 2 - 8);
if (ButtonDecrease != null)
ButtonDecrease.Location = new Point(Width - 16, Height / 2);
}

public event EventHandler ValueChanged = delegate { };

public void HideButtons()
{
ButtonIncrease.Visible = false;
Expand All @@ -151,7 +137,7 @@ protected override void OnKeyPress(KeyEventArgs e)
base.OnKeyPress(e);

if (e.KeyCode == UnityEngine.KeyCode.Return)
_ConfirmValue();
ConfirmValue();
}
protected override void OnMouseWheel(MouseEventArgs e)
{
Expand Down Expand Up @@ -187,7 +173,12 @@ public void ShowButtons()
ButtonIncrease.Visible = true;
ButtonDecrease.Visible = true;
}

public delegate void CallbackDelegate(object data);
protected void UpdateButtonsLocation(object sender, EventArgs e)
{
if (ButtonIncrease != null)
ButtonIncrease.Location = new Point(Width - 16, Height / 2 - 8);
if (ButtonDecrease != null)
ButtonDecrease.Location = new Point(Width - 16, Height / 2);
}
}
}

0 comments on commit fc54e8c

Please sign in to comment.