[12503] | 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>Common chart plotter 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, MouseAction mouseAction) {
|
---|
| 31 | return new RoutedUICommand(name, name, typeof(ChartCommands), new InputGestureCollection { new MouseGesture(mouseAction) });
|
---|
| 32 | }
|
---|
| 33 |
|
---|
| 34 | private static RoutedUICommand CreateCommand(string name, params InputGesture[] gestures)
|
---|
| 35 | {
|
---|
| 36 | return new RoutedUICommand(name, name, typeof(ChartCommands), new InputGestureCollection(gestures));
|
---|
| 37 | }
|
---|
| 38 |
|
---|
| 39 | #endregion
|
---|
| 40 |
|
---|
| 41 | private static readonly RoutedUICommand zoomOutToMouse = CreateCommand("ZoomOutToMouse", MouseAction.RightDoubleClick);
|
---|
| 42 | /// <summary>
|
---|
| 43 | /// Gets the value that represents the Zoom Out To Mouse command.
|
---|
| 44 | /// </summary>
|
---|
| 45 | public static RoutedUICommand ZoomOutToMouse
|
---|
| 46 | {
|
---|
| 47 | get { return ChartCommands.zoomOutToMouse; }
|
---|
| 48 | }
|
---|
| 49 |
|
---|
| 50 | private static readonly RoutedUICommand zoomInToMouse = CreateCommand("ZoomInToMouse", MouseAction.LeftDoubleClick);
|
---|
| 51 | /// <summary>
|
---|
| 52 | /// Gets the value that represents the zoom in to mouse command.
|
---|
| 53 | /// </summary>
|
---|
| 54 | /// <value></value>
|
---|
| 55 | public static RoutedUICommand ZoomInToMouse
|
---|
| 56 | {
|
---|
| 57 | get { return ChartCommands.zoomInToMouse; }
|
---|
| 58 | }
|
---|
| 59 |
|
---|
| 60 | private static readonly RoutedUICommand zoomWithParam = CreateCommand("ZoomWithParam");
|
---|
| 61 | /// <summary>
|
---|
| 62 | /// Gets the value that represents the zoom with parameter command.
|
---|
| 63 | /// </summary>
|
---|
| 64 | /// <value></value>
|
---|
| 65 | public static RoutedUICommand ZoomWithParameter
|
---|
| 66 | {
|
---|
| 67 | get { return zoomWithParam; }
|
---|
| 68 | }
|
---|
| 69 |
|
---|
| 70 | private static readonly RoutedUICommand zoomIn = CreateCommand("ZoomIn", Key.OemPlus);
|
---|
| 71 | /// <summary>
|
---|
| 72 | /// Gets the value that represents the zoom in command.
|
---|
| 73 | /// </summary>
|
---|
| 74 | /// <value></value>
|
---|
| 75 | public static RoutedUICommand ZoomIn
|
---|
| 76 | {
|
---|
| 77 | get { return zoomIn; }
|
---|
| 78 | }
|
---|
| 79 |
|
---|
| 80 | private static readonly RoutedUICommand zoomOut = CreateCommand("ZoomOut", Key.OemMinus);
|
---|
| 81 | /// <summary>
|
---|
| 82 | /// Gets the value that represents the zoom out command.
|
---|
| 83 | /// </summary>
|
---|
| 84 | /// <value></value>
|
---|
| 85 | public static RoutedUICommand ZoomOut
|
---|
| 86 | {
|
---|
| 87 | get { return zoomOut; }
|
---|
| 88 | }
|
---|
| 89 |
|
---|
| 90 | private static readonly RoutedUICommand fitToView = CreateCommand("FitToView", Key.Home);
|
---|
| 91 | /// <summary>
|
---|
| 92 | /// Gets the value that represents the fit to view command.
|
---|
| 93 | /// </summary>
|
---|
| 94 | /// <value></value>
|
---|
| 95 | public static RoutedUICommand FitToView
|
---|
| 96 | {
|
---|
| 97 | get { return ChartCommands.fitToView; }
|
---|
| 98 | }
|
---|
| 99 |
|
---|
| 100 | private static readonly RoutedUICommand scrollLeft = CreateCommand("ScrollLeft", Key.Left);
|
---|
| 101 | /// <summary>
|
---|
| 102 | /// Gets the value that represents the scroll left command.
|
---|
| 103 | /// </summary>
|
---|
| 104 | /// <value></value>
|
---|
| 105 | public static RoutedUICommand ScrollLeft
|
---|
| 106 | {
|
---|
| 107 | get { return ChartCommands.scrollLeft; }
|
---|
| 108 | }
|
---|
| 109 |
|
---|
| 110 | private static readonly RoutedUICommand scrollRight = CreateCommand("ScrollRight", Key.Right);
|
---|
| 111 | /// <summary>
|
---|
| 112 | /// Gets the value that represents the scroll right command.
|
---|
| 113 | /// </summary>
|
---|
| 114 | /// <value></value>
|
---|
| 115 | public static RoutedUICommand ScrollRight
|
---|
| 116 | {
|
---|
| 117 | get { return ChartCommands.scrollRight; }
|
---|
| 118 | }
|
---|
| 119 |
|
---|
| 120 | private static readonly RoutedUICommand scrollUp = CreateCommand("ScrollUp", Key.Up);
|
---|
| 121 | /// <summary>
|
---|
| 122 | /// Gets the value that represents the scroll up command.
|
---|
| 123 | /// </summary>
|
---|
| 124 | /// <value></value>
|
---|
| 125 | public static RoutedUICommand ScrollUp
|
---|
| 126 | {
|
---|
| 127 | get { return ChartCommands.scrollUp; }
|
---|
| 128 | }
|
---|
| 129 |
|
---|
| 130 | private static readonly RoutedUICommand scrollDown = CreateCommand("ScrollDown", Key.Down);
|
---|
| 131 | /// <summary>
|
---|
| 132 | /// Gets the value that represents the scroll down command.
|
---|
| 133 | /// </summary>
|
---|
| 134 | /// <value></value>
|
---|
| 135 | public static RoutedUICommand ScrollDown
|
---|
| 136 | {
|
---|
| 137 | get { return ChartCommands.scrollDown; }
|
---|
| 138 | }
|
---|
| 139 |
|
---|
| 140 | private static readonly RoutedUICommand saveScreenshot = CreateCommand("SaveScreenshot", new KeyGesture(Key.S, ModifierKeys.Control));
|
---|
| 141 | /// <summary>
|
---|
| 142 | /// Gets the value that represents the save screenshot command.
|
---|
| 143 | /// </summary>
|
---|
| 144 | /// <value></value>
|
---|
| 145 | public static RoutedUICommand SaveScreenshot
|
---|
| 146 | {
|
---|
| 147 | get { return ChartCommands.saveScreenshot; }
|
---|
| 148 | }
|
---|
| 149 |
|
---|
| 150 | private static readonly RoutedUICommand copyScreenshot = CreateCommand("CopyScreenshot", Key.F11);
|
---|
| 151 | /// <summary>
|
---|
| 152 | /// Gets the value that represents the copy screenshot command.
|
---|
| 153 | /// </summary>
|
---|
| 154 | /// <value></value>
|
---|
| 155 | public static RoutedUICommand CopyScreenshot
|
---|
| 156 | {
|
---|
| 157 | get { return ChartCommands.copyScreenshot; }
|
---|
| 158 | }
|
---|
| 159 |
|
---|
| 160 | private static readonly RoutedUICommand showHelp = CreateCommand("ShowHelp", Key.F1);
|
---|
| 161 | /// <summary>
|
---|
| 162 | /// Gets the value that represents the show help command.
|
---|
| 163 | /// </summary>
|
---|
| 164 | /// <value></value>
|
---|
| 165 | public static RoutedUICommand ShowHelp
|
---|
| 166 | {
|
---|
| 167 | get { return ChartCommands.showHelp; }
|
---|
| 168 | }
|
---|
| 169 | }
|
---|
| 170 | }
|
---|