Some fixes to slider
This commit is contained in:
parent
e22005bbea
commit
7aa040aebf
Binary file not shown.
Binary file not shown.
@ -43,6 +43,7 @@ using System.Drawing.Imaging;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Windows.Forms;
|
||||
using Switch_Toolbox.Library.Forms;
|
||||
using System.Globalization;
|
||||
|
||||
namespace BarSlider
|
||||
{
|
||||
@ -177,7 +178,8 @@ namespace BarSlider
|
||||
textBox.Width = ClientSize.Width - 50;
|
||||
textBox.Height = ClientSize.Height;
|
||||
textBox.TextChanged += new EventHandler(OnTextChanged);
|
||||
textBox.KeyDown += new KeyEventHandler(OnKeyPressed);
|
||||
textBox.KeyDown += new KeyEventHandler(OnKeyDown);
|
||||
textBox.KeyPress += new KeyPressEventHandler(OnKeyPressed);
|
||||
textBox.ReadOnly = false;
|
||||
textBox.ForeColor = this.ForeColor;
|
||||
textBox.BackColor = ActiveEditColor;
|
||||
@ -187,7 +189,7 @@ namespace BarSlider
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
private void OnKeyPressed(object sender, KeyEventArgs e)
|
||||
private void OnKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.KeyCode == Keys.Enter)
|
||||
{
|
||||
@ -195,6 +197,19 @@ namespace BarSlider
|
||||
}
|
||||
}
|
||||
|
||||
private void OnKeyPressed(object sender, KeyPressEventArgs e)
|
||||
{
|
||||
NumberFormatInfo numberFormat = CultureInfo.CurrentCulture.NumberFormat;
|
||||
string numberDecimalSeparator = numberFormat.NumberDecimalSeparator;
|
||||
string numberGroupSeparator = numberFormat.NumberGroupSeparator;
|
||||
string negativeSign = numberFormat.NegativeSign;
|
||||
string text = e.KeyChar.ToString();
|
||||
if (!char.IsDigit(e.KeyChar) && !text.Equals(numberDecimalSeparator) && !text.Equals(numberGroupSeparator) && !text.Equals(negativeSign) && e.KeyChar != '\b' && (Control.ModifierKeys & (Keys.Control | Keys.Alt)) == Keys.None)
|
||||
{
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTextChanged(object sender, EventArgs e)
|
||||
{
|
||||
float value;
|
||||
|
Loading…
x
Reference in New Issue
Block a user