1 | using System.Windows.Input;
|
---|
2 |
|
---|
3 | namespace Microsoft.Research.DynamicDataDisplay
|
---|
4 | {
|
---|
5 | // TODO: probably optimize memory usage by replacing implicit creation of
|
---|
6 | // all commands on first usage of this class -
|
---|
7 | // create each command on first access directly to it.
|
---|
8 |
|
---|
9 | /// <summary>This class holds keyboard shortcuts to common viewport navigation commands</summary>
|
---|
10 | public static class ChartCommands
|
---|
11 | {
|
---|
12 |
|
---|
13 | #region Auxiliary code for creation of commands
|
---|
14 |
|
---|
15 | private static RoutedUICommand CreateCommand(string name)
|
---|
16 | {
|
---|
17 | return new RoutedUICommand(name, name, typeof(ChartCommands));
|
---|
18 | }
|
---|
19 |
|
---|
20 | private static RoutedUICommand CreateCommand(string name, params Key[] keys)
|
---|
21 | {
|
---|
22 | InputGestureCollection gestures = new InputGestureCollection();
|
---|
23 | foreach (var key in keys)
|
---|
24 | {
|
---|
25 | gestures.Add(new KeyGesture(key));
|
---|
26 | }
|
---|
27 | return new RoutedUICommand(name, name, typeof(ChartCommands), gestures);
|
---|
28 | }
|
---|
29 |
|
---|
30 | private static RoutedUICommand CreateCommand(string name, params InputGesture[] gestures)
|
---|
31 | {
|
---|
32 | return new RoutedUICommand(name, name, typeof(ChartCommands), new InputGestureCollection(gestures));
|
---|
33 | }
|
---|
34 |
|
---|
35 | #endregion
|
---|
36 |
|
---|
37 | private static readonly RoutedUICommand zoomWithParam = CreateCommand("ZoomWithParam");
|
---|
38 | public static RoutedUICommand ZoomWithParameter
|
---|
39 | {
|
---|
40 | get { return zoomWithParam; }
|
---|
41 | }
|
---|
42 |
|
---|
43 | private static readonly RoutedUICommand zoomIn = CreateCommand("ZoomIn", Key.OemPlus);
|
---|
44 | public static RoutedUICommand ZoomIn
|
---|
45 | {
|
---|
46 | get { return zoomIn; }
|
---|
47 | }
|
---|
48 |
|
---|
49 | private static readonly RoutedUICommand zoomOut = CreateCommand("ZoomOut", Key.OemMinus);
|
---|
50 | public static RoutedUICommand ZoomOut
|
---|
51 | {
|
---|
52 | get { return zoomOut; }
|
---|
53 | }
|
---|
54 |
|
---|
55 | private static readonly RoutedUICommand fitToView = CreateCommand("FitToView", Key.Home);
|
---|
56 | public static RoutedUICommand FitToView
|
---|
57 | {
|
---|
58 | get { return ChartCommands.fitToView; }
|
---|
59 | }
|
---|
60 |
|
---|
61 | private static readonly RoutedUICommand scrollLeft = CreateCommand("ScrollLeft", Key.Left);
|
---|
62 | public static RoutedUICommand ScrollLeft
|
---|
63 | {
|
---|
64 | get { return ChartCommands.scrollLeft; }
|
---|
65 | }
|
---|
66 |
|
---|
67 | private static readonly RoutedUICommand scrollRight = CreateCommand("ScrollRight", Key.Right);
|
---|
68 | public static RoutedUICommand ScrollRight
|
---|
69 | {
|
---|
70 | get { return ChartCommands.scrollRight; }
|
---|
71 | }
|
---|
72 |
|
---|
73 | private static readonly RoutedUICommand scrollUp = CreateCommand("ScrollUp", Key.Up);
|
---|
74 | public static RoutedUICommand ScrollUp
|
---|
75 | {
|
---|
76 | get { return ChartCommands.scrollUp; }
|
---|
77 | }
|
---|
78 |
|
---|
79 | private static readonly RoutedUICommand scrollDown = CreateCommand("ScrollDown", Key.Down);
|
---|
80 | public static RoutedUICommand ScrollDown
|
---|
81 | {
|
---|
82 | get { return ChartCommands.scrollDown; }
|
---|
83 | }
|
---|
84 |
|
---|
85 | private static readonly RoutedUICommand saveScreenshot = CreateCommand("SaveScreenshot", new KeyGesture(Key.S, ModifierKeys.Control));
|
---|
86 | public static RoutedUICommand SaveScreenshot
|
---|
87 | {
|
---|
88 | get { return ChartCommands.saveScreenshot; }
|
---|
89 | }
|
---|
90 |
|
---|
91 | private static readonly RoutedUICommand copyScreenshot = CreateCommand("CopyScreenshot", Key.F11);
|
---|
92 | public static RoutedUICommand CopyScreenshot
|
---|
93 | {
|
---|
94 | get { return ChartCommands.copyScreenshot; }
|
---|
95 | }
|
---|
96 |
|
---|
97 | private static readonly RoutedUICommand showHelp = CreateCommand("ShowHelp", Key.F1);
|
---|
98 | public static RoutedUICommand ShowHelp
|
---|
99 | {
|
---|
100 | get { return ChartCommands.showHelp; }
|
---|
101 | }
|
---|
102 | }
|
---|
103 | }
|
---|