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
- IndentTextWriter.cs
- PipelineModuleStepContainer.cs
- QueuePropertyVariants.cs
- AudienceUriMode.cs
- AccessorTable.cs
- IndentTextWriter.cs
- RSAOAEPKeyExchangeDeformatter.cs
- CaseInsensitiveHashCodeProvider.cs
- CategoriesDocument.cs
- DBSqlParserColumn.cs
- EventMappingSettingsCollection.cs
- RetrieveVirtualItemEventArgs.cs
- SelectedGridItemChangedEvent.cs
- IsolatedStorageFileStream.cs
- TranslateTransform.cs
- TableItemStyle.cs
- NavigationHelper.cs
- XPathDocumentNavigator.cs
- ValidatingCollection.cs
- PopupRootAutomationPeer.cs
- RulePatternOps.cs
- LocatorPartList.cs
- ItemCheckEvent.cs
- OdbcConnectionFactory.cs
- Rijndael.cs
- CommandDesigner.cs
- _HeaderInfo.cs
- SqlDeflator.cs
- DBCSCodePageEncoding.cs
- PanelStyle.cs
- Stack.cs
- LinkGrep.cs
- SqlProcedureAttribute.cs
- InvokeSchedule.cs
- CategoryState.cs
- XmlNamespaceMapping.cs
- HtmlUtf8RawTextWriter.cs
- SvcMapFileSerializer.cs
- Msec.cs
- PropertyMap.cs
- NativeMethodsOther.cs
- WhitespaceRuleReader.cs
- OdbcException.cs
- WebException.cs
- SqlFlattener.cs
- TreeViewHitTestInfo.cs
- SwitchLevelAttribute.cs
- ProfileSettings.cs
- MergeFailedEvent.cs
- CharStorage.cs
- BinaryFormatter.cs
- MouseWheelEventArgs.cs
- HtmlInputImage.cs
- StyleSelector.cs
- SafeWaitHandle.cs
- WeakRefEnumerator.cs
- MappingMetadataHelper.cs
- MeasurementDCInfo.cs
- LockedAssemblyCache.cs
- XPathNodeList.cs
- LogicalExpr.cs
- ToolboxDataAttribute.cs
- ProfileProvider.cs
- AxisAngleRotation3D.cs
- TextBoxBase.cs
- XamlReaderHelper.cs
- MetricEntry.cs
- Currency.cs
- StylusTip.cs
- SchemaAttDef.cs
- UpDownEvent.cs
- BuildManager.cs
- XmlWellformedWriter.cs
- DocumentPageHost.cs
- HttpValueCollection.cs
- SimpleLine.cs
- ElementAtQueryOperator.cs
- SystemTcpStatistics.cs
- XmlSchemaSimpleTypeUnion.cs
- CollectionType.cs
- InvalidAsynchronousStateException.cs
- Parser.cs
- RegistryKey.cs
- TextParagraphView.cs
- Sql8ExpressionRewriter.cs
- TableLayoutRowStyleCollection.cs
- ObjectDataSourceMethodEditor.cs
- RangeValueProviderWrapper.cs
- Light.cs
- WindowsFormsSectionHandler.cs
- DataTableNameHandler.cs
- PropertyNames.cs
- ComEventsSink.cs
- Run.cs
- DataServiceQueryException.cs
- Context.cs
- TraceContext.cs
- WorkflowMessageEventHandler.cs
- CodeObject.cs
- AssemblyBuilder.cs