Changeset 13762 for branches/HeuristicLab.Visualization/HeuristicLab.Visualization/3.3/ChartControl.cs
- Timestamp:
- 04/14/16 14:13:57 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Visualization/HeuristicLab.Visualization/3.3/ChartControl.cs
r13716 r13762 34 34 protected bool RenderingRequired; 35 35 protected Dictionary<Type, ChartMode> Modes = new Dictionary<Type, ChartMode>(); 36 protected Stack<ChartMode> ModeStack = new Stack<ChartMode>(); 37 protected List<ChartMode.Shortcut> Shortcuts = new List<ChartMode.Shortcut>(); 38 protected ChartMode.Shortcut ActiveShortcut; 36 39 37 40 protected bool SuppressEvents { get; set; } … … 88 91 89 92 public void AddChartModes(params ChartMode[] chartModes) { 90 foreach (var chartMode in chartModes) 93 foreach (var chartMode in chartModes) { 91 94 Modes.Add(chartMode.GetType(), chartMode); 95 foreach (var shortcut in chartMode.Shortcuts) 96 Shortcuts.Add(shortcut); 97 } 92 98 93 99 ReloadModeToolBar(); 94 100 ReloadModeContextMenu(); 101 } 102 103 public void SetTempChartMode(ChartMode chartMode) { 104 if (Mode == chartMode) return; 105 106 ModeStack.Push(mode); 107 Mode = chartMode; 108 } 109 110 public void ResetTempChartMode() { 111 if (ModeStack.Any()) 112 Mode = ModeStack.Pop(); 95 113 } 96 114 … … 203 221 204 222 protected virtual void OnKeyDown(object sender, KeyEventArgs e) { 205 if (mode != null) 223 if (mode != null) { 206 224 mode.HandleOnKeyDown(sender, e); 225 226 if (e.Handled || ActiveShortcut != null) return; 227 228 foreach (var shortcut in Shortcuts) { 229 if (e.KeyCode == shortcut.Key && e.Modifiers == shortcut.Modifiers) { 230 ActiveShortcut = shortcut; 231 shortcut.DownAction(); 232 break; 233 } 234 } 235 } 207 236 } 208 237 209 238 protected virtual void OnKeyUp(object sender, KeyEventArgs e) { 210 if (mode != null) 239 if (mode != null) { 211 240 mode.HandleOnKeyUp(sender, e); 241 242 if (e.Handled || ActiveShortcut == null) return; 243 244 var modifiers = new List<Keys>(from key in Enum.GetValues(typeof(Keys)).Cast<Keys>() 245 where e.Modifiers.HasFlag(key) 246 select key); 247 248 if (ActiveShortcut.Key == e.KeyCode || ActiveShortcut.GetModifiers().Except(modifiers).Any()) { 249 ActiveShortcut.UpAction(); 250 ActiveShortcut = null; 251 } 252 } 212 253 } 213 254
Note: See TracChangeset
for help on using the changeset viewer.