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
- SecurityContextSecurityTokenParameters.cs
- TimeEnumHelper.cs
- MgmtConfigurationRecord.cs
- XmlAttributeAttribute.cs
- SerializerWriterEventHandlers.cs
- CodeAttributeArgumentCollection.cs
- WorkflowDesigner.cs
- CqlLexerHelpers.cs
- CommandConverter.cs
- MemberProjectionIndex.cs
- BooleanFunctions.cs
- RelativeSource.cs
- AttributeEmitter.cs
- CodeAttributeDeclarationCollection.cs
- ProbeMatchesCD1.cs
- ObjectStateManager.cs
- WindowInteropHelper.cs
- RuntimeVariablesExpression.cs
- CodeDOMUtility.cs
- GPRECTF.cs
- FacetChecker.cs
- ContentOperations.cs
- MetabaseServerConfig.cs
- RegexTree.cs
- Int32.cs
- __ComObject.cs
- DesignerLinkAdapter.cs
- FlowDocumentFormatter.cs
- XsltContext.cs
- AdPostCacheSubstitution.cs
- Permission.cs
- CodeDOMProvider.cs
- DataGridAutoGeneratingColumnEventArgs.cs
- ImmutableObjectAttribute.cs
- RoleService.cs
- KoreanLunisolarCalendar.cs
- SqlRewriteScalarSubqueries.cs
- ImageListImage.cs
- XmlAtomicValue.cs
- FrameworkContextData.cs
- Attributes.cs
- ScrollChangedEventArgs.cs
- MessageBox.cs
- LinqDataView.cs
- LinearKeyFrames.cs
- SiteIdentityPermission.cs
- RepeaterCommandEventArgs.cs
- ViewBox.cs
- UriTemplateLiteralPathSegment.cs
- ApplicationSecurityInfo.cs
- HWStack.cs
- ClientData.cs
- Panel.cs
- LineServicesCallbacks.cs
- XmlCharType.cs
- XamlToRtfWriter.cs
- TextBounds.cs
- TransformerInfoCollection.cs
- LifetimeServices.cs
- XmlMapping.cs
- CompilationUtil.cs
- COM2PropertyDescriptor.cs
- HeaderPanel.cs
- ValueProviderWrapper.cs
- codemethodreferenceexpression.cs
- NetPipeSectionData.cs
- MaterialCollection.cs
- ValidationSummary.cs
- XmlIterators.cs
- ExceptionUtil.cs
- SmiMetaDataProperty.cs
- StrongName.cs
- DataServiceRequestArgs.cs
- HttpRuntime.cs
- SocketAddress.cs
- ScriptHandlerFactory.cs
- ClientApiGenerator.cs
- DBNull.cs
- InstanceValue.cs
- PassportPrincipal.cs
- PointCollection.cs
- DocumentViewerBaseAutomationPeer.cs
- TextDecorations.cs
- MobileErrorInfo.cs
- SmtpException.cs
- FixedHyperLink.cs
- SessionStateItemCollection.cs
- StylusButtonEventArgs.cs
- SqlDataReaderSmi.cs
- ProxyGenerator.cs
- GeneralTransform3DCollection.cs
- ServiceDescriptions.cs
- RequestSecurityTokenResponseCollection.cs
- WebPartConnectionCollection.cs
- OuterGlowBitmapEffect.cs
- ZipPackagePart.cs
- SweepDirectionValidation.cs
- WSSecurityTokenSerializer.cs
- Helper.cs
- DependencyObjectType.cs