moel@345: using System; moel@345: using System.Collections.Generic; moel@345: using System.Text; moel@345: using System.Drawing; moel@345: using System.Windows.Forms; moel@345: using System.Reflection; moel@345: using System.ComponentModel; moel@345: using System.Drawing.Design; moel@345: moel@345: namespace Aga.Controls.Tree.NodeControls moel@345: { moel@345: public class NodeNumericUpDown : BaseTextControl moel@345: { moel@345: #region Properties moel@345: moel@345: private int _editorWidth = 100; moel@345: [DefaultValue(100)] moel@345: public int EditorWidth moel@345: { moel@345: get { return _editorWidth; } moel@345: set { _editorWidth = value; } moel@345: } moel@345: moel@345: private int _decimalPlaces = 0; moel@345: [Category("Data"), DefaultValue(0)] moel@345: public int DecimalPlaces moel@345: { moel@345: get moel@345: { moel@345: return this._decimalPlaces; moel@345: } moel@345: set moel@345: { moel@345: this._decimalPlaces = value; moel@345: } moel@345: } moel@345: moel@345: private decimal _increment = 1; moel@345: [Category("Data"), DefaultValue(1)] moel@345: public decimal Increment moel@345: { moel@345: get moel@345: { moel@345: return this._increment; moel@345: } moel@345: set moel@345: { moel@345: this._increment = value; moel@345: } moel@345: } moel@345: moel@345: private decimal _minimum = 0; moel@345: [Category("Data"), DefaultValue(0)] moel@345: public decimal Minimum moel@345: { moel@345: get moel@345: { moel@345: return _minimum; moel@345: } moel@345: set moel@345: { moel@345: _minimum = value; moel@345: } moel@345: } moel@345: moel@345: private decimal _maximum = 100; moel@345: [Category("Data"), DefaultValue(100)] moel@345: public decimal Maximum moel@345: { moel@345: get moel@345: { moel@345: return this._maximum; moel@345: } moel@345: set moel@345: { moel@345: this._maximum = value; moel@345: } moel@345: } moel@345: moel@345: #endregion moel@345: moel@345: public NodeNumericUpDown() moel@345: { moel@345: } moel@345: moel@345: protected override Size CalculateEditorSize(EditorContext context) moel@345: { moel@345: if (Parent.UseColumns) moel@345: return context.Bounds.Size; moel@345: else moel@345: return new Size(EditorWidth, context.Bounds.Height); moel@345: } moel@345: moel@345: protected override Control CreateEditor(TreeNodeAdv node) moel@345: { moel@345: NumericUpDown num = new NumericUpDown(); moel@345: num.Increment = Increment; moel@345: num.DecimalPlaces = DecimalPlaces; moel@345: num.Minimum = Minimum; moel@345: num.Maximum = Maximum; moel@345: num.Value = (decimal)GetValue(node); moel@345: SetEditControlProperties(num, node); moel@345: return num; moel@345: } moel@345: moel@345: protected override void DisposeEditor(Control editor) moel@345: { moel@345: } moel@345: moel@345: protected override void DoApplyChanges(TreeNodeAdv node, Control editor) moel@345: { moel@345: SetValue(node, (editor as NumericUpDown).Value); moel@345: } moel@345: } moel@345: }