Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Core / CSharp / System / Windows / Input / MouseButton.cs / 1305600 / MouseButton.cs
using System; using MS.Internal.PresentationCore; namespace System.Windows.Input { ////// The MouseButton enumeration describes the buttons available on /// the mouse device. /// ////// You must update MouseButtonUtilities.Validate if any changes are made to this type /// public enum MouseButton { ////// The left mouse button. /// Left, ////// The middle mouse button. /// Middle, ////// The right mouse button. /// Right, ////// The fourth mouse button. /// XButton1, ////// The fifth mouse button. /// XButton2 } ////// Utility class for MouseButton /// internal sealed class MouseButtonUtilities { ////// Private placeholder constructor /// ////// There is present to supress the autogeneration of a public one, which /// triggers an FxCop violation, as this is an internal class that is never instantiated /// private MouseButtonUtilities() { } ////// Ensures MouseButton is set to a valid value. /// ////// There is a proscription against using Enum.IsDefined(). (it is slow) /// So we manually validate using a switch statement. /// [FriendAccessAllowed] internal static void Validate(MouseButton button) { switch(button) { case MouseButton.Left: case MouseButton.Middle: case MouseButton.Right: case MouseButton.XButton1: case MouseButton.XButton2: break; default: throw new System.ComponentModel.InvalidEnumArgumentException("button", (int)button, typeof(MouseButton)); } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. using System; using MS.Internal.PresentationCore; namespace System.Windows.Input { ////// The MouseButton enumeration describes the buttons available on /// the mouse device. /// ////// You must update MouseButtonUtilities.Validate if any changes are made to this type /// public enum MouseButton { ////// The left mouse button. /// Left, ////// The middle mouse button. /// Middle, ////// The right mouse button. /// Right, ////// The fourth mouse button. /// XButton1, ////// The fifth mouse button. /// XButton2 } ////// Utility class for MouseButton /// internal sealed class MouseButtonUtilities { ////// Private placeholder constructor /// ////// There is present to supress the autogeneration of a public one, which /// triggers an FxCop violation, as this is an internal class that is never instantiated /// private MouseButtonUtilities() { } ////// Ensures MouseButton is set to a valid value. /// ////// There is a proscription against using Enum.IsDefined(). (it is slow) /// So we manually validate using a switch statement. /// [FriendAccessAllowed] internal static void Validate(MouseButton button) { switch(button) { case MouseButton.Left: case MouseButton.Middle: case MouseButton.Right: case MouseButton.XButton1: case MouseButton.XButton2: break; default: throw new System.ComponentModel.InvalidEnumArgumentException("button", (int)button, typeof(MouseButton)); } } } } // 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
- ReturnType.cs
- ManifestResourceInfo.cs
- ResourceManagerWrapper.cs
- Encoder.cs
- SwitchLevelAttribute.cs
- CheckBoxPopupAdapter.cs
- TypeSystem.cs
- ColorContext.cs
- DataPagerFieldCollection.cs
- HybridDictionary.cs
- BmpBitmapEncoder.cs
- DataGridViewAutoSizeColumnModeEventArgs.cs
- SHA1Managed.cs
- ObjectViewEntityCollectionData.cs
- SmtpDigestAuthenticationModule.cs
- UnauthorizedWebPart.cs
- AttributeQuery.cs
- SystemInformation.cs
- TemplatedControlDesigner.cs
- CombinedGeometry.cs
- DecoderFallback.cs
- SecurityDocument.cs
- HitTestDrawingContextWalker.cs
- InkPresenterAutomationPeer.cs
- WebControlParameterProxy.cs
- IdentifierService.cs
- MissingMemberException.cs
- SafeReadContext.cs
- ConnectionManagementSection.cs
- StylusPoint.cs
- CombinedGeometry.cs
- CodeMethodInvokeExpression.cs
- DetectRunnableInstancesTask.cs
- DataRecordObjectView.cs
- DataGridViewCellFormattingEventArgs.cs
- namescope.cs
- BitConverter.cs
- ClientRoleProvider.cs
- EncoderFallback.cs
- ConfigurationLocation.cs
- RequestResizeEvent.cs
- AuthenticateEventArgs.cs
- SimpleMailWebEventProvider.cs
- SqlClientMetaDataCollectionNames.cs
- NameTable.cs
- PeerIPHelper.cs
- TextRunCacheImp.cs
- Line.cs
- ComponentResourceManager.cs
- SerializableAttribute.cs
- CommonDialog.cs
- ClassHandlersStore.cs
- DesignOnlyAttribute.cs
- ProjectionAnalyzer.cs
- RegisterResponseInfo.cs
- GatewayDefinition.cs
- TextSpanModifier.cs
- XmlSerializerVersionAttribute.cs
- WindowsAltTab.cs
- ListBoxChrome.cs
- DataGridAddNewRow.cs
- QueryCacheEntry.cs
- RequestStatusBarUpdateEventArgs.cs
- SessionStateModule.cs
- JsonFormatWriterGenerator.cs
- ChtmlSelectionListAdapter.cs
- ConnectionManagementSection.cs
- CompilerGlobalScopeAttribute.cs
- BoundingRectTracker.cs
- SchemaMapping.cs
- ExecutedRoutedEventArgs.cs
- CommonDialog.cs
- SID.cs
- WorkflowOperationErrorHandler.cs
- CollectionsUtil.cs
- FontNameConverter.cs
- EqualityComparer.cs
- DbFunctionCommandTree.cs
- Contracts.cs
- IdentifierCollection.cs
- XmlSignificantWhitespace.cs
- VisualCollection.cs
- SafeFindHandle.cs
- OleCmdHelper.cs
- Vector3DKeyFrameCollection.cs
- TextBoxRenderer.cs
- XamlPathDataSerializer.cs
- ButtonChrome.cs
- XslAst.cs
- SqlBulkCopy.cs
- DataRowComparer.cs
- ProviderBase.cs
- WrappedIUnknown.cs
- GridItemPattern.cs
- TransformerTypeCollection.cs
- HtmlElement.cs
- ObjectAnimationBase.cs
- SQLInt64.cs
- XmlNodeWriter.cs
- FileInfo.cs