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
- cookiecontainer.cs
- FreezableOperations.cs
- SqlDataAdapter.cs
- LayoutEngine.cs
- FormViewCommandEventArgs.cs
- Vector3DCollectionConverter.cs
- FontInfo.cs
- CustomDictionarySources.cs
- ProcessModelSection.cs
- ReflectTypeDescriptionProvider.cs
- ListManagerBindingsCollection.cs
- SoapInteropTypes.cs
- BamlWriter.cs
- ComboBoxItem.cs
- StringExpressionSet.cs
- SubpageParaClient.cs
- XmlSchemaNotation.cs
- DefaultExpression.cs
- GeneralTransform3D.cs
- ZipIOLocalFileBlock.cs
- FillBehavior.cs
- PropertyTabAttribute.cs
- WebPermission.cs
- CompModSwitches.cs
- PopupEventArgs.cs
- UserMapPath.cs
- COM2FontConverter.cs
- HtmlImage.cs
- SoapWriter.cs
- MostlySingletonList.cs
- ConfigurationProperty.cs
- ConsumerConnectionPoint.cs
- WebConfigurationHostFileChange.cs
- SharedPersonalizationStateInfo.cs
- VectorAnimationUsingKeyFrames.cs
- CurrentChangedEventManager.cs
- Stacktrace.cs
- RefreshPropertiesAttribute.cs
- CompressionTransform.cs
- DuplexChannelFactory.cs
- HostDesigntimeLicenseContext.cs
- TransactionProxy.cs
- xdrvalidator.cs
- OracleCommand.cs
- GeneralTransformGroup.cs
- EntityContainerEmitter.cs
- Dictionary.cs
- SamlConditions.cs
- AncillaryOps.cs
- ViewStateException.cs
- MimeTypeMapper.cs
- RemotingConfiguration.cs
- StrokeNodeOperations2.cs
- DSACryptoServiceProvider.cs
- ImportDesigner.xaml.cs
- SqlRewriteScalarSubqueries.cs
- _ListenerRequestStream.cs
- versioninfo.cs
- UnsafeNativeMethods.cs
- ValueTypeIndexerReference.cs
- MaterializeFromAtom.cs
- TransformedBitmap.cs
- AttributeCollection.cs
- RadioButtonBaseAdapter.cs
- DrawItemEvent.cs
- ApplicationHost.cs
- AccessViolationException.cs
- SecurityPolicySection.cs
- ReliableChannelFactory.cs
- MeshGeometry3D.cs
- ProvidersHelper.cs
- IssuedSecurityTokenParameters.cs
- FormCollection.cs
- RequestDescription.cs
- CatalogPartChrome.cs
- DataGridSortCommandEventArgs.cs
- XmlStringTable.cs
- VBCodeProvider.cs
- CacheDict.cs
- CommonObjectSecurity.cs
- Activator.cs
- SystemResources.cs
- Queue.cs
- JulianCalendar.cs
- LinqDataSourceInsertEventArgs.cs
- CalendarButtonAutomationPeer.cs
- ConstantSlot.cs
- TextRangeAdaptor.cs
- ColorContext.cs
- DistinctQueryOperator.cs
- TableSectionStyle.cs
- TextRenderer.cs
- UInt16Converter.cs
- XmlSchemaAny.cs
- Misc.cs
- Helpers.cs
- CodeGotoStatement.cs
- XmlQueryStaticData.cs
- FtpCachePolicyElement.cs
- DiffuseMaterial.cs