Now calling display init. Not getting the expected error code though.
2 using System.Collections.Generic;
4 using System.Windows.Forms;
6 namespace Aga.Controls.Tree
8 internal class NormalInputState : InputState
10 private bool _mouseDownFlag = false;
12 public NormalInputState(TreeViewAdv tree) : base(tree)
16 public override void KeyDown(KeyEventArgs args)
18 if (Tree.CurrentNode == null && Tree.Root.Nodes.Count > 0)
19 Tree.CurrentNode = Tree.Root.Nodes[0];
21 if (Tree.CurrentNode != null)
26 if (!Tree.CurrentNode.IsExpanded)
27 Tree.CurrentNode.IsExpanded = true;
28 else if (Tree.CurrentNode.Nodes.Count > 0)
29 Tree.SelectedNode = Tree.CurrentNode.Nodes[0];
33 if (Tree.CurrentNode.IsExpanded)
34 Tree.CurrentNode.IsExpanded = false;
35 else if (Tree.CurrentNode.Parent != Tree.Root)
36 Tree.SelectedNode = Tree.CurrentNode.Parent;
48 NavigateForward(Math.Max(1, Tree.CurrentPageSize - 1));
52 NavigateBackward(Math.Max(1, Tree.CurrentPageSize - 1));
56 if (Tree.RowMap.Count > 0)
57 FocusRow(Tree.RowMap[0]);
61 if (Tree.RowMap.Count > 0)
62 FocusRow(Tree.RowMap[Tree.RowMap.Count-1]);
66 Tree.CurrentNode.Collapse();
68 args.SuppressKeyPress = true;
71 Tree.CurrentNode.Expand();
73 args.SuppressKeyPress = true;
76 Tree.CurrentNode.ExpandAll();
78 args.SuppressKeyPress = true;
81 if (args.Modifiers == Keys.Control)
82 Tree.SelectAllNodes();
88 public override void MouseDown(TreeNodeAdvMouseEventArgs args)
90 if (args.Node != null)
92 Tree.ItemDragMode = true;
93 Tree.ItemDragStart = args.Location;
95 if (args.Button == MouseButtons.Left || args.Button == MouseButtons.Right)
100 Tree.CurrentNode = args.Node;
101 if (args.Node.IsSelected)
102 _mouseDownFlag = true;
105 _mouseDownFlag = false;
106 DoMouseOperation(args);
118 Tree.ItemDragMode = false;
119 MouseDownAtEmptySpace(args);
123 public override void MouseUp(TreeNodeAdvMouseEventArgs args)
125 Tree.ItemDragMode = false;
126 if (_mouseDownFlag && args.Node != null)
128 if (args.Button == MouseButtons.Left)
129 DoMouseOperation(args);
130 else if (args.Button == MouseButtons.Right)
131 Tree.CurrentNode = args.Node;
133 _mouseDownFlag = false;
137 private void NavigateBackward(int n)
139 int row = Math.Max(Tree.CurrentNode.Row - n, 0);
140 if (row != Tree.CurrentNode.Row)
141 FocusRow(Tree.RowMap[row]);
144 private void NavigateForward(int n)
146 int row = Math.Min(Tree.CurrentNode.Row + n, Tree.RowCount - 1);
147 if (row != Tree.CurrentNode.Row)
148 FocusRow(Tree.RowMap[row]);
151 protected virtual void MouseDownAtEmptySpace(TreeNodeAdvMouseEventArgs args)
153 Tree.ClearSelection();
156 protected virtual void FocusRow(TreeNodeAdv node)
158 Tree.SuspendSelectionEvent = true;
161 Tree.ClearSelectionInternal();
162 Tree.CurrentNode = node;
163 Tree.SelectionStart = node;
164 node.IsSelected = true;
169 Tree.SuspendSelectionEvent = false;
173 protected bool CanSelect(TreeNodeAdv node)
175 if (Tree.SelectionMode == TreeSelectionMode.MultiSameParent)
177 return (Tree.SelectionStart == null || node.Parent == Tree.SelectionStart.Parent);
183 protected virtual void DoMouseOperation(TreeNodeAdvMouseEventArgs args)
185 if (Tree.SelectedNodes.Count == 1 && args.Node != null && args.Node.IsSelected)
188 Tree.SuspendSelectionEvent = true;
191 Tree.ClearSelectionInternal();
192 if (args.Node != null)
193 args.Node.IsSelected = true;
194 Tree.SelectionStart = args.Node;
198 Tree.SuspendSelectionEvent = false;