Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / wpf / src / Core / CSharp / System / Windows / Input / Command / MouseBinding.cs / 1 / MouseBinding.cs
//---------------------------------------------------------------------------- // //// Copyright (C) Microsoft Corporation. All rights reserved. // // // // Description: The MouseBinding class is used by the developer to create Mouse Input Bindings // // See spec at : http://avalon/coreui/Specs/Commanding(new).mht // //* MouseBinding class serves the purpose of Input Bindings for Mouse Device. // // History: // 06/01/2003 : chandras - Created // 05/01/2004 : chandras- changed to new design. //--------------------------------------------------------------------------- using System; using System.Windows.Input; using System.Windows; using System.Windows.Markup; using System.ComponentModel; using SR=MS.Internal.PresentationCore.SR; using SRID=MS.Internal.PresentationCore.SRID; namespace System.Windows.Input { ////// MouseBinding - Implements InputBinding (generic InputGesture-Command map) /// MouseBinding acts like a map for MouseGesture and Commands. /// Most of the logic is in InputBinding and MouseGesture, this only /// facilitates user to specify MouseAction directly without going in /// MouseGesture path. Also it provides the MouseGestureTypeConverter /// on the Gesture property to have MouseGesture, like "RightClick" /// defined in Markup as Gesture="RightClick" working. /// public class MouseBinding : InputBinding { //----------------------------------------------------- // // Constructors // //----------------------------------------------------- #region Constructors ////// constructor /// public MouseBinding() : base() { } ////// Constructor /// /// Command Associated /// Mouse Action internal MouseBinding(ICommand command, MouseAction mouseAction) : this(command, new MouseGesture(mouseAction)) { } ////// Constructor /// /// Command Associated /// Mmouse Gesture associated public MouseBinding(ICommand command, MouseGesture gesture) : base(command, gesture) { } #endregion Constructors //------------------------------------------------------ // // Public Methods // //----------------------------------------------------- #region Public Methods ////// MouseGesture /// [TypeConverter(typeof(MouseGestureConverter))] [ValueSerializer(typeof(MouseGestureValueSerializer))] public override InputGesture Gesture { get { return base.Gesture as MouseGesture; } set { if (value is MouseGesture) { base.Gesture = value; } else { throw new ArgumentException(SR.Get(SRID.InputBinding_ExpectedInputGesture, typeof(MouseGesture))); } } } #endregion Public Methods //------------------------------------------------------ // // Internal Methods // //------------------------------------------------------ //----------------------------------------------------- // // Private Fields // //------------------------------------------------------ //----------------------------------------------------- // // Public Methods // //----------------------------------------------------- #region Public Methods ////// MouseAction /// public MouseAction MouseAction { get { lock (_dataLock) { if (null != Gesture) { return ((MouseGesture)Gesture).MouseAction; } return MouseAction.None; } } set { lock (_dataLock) { if (null == Gesture) { Gesture = new MouseGesture((MouseAction)value); } else { ((MouseGesture)Gesture).MouseAction = (MouseAction)value; } } } } #endregion Public Methods //----------------------------------------------------- // // 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 MouseBinding class is used by the developer to create Mouse Input Bindings // // See spec at : http://avalon/coreui/Specs/Commanding(new).mht // //* MouseBinding class serves the purpose of Input Bindings for Mouse Device. // // History: // 06/01/2003 : chandras - Created // 05/01/2004 : chandras- changed to new design. //--------------------------------------------------------------------------- using System; using System.Windows.Input; using System.Windows; using System.Windows.Markup; using System.ComponentModel; using SR=MS.Internal.PresentationCore.SR; using SRID=MS.Internal.PresentationCore.SRID; namespace System.Windows.Input { ////// MouseBinding - Implements InputBinding (generic InputGesture-Command map) /// MouseBinding acts like a map for MouseGesture and Commands. /// Most of the logic is in InputBinding and MouseGesture, this only /// facilitates user to specify MouseAction directly without going in /// MouseGesture path. Also it provides the MouseGestureTypeConverter /// on the Gesture property to have MouseGesture, like "RightClick" /// defined in Markup as Gesture="RightClick" working. /// public class MouseBinding : InputBinding { //----------------------------------------------------- // // Constructors // //----------------------------------------------------- #region Constructors ////// constructor /// public MouseBinding() : base() { } ////// Constructor /// /// Command Associated /// Mouse Action internal MouseBinding(ICommand command, MouseAction mouseAction) : this(command, new MouseGesture(mouseAction)) { } ////// Constructor /// /// Command Associated /// Mmouse Gesture associated public MouseBinding(ICommand command, MouseGesture gesture) : base(command, gesture) { } #endregion Constructors //------------------------------------------------------ // // Public Methods // //----------------------------------------------------- #region Public Methods ////// MouseGesture /// [TypeConverter(typeof(MouseGestureConverter))] [ValueSerializer(typeof(MouseGestureValueSerializer))] public override InputGesture Gesture { get { return base.Gesture as MouseGesture; } set { if (value is MouseGesture) { base.Gesture = value; } else { throw new ArgumentException(SR.Get(SRID.InputBinding_ExpectedInputGesture, typeof(MouseGesture))); } } } #endregion Public Methods //------------------------------------------------------ // // Internal Methods // //------------------------------------------------------ //----------------------------------------------------- // // Private Fields // //------------------------------------------------------ //----------------------------------------------------- // // Public Methods // //----------------------------------------------------- #region Public Methods ////// MouseAction /// public MouseAction MouseAction { get { lock (_dataLock) { if (null != Gesture) { return ((MouseGesture)Gesture).MouseAction; } return MouseAction.None; } } set { lock (_dataLock) { if (null == Gesture) { Gesture = new MouseGesture((MouseAction)value); } else { ((MouseGesture)Gesture).MouseAction = (MouseAction)value; } } } } #endregion Public Methods //----------------------------------------------------- // // 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
- WebHttpElement.cs
- PeerCollaboration.cs
- RootBrowserWindow.cs
- MsmqOutputChannel.cs
- DynamicRendererThreadManager.cs
- RequestCachePolicy.cs
- AuthenticationSection.cs
- CommentAction.cs
- CalendarModeChangedEventArgs.cs
- Clipboard.cs
- InternalsVisibleToAttribute.cs
- DataSetMappper.cs
- EncryptedData.cs
- ReferenceAssemblyAttribute.cs
- TreeViewImageKeyConverter.cs
- DynamicRenderer.cs
- GridViewColumnCollectionChangedEventArgs.cs
- TimeSpanValidatorAttribute.cs
- DrawingContextDrawingContextWalker.cs
- NotifyInputEventArgs.cs
- PrintPreviewControl.cs
- EdmComplexTypeAttribute.cs
- ContextMenuAutomationPeer.cs
- KeyMatchBuilder.cs
- MultipartContentParser.cs
- ThicknessAnimationBase.cs
- QilTargetType.cs
- DrawingContextWalker.cs
- CompModSwitches.cs
- WindowsScroll.cs
- Filter.cs
- SystemIPAddressInformation.cs
- DataFormat.cs
- GenericIdentity.cs
- ReadOnlyCollection.cs
- ColumnCollection.cs
- Cloud.cs
- RewritingValidator.cs
- RsaEndpointIdentity.cs
- Repeater.cs
- WebBrowser.cs
- Int32Rect.cs
- WsatStrings.cs
- EncoderNLS.cs
- PathFigureCollectionConverter.cs
- ListControlConvertEventArgs.cs
- EntityStoreSchemaGenerator.cs
- WebPartCatalogCloseVerb.cs
- QilReference.cs
- QilCloneVisitor.cs
- MergablePropertyAttribute.cs
- AuthenticationManager.cs
- HttpRequestCacheValidator.cs
- SqlConnectionFactory.cs
- ACE.cs
- KnownTypes.cs
- HtmlElement.cs
- CharacterHit.cs
- AutomationElement.cs
- BufferBuilder.cs
- ReadContentAsBinaryHelper.cs
- ProxySimple.cs
- securestring.cs
- ClientTarget.cs
- SmiConnection.cs
- BrowserCapabilitiesCodeGenerator.cs
- InputLangChangeEvent.cs
- NullableIntMinMaxAggregationOperator.cs
- FillRuleValidation.cs
- CalendarDesigner.cs
- Merger.cs
- ExeContext.cs
- FormatterServicesNoSerializableCheck.cs
- sitestring.cs
- UrlMapping.cs
- SystemIcmpV4Statistics.cs
- Utils.cs
- webproxy.cs
- BaseConfigurationRecord.cs
- _Events.cs
- ObjectListGeneralPage.cs
- Rijndael.cs
- GenerateTemporaryAssemblyTask.cs
- BamlWriter.cs
- SafeNativeMethods.cs
- TreeIterator.cs
- HttpProfileBase.cs
- Converter.cs
- Rights.cs
- ReflectionUtil.cs
- CookieHandler.cs
- ConstructorArgumentAttribute.cs
- SqlParameterCollection.cs
- SharedUtils.cs
- CodeCastExpression.cs
- EnumerableRowCollectionExtensions.cs
- NullExtension.cs
- Scanner.cs
- XmlILAnnotation.cs
- DataContext.cs