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
- CharacterBufferReference.cs
- XmlSchemaInclude.cs
- InfoCardRSACryptoProvider.cs
- HttpListenerRequest.cs
- OdbcRowUpdatingEvent.cs
- TreeIterators.cs
- DataGridTemplateColumn.cs
- ConstructorBuilder.cs
- wgx_commands.cs
- XMLSyntaxException.cs
- MimeFormatter.cs
- NameTable.cs
- entityreference_tresulttype.cs
- JournalEntryListConverter.cs
- ResourcePermissionBase.cs
- ProfileSection.cs
- _NegoStream.cs
- AssemblyFilter.cs
- TableItemStyle.cs
- RemoteWebConfigurationHost.cs
- AudioDeviceOut.cs
- MenuItemStyleCollectionEditor.cs
- SafeFileHandle.cs
- Interlocked.cs
- BrowserCapabilitiesCompiler.cs
- CodeSubDirectoriesCollection.cs
- FlowDocumentReader.cs
- XsltCompileContext.cs
- WsatExtendedInformation.cs
- LicenseProviderAttribute.cs
- FixedSOMFixedBlock.cs
- InfoCardPolicy.cs
- Visitors.cs
- TextEffect.cs
- Span.cs
- SoapEnumAttribute.cs
- IndexOutOfRangeException.cs
- QueryContinueDragEventArgs.cs
- GridToolTip.cs
- DataGridAddNewRow.cs
- TypeBuilderInstantiation.cs
- XmlSchemaRedefine.cs
- GroupQuery.cs
- RawMouseInputReport.cs
- XPathDocumentIterator.cs
- httpstaticobjectscollection.cs
- ServiceHttpModule.cs
- DebugInfoExpression.cs
- AdRotator.cs
- HtmlDocument.cs
- ScriptReference.cs
- CommandEventArgs.cs
- ConsumerConnectionPoint.cs
- IPipelineRuntime.cs
- RenameRuleObjectDialog.Designer.cs
- HMACSHA1.cs
- X509Certificate2Collection.cs
- ValidatingReaderNodeData.cs
- TreeNodeBindingDepthConverter.cs
- WebResponse.cs
- NativeMethods.cs
- WorkflowPageSetupDialog.cs
- BlurBitmapEffect.cs
- TableCell.cs
- TransportConfigurationTypeElement.cs
- MulticastIPAddressInformationCollection.cs
- DurationConverter.cs
- GridViewHeaderRowPresenterAutomationPeer.cs
- ZipIOCentralDirectoryBlock.cs
- EdmComplexPropertyAttribute.cs
- SqlServer2KCompatibilityAnnotation.cs
- Events.cs
- ImportContext.cs
- mactripleDES.cs
- ArgumentValidation.cs
- IisTraceListener.cs
- DebugControllerThread.cs
- MissingMethodException.cs
- RecognizedWordUnit.cs
- DbMetaDataColumnNames.cs
- PropertyValueUIItem.cs
- Int32Collection.cs
- SemanticResolver.cs
- WebServiceFault.cs
- FixedBufferAttribute.cs
- XmlSchemaIdentityConstraint.cs
- BindingValueChangedEventArgs.cs
- ObjectListItemCollection.cs
- WindowCollection.cs
- XmlException.cs
- UnsafeNativeMethods.cs
- DataSourceXmlClassAttribute.cs
- ProgressBarRenderer.cs
- UnsignedPublishLicense.cs
- RootContext.cs
- DataGridRowHeader.cs
- CodeTypeDeclaration.cs
- IsolatedStorageFileStream.cs
- ParsedRoute.cs
- HttpContextWrapper.cs