External/Aga.Controls/Tree/NodeControls/NodeNumericUpDown.cs
changeset 345 0c551e8818e0
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/External/Aga.Controls/Tree/NodeControls/NodeNumericUpDown.cs	Sun May 27 15:16:19 2012 +0000
     1.3 @@ -0,0 +1,115 @@
     1.4 +using System;
     1.5 +using System.Collections.Generic;
     1.6 +using System.Text;
     1.7 +using System.Drawing;
     1.8 +using System.Windows.Forms;
     1.9 +using System.Reflection;
    1.10 +using System.ComponentModel;
    1.11 +using System.Drawing.Design;
    1.12 +
    1.13 +namespace Aga.Controls.Tree.NodeControls
    1.14 +{
    1.15 +	public class NodeNumericUpDown : BaseTextControl
    1.16 +	{
    1.17 +		#region Properties
    1.18 +
    1.19 +		private int _editorWidth = 100;
    1.20 +		[DefaultValue(100)]
    1.21 +		public int EditorWidth
    1.22 +		{
    1.23 +			get { return _editorWidth; }
    1.24 +			set { _editorWidth = value; }
    1.25 +		}
    1.26 +
    1.27 +		private int _decimalPlaces = 0;
    1.28 +		[Category("Data"), DefaultValue(0)]
    1.29 +		public int DecimalPlaces
    1.30 +		{
    1.31 +			get
    1.32 +			{
    1.33 +				return this._decimalPlaces;
    1.34 +			}
    1.35 +			set
    1.36 +			{
    1.37 +				this._decimalPlaces = value;
    1.38 +			}
    1.39 +		}
    1.40 +
    1.41 +		private decimal _increment = 1;
    1.42 +		[Category("Data"), DefaultValue(1)]
    1.43 +		public decimal Increment
    1.44 +		{
    1.45 +			get
    1.46 +			{
    1.47 +				return this._increment;
    1.48 +			}
    1.49 +			set
    1.50 +			{
    1.51 +				this._increment = value;
    1.52 +			}
    1.53 +		}
    1.54 +
    1.55 +		private decimal _minimum = 0;
    1.56 +		[Category("Data"), DefaultValue(0)]
    1.57 +		public decimal Minimum
    1.58 +		{
    1.59 +			get
    1.60 +			{
    1.61 +				return _minimum;
    1.62 +			}
    1.63 +			set
    1.64 +			{
    1.65 +				_minimum = value;
    1.66 +			}
    1.67 +		}
    1.68 +
    1.69 +		private decimal _maximum = 100;
    1.70 +		[Category("Data"), DefaultValue(100)]
    1.71 +		public decimal Maximum
    1.72 +		{
    1.73 +			get
    1.74 +			{
    1.75 +				return this._maximum;
    1.76 +			}
    1.77 +			set
    1.78 +			{
    1.79 +				this._maximum = value;
    1.80 +			}
    1.81 +		}
    1.82 +
    1.83 +		#endregion
    1.84 +
    1.85 +		public NodeNumericUpDown()
    1.86 +		{
    1.87 +		}
    1.88 +
    1.89 +		protected override Size CalculateEditorSize(EditorContext context)
    1.90 +		{
    1.91 +			if (Parent.UseColumns)
    1.92 +				return context.Bounds.Size;
    1.93 +			else
    1.94 +				return new Size(EditorWidth, context.Bounds.Height);
    1.95 +		}
    1.96 +
    1.97 +		protected override Control CreateEditor(TreeNodeAdv node)
    1.98 +		{
    1.99 +			NumericUpDown num = new NumericUpDown();
   1.100 +			num.Increment = Increment;
   1.101 +			num.DecimalPlaces = DecimalPlaces;
   1.102 +			num.Minimum = Minimum;
   1.103 +			num.Maximum = Maximum;
   1.104 +			num.Value = (decimal)GetValue(node);
   1.105 +			SetEditControlProperties(num, node);
   1.106 +			return num;
   1.107 +		}
   1.108 +
   1.109 +		protected override void DisposeEditor(Control editor)
   1.110 +		{
   1.111 +		}
   1.112 +
   1.113 +		protected override void DoApplyChanges(TreeNodeAdv node, Control editor)
   1.114 +		{
   1.115 +			SetValue(node, (editor as NumericUpDown).Value);
   1.116 +		}
   1.117 +	}
   1.118 +}