Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Core / CSharp / System / Windows / Media / Animation / ParallelTimeline.cs / 1305600 / ParallelTimeline.cs
//----------------------------------------------------------------------------
//
// Copyright (C) Microsoft Corporation. All rights reserved.
//
//---------------------------------------------------------------------------
using MS.Internal;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.ComponentModel;
namespace System.Windows.Media.Animation
{
///
/// This class represents a group of Timelines where the children
/// become active according to the value of their Begin property rather
/// than their specific order in the Children collection. Children
/// are also able to overlap and run in parallel with each other.
///
public partial class ParallelTimeline : TimelineGroup
{
#region Constructors
///
/// Creates a ParallelTimeline with default properties.
///
public ParallelTimeline()
: base()
{
}
///
/// Creates a ParallelTimeline with the specified BeginTime.
///
///
/// The scheduled BeginTime for this ParallelTimeline.
///
public ParallelTimeline(TimeSpan? beginTime)
: base(beginTime)
{
}
///
/// Creates a ParallelTimeline with the specified begin time and duration.
///
///
/// The scheduled BeginTime for this ParallelTimeline.
///
///
/// The simple Duration of this ParallelTimeline.
///
public ParallelTimeline(TimeSpan? beginTime, Duration duration)
: base(beginTime, duration)
{
}
///
/// Creates a ParallelTimeline with the specified BeginTime, Duration and RepeatBehavior.
///
///
/// The scheduled BeginTime for this ParallelTimeline.
///
///
/// The simple Duration of this ParallelTimeline.
///
///
/// The RepeatBehavior for this ParallelTimeline.
///
public ParallelTimeline(TimeSpan? beginTime, Duration duration, RepeatBehavior repeatBehavior)
: base(beginTime, duration, repeatBehavior)
{
}
#endregion
#region Methods
///
/// Return the duration from a specific clock
///
///
/// The Clock whose natural duration is desired.
///
///
/// A Duration quantity representing the natural duration.
///
protected override Duration GetNaturalDurationCore(Clock clock)
{
Duration simpleDuration = TimeSpan.Zero;
ClockGroup clockGroup = clock as ClockGroup;
if (clockGroup != null)
{
List children = clockGroup.InternalChildren;
// The container ends when all of its children have ended at least
// one of their active periods.
if (children != null)
{
bool hasChildWithUnresolvedDuration = false;
for (int childIndex = 0; childIndex < children.Count; childIndex++)
{
Duration childEndOfActivePeriod = children[childIndex].EndOfActivePeriod;
if (childEndOfActivePeriod == Duration.Forever)
{
// If we have even one child with a duration of forever
// our resolved duration will also be forever. It doesn't
// matter if other children have unresolved durations.
return Duration.Forever;
}
else if (childEndOfActivePeriod == Duration.Automatic)
{
hasChildWithUnresolvedDuration = true;
}
else if (childEndOfActivePeriod > simpleDuration)
{
simpleDuration = childEndOfActivePeriod;
}
}
// We've iterated through all our children. We know that at this
// point none of them have a duration of Forever or we would have
// returned already. If any of them still have unresolved
// durations then our duration is also still unresolved and we
// will return automatic. Otherwise, we'll fall out of the 'if'
// block and return the simpleDuration as our final resolved
// duration.
if (hasChildWithUnresolvedDuration)
{
return Duration.Automatic;
}
}
}
return simpleDuration;
}
#endregion
#region SlipBehavior Property
///
/// SlipBehavior Property
///
public static readonly DependencyProperty SlipBehaviorProperty =
DependencyProperty.Register(
"SlipBehavior",
typeof(SlipBehavior),
typeof(ParallelTimeline),
new PropertyMetadata(
SlipBehavior.Grow,
new PropertyChangedCallback(ParallelTimeline_PropertyChangedFunction)),
new ValidateValueCallback(ValidateSlipBehavior));
private static bool ValidateSlipBehavior(object value)
{
return TimeEnumHelper.IsValidSlipBehavior((SlipBehavior)value);
}
///
/// Returns the SlipBehavior for this ClockGroup
///
[DefaultValue(SlipBehavior.Grow)]
public SlipBehavior SlipBehavior
{
get
{
return (SlipBehavior)GetValue(SlipBehaviorProperty);
}
set
{
SetValue(SlipBehaviorProperty, value);
}
}
internal static void ParallelTimeline_PropertyChangedFunction(DependencyObject d,
DependencyPropertyChangedEventArgs e)
{
((ParallelTimeline)d).PropertyChanged(e.Property);
}
#endregion // SlipBehavior Property
}
}
// 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 MS.Internal;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.ComponentModel;
namespace System.Windows.Media.Animation
{
///
/// This class represents a group of Timelines where the children
/// become active according to the value of their Begin property rather
/// than their specific order in the Children collection. Children
/// are also able to overlap and run in parallel with each other.
///
public partial class ParallelTimeline : TimelineGroup
{
#region Constructors
///
/// Creates a ParallelTimeline with default properties.
///
public ParallelTimeline()
: base()
{
}
///
/// Creates a ParallelTimeline with the specified BeginTime.
///
///
/// The scheduled BeginTime for this ParallelTimeline.
///
public ParallelTimeline(TimeSpan? beginTime)
: base(beginTime)
{
}
///
/// Creates a ParallelTimeline with the specified begin time and duration.
///
///
/// The scheduled BeginTime for this ParallelTimeline.
///
///
/// The simple Duration of this ParallelTimeline.
///
public ParallelTimeline(TimeSpan? beginTime, Duration duration)
: base(beginTime, duration)
{
}
///
/// Creates a ParallelTimeline with the specified BeginTime, Duration and RepeatBehavior.
///
///
/// The scheduled BeginTime for this ParallelTimeline.
///
///
/// The simple Duration of this ParallelTimeline.
///
///
/// The RepeatBehavior for this ParallelTimeline.
///
public ParallelTimeline(TimeSpan? beginTime, Duration duration, RepeatBehavior repeatBehavior)
: base(beginTime, duration, repeatBehavior)
{
}
#endregion
#region Methods
///
/// Return the duration from a specific clock
///
///
/// The Clock whose natural duration is desired.
///
///
/// A Duration quantity representing the natural duration.
///
protected override Duration GetNaturalDurationCore(Clock clock)
{
Duration simpleDuration = TimeSpan.Zero;
ClockGroup clockGroup = clock as ClockGroup;
if (clockGroup != null)
{
List children = clockGroup.InternalChildren;
// The container ends when all of its children have ended at least
// one of their active periods.
if (children != null)
{
bool hasChildWithUnresolvedDuration = false;
for (int childIndex = 0; childIndex < children.Count; childIndex++)
{
Duration childEndOfActivePeriod = children[childIndex].EndOfActivePeriod;
if (childEndOfActivePeriod == Duration.Forever)
{
// If we have even one child with a duration of forever
// our resolved duration will also be forever. It doesn't
// matter if other children have unresolved durations.
return Duration.Forever;
}
else if (childEndOfActivePeriod == Duration.Automatic)
{
hasChildWithUnresolvedDuration = true;
}
else if (childEndOfActivePeriod > simpleDuration)
{
simpleDuration = childEndOfActivePeriod;
}
}
// We've iterated through all our children. We know that at this
// point none of them have a duration of Forever or we would have
// returned already. If any of them still have unresolved
// durations then our duration is also still unresolved and we
// will return automatic. Otherwise, we'll fall out of the 'if'
// block and return the simpleDuration as our final resolved
// duration.
if (hasChildWithUnresolvedDuration)
{
return Duration.Automatic;
}
}
}
return simpleDuration;
}
#endregion
#region SlipBehavior Property
///
/// SlipBehavior Property
///
public static readonly DependencyProperty SlipBehaviorProperty =
DependencyProperty.Register(
"SlipBehavior",
typeof(SlipBehavior),
typeof(ParallelTimeline),
new PropertyMetadata(
SlipBehavior.Grow,
new PropertyChangedCallback(ParallelTimeline_PropertyChangedFunction)),
new ValidateValueCallback(ValidateSlipBehavior));
private static bool ValidateSlipBehavior(object value)
{
return TimeEnumHelper.IsValidSlipBehavior((SlipBehavior)value);
}
///
/// Returns the SlipBehavior for this ClockGroup
///
[DefaultValue(SlipBehavior.Grow)]
public SlipBehavior SlipBehavior
{
get
{
return (SlipBehavior)GetValue(SlipBehaviorProperty);
}
set
{
SetValue(SlipBehaviorProperty, value);
}
}
internal static void ParallelTimeline_PropertyChangedFunction(DependencyObject d,
DependencyPropertyChangedEventArgs e)
{
((ParallelTimeline)d).PropertyChanged(e.Property);
}
#endregion // SlipBehavior Property
}
}
// 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
- VBIdentifierName.cs
- BuildManagerHost.cs
- ToggleProviderWrapper.cs
- BaseContextMenu.cs
- HwndMouseInputProvider.cs
- XmlRawWriter.cs
- CheckableControlBaseAdapter.cs
- MetadataHelper.cs
- MimePart.cs
- ToolStripDropDownItem.cs
- Math.cs
- ScrollContentPresenter.cs
- LostFocusEventManager.cs
- XsltArgumentList.cs
- SafeArrayTypeMismatchException.cs
- IBuiltInEvidence.cs
- WebPartsPersonalization.cs
- Solver.cs
- PagerSettings.cs
- MergePropertyDescriptor.cs
- XsdBuilder.cs
- StructureChangedEventArgs.cs
- JavascriptCallbackMessageInspector.cs
- RowToFieldTransformer.cs
- ImportCatalogPart.cs
- RawMouseInputReport.cs
- BitmapFrameDecode.cs
- FileUtil.cs
- ReachPageContentCollectionSerializer.cs
- BooleanAnimationBase.cs
- __ComObject.cs
- StylusDevice.cs
- KnownIds.cs
- AbsoluteQuery.cs
- TrustManagerPromptUI.cs
- EntitySqlException.cs
- FirstMatchCodeGroup.cs
- ToolStrip.cs
- ConstraintStruct.cs
- ControlSerializer.cs
- SystemIPGlobalProperties.cs
- PocoEntityKeyStrategy.cs
- InputLangChangeRequestEvent.cs
- MarkerProperties.cs
- Compiler.cs
- DBConnection.cs
- RowBinding.cs
- ToolStripActionList.cs
- ISAPIWorkerRequest.cs
- UnhandledExceptionEventArgs.cs
- EmbossBitmapEffect.cs
- LogRecordSequence.cs
- LinkArea.cs
- PropertyEmitterBase.cs
- GeneralTransform2DTo3DTo2D.cs
- StringToken.cs
- TypedDataSetSchemaImporterExtensionFx35.cs
- RemoteX509AsymmetricSecurityKey.cs
- DataStreams.cs
- ColumnMapCopier.cs
- StylusDownEventArgs.cs
- TextServicesDisplayAttribute.cs
- processwaithandle.cs
- ApplicationSecurityManager.cs
- PlainXmlWriter.cs
- ObjectDataSource.cs
- EventDescriptor.cs
- EmptyStringExpandableObjectConverter.cs
- Ipv6Element.cs
- WebProxyScriptElement.cs
- JsonClassDataContract.cs
- XPathNodeIterator.cs
- ContextMenuService.cs
- WindowsUserNameSecurityTokenAuthenticator.cs
- EntityViewGenerator.cs
- EdmItemError.cs
- PageParserFilter.cs
- ChannelEndpointElementCollection.cs
- PathFigureCollection.cs
- XPathNavigatorReader.cs
- ClientConvert.cs
- RegexCapture.cs
- BitSet.cs
- NavigationWindow.cs
- EventItfInfo.cs
- StylusButtonEventArgs.cs
- XmlMtomReader.cs
- ListControlDesigner.cs
- TrackingMemoryStreamFactory.cs
- ConvertEvent.cs
- TextEditorContextMenu.cs
- HijriCalendar.cs
- ClientFormsIdentity.cs
- OleStrCAMarshaler.cs
- LinqDataView.cs
- AutomationPatternInfo.cs
- StaticContext.cs
- FileDialogPermission.cs
- DetailsViewRow.cs
- PropertyChangeTracker.cs