External/Aga.Controls/Tree/NodeControls/NodeNumericUpDown.cs
author moel.mich
Tue, 30 Dec 2014 22:47:39 +0000
changeset 431 0e46e3ca812a
permissions -rw-r--r--
Fixed the following issue (present only on 32-bit systems):

Version: 0.7.0.0

System.NullReferenceException: Object reference not set to an instance of an object.
at OpenHardwareMonitor.GUI.MainForm.timer_Tick(Object sender, EventArgs e)
at System.Windows.Forms.Timer.OnTick(EventArgs e)
at System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

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