Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Core / CSharp / System / Windows / Input / InertiaExpansionBehavior.cs / 1305600 / InertiaExpansionBehavior.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 InertiaExpansionBehavior
{
///
/// Instantiates a new instance of this class.
///
public InertiaExpansionBehavior()
{
}
///
/// Instantiates a new instance of this class.
///
internal InertiaExpansionBehavior(Vector initialVelocity)
{
_initialVelocity = initialVelocity;
}
///
/// The initial rate of change of size 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;
_isDesiredExpansionSet = false;
_desiredExpansion = new Vector(double.NaN, double.NaN);
}
}
///
/// The desired total change in size.
///
public Vector DesiredExpansion
{
get { return _desiredExpansion; }
set
{
_isDesiredExpansionSet = true;
_desiredExpansion = value;
_isDesiredDecelerationSet = false;
_desiredDeceleration = double.NaN;
}
}
public double InitialRadius
{
get { return _initialRadius; }
set
{
_isInitialRadiusSet = true;
_initialRadius = value;
}
}
internal bool CanUseForInertia()
{
return _isInitialVelocitySet || _isInitialRadiusSet || _isDesiredDecelerationSet || _isDesiredExpansionSet;
}
internal static void ApplyParameters(InertiaExpansionBehavior behavior, InertiaProcessor2D processor, Vector initialVelocity)
{
if (behavior != null && behavior.CanUseForInertia())
{
InertiaExpansionBehavior2D behavior2D = new InertiaExpansionBehavior2D();
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._isDesiredExpansionSet)
{
behavior2D.DesiredExpansionX = (float)behavior._desiredExpansion.X;
behavior2D.DesiredExpansionY = (float)behavior._desiredExpansion.Y;
}
if (behavior._isInitialRadiusSet)
{
behavior2D.InitialRadius = (float)behavior._initialRadius;
}
processor.ExpansionBehavior = behavior2D;
}
}
private bool _isInitialVelocitySet;
private Vector _initialVelocity = new Vector(double.NaN, double.NaN);
private bool _isDesiredDecelerationSet;
private double _desiredDeceleration = double.NaN;
private bool _isDesiredExpansionSet;
private Vector _desiredExpansion = new Vector(double.NaN, double.NaN);
private bool _isInitialRadiusSet;
private double _initialRadius = 1.0;
}
}
// 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 InertiaExpansionBehavior
{
///
/// Instantiates a new instance of this class.
///
public InertiaExpansionBehavior()
{
}
///
/// Instantiates a new instance of this class.
///
internal InertiaExpansionBehavior(Vector initialVelocity)
{
_initialVelocity = initialVelocity;
}
///
/// The initial rate of change of size 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;
_isDesiredExpansionSet = false;
_desiredExpansion = new Vector(double.NaN, double.NaN);
}
}
///
/// The desired total change in size.
///
public Vector DesiredExpansion
{
get { return _desiredExpansion; }
set
{
_isDesiredExpansionSet = true;
_desiredExpansion = value;
_isDesiredDecelerationSet = false;
_desiredDeceleration = double.NaN;
}
}
public double InitialRadius
{
get { return _initialRadius; }
set
{
_isInitialRadiusSet = true;
_initialRadius = value;
}
}
internal bool CanUseForInertia()
{
return _isInitialVelocitySet || _isInitialRadiusSet || _isDesiredDecelerationSet || _isDesiredExpansionSet;
}
internal static void ApplyParameters(InertiaExpansionBehavior behavior, InertiaProcessor2D processor, Vector initialVelocity)
{
if (behavior != null && behavior.CanUseForInertia())
{
InertiaExpansionBehavior2D behavior2D = new InertiaExpansionBehavior2D();
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._isDesiredExpansionSet)
{
behavior2D.DesiredExpansionX = (float)behavior._desiredExpansion.X;
behavior2D.DesiredExpansionY = (float)behavior._desiredExpansion.Y;
}
if (behavior._isInitialRadiusSet)
{
behavior2D.InitialRadius = (float)behavior._initialRadius;
}
processor.ExpansionBehavior = behavior2D;
}
}
private bool _isInitialVelocitySet;
private Vector _initialVelocity = new Vector(double.NaN, double.NaN);
private bool _isDesiredDecelerationSet;
private double _desiredDeceleration = double.NaN;
private bool _isDesiredExpansionSet;
private Vector _desiredExpansion = new Vector(double.NaN, double.NaN);
private bool _isInitialRadiusSet;
private double _initialRadius = 1.0;
}
}
// 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
- FontFamily.cs
- FlowLayoutPanel.cs
- PostBackOptions.cs
- MetabaseServerConfig.cs
- Application.cs
- InputScopeNameConverter.cs
- ApplyImportsAction.cs
- Vector3D.cs
- RegexStringValidator.cs
- UIElementCollection.cs
- ScrollItemProviderWrapper.cs
- TransactionManager.cs
- RecommendedAsConfigurableAttribute.cs
- sitestring.cs
- DictionaryManager.cs
- Int32Storage.cs
- SetterTriggerConditionValueConverter.cs
- DesignerActionMethodItem.cs
- TabControl.cs
- TemplateParser.cs
- WebBrowserNavigatedEventHandler.cs
- Int64AnimationBase.cs
- odbcmetadatacolumnnames.cs
- DataGridViewSortCompareEventArgs.cs
- KoreanLunisolarCalendar.cs
- TreeNode.cs
- MetadataLocation.cs
- DefaultHttpHandler.cs
- ReadOnlyHierarchicalDataSource.cs
- GZipObjectSerializer.cs
- DrawingContextDrawingContextWalker.cs
- TypeHelpers.cs
- ComponentEvent.cs
- AsyncWaitHandle.cs
- DbDataRecord.cs
- ChangePassword.cs
- TopClause.cs
- DataColumnMapping.cs
- Application.cs
- UnsafeNativeMethods.cs
- WorkflowRuntimeServicesBehavior.cs
- ZoneButton.cs
- EmptyQuery.cs
- MorphHelper.cs
- LayeredChannelFactory.cs
- DoubleLinkList.cs
- DesignerUtility.cs
- SiteMapSection.cs
- EntityContainer.cs
- JapaneseCalendar.cs
- TypeBuilder.cs
- VirtualPathUtility.cs
- RSAOAEPKeyExchangeDeformatter.cs
- GroupByQueryOperator.cs
- FixedSOMImage.cs
- TemplateInstanceAttribute.cs
- XmlLanguageConverter.cs
- XmlDomTextWriter.cs
- TransformPattern.cs
- PlainXmlWriter.cs
- SqlConnectionHelper.cs
- ContentPathSegment.cs
- WindowsListViewItem.cs
- DataTemplateSelector.cs
- CompositeDataBoundControl.cs
- ClientProxyGenerator.cs
- HttpProfileBase.cs
- SourceChangedEventArgs.cs
- TextEffect.cs
- CodeTypeDelegate.cs
- AuthorizationRuleCollection.cs
- XmlSchemaInferenceException.cs
- TeredoHelper.cs
- LocalizationComments.cs
- StructuredType.cs
- PublisherMembershipCondition.cs
- EventSetter.cs
- WindowsListViewSubItem.cs
- ContentType.cs
- Helper.cs
- ScrollProviderWrapper.cs
- ChangesetResponse.cs
- SqlXml.cs
- HttpCachePolicyWrapper.cs
- KeyManager.cs
- DynamicRenderer.cs
- SQLMoneyStorage.cs
- XmlSchemaSimpleContentRestriction.cs
- TabPanel.cs
- AttachedAnnotationChangedEventArgs.cs
- ComponentDispatcher.cs
- XmlDesigner.cs
- CompiledQueryCacheEntry.cs
- TreeNode.cs
- NumberSubstitution.cs
- WebPartCancelEventArgs.cs
- ToolStripItem.cs
- Calendar.cs
- Automation.cs
- EditorZoneBase.cs