External/Aga.Controls/Tree/NodeControls/NodeNumericUpDown.cs
author moel.mich
Sun, 27 May 2012 15:16:19 +0000
changeset 345 0c551e8818e0
permissions -rw-r--r--
Added the source code of Aga.Controls (TreeViewAdv for .Net) version 1.7.0.0.
     1 using System;
     2 using System.Collections.Generic;
     3 using System.Text;
     4 using System.Drawing;
     5 using System.Windows.Forms;
     6 using System.Reflection;
     7 using System.ComponentModel;
     8 using System.Drawing.Design;
     9 
    10 namespace Aga.Controls.Tree.NodeControls
    11 {
    12 	public class NodeNumericUpDown : BaseTextControl
    13 	{
    14 		#region Properties
    15 
    16 		private int _editorWidth = 100;
    17 		[DefaultValue(100)]
    18 		public int EditorWidth
    19 		{
    20 			get { return _editorWidth; }
    21 			set { _editorWidth = value; }
    22 		}
    23 
    24 		private int _decimalPlaces = 0;
    25 		[Category("Data"), DefaultValue(0)]
    26 		public int DecimalPlaces
    27 		{
    28 			get
    29 			{
    30 				return this._decimalPlaces;
    31 			}
    32 			set
    33 			{
    34 				this._decimalPlaces = value;
    35 			}
    36 		}
    37 
    38 		private decimal _increment = 1;
    39 		[Category("Data"), DefaultValue(1)]
    40 		public decimal Increment
    41 		{
    42 			get
    43 			{
    44 				return this._increment;
    45 			}
    46 			set
    47 			{
    48 				this._increment = value;
    49 			}
    50 		}
    51 
    52 		private decimal _minimum = 0;
    53 		[Category("Data"), DefaultValue(0)]
    54 		public decimal Minimum
    55 		{
    56 			get
    57 			{
    58 				return _minimum;
    59 			}
    60 			set
    61 			{
    62 				_minimum = value;
    63 			}
    64 		}
    65 
    66 		private decimal _maximum = 100;
    67 		[Category("Data"), DefaultValue(100)]
    68 		public decimal Maximum
    69 		{
    70 			get
    71 			{
    72 				return this._maximum;
    73 			}
    74 			set
    75 			{
    76 				this._maximum = value;
    77 			}
    78 		}
    79 
    80 		#endregion
    81 
    82 		public NodeNumericUpDown()
    83 		{
    84 		}
    85 
    86 		protected override Size CalculateEditorSize(EditorContext context)
    87 		{
    88 			if (Parent.UseColumns)
    89 				return context.Bounds.Size;
    90 			else
    91 				return new Size(EditorWidth, context.Bounds.Height);
    92 		}
    93 
    94 		protected override Control CreateEditor(TreeNodeAdv node)
    95 		{
    96 			NumericUpDown num = new NumericUpDown();
    97 			num.Increment = Increment;
    98 			num.DecimalPlaces = DecimalPlaces;
    99 			num.Minimum = Minimum;
   100 			num.Maximum = Maximum;
   101 			num.Value = (decimal)GetValue(node);
   102 			SetEditControlProperties(num, node);
   103 			return num;
   104 		}
   105 
   106 		protected override void DisposeEditor(Control editor)
   107 		{
   108 		}
   109 
   110 		protected override void DoApplyChanges(TreeNodeAdv node, Control editor)
   111 		{
   112 			SetValue(node, (editor as NumericUpDown).Value);
   113 		}
   114 	}
   115 }