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
- SurrogateSelector.cs
- ReverseInheritProperty.cs
- EventPrivateKey.cs
- AstTree.cs
- WasAdminWrapper.cs
- TreeNodeClickEventArgs.cs
- InvalidTimeZoneException.cs
- ChannelBinding.cs
- EventProvider.cs
- BuilderPropertyEntry.cs
- BitmapDecoder.cs
- ExpressionVisitorHelpers.cs
- Vector3DAnimationUsingKeyFrames.cs
- TreeNodeStyleCollection.cs
- AdRotator.cs
- HwndHostAutomationPeer.cs
- WindowAutomationPeer.cs
- Scheduling.cs
- EntityCommandDefinition.cs
- DbConnectionStringBuilder.cs
- DesignerTransaction.cs
- DesignerTextWriter.cs
- StrokeRenderer.cs
- Literal.cs
- TextTreePropertyUndoUnit.cs
- XmlQualifiedName.cs
- AmbientLight.cs
- IMembershipProvider.cs
- ContentFileHelper.cs
- SecurityDocument.cs
- ConfigXmlCDataSection.cs
- WebEvents.cs
- XmlAttributeOverrides.cs
- DelimitedListTraceListener.cs
- PipelineModuleStepContainer.cs
- ProcessHostServerConfig.cs
- FileUpload.cs
- TreeViewItemAutomationPeer.cs
- CompositeFontParser.cs
- TypeConverterAttribute.cs
- IDQuery.cs
- EdmPropertyAttribute.cs
- PermissionAttributes.cs
- CustomPopupPlacement.cs
- Pen.cs
- Win32Native.cs
- LineProperties.cs
- HandleRef.cs
- Transform3D.cs
- ListViewGroupItemCollection.cs
- KeyPressEvent.cs
- TreeNodeCollectionEditor.cs
- HttpPostedFile.cs
- TableLayoutColumnStyleCollection.cs
- EtwTrace.cs
- regiisutil.cs
- SqlMethods.cs
- Size3D.cs
- ResponseBodyWriter.cs
- ipaddressinformationcollection.cs
- SqlWebEventProvider.cs
- XmlSchemaCompilationSettings.cs
- DynamicResourceExtensionConverter.cs
- XmlQueryCardinality.cs
- CompletedAsyncResult.cs
- OperationParameterInfo.cs
- MailAddressCollection.cs
- StringAttributeCollection.cs
- ImportCatalogPart.cs
- IOThreadScheduler.cs
- ExpressionBinding.cs
- WriteableBitmap.cs
- DirtyTextRange.cs
- ComPlusTypeLoader.cs
- AsyncCompletedEventArgs.cs
- DiscoveryDocumentReference.cs
- HttpWriter.cs
- DataKey.cs
- FileStream.cs
- XmlSchemaImport.cs
- CheckoutException.cs
- SendKeys.cs
- AppDomainProtocolHandler.cs
- SamlAuthorizationDecisionStatement.cs
- DesignerWithHeader.cs
- WmlPanelAdapter.cs
- IPAddressCollection.cs
- FactoryGenerator.cs
- NegotiateStream.cs
- Misc.cs
- TabItemAutomationPeer.cs
- QueryTask.cs
- XmlValidatingReaderImpl.cs
- AnnotationAdorner.cs
- TablePatternIdentifiers.cs
- ExclusiveCanonicalizationTransform.cs
- ArrayElementGridEntry.cs
- XhtmlBasicImageAdapter.cs
- HierarchicalDataSourceControl.cs
- LabelAutomationPeer.cs