Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / wpf / src / Core / CSharp / System / Windows / Input / Command / ComponentCommands.cs / 1 / ComponentCommands.cs
//---------------------------------------------------------------------------- // //// Copyright (C) Microsoft Corporation. All rights reserved. // // // // Description: The ComponentCommands class defines a standard set of commands that are required in Controls. // // See spec at : http://avalon/CoreUI/Specs%20%20Eventing%20and%20Commanding/CommandLibrarySpec.mht // // // History: // 03/31/2004 : chandras - Created // 04/28/2004 : Added Accelerator table loading from Resource // 02/02/2005 : Created ComponentCommands class from CommandLibrary class. // //--------------------------------------------------------------------------- using System; using System.Windows; using System.Windows.Input; using System.Collections; using System.ComponentModel; using SR=MS.Internal.PresentationCore.SR; using SRID=MS.Internal.PresentationCore.SRID; namespace System.Windows.Input { ////// ComponentCommands - Set of Standard Commands /// public static class ComponentCommands { //----------------------------------------------------- // // Public Methods // //----------------------------------------------------- #region Public Methods ////// ScrollPageUp Command /// public static RoutedUICommand ScrollPageUp { get { return _EnsureCommand(CommandId.ScrollPageUp); } } ////// ScrollPageDown Command /// public static RoutedUICommand ScrollPageDown { get { return _EnsureCommand(CommandId.ScrollPageDown); } } ////// ScrollPageLeft Command /// public static RoutedUICommand ScrollPageLeft { get { return _EnsureCommand(CommandId.ScrollPageLeft); } } ////// ScrollPageRight Command /// public static RoutedUICommand ScrollPageRight { get { return _EnsureCommand(CommandId.ScrollPageRight); } } ////// ScrollByLine Command /// public static RoutedUICommand ScrollByLine { get { return _EnsureCommand(CommandId.ScrollByLine); } } ////// MoveLeft Command /// public static RoutedUICommand MoveLeft { get { return _EnsureCommand(CommandId.MoveLeft); } } ////// MoveRight Command /// public static RoutedUICommand MoveRight { get { return _EnsureCommand(CommandId.MoveRight); } } ////// MoveUp Command /// public static RoutedUICommand MoveUp { get { return _EnsureCommand(CommandId.MoveUp); } } ////// MoveDown Command /// public static RoutedUICommand MoveDown { get { return _EnsureCommand(CommandId.MoveDown); } } ////// MoveToHome Command /// public static RoutedUICommand MoveToHome { get { return _EnsureCommand(CommandId.MoveToHome); } } ////// MoveToEnd Command /// public static RoutedUICommand MoveToEnd { get { return _EnsureCommand(CommandId.MoveToEnd); } } ////// MoveToPageUp Command /// public static RoutedUICommand MoveToPageUp { get { return _EnsureCommand(CommandId.MoveToPageUp); } } ////// MoveToPageDown Command /// public static RoutedUICommand MoveToPageDown { get { return _EnsureCommand(CommandId.MoveToPageDown); } } ////// Extend Selection Up Command /// public static RoutedUICommand ExtendSelectionUp { get { return _EnsureCommand(CommandId.ExtendSelectionUp); } } ////// ExtendSelectionDown Command /// public static RoutedUICommand ExtendSelectionDown { get { return _EnsureCommand(CommandId.ExtendSelectionDown); } } ////// ExtendSelectionLeft Command /// public static RoutedUICommand ExtendSelectionLeft { get { return _EnsureCommand(CommandId.ExtendSelectionLeft); } } ////// ExtendSelectionRight Command /// public static RoutedUICommand ExtendSelectionRight { get { return _EnsureCommand(CommandId.ExtendSelectionRight); } } ////// SelectToHome Command /// public static RoutedUICommand SelectToHome { get { return _EnsureCommand(CommandId.SelectToHome); } } ////// SelectToEnd Command /// public static RoutedUICommand SelectToEnd { get { return _EnsureCommand(CommandId.SelectToEnd); } } ////// SelectToPageUp Command /// public static RoutedUICommand SelectToPageUp { get { return _EnsureCommand(CommandId.SelectToPageUp); } } ////// SelectToPageDown Command /// public static RoutedUICommand SelectToPageDown { get { return _EnsureCommand(CommandId.SelectToPageDown); } } ////// MoveFocusUp Command /// public static RoutedUICommand MoveFocusUp { get { return _EnsureCommand(CommandId.MoveFocusUp); } } ////// MoveFocusDown Command /// public static RoutedUICommand MoveFocusDown { get { return _EnsureCommand(CommandId.MoveFocusDown); } } ////// MoveFocusForward Command /// public static RoutedUICommand MoveFocusForward { get { return _EnsureCommand(CommandId.MoveFocusForward); } } ////// MoveFocusBack /// public static RoutedUICommand MoveFocusBack { get { return _EnsureCommand(CommandId.MoveFocusBack); } } ////// MoveFocusPageUp Command /// public static RoutedUICommand MoveFocusPageUp { get { return _EnsureCommand(CommandId.MoveFocusPageUp); } } ////// MoveFocusPageDown /// public static RoutedUICommand MoveFocusPageDown { get { return _EnsureCommand(CommandId.MoveFocusPageDown); } } #endregion Public Methods //------------------------------------------------------ // // Private Methods // //----------------------------------------------------- #region Private Methods private static string GetPropertyName(CommandId commandId) { string propertyName = String.Empty; switch (commandId) { case CommandId.ScrollPageUp:propertyName = "ScrollPageUp"; break; case CommandId.ScrollPageDown:propertyName = "ScrollPageDown"; break; case CommandId.ScrollPageLeft: propertyName = "ScrollPageLeft"; break; case CommandId.ScrollPageRight: propertyName = "ScrollPageRight"; break; case CommandId.ScrollByLine:propertyName = "ScrollByLine"; break; case CommandId.MoveLeft:propertyName = "MoveLeft";break; case CommandId.MoveRight:propertyName = "MoveRight";break; case CommandId.MoveUp:propertyName = "MoveUp"; break; case CommandId.MoveDown:propertyName = "MoveDown"; break; case CommandId.ExtendSelectionUp:propertyName = "ExtendSelectionUp"; break; case CommandId.ExtendSelectionDown:propertyName = "ExtendSelectionDown"; break; case CommandId.ExtendSelectionLeft:propertyName = "ExtendSelectionLeft"; break; case CommandId.ExtendSelectionRight:propertyName = "ExtendSelectionRight"; break; case CommandId.MoveToHome:propertyName = "MoveToHome"; break; case CommandId.MoveToEnd:propertyName = "MoveToEnd"; break; case CommandId.MoveToPageUp:propertyName = "MoveToPageUp"; break; case CommandId.MoveToPageDown:propertyName = "MoveToPageDown"; break; case CommandId.SelectToHome:propertyName = "SelectToHome"; break; case CommandId.SelectToEnd:propertyName = "SelectToEnd"; break; case CommandId.SelectToPageDown:propertyName = "SelectToPageDown"; break; case CommandId.SelectToPageUp:propertyName = "SelectToPageUp"; break; case CommandId.MoveFocusUp:propertyName = "MoveFocusUp"; break; case CommandId.MoveFocusDown:propertyName = "MoveFocusDown"; break; case CommandId.MoveFocusBack:propertyName = "MoveFocusBack"; break; case CommandId.MoveFocusForward:propertyName = "MoveFocusForward"; break; case CommandId.MoveFocusPageUp:propertyName = "MoveFocusPageUp"; break; case CommandId.MoveFocusPageDown:propertyName = "MoveFocusPageDown"; break; } return propertyName; } internal static string GetUIText(byte commandId) { string uiText = String.Empty; switch ((CommandId)commandId) { case CommandId.ScrollPageUp: uiText = SR.Get(SRID.ScrollPageUpText); break; case CommandId.ScrollPageDown: uiText = SR.Get(SRID.ScrollPageDownText); break; case CommandId.ScrollPageLeft: uiText = SR.Get(SRID.ScrollPageLeftText); break; case CommandId.ScrollPageRight: uiText = SR.Get(SRID.ScrollPageRightText); break; case CommandId.ScrollByLine: uiText = SR.Get(SRID.ScrollByLineText); break; case CommandId.MoveLeft:uiText = SR.Get(SRID.MoveLeftText);break; case CommandId.MoveRight:uiText = SR.Get(SRID.MoveRightText);break; case CommandId.MoveUp: uiText = SR.Get(SRID.MoveUpText); break; case CommandId.MoveDown: uiText = SR.Get(SRID.MoveDownText); break; case CommandId.ExtendSelectionUp: uiText = SR.Get(SRID.ExtendSelectionUpText); break; case CommandId.ExtendSelectionDown: uiText = SR.Get(SRID.ExtendSelectionDownText); break; case CommandId.ExtendSelectionLeft: uiText = SR.Get(SRID.ExtendSelectionLeftText); break; case CommandId.ExtendSelectionRight: uiText = SR.Get(SRID.ExtendSelectionRightText); break; case CommandId.MoveToHome: uiText = SR.Get(SRID.MoveToHomeText); break; case CommandId.MoveToEnd: uiText = SR.Get(SRID.MoveToEndText); break; case CommandId.MoveToPageUp: uiText = SR.Get(SRID.MoveToPageUpText); break; case CommandId.MoveToPageDown: uiText = SR.Get(SRID.MoveToPageDownText); break; case CommandId.SelectToHome: uiText = SR.Get(SRID.SelectToHomeText); break; case CommandId.SelectToEnd: uiText = SR.Get(SRID.SelectToEndText); break; case CommandId.SelectToPageDown: uiText = SR.Get(SRID.SelectToPageDownText); break; case CommandId.SelectToPageUp: uiText = SR.Get(SRID.SelectToPageUpText); break; case CommandId.MoveFocusUp: uiText = SR.Get(SRID.MoveFocusUpText); break; case CommandId.MoveFocusDown: uiText = SR.Get(SRID.MoveFocusDownText); break; case CommandId.MoveFocusBack: uiText = SR.Get(SRID.MoveFocusBackText); break; case CommandId.MoveFocusForward: uiText = SR.Get(SRID.MoveFocusForwardText); break; case CommandId.MoveFocusPageUp: uiText = SR.Get(SRID.MoveFocusPageUpText); break; case CommandId.MoveFocusPageDown: uiText = SR.Get(SRID.MoveFocusPageDownText); break; } return uiText; } internal static InputGestureCollection LoadDefaultGestureFromResource(byte commandId) { InputGestureCollection gestures = new InputGestureCollection(); //Standard Commands switch ((CommandId)commandId) { case CommandId.ScrollPageUp: KeyGesture.AddGesturesFromResourceStrings( SR.Get(SRID.ScrollPageUpKey), SR.Get(SRID.ScrollPageUpKeyDisplayString), gestures); break; case CommandId.ScrollPageDown: KeyGesture.AddGesturesFromResourceStrings( SR.Get(SRID.ScrollPageDownKey), SR.Get(SRID.ScrollPageDownKeyDisplayString), gestures); break; case CommandId.ScrollPageLeft: KeyGesture.AddGesturesFromResourceStrings( SR.Get(SRID.ScrollPageLeftKey), SR.Get(SRID.ScrollPageLeftKeyDisplayString), gestures); break; case CommandId.ScrollPageRight: KeyGesture.AddGesturesFromResourceStrings( SR.Get(SRID.ScrollPageRightKey), SR.Get(SRID.ScrollPageRightKeyDisplayString), gestures); break; case CommandId.ScrollByLine: KeyGesture.AddGesturesFromResourceStrings( SR.Get(SRID.ScrollByLineKey), SR.Get(SRID.ScrollByLineKeyDisplayString), gestures); break; case CommandId.MoveLeft: KeyGesture.AddGesturesFromResourceStrings( SR.Get(SRID.MoveLeftKey), SR.Get(SRID.MoveLeftKeyDisplayString), gestures); break; case CommandId.MoveRight: KeyGesture.AddGesturesFromResourceStrings( SR.Get(SRID.MoveRightKey), SR.Get(SRID.MoveRightKeyDisplayString), gestures); break; case CommandId.MoveUp: KeyGesture.AddGesturesFromResourceStrings( SR.Get(SRID.MoveUpKey), SR.Get(SRID.MoveUpKeyDisplayString), gestures); break; case CommandId.MoveDown: KeyGesture.AddGesturesFromResourceStrings( SR.Get(SRID.MoveDownKey), SR.Get(SRID.MoveDownKeyDisplayString), gestures); break; case CommandId.ExtendSelectionUp: KeyGesture.AddGesturesFromResourceStrings( SR.Get(SRID.ExtendSelectionUpKey), SR.Get(SRID.ExtendSelectionUpKeyDisplayString), gestures); break; case CommandId.ExtendSelectionDown: KeyGesture.AddGesturesFromResourceStrings( SR.Get(SRID.ExtendSelectionDownKey), SR.Get(SRID.ExtendSelectionDownKeyDisplayString), gestures); break; case CommandId.ExtendSelectionLeft: KeyGesture.AddGesturesFromResourceStrings( SR.Get(SRID.ExtendSelectionLeftKey), SR.Get(SRID.ExtendSelectionLeftKeyDisplayString), gestures); break; case CommandId.ExtendSelectionRight: KeyGesture.AddGesturesFromResourceStrings( SR.Get(SRID.ExtendSelectionRightKey), SR.Get(SRID.ExtendSelectionRightKeyDisplayString), gestures); break; case CommandId.MoveToHome: KeyGesture.AddGesturesFromResourceStrings( SR.Get(SRID.MoveToHomeKey), SR.Get(SRID.MoveToHomeKeyDisplayString), gestures); break; case CommandId.MoveToEnd: KeyGesture.AddGesturesFromResourceStrings( SR.Get(SRID.MoveToEndKey), SR.Get(SRID.MoveToEndKeyDisplayString), gestures); break; case CommandId.MoveToPageUp: KeyGesture.AddGesturesFromResourceStrings( SR.Get(SRID.MoveToPageUpKey), SR.Get(SRID.MoveToPageUpKeyDisplayString), gestures); break; case CommandId.MoveToPageDown: KeyGesture.AddGesturesFromResourceStrings( SR.Get(SRID.MoveToPageDownKey), SR.Get(SRID.MoveToPageDownKeyDisplayString), gestures); break; case CommandId.SelectToHome: KeyGesture.AddGesturesFromResourceStrings( SR.Get(SRID.SelectToHomeKey), SR.Get(SRID.SelectToHomeKeyDisplayString), gestures); break; case CommandId.SelectToEnd: KeyGesture.AddGesturesFromResourceStrings( SR.Get(SRID.SelectToEndKey), SR.Get(SRID.SelectToEndKeyDisplayString), gestures); break; case CommandId.SelectToPageDown: KeyGesture.AddGesturesFromResourceStrings( SR.Get(SRID.SelectToPageDownKey), SR.Get(SRID.SelectToPageDownKeyDisplayString), gestures); break; case CommandId.SelectToPageUp: KeyGesture.AddGesturesFromResourceStrings( SR.Get(SRID.SelectToPageUpKey), SR.Get(SRID.SelectToPageUpKeyDisplayString), gestures); break; case CommandId.MoveFocusUp: KeyGesture.AddGesturesFromResourceStrings( SR.Get(SRID.MoveFocusUpKey), SR.Get(SRID.MoveFocusUpKeyDisplayString), gestures); break; case CommandId.MoveFocusDown: KeyGesture.AddGesturesFromResourceStrings( SR.Get(SRID.MoveFocusDownKey), SR.Get(SRID.MoveFocusDownKeyDisplayString), gestures); break; case CommandId.MoveFocusBack: KeyGesture.AddGesturesFromResourceStrings( SR.Get(SRID.MoveFocusBackKey), SR.Get(SRID.MoveFocusBackKeyDisplayString), gestures); break; case CommandId.MoveFocusForward: KeyGesture.AddGesturesFromResourceStrings( SR.Get(SRID.MoveFocusForwardKey), SR.Get(SRID.MoveFocusForwardKeyDisplayString), gestures); break; case CommandId.MoveFocusPageUp: KeyGesture.AddGesturesFromResourceStrings( SR.Get(SRID.MoveFocusPageUpKey), SR.Get(SRID.MoveFocusPageUpKeyDisplayString), gestures); break; case CommandId.MoveFocusPageDown: KeyGesture.AddGesturesFromResourceStrings( SR.Get(SRID.MoveFocusPageDownKey), SR.Get(SRID.MoveFocusPageDownKeyDisplayString), gestures); break; } return gestures; } private static RoutedUICommand _EnsureCommand(CommandId idCommand) { if (idCommand >= 0 && idCommand < CommandId.Last) { lock (_internalCommands.SyncRoot) { if (_internalCommands[(int)idCommand] == null) { RoutedUICommand newCommand = new RoutedUICommand(GetPropertyName(idCommand), typeof(ComponentCommands), (byte)idCommand); newCommand.AreInputGesturesDelayLoaded = true; _internalCommands[(int)idCommand] = newCommand; } } return _internalCommands[(int)idCommand]; } return null; } #endregion Private Methods //------------------------------------------------------ // // Private Fields // //------------------------------------------------------ #region Private Fields // these constants will go away in future, its just to index into the right one. private enum CommandId : byte { // Formatting ScrollPageUp = 1, ScrollPageDown = 2, ScrollPageLeft = 3, ScrollPageRight = 4, ScrollByLine = 5, MoveLeft = 6, MoveRight = 7, MoveUp = 8, MoveDown = 9, MoveToHome = 10, MoveToEnd = 11, MoveToPageUp = 12, MoveToPageDown = 13, SelectToHome = 14, SelectToEnd = 15, SelectToPageUp = 16, SelectToPageDown = 17, MoveFocusUp = 18, MoveFocusDown = 19, MoveFocusForward = 20, MoveFocusBack = 21, MoveFocusPageUp = 22, MoveFocusPageDown = 23, ExtendSelectionLeft = 24, ExtendSelectionRight = 25, ExtendSelectionUp = 26, ExtendSelectionDown = 27, // Last Last = 28 } private static RoutedUICommand[] _internalCommands = new RoutedUICommand[(int)CommandId.Last]; #endregion Private Fields } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. //---------------------------------------------------------------------------- // //// Copyright (C) Microsoft Corporation. All rights reserved. // // // // Description: The ComponentCommands class defines a standard set of commands that are required in Controls. // // See spec at : http://avalon/CoreUI/Specs%20%20Eventing%20and%20Commanding/CommandLibrarySpec.mht // // // History: // 03/31/2004 : chandras - Created // 04/28/2004 : Added Accelerator table loading from Resource // 02/02/2005 : Created ComponentCommands class from CommandLibrary class. // //--------------------------------------------------------------------------- using System; using System.Windows; using System.Windows.Input; using System.Collections; using System.ComponentModel; using SR=MS.Internal.PresentationCore.SR; using SRID=MS.Internal.PresentationCore.SRID; namespace System.Windows.Input { ////// ComponentCommands - Set of Standard Commands /// public static class ComponentCommands { //----------------------------------------------------- // // Public Methods // //----------------------------------------------------- #region Public Methods ////// ScrollPageUp Command /// public static RoutedUICommand ScrollPageUp { get { return _EnsureCommand(CommandId.ScrollPageUp); } } ////// ScrollPageDown Command /// public static RoutedUICommand ScrollPageDown { get { return _EnsureCommand(CommandId.ScrollPageDown); } } ////// ScrollPageLeft Command /// public static RoutedUICommand ScrollPageLeft { get { return _EnsureCommand(CommandId.ScrollPageLeft); } } ////// ScrollPageRight Command /// public static RoutedUICommand ScrollPageRight { get { return _EnsureCommand(CommandId.ScrollPageRight); } } ////// ScrollByLine Command /// public static RoutedUICommand ScrollByLine { get { return _EnsureCommand(CommandId.ScrollByLine); } } ////// MoveLeft Command /// public static RoutedUICommand MoveLeft { get { return _EnsureCommand(CommandId.MoveLeft); } } ////// MoveRight Command /// public static RoutedUICommand MoveRight { get { return _EnsureCommand(CommandId.MoveRight); } } ////// MoveUp Command /// public static RoutedUICommand MoveUp { get { return _EnsureCommand(CommandId.MoveUp); } } ////// MoveDown Command /// public static RoutedUICommand MoveDown { get { return _EnsureCommand(CommandId.MoveDown); } } ////// MoveToHome Command /// public static RoutedUICommand MoveToHome { get { return _EnsureCommand(CommandId.MoveToHome); } } ////// MoveToEnd Command /// public static RoutedUICommand MoveToEnd { get { return _EnsureCommand(CommandId.MoveToEnd); } } ////// MoveToPageUp Command /// public static RoutedUICommand MoveToPageUp { get { return _EnsureCommand(CommandId.MoveToPageUp); } } ////// MoveToPageDown Command /// public static RoutedUICommand MoveToPageDown { get { return _EnsureCommand(CommandId.MoveToPageDown); } } ////// Extend Selection Up Command /// public static RoutedUICommand ExtendSelectionUp { get { return _EnsureCommand(CommandId.ExtendSelectionUp); } } ////// ExtendSelectionDown Command /// public static RoutedUICommand ExtendSelectionDown { get { return _EnsureCommand(CommandId.ExtendSelectionDown); } } ////// ExtendSelectionLeft Command /// public static RoutedUICommand ExtendSelectionLeft { get { return _EnsureCommand(CommandId.ExtendSelectionLeft); } } ////// ExtendSelectionRight Command /// public static RoutedUICommand ExtendSelectionRight { get { return _EnsureCommand(CommandId.ExtendSelectionRight); } } ////// SelectToHome Command /// public static RoutedUICommand SelectToHome { get { return _EnsureCommand(CommandId.SelectToHome); } } ////// SelectToEnd Command /// public static RoutedUICommand SelectToEnd { get { return _EnsureCommand(CommandId.SelectToEnd); } } ////// SelectToPageUp Command /// public static RoutedUICommand SelectToPageUp { get { return _EnsureCommand(CommandId.SelectToPageUp); } } ////// SelectToPageDown Command /// public static RoutedUICommand SelectToPageDown { get { return _EnsureCommand(CommandId.SelectToPageDown); } } ////// MoveFocusUp Command /// public static RoutedUICommand MoveFocusUp { get { return _EnsureCommand(CommandId.MoveFocusUp); } } ////// MoveFocusDown Command /// public static RoutedUICommand MoveFocusDown { get { return _EnsureCommand(CommandId.MoveFocusDown); } } ////// MoveFocusForward Command /// public static RoutedUICommand MoveFocusForward { get { return _EnsureCommand(CommandId.MoveFocusForward); } } ////// MoveFocusBack /// public static RoutedUICommand MoveFocusBack { get { return _EnsureCommand(CommandId.MoveFocusBack); } } ////// MoveFocusPageUp Command /// public static RoutedUICommand MoveFocusPageUp { get { return _EnsureCommand(CommandId.MoveFocusPageUp); } } ////// MoveFocusPageDown /// public static RoutedUICommand MoveFocusPageDown { get { return _EnsureCommand(CommandId.MoveFocusPageDown); } } #endregion Public Methods //------------------------------------------------------ // // Private Methods // //----------------------------------------------------- #region Private Methods private static string GetPropertyName(CommandId commandId) { string propertyName = String.Empty; switch (commandId) { case CommandId.ScrollPageUp:propertyName = "ScrollPageUp"; break; case CommandId.ScrollPageDown:propertyName = "ScrollPageDown"; break; case CommandId.ScrollPageLeft: propertyName = "ScrollPageLeft"; break; case CommandId.ScrollPageRight: propertyName = "ScrollPageRight"; break; case CommandId.ScrollByLine:propertyName = "ScrollByLine"; break; case CommandId.MoveLeft:propertyName = "MoveLeft";break; case CommandId.MoveRight:propertyName = "MoveRight";break; case CommandId.MoveUp:propertyName = "MoveUp"; break; case CommandId.MoveDown:propertyName = "MoveDown"; break; case CommandId.ExtendSelectionUp:propertyName = "ExtendSelectionUp"; break; case CommandId.ExtendSelectionDown:propertyName = "ExtendSelectionDown"; break; case CommandId.ExtendSelectionLeft:propertyName = "ExtendSelectionLeft"; break; case CommandId.ExtendSelectionRight:propertyName = "ExtendSelectionRight"; break; case CommandId.MoveToHome:propertyName = "MoveToHome"; break; case CommandId.MoveToEnd:propertyName = "MoveToEnd"; break; case CommandId.MoveToPageUp:propertyName = "MoveToPageUp"; break; case CommandId.MoveToPageDown:propertyName = "MoveToPageDown"; break; case CommandId.SelectToHome:propertyName = "SelectToHome"; break; case CommandId.SelectToEnd:propertyName = "SelectToEnd"; break; case CommandId.SelectToPageDown:propertyName = "SelectToPageDown"; break; case CommandId.SelectToPageUp:propertyName = "SelectToPageUp"; break; case CommandId.MoveFocusUp:propertyName = "MoveFocusUp"; break; case CommandId.MoveFocusDown:propertyName = "MoveFocusDown"; break; case CommandId.MoveFocusBack:propertyName = "MoveFocusBack"; break; case CommandId.MoveFocusForward:propertyName = "MoveFocusForward"; break; case CommandId.MoveFocusPageUp:propertyName = "MoveFocusPageUp"; break; case CommandId.MoveFocusPageDown:propertyName = "MoveFocusPageDown"; break; } return propertyName; } internal static string GetUIText(byte commandId) { string uiText = String.Empty; switch ((CommandId)commandId) { case CommandId.ScrollPageUp: uiText = SR.Get(SRID.ScrollPageUpText); break; case CommandId.ScrollPageDown: uiText = SR.Get(SRID.ScrollPageDownText); break; case CommandId.ScrollPageLeft: uiText = SR.Get(SRID.ScrollPageLeftText); break; case CommandId.ScrollPageRight: uiText = SR.Get(SRID.ScrollPageRightText); break; case CommandId.ScrollByLine: uiText = SR.Get(SRID.ScrollByLineText); break; case CommandId.MoveLeft:uiText = SR.Get(SRID.MoveLeftText);break; case CommandId.MoveRight:uiText = SR.Get(SRID.MoveRightText);break; case CommandId.MoveUp: uiText = SR.Get(SRID.MoveUpText); break; case CommandId.MoveDown: uiText = SR.Get(SRID.MoveDownText); break; case CommandId.ExtendSelectionUp: uiText = SR.Get(SRID.ExtendSelectionUpText); break; case CommandId.ExtendSelectionDown: uiText = SR.Get(SRID.ExtendSelectionDownText); break; case CommandId.ExtendSelectionLeft: uiText = SR.Get(SRID.ExtendSelectionLeftText); break; case CommandId.ExtendSelectionRight: uiText = SR.Get(SRID.ExtendSelectionRightText); break; case CommandId.MoveToHome: uiText = SR.Get(SRID.MoveToHomeText); break; case CommandId.MoveToEnd: uiText = SR.Get(SRID.MoveToEndText); break; case CommandId.MoveToPageUp: uiText = SR.Get(SRID.MoveToPageUpText); break; case CommandId.MoveToPageDown: uiText = SR.Get(SRID.MoveToPageDownText); break; case CommandId.SelectToHome: uiText = SR.Get(SRID.SelectToHomeText); break; case CommandId.SelectToEnd: uiText = SR.Get(SRID.SelectToEndText); break; case CommandId.SelectToPageDown: uiText = SR.Get(SRID.SelectToPageDownText); break; case CommandId.SelectToPageUp: uiText = SR.Get(SRID.SelectToPageUpText); break; case CommandId.MoveFocusUp: uiText = SR.Get(SRID.MoveFocusUpText); break; case CommandId.MoveFocusDown: uiText = SR.Get(SRID.MoveFocusDownText); break; case CommandId.MoveFocusBack: uiText = SR.Get(SRID.MoveFocusBackText); break; case CommandId.MoveFocusForward: uiText = SR.Get(SRID.MoveFocusForwardText); break; case CommandId.MoveFocusPageUp: uiText = SR.Get(SRID.MoveFocusPageUpText); break; case CommandId.MoveFocusPageDown: uiText = SR.Get(SRID.MoveFocusPageDownText); break; } return uiText; } internal static InputGestureCollection LoadDefaultGestureFromResource(byte commandId) { InputGestureCollection gestures = new InputGestureCollection(); //Standard Commands switch ((CommandId)commandId) { case CommandId.ScrollPageUp: KeyGesture.AddGesturesFromResourceStrings( SR.Get(SRID.ScrollPageUpKey), SR.Get(SRID.ScrollPageUpKeyDisplayString), gestures); break; case CommandId.ScrollPageDown: KeyGesture.AddGesturesFromResourceStrings( SR.Get(SRID.ScrollPageDownKey), SR.Get(SRID.ScrollPageDownKeyDisplayString), gestures); break; case CommandId.ScrollPageLeft: KeyGesture.AddGesturesFromResourceStrings( SR.Get(SRID.ScrollPageLeftKey), SR.Get(SRID.ScrollPageLeftKeyDisplayString), gestures); break; case CommandId.ScrollPageRight: KeyGesture.AddGesturesFromResourceStrings( SR.Get(SRID.ScrollPageRightKey), SR.Get(SRID.ScrollPageRightKeyDisplayString), gestures); break; case CommandId.ScrollByLine: KeyGesture.AddGesturesFromResourceStrings( SR.Get(SRID.ScrollByLineKey), SR.Get(SRID.ScrollByLineKeyDisplayString), gestures); break; case CommandId.MoveLeft: KeyGesture.AddGesturesFromResourceStrings( SR.Get(SRID.MoveLeftKey), SR.Get(SRID.MoveLeftKeyDisplayString), gestures); break; case CommandId.MoveRight: KeyGesture.AddGesturesFromResourceStrings( SR.Get(SRID.MoveRightKey), SR.Get(SRID.MoveRightKeyDisplayString), gestures); break; case CommandId.MoveUp: KeyGesture.AddGesturesFromResourceStrings( SR.Get(SRID.MoveUpKey), SR.Get(SRID.MoveUpKeyDisplayString), gestures); break; case CommandId.MoveDown: KeyGesture.AddGesturesFromResourceStrings( SR.Get(SRID.MoveDownKey), SR.Get(SRID.MoveDownKeyDisplayString), gestures); break; case CommandId.ExtendSelectionUp: KeyGesture.AddGesturesFromResourceStrings( SR.Get(SRID.ExtendSelectionUpKey), SR.Get(SRID.ExtendSelectionUpKeyDisplayString), gestures); break; case CommandId.ExtendSelectionDown: KeyGesture.AddGesturesFromResourceStrings( SR.Get(SRID.ExtendSelectionDownKey), SR.Get(SRID.ExtendSelectionDownKeyDisplayString), gestures); break; case CommandId.ExtendSelectionLeft: KeyGesture.AddGesturesFromResourceStrings( SR.Get(SRID.ExtendSelectionLeftKey), SR.Get(SRID.ExtendSelectionLeftKeyDisplayString), gestures); break; case CommandId.ExtendSelectionRight: KeyGesture.AddGesturesFromResourceStrings( SR.Get(SRID.ExtendSelectionRightKey), SR.Get(SRID.ExtendSelectionRightKeyDisplayString), gestures); break; case CommandId.MoveToHome: KeyGesture.AddGesturesFromResourceStrings( SR.Get(SRID.MoveToHomeKey), SR.Get(SRID.MoveToHomeKeyDisplayString), gestures); break; case CommandId.MoveToEnd: KeyGesture.AddGesturesFromResourceStrings( SR.Get(SRID.MoveToEndKey), SR.Get(SRID.MoveToEndKeyDisplayString), gestures); break; case CommandId.MoveToPageUp: KeyGesture.AddGesturesFromResourceStrings( SR.Get(SRID.MoveToPageUpKey), SR.Get(SRID.MoveToPageUpKeyDisplayString), gestures); break; case CommandId.MoveToPageDown: KeyGesture.AddGesturesFromResourceStrings( SR.Get(SRID.MoveToPageDownKey), SR.Get(SRID.MoveToPageDownKeyDisplayString), gestures); break; case CommandId.SelectToHome: KeyGesture.AddGesturesFromResourceStrings( SR.Get(SRID.SelectToHomeKey), SR.Get(SRID.SelectToHomeKeyDisplayString), gestures); break; case CommandId.SelectToEnd: KeyGesture.AddGesturesFromResourceStrings( SR.Get(SRID.SelectToEndKey), SR.Get(SRID.SelectToEndKeyDisplayString), gestures); break; case CommandId.SelectToPageDown: KeyGesture.AddGesturesFromResourceStrings( SR.Get(SRID.SelectToPageDownKey), SR.Get(SRID.SelectToPageDownKeyDisplayString), gestures); break; case CommandId.SelectToPageUp: KeyGesture.AddGesturesFromResourceStrings( SR.Get(SRID.SelectToPageUpKey), SR.Get(SRID.SelectToPageUpKeyDisplayString), gestures); break; case CommandId.MoveFocusUp: KeyGesture.AddGesturesFromResourceStrings( SR.Get(SRID.MoveFocusUpKey), SR.Get(SRID.MoveFocusUpKeyDisplayString), gestures); break; case CommandId.MoveFocusDown: KeyGesture.AddGesturesFromResourceStrings( SR.Get(SRID.MoveFocusDownKey), SR.Get(SRID.MoveFocusDownKeyDisplayString), gestures); break; case CommandId.MoveFocusBack: KeyGesture.AddGesturesFromResourceStrings( SR.Get(SRID.MoveFocusBackKey), SR.Get(SRID.MoveFocusBackKeyDisplayString), gestures); break; case CommandId.MoveFocusForward: KeyGesture.AddGesturesFromResourceStrings( SR.Get(SRID.MoveFocusForwardKey), SR.Get(SRID.MoveFocusForwardKeyDisplayString), gestures); break; case CommandId.MoveFocusPageUp: KeyGesture.AddGesturesFromResourceStrings( SR.Get(SRID.MoveFocusPageUpKey), SR.Get(SRID.MoveFocusPageUpKeyDisplayString), gestures); break; case CommandId.MoveFocusPageDown: KeyGesture.AddGesturesFromResourceStrings( SR.Get(SRID.MoveFocusPageDownKey), SR.Get(SRID.MoveFocusPageDownKeyDisplayString), gestures); break; } return gestures; } private static RoutedUICommand _EnsureCommand(CommandId idCommand) { if (idCommand >= 0 && idCommand < CommandId.Last) { lock (_internalCommands.SyncRoot) { if (_internalCommands[(int)idCommand] == null) { RoutedUICommand newCommand = new RoutedUICommand(GetPropertyName(idCommand), typeof(ComponentCommands), (byte)idCommand); newCommand.AreInputGesturesDelayLoaded = true; _internalCommands[(int)idCommand] = newCommand; } } return _internalCommands[(int)idCommand]; } return null; } #endregion Private Methods //------------------------------------------------------ // // Private Fields // //------------------------------------------------------ #region Private Fields // these constants will go away in future, its just to index into the right one. private enum CommandId : byte { // Formatting ScrollPageUp = 1, ScrollPageDown = 2, ScrollPageLeft = 3, ScrollPageRight = 4, ScrollByLine = 5, MoveLeft = 6, MoveRight = 7, MoveUp = 8, MoveDown = 9, MoveToHome = 10, MoveToEnd = 11, MoveToPageUp = 12, MoveToPageDown = 13, SelectToHome = 14, SelectToEnd = 15, SelectToPageUp = 16, SelectToPageDown = 17, MoveFocusUp = 18, MoveFocusDown = 19, MoveFocusForward = 20, MoveFocusBack = 21, MoveFocusPageUp = 22, MoveFocusPageDown = 23, ExtendSelectionLeft = 24, ExtendSelectionRight = 25, ExtendSelectionUp = 26, ExtendSelectionDown = 27, // Last Last = 28 } private static RoutedUICommand[] _internalCommands = new RoutedUICommand[(int)CommandId.Last]; #endregion Private Fields } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- RealProxy.cs
- BinaryObjectWriter.cs
- ValueUtilsSmi.cs
- METAHEADER.cs
- Matrix3DConverter.cs
- StringFreezingAttribute.cs
- MimeParameter.cs
- MatrixTransform3D.cs
- PeerNameRecord.cs
- DownloadProgressEventArgs.cs
- EntityDataSourceChangingEventArgs.cs
- SendMailErrorEventArgs.cs
- StateDesigner.cs
- ValidationManager.cs
- DataAdapter.cs
- ServiceReference.cs
- OptimizedTemplateContent.cs
- httpstaticobjectscollection.cs
- PersonalizationStateQuery.cs
- AudioDeviceOut.cs
- DataGridRelationshipRow.cs
- EntityDataSourceReferenceGroup.cs
- PersonalizationStateQuery.cs
- Focus.cs
- Method.cs
- FormsAuthenticationConfiguration.cs
- LocalizableAttribute.cs
- Win32.cs
- ThemeDictionaryExtension.cs
- SHA256Managed.cs
- CodeGeneratorOptions.cs
- DrawingAttributesDefaultValueFactory.cs
- SelectedCellsCollection.cs
- Documentation.cs
- ModifierKeysValueSerializer.cs
- CollectionChangeEventArgs.cs
- ContextMarshalException.cs
- UnhandledExceptionEventArgs.cs
- HttpCacheVary.cs
- ButtonBaseDesigner.cs
- SqlUtils.cs
- PassportPrincipal.cs
- CommonDialog.cs
- Compiler.cs
- MailHeaderInfo.cs
- SafeHandles.cs
- PeerCustomResolverSettings.cs
- AddInEnvironment.cs
- ListView.cs
- CodeMemberEvent.cs
- SoundPlayerAction.cs
- MeasureData.cs
- HandledMouseEvent.cs
- propertyentry.cs
- DirectoryObjectSecurity.cs
- ToggleButtonAutomationPeer.cs
- DataGridLengthConverter.cs
- RawUIStateInputReport.cs
- ClientSponsor.cs
- backend.cs
- DecimalAnimation.cs
- mediaeventargs.cs
- SerializationHelper.cs
- ObfuscationAttribute.cs
- NativeMethods.cs
- DataGrid.cs
- formatter.cs
- Stylus.cs
- X509Utils.cs
- WebPartManagerInternals.cs
- StateInitialization.cs
- CodeArrayCreateExpression.cs
- SmtpReplyReader.cs
- TypedOperationInfo.cs
- Decoder.cs
- FtpRequestCacheValidator.cs
- HtmlTitle.cs
- TypeHelper.cs
- UInt64.cs
- Size.cs
- AccessDataSourceView.cs
- ZoneLinkButton.cs
- Rule.cs
- PersonalizationProvider.cs
- DeclarativeCatalogPart.cs
- ExecutedRoutedEventArgs.cs
- RegexWriter.cs
- StatusStrip.cs
- RelationshipType.cs
- OrderedDictionaryStateHelper.cs
- ConnectionStringSettingsCollection.cs
- XmlSchemaAttributeGroup.cs
- DocumentViewerConstants.cs
- RegexCharClass.cs
- __Filters.cs
- SqlConnectionPoolGroupProviderInfo.cs
- ColumnPropertiesGroup.cs
- DataGridState.cs
- CqlQuery.cs
- ServicePointManagerElement.cs