!B (Sandbox) (CE-21795) Importing models with multisubmaterials via fbx switches...
[CRYENGINE.git] / Code / Tools / LuaRemoteDebugger / Aga.Controls / Tree / Input / NormalInputState.cs
blob5a12f03f6881973ccfb05fa4ec17b158f1177f1c
1 // Copyright 2001-2019 Crytek GmbH / Crytek Group. All rights reserved.
3 using System;
4 using System.Collections.Generic;
5 using System.Text;
6 using System.Windows.Forms;
8 namespace Aga.Controls.Tree
10 internal class NormalInputState : InputState
12 private bool _mouseDownFlag = false;
14 public NormalInputState(TreeViewAdv tree) : base(tree)
18 public override void KeyDown(KeyEventArgs args)
20 if (Tree.CurrentNode == null && Tree.Root.Nodes.Count > 0)
21 Tree.CurrentNode = Tree.Root.Nodes[0];
23 if (Tree.CurrentNode != null)
25 switch (args.KeyCode)
27 case Keys.Right:
28 if (!Tree.CurrentNode.IsExpanded)
29 Tree.CurrentNode.IsExpanded = true;
30 else if (Tree.CurrentNode.Nodes.Count > 0)
31 Tree.SelectedNode = Tree.CurrentNode.Nodes[0];
32 args.Handled = true;
33 break;
34 case Keys.Left:
35 if (Tree.CurrentNode.IsExpanded)
36 Tree.CurrentNode.IsExpanded = false;
37 else if (Tree.CurrentNode.Parent != Tree.Root)
38 Tree.SelectedNode = Tree.CurrentNode.Parent;
39 args.Handled = true;
40 break;
41 case Keys.Down:
42 NavigateForward(1);
43 args.Handled = true;
44 break;
45 case Keys.Up:
46 NavigateBackward(1);
47 args.Handled = true;
48 break;
49 case Keys.PageDown:
50 NavigateForward(Math.Max(1, Tree.CurrentPageSize - 1));
51 args.Handled = true;
52 break;
53 case Keys.PageUp:
54 NavigateBackward(Math.Max(1, Tree.CurrentPageSize - 1));
55 args.Handled = true;
56 break;
57 case Keys.Home:
58 if (Tree.RowMap.Count > 0)
59 FocusRow(Tree.RowMap[0]);
60 args.Handled = true;
61 break;
62 case Keys.End:
63 if (Tree.RowMap.Count > 0)
64 FocusRow(Tree.RowMap[Tree.RowMap.Count-1]);
65 args.Handled = true;
66 break;
67 case Keys.Subtract:
68 Tree.CurrentNode.Collapse();
69 args.Handled = true;
70 args.SuppressKeyPress = true;
71 break;
72 case Keys.Add:
73 Tree.CurrentNode.Expand();
74 args.Handled = true;
75 args.SuppressKeyPress = true;
76 break;
77 case Keys.Multiply:
78 Tree.CurrentNode.ExpandAll();
79 args.Handled = true;
80 args.SuppressKeyPress = true;
81 break;
82 case Keys.A:
83 if (args.Modifiers == Keys.Control)
84 Tree.SelectAllNodes();
85 break;
90 public override void MouseDown(TreeNodeAdvMouseEventArgs args)
92 if (args.Node != null)
94 Tree.ItemDragMode = true;
95 Tree.ItemDragStart = args.Location;
97 if (args.Button == MouseButtons.Left || args.Button == MouseButtons.Right)
99 Tree.BeginUpdate();
102 Tree.CurrentNode = args.Node;
103 if (args.Node.IsSelected)
104 _mouseDownFlag = true;
105 else
107 _mouseDownFlag = false;
108 DoMouseOperation(args);
111 finally
113 Tree.EndUpdate();
118 else
120 Tree.ItemDragMode = false;
121 MouseDownAtEmptySpace(args);
125 public override void MouseUp(TreeNodeAdvMouseEventArgs args)
127 Tree.ItemDragMode = false;
128 if (_mouseDownFlag && args.Node != null)
130 if (args.Button == MouseButtons.Left)
131 DoMouseOperation(args);
132 else if (args.Button == MouseButtons.Right)
133 Tree.CurrentNode = args.Node;
135 _mouseDownFlag = false;
139 private void NavigateBackward(int n)
141 int row = Math.Max(Tree.CurrentNode.Row - n, 0);
142 if (row != Tree.CurrentNode.Row)
143 FocusRow(Tree.RowMap[row]);
146 private void NavigateForward(int n)
148 int row = Math.Min(Tree.CurrentNode.Row + n, Tree.RowCount - 1);
149 if (row != Tree.CurrentNode.Row)
150 FocusRow(Tree.RowMap[row]);
153 protected virtual void MouseDownAtEmptySpace(TreeNodeAdvMouseEventArgs args)
155 Tree.ClearSelection();
158 protected virtual void FocusRow(TreeNodeAdv node)
160 Tree.SuspendSelectionEvent = true;
163 Tree.ClearSelectionInternal();
164 Tree.CurrentNode = node;
165 Tree.SelectionStart = node;
166 node.IsSelected = true;
167 Tree.ScrollTo(node);
169 finally
171 Tree.SuspendSelectionEvent = false;
175 protected bool CanSelect(TreeNodeAdv node)
177 if (Tree.SelectionMode == TreeSelectionMode.MultiSameParent)
179 return (Tree.SelectionStart == null || node.Parent == Tree.SelectionStart.Parent);
181 else
182 return true;
185 protected virtual void DoMouseOperation(TreeNodeAdvMouseEventArgs args)
187 if (Tree.SelectedNodes.Count == 1 && args.Node != null && args.Node.IsSelected)
188 return;
190 Tree.SuspendSelectionEvent = true;
193 Tree.ClearSelectionInternal();
194 if (args.Node != null)
195 args.Node.IsSelected = true;
196 Tree.SelectionStart = args.Node;
198 finally
200 Tree.SuspendSelectionEvent = false;