Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / 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
- CopyEncoder.cs
- EventNotify.cs
- PeerChannelFactory.cs
- FixedSOMPageElement.cs
- TextFormatter.cs
- GeneralTransformCollection.cs
- COM2Enum.cs
- IncomingWebRequestContext.cs
- DSACryptoServiceProvider.cs
- FixedDocumentPaginator.cs
- TemplateColumn.cs
- OdbcCommand.cs
- TextEndOfLine.cs
- CatalogPart.cs
- ColumnResizeAdorner.cs
- LoginUtil.cs
- EntityDataSourceDesigner.cs
- HostVisual.cs
- SBCSCodePageEncoding.cs
- Expression.cs
- WizardForm.cs
- DataControlFieldHeaderCell.cs
- SliderAutomationPeer.cs
- RequestQueryParser.cs
- RequiredAttributeAttribute.cs
- WizardForm.cs
- DetailsViewCommandEventArgs.cs
- BuildProviderCollection.cs
- TypeReference.cs
- Compiler.cs
- FrameworkElement.cs
- AssemblyResourceLoader.cs
- DataGridColumnCollection.cs
- ValidatingPropertiesEventArgs.cs
- TextStore.cs
- DesignSurfaceManager.cs
- WebPartManager.cs
- HttpStreamXmlDictionaryReader.cs
- NonceToken.cs
- BitmapEffectInput.cs
- SystemDropShadowChrome.cs
- CounterSample.cs
- BrowserDefinition.cs
- InfiniteIntConverter.cs
- IgnoreSectionHandler.cs
- ArrayConverter.cs
- CustomValidator.cs
- EncoderBestFitFallback.cs
- DecoderFallback.cs
- ExceptionHandlerDesigner.cs
- ConfigurationStrings.cs
- ProcessModelInfo.cs
- UnsafeNativeMethods.cs
- DataGridViewAdvancedBorderStyle.cs
- FunctionNode.cs
- ScrollData.cs
- ProtectedConfigurationProviderCollection.cs
- SRGSCompiler.cs
- XmlSerializerFactory.cs
- KnownBoxes.cs
- WindowCollection.cs
- XsltQilFactory.cs
- ColumnResizeAdorner.cs
- LoopExpression.cs
- BaseTemplateParser.cs
- ToolStripSeparatorRenderEventArgs.cs
- tibetanshape.cs
- XmlSchemaProviderAttribute.cs
- QueryContinueDragEventArgs.cs
- SingleQueryOperator.cs
- ServiceHostFactory.cs
- ECDsaCng.cs
- MetadataWorkspace.cs
- DocumentScope.cs
- EnumConverter.cs
- HtmlAnchor.cs
- EntityDataSource.cs
- filewebresponse.cs
- UriExt.cs
- ZipPackage.cs
- HtmlInputReset.cs
- shaper.cs
- UserMapPath.cs
- MemberAssignmentAnalysis.cs
- ProcessProtocolHandler.cs
- FileStream.cs
- ListViewItemCollectionEditor.cs
- UpdateTranslator.cs
- SuppressMessageAttribute.cs
- WebDisplayNameAttribute.cs
- CreateUserErrorEventArgs.cs
- QueryCreatedEventArgs.cs
- ObjectIDGenerator.cs
- SoapReflectionImporter.cs
- AutoGeneratedFieldProperties.cs
- CodeChecksumPragma.cs
- HitTestWithPointDrawingContextWalker.cs
- XPathNavigatorKeyComparer.cs
- EntityDataSourceDesigner.cs
- SoapException.cs