1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Text;
using System.Windows.Forms;
using QuickRoute.BusinessEntities.Numeric;
namespace QuickRoute.Controls
{
public partial class CustomUpDown : NumericUpDown
{
readonly double[] deltas = new double[] { 1, 10, 100 };
double value = 0;
NumericConverter numericConverter = new NumericConverter();
public override void DownButton()
{
if ((Control.ModifierKeys & Keys.Control) == Keys.Control && (Control.ModifierKeys & Keys.Shift) == Keys.Shift) value -= deltas[2];
else if ((Control.ModifierKeys & Keys.Control) == Keys.Control) value -= deltas[1];
else value -= deltas[0];
}
public override void UpButton()
{
if ((Control.ModifierKeys & Keys.Control) == Keys.Control && (Control.ModifierKeys & Keys.Shift) == Keys.Shift) value += deltas[2];
else if ((Control.ModifierKeys & Keys.Control) == Keys.Control) value += deltas[1];
else value += deltas[0];
}
protected override void UpdateEditText()
{
numericConverter = new TimeConverter(TimeConverter.TimeConverterType.ElapsedTime);
double? tmpValue = numericConverter.ToNumeric(Text);
if (tmpValue.HasValue) Value = tmpValue.Value;
}
new public double Value
{
get { return value; }
set
{
this.value = value;
Text = numericConverter.ToString(this.value);
}
}
protected override void OnKeyDown(KeyEventArgs e)
{
}
protected override void OnKeyPress(KeyPressEventArgs e)
{
}
}
}
|