Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Core / CSharp / System / Windows / Input / InertiaRotationBehavior.cs / 1305600 / InertiaRotationBehavior.cs
//---------------------------------------------------------------------------- // // Copyright (C) Microsoft Corporation. All rights reserved. // //--------------------------------------------------------------------------- using System; using System.Diagnostics; using System.Windows; using System.Windows.Input.Manipulations; namespace System.Windows.Input { ////// Provides information about the inertia behavior. /// public class InertiaRotationBehavior { ////// Instantiates a new instance of this class. /// public InertiaRotationBehavior() { } ////// Instantiates a new instance of this class. /// internal InertiaRotationBehavior(double initialVelocity) { _initialVelocity = initialVelocity; } ////// The initial rate of angular change of the element at the start of the inertia phase in degrees/ms. /// public double InitialVelocity { get { return _initialVelocity; } set { _isInitialVelocitySet = true; _initialVelocity = value; } } ////// The desired rate of change of velocity in degrees/ms^2. /// public double DesiredDeceleration { get { return _desiredDeceleration; } set { if (Double.IsInfinity(value) || Double.IsNaN(value)) { throw new ArgumentOutOfRangeException("value"); } _isDesiredDecelerationSet = true; _desiredDeceleration = value; _isDesiredRotationSet = false; _desiredRotation = double.NaN; } } ////// The desired total change in angle in degrees. /// public double DesiredRotation { get { return _desiredRotation; } set { if (Double.IsInfinity(value) || Double.IsNaN(value)) { throw new ArgumentOutOfRangeException("value"); } _isDesiredRotationSet = true; _desiredRotation = value; _isDesiredDecelerationSet = false; _desiredDeceleration = double.NaN; } } internal bool CanUseForInertia() { return _isInitialVelocitySet || _isDesiredDecelerationSet || _isDesiredRotationSet; } internal static void ApplyParameters(InertiaRotationBehavior behavior, InertiaProcessor2D processor, double initialVelocity) { if (behavior != null && behavior.CanUseForInertia()) { InertiaRotationBehavior2D behavior2D = new InertiaRotationBehavior2D(); if (behavior._isInitialVelocitySet) { behavior2D.InitialVelocity = (float)AngleUtil.DegreesToRadians(behavior._initialVelocity); } else { behavior2D.InitialVelocity = (float)AngleUtil.DegreesToRadians(initialVelocity); } if (behavior._isDesiredDecelerationSet) { behavior2D.DesiredDeceleration = (float)AngleUtil.DegreesToRadians(behavior._desiredDeceleration); } if (behavior._isDesiredRotationSet) { behavior2D.DesiredRotation = (float)AngleUtil.DegreesToRadians(behavior._desiredRotation); } processor.RotationBehavior = behavior2D; } } private bool _isInitialVelocitySet; private double _initialVelocity = double.NaN; private bool _isDesiredDecelerationSet; private double _desiredDeceleration = double.NaN; private bool _isDesiredRotationSet; private double _desiredRotation = double.NaN; } } // 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. // //--------------------------------------------------------------------------- using System; using System.Diagnostics; using System.Windows; using System.Windows.Input.Manipulations; namespace System.Windows.Input { ////// Provides information about the inertia behavior. /// public class InertiaRotationBehavior { ////// Instantiates a new instance of this class. /// public InertiaRotationBehavior() { } ////// Instantiates a new instance of this class. /// internal InertiaRotationBehavior(double initialVelocity) { _initialVelocity = initialVelocity; } ////// The initial rate of angular change of the element at the start of the inertia phase in degrees/ms. /// public double InitialVelocity { get { return _initialVelocity; } set { _isInitialVelocitySet = true; _initialVelocity = value; } } ////// The desired rate of change of velocity in degrees/ms^2. /// public double DesiredDeceleration { get { return _desiredDeceleration; } set { if (Double.IsInfinity(value) || Double.IsNaN(value)) { throw new ArgumentOutOfRangeException("value"); } _isDesiredDecelerationSet = true; _desiredDeceleration = value; _isDesiredRotationSet = false; _desiredRotation = double.NaN; } } ////// The desired total change in angle in degrees. /// public double DesiredRotation { get { return _desiredRotation; } set { if (Double.IsInfinity(value) || Double.IsNaN(value)) { throw new ArgumentOutOfRangeException("value"); } _isDesiredRotationSet = true; _desiredRotation = value; _isDesiredDecelerationSet = false; _desiredDeceleration = double.NaN; } } internal bool CanUseForInertia() { return _isInitialVelocitySet || _isDesiredDecelerationSet || _isDesiredRotationSet; } internal static void ApplyParameters(InertiaRotationBehavior behavior, InertiaProcessor2D processor, double initialVelocity) { if (behavior != null && behavior.CanUseForInertia()) { InertiaRotationBehavior2D behavior2D = new InertiaRotationBehavior2D(); if (behavior._isInitialVelocitySet) { behavior2D.InitialVelocity = (float)AngleUtil.DegreesToRadians(behavior._initialVelocity); } else { behavior2D.InitialVelocity = (float)AngleUtil.DegreesToRadians(initialVelocity); } if (behavior._isDesiredDecelerationSet) { behavior2D.DesiredDeceleration = (float)AngleUtil.DegreesToRadians(behavior._desiredDeceleration); } if (behavior._isDesiredRotationSet) { behavior2D.DesiredRotation = (float)AngleUtil.DegreesToRadians(behavior._desiredRotation); } processor.RotationBehavior = behavior2D; } } private bool _isInitialVelocitySet; private double _initialVelocity = double.NaN; private bool _isDesiredDecelerationSet; private double _desiredDeceleration = double.NaN; private bool _isDesiredRotationSet; private double _desiredRotation = double.NaN; } } // 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
- FilterInvalidBodyAccessException.cs
- DataGridViewCellParsingEventArgs.cs
- UIElement3D.cs
- FlowchartSizeFeature.cs
- RightsController.cs
- SystemGatewayIPAddressInformation.cs
- LambdaCompiler.ControlFlow.cs
- DataGridViewRowHeightInfoPushedEventArgs.cs
- SecurityValidationBehavior.cs
- CorrelationResolver.cs
- DbExpressionRules.cs
- x509store.cs
- ReachFixedPageSerializer.cs
- NavigationEventArgs.cs
- ObjectListSelectEventArgs.cs
- ProviderSettings.cs
- PeerNameResolver.cs
- WebPartActionVerb.cs
- OciLobLocator.cs
- ButtonColumn.cs
- WindowsRegion.cs
- UriGenerator.cs
- MergeExecutor.cs
- ColumnBinding.cs
- AlphaSortedEnumConverter.cs
- EntityProviderServices.cs
- UnsafeMethods.cs
- FontInfo.cs
- UInt64.cs
- RawAppCommandInputReport.cs
- LogStore.cs
- ErrorView.xaml.cs
- MouseCaptureWithinProperty.cs
- XmlILStorageConverter.cs
- XPathException.cs
- WorkflowPageSetupDialog.cs
- ResourcePermissionBaseEntry.cs
- JournalEntry.cs
- ScriptingSectionGroup.cs
- AuthStoreRoleProvider.cs
- XmlHierarchicalDataSourceView.cs
- TextPattern.cs
- SettingsPropertyCollection.cs
- CatalogZone.cs
- AliasedSlot.cs
- XPathException.cs
- MimeTypeAttribute.cs
- PrivateFontCollection.cs
- XmlCompatibilityReader.cs
- PreviousTrackingServiceAttribute.cs
- TransformerInfoCollection.cs
- httpapplicationstate.cs
- SingleSelectRootGridEntry.cs
- PackagePart.cs
- ReadContentAsBinaryHelper.cs
- RequestFactory.cs
- AvTraceDetails.cs
- WindowsButton.cs
- DragAssistanceManager.cs
- ConnectionPoint.cs
- Int64Converter.cs
- RequestUriProcessor.cs
- XmlExtensionFunction.cs
- Int32CAMarshaler.cs
- InstanceStoreQueryResult.cs
- TrackingLocationCollection.cs
- XmlName.cs
- ClientSettingsProvider.cs
- GraphicsContext.cs
- UnknownWrapper.cs
- TextSyndicationContentKindHelper.cs
- LinkedResourceCollection.cs
- WmlValidationSummaryAdapter.cs
- DropTarget.cs
- RegularExpressionValidator.cs
- PointAnimationUsingPath.cs
- SmtpSection.cs
- IxmlLineInfo.cs
- NameValueConfigurationElement.cs
- ColorTransformHelper.cs
- ProtocolElement.cs
- MemoryFailPoint.cs
- RectangleHotSpot.cs
- CompositeScriptReference.cs
- ImageConverter.cs
- TcpTransportSecurityElement.cs
- PEFileEvidenceFactory.cs
- DateTimeStorage.cs
- ComplexType.cs
- ThreadExceptionDialog.cs
- BufferedReadStream.cs
- BamlLocalizableResourceKey.cs
- EmptyEnumerable.cs
- FreezableDefaultValueFactory.cs
- FigureParagraph.cs
- ImageSource.cs
- Quad.cs
- ClockGroup.cs
- SchemaAttDef.cs
- MenuEventArgs.cs