Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / wpf / src / Core / CSharp / System / Windows / Input / Command / MouseGesture.cs / 1 / MouseGesture.cs
//---------------------------------------------------------------------------- // //// Copyright (C) Microsoft Corporation. All rights reserved. // // // // Description: The MouseGesture class is used by the developer to create Gestures for // Mouse Device // // See spec at : http://avalon/coreUI/Specs/Commanding%20--%20design.htm // // // History: // 03/26/2004 : chandras - Created // //--------------------------------------------------------------------------- using System; using System.Windows.Input; using System.Windows; using System.Windows.Markup; using System.ComponentModel; namespace System.Windows.Input { ////// MouseGesture - MouseAction and Modifier combination. /// Can be set on properties of MouseBinding and RoutedCommand. /// [TypeConverter(typeof(MouseGestureConverter))] [ValueSerializer(typeof(MouseGestureValueSerializer))] public class MouseGesture : InputGesture { //----------------------------------------------------- // // Constructors // //----------------------------------------------------- #region Constructors ////// Constructor /// public MouseGesture() // Mouse action { } ////// constructor /// /// Mouse Action public MouseGesture(MouseAction mouseAction): this(mouseAction, ModifierKeys.None) { } ////// Constructor /// /// Mouse Action /// Modifiers public MouseGesture( MouseAction mouseAction,ModifierKeys modifiers) // acclerator action { if (!MouseGesture.IsDefinedMouseAction(mouseAction)) throw new InvalidEnumArgumentException("mouseAction", (int)mouseAction, typeof(MouseAction)); if (!ModifierKeysConverter.IsDefinedModifierKeys(modifiers)) throw new InvalidEnumArgumentException("modifiers", (int)modifiers, typeof(ModifierKeys)); _modifiers = modifiers; _mouseAction = mouseAction; //AttachClassListeners(); } #endregion Constructors //------------------------------------------------------ // // Public Methods // //----------------------------------------------------- #region Public Methods ////// Action /// public MouseAction MouseAction { get { return _mouseAction; } set { if (!MouseGesture.IsDefinedMouseAction((MouseAction)value)) throw new InvalidEnumArgumentException("value", (int)value, typeof(MouseAction)); _mouseAction = (MouseAction)value; } } ////// Modifiers /// public ModifierKeys Modifiers { get { return _modifiers; } set { if (!ModifierKeysConverter.IsDefinedModifierKeys((ModifierKeys)value)) throw new InvalidEnumArgumentException("value", (int)value, typeof(ModifierKeys)); _modifiers = (ModifierKeys)value; } } ////// Compares InputEventArgs with current Input /// /// the element to receive the command /// inputEventArgs to compare to ///True - if matches, false otherwise. /// public override bool Matches(object targetElement, InputEventArgs inputEventArgs) { MouseAction mouseAction = GetMouseAction(inputEventArgs); if(mouseAction != MouseAction.None) { return ( ( (int)this.MouseAction == (int)mouseAction ) && ( this.Modifiers == Keyboard.Modifiers ) ); } return false; } // Helper like Enum.IsDefined, for MouseAction. internal static bool IsDefinedMouseAction(MouseAction mouseAction) { return (mouseAction >= MouseAction.None && mouseAction <= MouseAction.MiddleDoubleClick); } #endregion Public Methods //------------------------------------------------------ // // Internal Methods // //------------------------------------------------------ #region Internal Methods internal static MouseAction GetMouseAction(InputEventArgs inputArgs) { MouseAction MouseAction = MouseAction.None; MouseEventArgs mouseArgs = inputArgs as MouseEventArgs; if(mouseArgs != null) { if(inputArgs is MouseWheelEventArgs) { MouseAction = MouseAction.WheelClick; } else { MouseButtonEventArgs args = inputArgs as MouseButtonEventArgs; switch(args.ChangedButton) { case MouseButton.Left: { if(args.ClickCount == 2) MouseAction = MouseAction.LeftDoubleClick; else if(args.ClickCount == 1) MouseAction = MouseAction.LeftClick; } break; case MouseButton.Right: { if(args.ClickCount == 2) MouseAction = MouseAction.RightDoubleClick; else if(args.ClickCount == 1) MouseAction = MouseAction.RightClick; } break; case MouseButton.Middle: { if(args.ClickCount == 2) MouseAction = MouseAction.MiddleDoubleClick; else if(args.ClickCount == 1) MouseAction = MouseAction.MiddleClick; } break; } } } return MouseAction; } #endregion Internal Methods //----------------------------------------------------- // // Private Fields // //------------------------------------------------------ #region Private Fields private MouseAction _mouseAction = MouseAction.None; private ModifierKeys _modifiers = ModifierKeys.None; // private static bool _classRegistered = false; #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 MouseGesture class is used by the developer to create Gestures for // Mouse Device // // See spec at : http://avalon/coreUI/Specs/Commanding%20--%20design.htm // // // History: // 03/26/2004 : chandras - Created // //--------------------------------------------------------------------------- using System; using System.Windows.Input; using System.Windows; using System.Windows.Markup; using System.ComponentModel; namespace System.Windows.Input { ////// MouseGesture - MouseAction and Modifier combination. /// Can be set on properties of MouseBinding and RoutedCommand. /// [TypeConverter(typeof(MouseGestureConverter))] [ValueSerializer(typeof(MouseGestureValueSerializer))] public class MouseGesture : InputGesture { //----------------------------------------------------- // // Constructors // //----------------------------------------------------- #region Constructors ////// Constructor /// public MouseGesture() // Mouse action { } ////// constructor /// /// Mouse Action public MouseGesture(MouseAction mouseAction): this(mouseAction, ModifierKeys.None) { } ////// Constructor /// /// Mouse Action /// Modifiers public MouseGesture( MouseAction mouseAction,ModifierKeys modifiers) // acclerator action { if (!MouseGesture.IsDefinedMouseAction(mouseAction)) throw new InvalidEnumArgumentException("mouseAction", (int)mouseAction, typeof(MouseAction)); if (!ModifierKeysConverter.IsDefinedModifierKeys(modifiers)) throw new InvalidEnumArgumentException("modifiers", (int)modifiers, typeof(ModifierKeys)); _modifiers = modifiers; _mouseAction = mouseAction; //AttachClassListeners(); } #endregion Constructors //------------------------------------------------------ // // Public Methods // //----------------------------------------------------- #region Public Methods ////// Action /// public MouseAction MouseAction { get { return _mouseAction; } set { if (!MouseGesture.IsDefinedMouseAction((MouseAction)value)) throw new InvalidEnumArgumentException("value", (int)value, typeof(MouseAction)); _mouseAction = (MouseAction)value; } } ////// Modifiers /// public ModifierKeys Modifiers { get { return _modifiers; } set { if (!ModifierKeysConverter.IsDefinedModifierKeys((ModifierKeys)value)) throw new InvalidEnumArgumentException("value", (int)value, typeof(ModifierKeys)); _modifiers = (ModifierKeys)value; } } ////// Compares InputEventArgs with current Input /// /// the element to receive the command /// inputEventArgs to compare to ///True - if matches, false otherwise. /// public override bool Matches(object targetElement, InputEventArgs inputEventArgs) { MouseAction mouseAction = GetMouseAction(inputEventArgs); if(mouseAction != MouseAction.None) { return ( ( (int)this.MouseAction == (int)mouseAction ) && ( this.Modifiers == Keyboard.Modifiers ) ); } return false; } // Helper like Enum.IsDefined, for MouseAction. internal static bool IsDefinedMouseAction(MouseAction mouseAction) { return (mouseAction >= MouseAction.None && mouseAction <= MouseAction.MiddleDoubleClick); } #endregion Public Methods //------------------------------------------------------ // // Internal Methods // //------------------------------------------------------ #region Internal Methods internal static MouseAction GetMouseAction(InputEventArgs inputArgs) { MouseAction MouseAction = MouseAction.None; MouseEventArgs mouseArgs = inputArgs as MouseEventArgs; if(mouseArgs != null) { if(inputArgs is MouseWheelEventArgs) { MouseAction = MouseAction.WheelClick; } else { MouseButtonEventArgs args = inputArgs as MouseButtonEventArgs; switch(args.ChangedButton) { case MouseButton.Left: { if(args.ClickCount == 2) MouseAction = MouseAction.LeftDoubleClick; else if(args.ClickCount == 1) MouseAction = MouseAction.LeftClick; } break; case MouseButton.Right: { if(args.ClickCount == 2) MouseAction = MouseAction.RightDoubleClick; else if(args.ClickCount == 1) MouseAction = MouseAction.RightClick; } break; case MouseButton.Middle: { if(args.ClickCount == 2) MouseAction = MouseAction.MiddleDoubleClick; else if(args.ClickCount == 1) MouseAction = MouseAction.MiddleClick; } break; } } } return MouseAction; } #endregion Internal Methods //----------------------------------------------------- // // Private Fields // //------------------------------------------------------ #region Private Fields private MouseAction _mouseAction = MouseAction.None; private ModifierKeys _modifiers = ModifierKeys.None; // private static bool _classRegistered = false; #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
- TranslateTransform3D.cs
- PropertyOverridesDialog.cs
- CacheChildrenQuery.cs
- PrimitiveXmlSerializers.cs
- SafeProcessHandle.cs
- ConfigurationSettings.cs
- SelectionEditor.cs
- WS2007FederationHttpBindingCollectionElement.cs
- XmlSerializerVersionAttribute.cs
- EdmScalarPropertyAttribute.cs
- ValueTypeIndexerReference.cs
- TreeNodeMouseHoverEvent.cs
- SiteMapHierarchicalDataSourceView.cs
- ListViewTableRow.cs
- CustomExpressionEventArgs.cs
- MouseEventArgs.cs
- WindowsListViewGroupHelper.cs
- ColorIndependentAnimationStorage.cs
- DataFormats.cs
- ItemDragEvent.cs
- ColumnClickEvent.cs
- WebPartsPersonalizationAuthorization.cs
- PlanCompiler.cs
- GlobalItem.cs
- XhtmlBasicPageAdapter.cs
- SapiRecoInterop.cs
- Membership.cs
- FieldNameLookup.cs
- InteropExecutor.cs
- HatchBrush.cs
- X509CertificateCollection.cs
- ValidationEventArgs.cs
- SharedStream.cs
- SafeReversePInvokeHandle.cs
- ShapingWorkspace.cs
- ProxyFragment.cs
- PropagatorResult.cs
- _IPv4Address.cs
- MetaDataInfo.cs
- TrackingServices.cs
- TranslateTransform.cs
- MessageQueueKey.cs
- EndpointIdentityConverter.cs
- HelpInfo.cs
- BackoffTimeoutHelper.cs
- RandomNumberGenerator.cs
- HttpWrapper.cs
- SamlAssertionDirectKeyIdentifierClause.cs
- TransformerTypeCollection.cs
- serverconfig.cs
- TableLayoutColumnStyleCollection.cs
- GetLedgerRequest.cs
- CompilerErrorCollection.cs
- ToolBarTray.cs
- MonthChangedEventArgs.cs
- FindCriteriaApril2005.cs
- DataTableCollection.cs
- DoubleConverter.cs
- PersonalizationStateInfo.cs
- WindowsAltTab.cs
- WindowsFormsHost.cs
- HtmlFormWrapper.cs
- Button.cs
- AlphabeticalEnumConverter.cs
- TemplateKey.cs
- Win32KeyboardDevice.cs
- EventItfInfo.cs
- PersistChildrenAttribute.cs
- TCPListener.cs
- ChannelServices.cs
- VisualTreeUtils.cs
- UncommonField.cs
- versioninfo.cs
- OdbcEnvironment.cs
- CapabilitiesUse.cs
- TableParagraph.cs
- MissingFieldException.cs
- StateItem.cs
- HostVisual.cs
- webeventbuffer.cs
- ComboBox.cs
- IPHostEntry.cs
- DateBoldEvent.cs
- XmlSchemaComplexContentExtension.cs
- X509SecurityTokenProvider.cs
- SqlCommandSet.cs
- DataGridPageChangedEventArgs.cs
- PropertyFilterAttribute.cs
- StandardCommandToolStripMenuItem.cs
- SortedSetDebugView.cs
- InvokeProviderWrapper.cs
- unitconverter.cs
- SerializationAttributes.cs
- AlignmentYValidation.cs
- TextFindEngine.cs
- OracleSqlParser.cs
- HashSet.cs
- SpinLock.cs
- OAVariantLib.cs
- UserControlParser.cs