1
0
mirror of synced 2025-02-25 22:38:07 +01:00

Some fixes to slider

This commit is contained in:
KillzXGaming 2019-06-10 20:58:12 -04:00
parent e22005bbea
commit 7aa040aebf
3 changed files with 17 additions and 2 deletions

View File

@ -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;