Added the small modifications to the Aga.Controls required by the Open Hardware Monitor.
2 using System.Collections.Generic;
3 using System.Collections.ObjectModel;
4 using System.ComponentModel;
6 using System.Drawing.Design;
7 using System.Windows.Forms;
9 using Aga.Controls.Tree.NodeControls;
11 namespace Aga.Controls.Tree
13 public partial class TreeViewAdv
15 private Cursor _innerCursor = null;
17 public override Cursor Cursor
21 if (_innerCursor != null)
32 #region Internal Properties
34 private IRowLayout _rowLayout;
36 private bool _dragMode;
39 get { return _dragMode; }
46 if (_dragBitmap != null)
47 _dragBitmap.Dispose();
55 internal int ColumnHeaderHeight
60 return _columnHeaderHeight;
67 /// returns all nodes, which parent is expanded
69 private IEnumerable<TreeNodeAdv> VisibleNodes
73 TreeNodeAdv node = Root;
76 node = node.NextVisibleNode;
83 private bool _suspendSelectionEvent;
84 internal bool SuspendSelectionEvent
86 get { return _suspendSelectionEvent; }
89 if (value != _suspendSelectionEvent)
91 _suspendSelectionEvent = value;
92 if (!_suspendSelectionEvent && _fireSelectionEvent)
98 private List<TreeNodeAdv> _rowMap;
99 internal List<TreeNodeAdv> RowMap
101 get { return _rowMap; }
104 private TreeNodeAdv _selectionStart;
105 internal TreeNodeAdv SelectionStart
107 get { return _selectionStart; }
108 set { _selectionStart = value; }
111 private InputState _input;
112 internal InputState Input
114 get { return _input; }
121 private bool _itemDragMode;
122 internal bool ItemDragMode
124 get { return _itemDragMode; }
125 set { _itemDragMode = value; }
128 private Point _itemDragStart;
129 internal Point ItemDragStart
131 get { return _itemDragStart; }
132 set { _itemDragStart = value; }
137 /// Number of rows fits to the current page
139 internal int CurrentPageSize
143 return _rowLayout.CurrentPageSize;
148 /// Number of all visible nodes (which parent is expanded)
150 internal int RowCount
158 private int _contentWidth = 0;
159 private int ContentWidth
163 return _contentWidth;
167 private int _firstVisibleRow;
168 internal int FirstVisibleRow
170 get { return _firstVisibleRow; }
174 _firstVisibleRow = value;
179 private int _offsetX;
182 get { return _offsetX; }
191 public override Rectangle DisplayRectangle
195 Rectangle r = ClientRectangle;
196 //r.Y += ColumnHeaderHeight;
197 //r.Height -= ColumnHeaderHeight;
198 int w = _vScrollBar.Visible ? _vScrollBar.Width : 0;
199 int h = _hScrollBar.Visible ? _hScrollBar.Height : 0;
200 return new Rectangle(r.X, r.Y, r.Width - w, r.Height - h);
204 private List<TreeNodeAdv> _selection;
205 internal List<TreeNodeAdv> Selection
207 get { return _selection; }
212 #region Public Properties
216 private bool _shiftFirstNode;
217 [DefaultValue(false), Category("Behavior")]
218 public bool ShiftFirstNode
220 get { return _shiftFirstNode; }
221 set { _shiftFirstNode = value; }
224 private bool _displayDraggingNodes;
225 [DefaultValue(false), Category("Behavior")]
226 public bool DisplayDraggingNodes
228 get { return _displayDraggingNodes; }
229 set { _displayDraggingNodes = value; }
232 private bool _fullRowSelect;
233 [DefaultValue(false), Category("Behavior")]
234 public bool FullRowSelect
236 get { return _fullRowSelect; }
239 _fullRowSelect = value;
244 private bool _useColumns;
245 [DefaultValue(false), Category("Behavior")]
246 public bool UseColumns
248 get { return _useColumns; }
256 private bool _allowColumnReorder;
257 [DefaultValue(false), Category("Behavior")]
258 public bool AllowColumnReorder
260 get { return _allowColumnReorder; }
261 set { _allowColumnReorder = value; }
264 private bool _showLines = true;
265 [DefaultValue(true), Category("Behavior")]
266 public bool ShowLines
268 get { return _showLines; }
276 private bool _showPlusMinus = true;
277 [DefaultValue(true), Category("Behavior")]
278 public bool ShowPlusMinus
280 get { return _showPlusMinus; }
283 _showPlusMinus = value;
288 private bool _showNodeToolTips = false;
289 [DefaultValue(false), Category("Behavior")]
290 public bool ShowNodeToolTips
292 get { return _showNodeToolTips; }
293 set { _showNodeToolTips = value; }
296 [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "value"), System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic"), DefaultValue(true), Category("Behavior"), Obsolete("No longer used")]
297 public bool KeepNodesExpanded
303 private ITreeModel _model;
305 /// The model associated with this <see cref="TreeViewAdv"/>.
307 /// <seealso cref="ITreeModel"/>
308 /// <seealso cref="TreeModel"/>
310 public ITreeModel Model
312 get { return _model; }
317 AbortBackgroundExpandingThreads();
329 private static Font _font = SystemFonts.MessageBoxFont;
331 /// The font to render <see cref="TreeViewAdv"/> content in.
333 [Category("Appearance"), Description("The font to render TreeViewAdv content in.")]
334 public override Font Font
346 if (value == DefaultFont)
353 public override void ResetFont()
357 private bool ShouldSerializeFont()
359 return (!Font.Equals(_font));
363 private BorderStyle _borderStyle = BorderStyle.Fixed3D;
364 [DefaultValue(BorderStyle.Fixed3D), Category("Appearance")]
365 public BorderStyle BorderStyle
369 return this._borderStyle;
373 if (_borderStyle != value)
375 _borderStyle = value;
381 private bool _autoRowHeight = false;
383 /// Set to true to expand each row's height to fit the text of it's largest column.
385 [DefaultValue(false), Category("Appearance"), Description("Expand each row's height to fit the text of it's largest column.")]
386 public bool AutoRowHeight
390 return _autoRowHeight;
394 _autoRowHeight = value;
396 _rowLayout = new AutoRowHeightLayout(this, RowHeight);
398 _rowLayout = new FixedRowHeightLayout(this, RowHeight);
403 private GridLineStyle _gridLineStyle = GridLineStyle.None;
404 [DefaultValue(GridLineStyle.None), Category("Appearance")]
405 public GridLineStyle GridLineStyle
409 return _gridLineStyle;
413 if (value != _gridLineStyle)
415 _gridLineStyle = value;
417 OnGridLineStyleChanged();
422 private int _rowHeight = 16;
423 [DefaultValue(16), Category("Appearance")]
433 throw new ArgumentOutOfRangeException("value");
436 _rowLayout.PreferredRowHeight = value;
441 private TreeSelectionMode _selectionMode = TreeSelectionMode.Single;
442 [DefaultValue(TreeSelectionMode.Single), Category("Behavior")]
443 public TreeSelectionMode SelectionMode
445 get { return _selectionMode; }
446 set { _selectionMode = value; }
449 private bool _hideSelection;
450 [DefaultValue(false), Category("Behavior")]
451 public bool HideSelection
453 get { return _hideSelection; }
456 _hideSelection = value;
461 private float _topEdgeSensivity = 0.3f;
462 [DefaultValue(0.3f), Category("Behavior")]
463 public float TopEdgeSensivity
465 get { return _topEdgeSensivity; }
468 if (value < 0 || value > 1)
469 throw new ArgumentOutOfRangeException();
470 _topEdgeSensivity = value;
474 private float _bottomEdgeSensivity = 0.3f;
475 [DefaultValue(0.3f), Category("Behavior")]
476 public float BottomEdgeSensivity
478 get { return _bottomEdgeSensivity; }
481 if (value < 0 || value > 1)
482 throw new ArgumentOutOfRangeException("value should be from 0 to 1");
483 _bottomEdgeSensivity = value;
487 private bool _loadOnDemand;
488 [DefaultValue(false), Category("Behavior")]
489 public bool LoadOnDemand
491 get { return _loadOnDemand; }
492 set { _loadOnDemand = value; }
495 private bool _unloadCollapsedOnReload = false;
496 [DefaultValue(false), Category("Behavior")]
497 public bool UnloadCollapsedOnReload
499 get { return _unloadCollapsedOnReload; }
500 set { _unloadCollapsedOnReload = value; }
503 private int _indent = 19;
504 [DefaultValue(19), Category("Behavior")]
507 get { return _indent; }
515 private Color _lineColor = SystemColors.ControlDark;
516 [Category("Behavior")]
517 public Color LineColor
519 get { return _lineColor; }
528 private Color _dragDropMarkColor = Color.Black;
529 [Category("Behavior")]
530 public Color DragDropMarkColor
532 get { return _dragDropMarkColor; }
535 _dragDropMarkColor = value;
540 private float _dragDropMarkWidth = 3.0f;
541 [DefaultValue(3.0f), Category("Behavior")]
542 public float DragDropMarkWidth
544 get { return _dragDropMarkWidth; }
547 _dragDropMarkWidth = value;
552 private bool _highlightDropPosition = true;
553 [DefaultValue(true), Category("Behavior")]
554 public bool HighlightDropPosition
556 get { return _highlightDropPosition; }
557 set { _highlightDropPosition = value; }
560 private TreeColumnCollection _columns;
561 [Category("Behavior"), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
562 public Collection<TreeColumn> Columns
564 get { return _columns; }
567 private NodeControlsCollection _controls;
568 [Category("Behavior"), DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
569 [Editor(typeof(NodeControlCollectionEditor), typeof(UITypeEditor))]
570 public Collection<NodeControl> NodeControls
578 private bool _asyncExpanding;
580 /// When set to true, node contents will be read in background thread.
582 [Category("Behavior"), DefaultValue(false), Description("Read children in a background thread when expanding.")]
583 public bool AsyncExpanding
585 get { return _asyncExpanding; }
586 set { _asyncExpanding = value; }
593 private IToolTipProvider _defaultToolTipProvider = null;
595 public IToolTipProvider DefaultToolTipProvider
597 get { return _defaultToolTipProvider; }
598 set { _defaultToolTipProvider = value; }
602 public IEnumerable<TreeNodeAdv> AllNodes
606 if (_root.Nodes.Count > 0)
608 TreeNodeAdv node = _root.Nodes[0];
612 if (node.Nodes.Count > 0)
613 node = node.Nodes[0];
614 else if (node.NextNode != null)
615 node = node.NextNode;
617 node = node.BottomNode;
623 private DropPosition _dropPosition;
625 public DropPosition DropPosition
627 get { return _dropPosition; }
628 set { _dropPosition = value; }
631 private TreeNodeAdv _root;
633 public TreeNodeAdv Root
635 get { return _root; }
638 private ReadOnlyCollection<TreeNodeAdv> _readonlySelection;
640 public ReadOnlyCollection<TreeNodeAdv> SelectedNodes
644 return _readonlySelection;
649 public TreeNodeAdv SelectedNode
653 if (Selection.Count > 0)
655 if (CurrentNode != null && CurrentNode.IsSelected)
665 if (SelectedNode == value)
673 ClearSelectionInternal();
677 if (!IsMyNode(value))
678 throw new ArgumentException();
680 ClearSelectionInternal();
681 value.IsSelected = true;
683 EnsureVisible(value);
693 private TreeNodeAdv _currentNode;
695 public TreeNodeAdv CurrentNode
697 get { return _currentNode; }
698 internal set { _currentNode = value; }
704 get { return RowMap.Count; }
708 /// Indicates the distance the content is scrolled to the left
711 public int HorizontalScrollPosition
715 if (_hScrollBar.Visible)
716 return _hScrollBar.Value;