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 / 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
- RequestStatusBarUpdateEventArgs.cs
- XmlSchemaInclude.cs
- MonitorWrapper.cs
- Compensate.cs
- Configuration.cs
- X509SecurityTokenProvider.cs
- Int64Storage.cs
- FixedTextView.cs
- SqlXmlStorage.cs
- SoapIncludeAttribute.cs
- SystemException.cs
- ObfuscationAttribute.cs
- BitmapEffectGeneralTransform.cs
- HwndTarget.cs
- XmlSerializerSection.cs
- FtpWebRequest.cs
- GridViewSortEventArgs.cs
- DataGridViewColumnHeaderCell.cs
- messageonlyhwndwrapper.cs
- DockPattern.cs
- Compiler.cs
- AuthenticationModuleElement.cs
- CharacterMetrics.cs
- CoTaskMemHandle.cs
- DataTableClearEvent.cs
- SqlCharStream.cs
- DocumentOrderComparer.cs
- OutputCacheModule.cs
- SapiRecognizer.cs
- OrderedDictionaryStateHelper.cs
- GridViewHeaderRowPresenterAutomationPeer.cs
- OverflowException.cs
- TreeBuilderXamlTranslator.cs
- MarshalByValueComponent.cs
- TextFindEngine.cs
- ConfigXmlElement.cs
- WindowsRichEdit.cs
- InputScopeConverter.cs
- ModuleBuilder.cs
- HtmlTableCell.cs
- OpCellTreeNode.cs
- EventDrivenDesigner.cs
- InternalBufferOverflowException.cs
- PropertySet.cs
- DesignerActionItem.cs
- WindowsGraphics.cs
- UriParserTemplates.cs
- EmptyImpersonationContext.cs
- _SingleItemRequestCache.cs
- QuadraticBezierSegment.cs
- Psha1DerivedKeyGenerator.cs
- TraceContextEventArgs.cs
- UrlMappingsSection.cs
- IncrementalReadDecoders.cs
- HandlerMappingMemo.cs
- PageRequestManager.cs
- TypeDescriptionProvider.cs
- ACL.cs
- ExtentCqlBlock.cs
- MDIWindowDialog.cs
- RemoteWebConfigurationHost.cs
- MulticastOption.cs
- WebProxyScriptElement.cs
- PreloadedPackages.cs
- ToolStripDropDownItem.cs
- LogoValidationException.cs
- Slider.cs
- DataViewManager.cs
- XmlElement.cs
- MessageAction.cs
- MailBnfHelper.cs
- ContentElementAutomationPeer.cs
- Error.cs
- FrameSecurityDescriptor.cs
- MetadataCacheItem.cs
- TypeGeneratedEventArgs.cs
- ClientBuildManager.cs
- DictionarySectionHandler.cs
- ScriptDescriptor.cs
- ImageBrush.cs
- EmbossBitmapEffect.cs
- BooleanAnimationBase.cs
- MsmqIntegrationChannelListener.cs
- WebServiceErrorEvent.cs
- NativeMethods.cs
- DocumentViewerAutomationPeer.cs
- SoapCommonClasses.cs
- SessionEndingCancelEventArgs.cs
- DataGridViewRowHeightInfoPushedEventArgs.cs
- ListMarkerLine.cs
- SrgsRuleRef.cs
- UniqueConstraint.cs
- LongValidator.cs
- XmlWriterSettings.cs
- PolicyChain.cs
- MSAAEventDispatcher.cs
- PersonalizationProviderHelper.cs
- SafeNativeMethodsCLR.cs
- DocumentPageTextView.cs
- TraceFilter.cs