Code:
/ 4.0 / 4.0 / untmp / 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.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- QuerySubExprEliminator.cs
- SwitchCase.cs
- MimeParameter.cs
- StreamInfo.cs
- EventDescriptorCollection.cs
- RequestCache.cs
- ExpressionBuilderContext.cs
- ToolStripSeparatorRenderEventArgs.cs
- SortFieldComparer.cs
- validation.cs
- EntityDescriptor.cs
- COM2PropertyDescriptor.cs
- Module.cs
- StringAnimationUsingKeyFrames.cs
- CodeSnippetStatement.cs
- CacheHelper.cs
- Module.cs
- Propagator.JoinPropagator.cs
- Int32EqualityComparer.cs
- AdPostCacheSubstitution.cs
- ActivityDesignerHelper.cs
- PageParser.cs
- ADRole.cs
- WebResourceAttribute.cs
- StyleSelector.cs
- ContentValidator.cs
- UrlMappingsSection.cs
- xsdvalidator.cs
- FixedSOMLineCollection.cs
- ExceptionUtil.cs
- PostBackOptions.cs
- ReadOnlyDataSource.cs
- Win32SafeHandles.cs
- ResourceReferenceExpressionConverter.cs
- OptimizedTemplateContentHelper.cs
- DataSourceExpression.cs
- ControlCachePolicy.cs
- DependencyObject.cs
- IconHelper.cs
- Slider.cs
- WebResponse.cs
- SQLDoubleStorage.cs
- DesignTableCollection.cs
- UiaCoreTypesApi.cs
- PropertyMetadata.cs
- Utilities.cs
- PathParser.cs
- ReaderWriterLock.cs
- XappLauncher.cs
- CRYPTPROTECT_PROMPTSTRUCT.cs
- XappLauncher.cs
- LocalizedNameDescriptionPair.cs
- CodeAccessSecurityEngine.cs
- CollectionDataContract.cs
- _NetworkingPerfCounters.cs
- OptionUsage.cs
- ListenerSessionConnection.cs
- SHA512.cs
- RemotingConfigParser.cs
- NumericUpDownAccelerationCollection.cs
- StrokeFIndices.cs
- AssociationSet.cs
- WorkBatch.cs
- ContextStack.cs
- GlyphRunDrawing.cs
- SqlAggregateChecker.cs
- TextFormattingConverter.cs
- WindowsContainer.cs
- StringTraceRecord.cs
- ResourceIDHelper.cs
- Misc.cs
- EntryIndex.cs
- UriParserTemplates.cs
- CompiledRegexRunner.cs
- PropagatorResult.cs
- XmlDeclaration.cs
- CRYPTPROTECT_PROMPTSTRUCT.cs
- IriParsingElement.cs
- RoutedCommand.cs
- HttpModuleCollection.cs
- StrongName.cs
- AttachedPropertyBrowsableForChildrenAttribute.cs
- SBCSCodePageEncoding.cs
- Pointer.cs
- ThemeInfoAttribute.cs
- ScrollBarAutomationPeer.cs
- ColumnHeaderConverter.cs
- ServicesUtilities.cs
- EventProviderWriter.cs
- StringValueSerializer.cs
- DotAtomReader.cs
- AlternateViewCollection.cs
- SoapTypeAttribute.cs
- RegistryPermission.cs
- PropertyItemInternal.cs
- ServicesExceptionNotHandledEventArgs.cs
- ComplusTypeValidator.cs
- WebPartCancelEventArgs.cs
- ResourceContainer.cs
- IsolatedStorageException.cs