Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Core / CSharp / System / Windows / Input / InertiaTranslationBehavior.cs / 1305600 / InertiaTranslationBehavior.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 InertiaTranslationBehavior { ////// Instantiates a new instance of this class. /// public InertiaTranslationBehavior() { } ////// Instantiates a new instance of this class. /// internal InertiaTranslationBehavior(Vector initialVelocity) { _initialVelocity = initialVelocity; } ////// The initial rate of change of position of the element at the start of the inertia phase. /// public Vector InitialVelocity { get { return _initialVelocity; } set { _isInitialVelocitySet = true; _initialVelocity = value; } } ////// The desired rate of change of velocity. /// public double DesiredDeceleration { get { return _desiredDeceleration; } set { if (Double.IsInfinity(value) || Double.IsNaN(value)) { throw new ArgumentOutOfRangeException("value"); } _isDesiredDecelerationSet = true; _desiredDeceleration = value; _isDesiredDisplacementSet = false; _desiredDisplacement = double.NaN; } } ////// The desired total change in position. /// public double DesiredDisplacement { get { return _desiredDisplacement; } set { if (Double.IsInfinity(value) || Double.IsNaN(value)) { throw new ArgumentOutOfRangeException("value"); } _isDesiredDisplacementSet = true; _desiredDisplacement = value; _isDesiredDecelerationSet = false; _desiredDeceleration = double.NaN; } } internal bool CanUseForInertia() { return _isInitialVelocitySet || _isDesiredDecelerationSet || _isDesiredDisplacementSet; } internal static void ApplyParameters(InertiaTranslationBehavior behavior, InertiaProcessor2D processor, Vector initialVelocity) { if (behavior != null && behavior.CanUseForInertia()) { InertiaTranslationBehavior2D behavior2D = new InertiaTranslationBehavior2D(); if (behavior._isInitialVelocitySet) { behavior2D.InitialVelocityX = (float)behavior._initialVelocity.X; behavior2D.InitialVelocityY = (float)behavior._initialVelocity.Y; } else { behavior2D.InitialVelocityX = (float)initialVelocity.X; behavior2D.InitialVelocityY = (float)initialVelocity.Y; } if (behavior._isDesiredDecelerationSet) { behavior2D.DesiredDeceleration = (float)behavior._desiredDeceleration; } if (behavior._isDesiredDisplacementSet) { behavior2D.DesiredDisplacement = (float)behavior._desiredDisplacement; } processor.TranslationBehavior = behavior2D; } } private bool _isInitialVelocitySet; private Vector _initialVelocity = new Vector(double.NaN, double.NaN); private bool _isDesiredDecelerationSet; private double _desiredDeceleration = double.NaN; private bool _isDesiredDisplacementSet; private double _desiredDisplacement = 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 InertiaTranslationBehavior { ////// Instantiates a new instance of this class. /// public InertiaTranslationBehavior() { } ////// Instantiates a new instance of this class. /// internal InertiaTranslationBehavior(Vector initialVelocity) { _initialVelocity = initialVelocity; } ////// The initial rate of change of position of the element at the start of the inertia phase. /// public Vector InitialVelocity { get { return _initialVelocity; } set { _isInitialVelocitySet = true; _initialVelocity = value; } } ////// The desired rate of change of velocity. /// public double DesiredDeceleration { get { return _desiredDeceleration; } set { if (Double.IsInfinity(value) || Double.IsNaN(value)) { throw new ArgumentOutOfRangeException("value"); } _isDesiredDecelerationSet = true; _desiredDeceleration = value; _isDesiredDisplacementSet = false; _desiredDisplacement = double.NaN; } } ////// The desired total change in position. /// public double DesiredDisplacement { get { return _desiredDisplacement; } set { if (Double.IsInfinity(value) || Double.IsNaN(value)) { throw new ArgumentOutOfRangeException("value"); } _isDesiredDisplacementSet = true; _desiredDisplacement = value; _isDesiredDecelerationSet = false; _desiredDeceleration = double.NaN; } } internal bool CanUseForInertia() { return _isInitialVelocitySet || _isDesiredDecelerationSet || _isDesiredDisplacementSet; } internal static void ApplyParameters(InertiaTranslationBehavior behavior, InertiaProcessor2D processor, Vector initialVelocity) { if (behavior != null && behavior.CanUseForInertia()) { InertiaTranslationBehavior2D behavior2D = new InertiaTranslationBehavior2D(); if (behavior._isInitialVelocitySet) { behavior2D.InitialVelocityX = (float)behavior._initialVelocity.X; behavior2D.InitialVelocityY = (float)behavior._initialVelocity.Y; } else { behavior2D.InitialVelocityX = (float)initialVelocity.X; behavior2D.InitialVelocityY = (float)initialVelocity.Y; } if (behavior._isDesiredDecelerationSet) { behavior2D.DesiredDeceleration = (float)behavior._desiredDeceleration; } if (behavior._isDesiredDisplacementSet) { behavior2D.DesiredDisplacement = (float)behavior._desiredDisplacement; } processor.TranslationBehavior = behavior2D; } } private bool _isInitialVelocitySet; private Vector _initialVelocity = new Vector(double.NaN, double.NaN); private bool _isDesiredDecelerationSet; private double _desiredDeceleration = double.NaN; private bool _isDesiredDisplacementSet; private double _desiredDisplacement = 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
- DependencySource.cs
- TaiwanLunisolarCalendar.cs
- TextServicesManager.cs
- DesignerAdapterAttribute.cs
- TrustManagerPromptUI.cs
- UnaryQueryOperator.cs
- QuaternionKeyFrameCollection.cs
- DataGridItemEventArgs.cs
- XmlILOptimizerVisitor.cs
- RequiredAttributeAttribute.cs
- HtmlInputControl.cs
- ViewLoader.cs
- InternalDispatchObject.cs
- DictionaryBase.cs
- InheritedPropertyChangedEventArgs.cs
- WebPartsSection.cs
- ClientConfigurationHost.cs
- ChangeTracker.cs
- NotFiniteNumberException.cs
- AppDomainAttributes.cs
- Bidi.cs
- SqlMethodAttribute.cs
- SystemIPAddressInformation.cs
- SettingsBase.cs
- GridPattern.cs
- XmlDataSource.cs
- RsaSecurityTokenAuthenticator.cs
- Package.cs
- LocalizabilityAttribute.cs
- Message.cs
- ListBase.cs
- InplaceBitmapMetadataWriter.cs
- MemberPathMap.cs
- ServiceDescriptionContext.cs
- HttpListenerContext.cs
- QilReference.cs
- MetadataExchangeClient.cs
- RoleService.cs
- DescendentsWalker.cs
- AssemblyNameUtility.cs
- DesignerListAdapter.cs
- BindToObject.cs
- WindowsStatic.cs
- EventLogPermission.cs
- HostTimeoutsElement.cs
- SharedPerformanceCounter.cs
- SafeNativeMethods.cs
- WindowsRichEditRange.cs
- SecurityPolicySection.cs
- PreloadedPackages.cs
- PointUtil.cs
- DataContractJsonSerializerOperationBehavior.cs
- CompositeCollection.cs
- DataGridViewHitTestInfo.cs
- CompModSwitches.cs
- Publisher.cs
- InvalidateEvent.cs
- WebPartDisplayModeCancelEventArgs.cs
- TableLayoutStyleCollection.cs
- AnnotationAdorner.cs
- ExpressionBuilder.cs
- XmlObjectSerializerReadContextComplex.cs
- DispatcherFrame.cs
- ImportContext.cs
- PopupEventArgs.cs
- SmiRequestExecutor.cs
- XhtmlTextWriter.cs
- BooleanExpr.cs
- EventWaitHandle.cs
- SrgsToken.cs
- EventLogEntry.cs
- SpeechRecognitionEngine.cs
- QueryContinueDragEventArgs.cs
- XmlElementList.cs
- RadioButton.cs
- TextEffectResolver.cs
- DrawListViewSubItemEventArgs.cs
- ListViewItem.cs
- CollectionConverter.cs
- XDRSchema.cs
- WCFModelStrings.Designer.cs
- ListGeneralPage.cs
- StreamUpgradeProvider.cs
- ThreadExceptionEvent.cs
- MatrixValueSerializer.cs
- XmlTextReaderImplHelpers.cs
- _NestedSingleAsyncResult.cs
- PolyQuadraticBezierSegment.cs
- MenuStrip.cs
- RuleSetDialog.Designer.cs
- XmlUTF8TextWriter.cs
- DbSetClause.cs
- CheckableControlBaseAdapter.cs
- ObjectDataProvider.cs
- SqlReferenceCollection.cs
- AggregatePushdown.cs
- WebPartsPersonalizationAuthorization.cs
- CheckPair.cs
- ServicePointManagerElement.cs
- IntPtr.cs