Clock 类

定义

维护 Timeline 的运行时时序状态。Maintains run-time timing state for a Timeline.

public ref class Clock : System::Windows::Threading::DispatcherObject
public class Clock : System.Windows.Threading.DispatcherObject
type Clock = class
    inherit DispatcherObject
Public Class Clock
Inherits DispatcherObject
继承
派生

注解

本身并不实际执行任何操作,而不是描述段时间。TimelineA Timeline, by itself, doesn't actually do anything other than describe a segment of time. 它是执行实际工作Clock的时间线对象: 它为时间线维护与计时相关的运行时状态。It's the timeline's Clock object that does the real work: it maintains timing-related run-time state for the timeline.

在大多数情况下, 时钟会自动为时间线创建。In most cases, a clock is created automatically for your timeline. Storyboard 使用BeginAnimation或方法对进行动画处理时, 会自动为时间线和动画创建时钟, 并将其应用于其目标属性。When you animate by using a Storyboard or the BeginAnimation method, clocks are automatically created for your timelines and animations and applied to their targeted properties. 相关示例,请参阅如何:使用情节提要对属性进行动画处理, 以及如何:在不使用情节提要的情况下对属性进行动画处理。For examples, see How to: Animate a Property by Using a Storyboard and How to: Animate a Property Without Using a Storyboard.

你还可以CreateClock使用方法Clock显式创建。You can also create a Clock explicitly by using the CreateClock method. 在性能密集型方案 (如对大量类似对象进行动画处理) 中, 管理自己Clock的使用可以提供性能优势。In performance-intensive scenarios, such as animating large numbers of similar objects, managing your own Clock use can provide performance benefits.

时钟安排在与从中创建它们的Timeline对象树的结构相匹配的树中。Clocks are arranged in trees that match the structure of the Timeline objects tree from which they are created. 此类计时树的根时钟可以通过检索其Controller来以交互方式 (暂停、恢复、停止等) 进行操作。The root clock of such a timing tree can be interactively manipulated (paused, resumed, stopped, and so on) by retrieving its Controller. 非根时钟无法直接控制。Non-root clocks cannot be directly controlled.

创建后, 无法修改时钟 (但可以对其进行操作)。Once created, a clock cannot be modified (but it can be manipulated).

使用时间线作为计时器Using a Timeline as a Timer

仅当存在与其相关联的事件处理程序时, 或 (在AnimationClock对象的情况下) 与属性相关联的事件处理程序时, 时间线的时钟才会进行。A timeline's clock will only progress when there's an event handler associated with it or (in the case of an AnimationClock object) it is associated with a property. 出于此原因 (以及其他), 不建议使用Timeline作为计时器。For this reason (and others), it's not recommended that you use a Timeline as a timer.

继承者说明

如果派生类要GetCurrentTimeCore()修改此时钟的时间流, 则应实现。Derived classes should implement GetCurrentTimeCore() if they want to modify how time flows for this clock. 派生类可以通过重写DiscontinuousTimeMovement()SpeedChanged()Stopped()方法, 在时钟重复、跳过、查找、启动、暂停、恢复或停止时执行额外的工作。Derived classes can be made to do additional work when the clock repeats, skips, seeks, begins, pauses, resumes, or stops by overriding the DiscontinuousTimeMovement(), SpeedChanged(), and Stopped() methods.

构造函数

Clock(Timeline)

使用指定的 Clock 作为模板来初始化 Timeline 类的新实例。Initializes a new instance of the Clock class, using the specified Timeline as a template. 新的 Clock 对象没有子级。The new Clock object has no children.

属性

Controller

获取可用来启动、暂停、恢复、查找、跳过、停止或删除此 ClockClockControllerGets a ClockController that can be used to start, pause, resume, seek, skip, stop, or remove this Clock.

CurrentGlobalSpeed

获取时钟相对于实际时间的当前前进速率。Gets the rate at which the clock's time is currently progressing, compared to real-world time.

CurrentGlobalTime

获取当前全局时间,它由 WPFWPF 计时系统建立。Gets the current global time, as established by the WPFWPF timing system.

CurrentIteration

获取此时钟的当前迭代。Get the current iteration of this clock.

CurrentProgress

获取此 Clock 在其当前迭代中的当前进度。Gets the current progress of this Clock within its current iteration.

CurrentState

获取指示时钟当前处于 ActiveFilling 还是 Stopped 状态的值。Gets a value indicating whether the clock is currently Active, Filling, or Stopped.

CurrentTime

在此时钟的当前迭代中获取它的当前时间。Gets this clock's current time within its current iteration.

Dispatcher

获取与此 Dispatcher 关联的 DispatcherObjectGets the Dispatcher this DispatcherObject is associated with.

(继承自 DispatcherObject)
HasControllableRoot

获取一个值,该值指示此 Clock 是否为可控制的时钟树的一部分。Gets a value that indicates whether this Clock is part of a controllable clock tree.

IsPaused

获取指示此 Clock 或其任何父级是否已暂停的值。Gets a value that indicates whether this Clock, or any of its parents, is paused.

NaturalDuration

获取此时钟的 Timeline 的自然持续时间。Gets the natural duration of this clock's Timeline.

Parent

获取此时钟的父时钟。Gets the clock that is the parent of this clock.

Timeline

获取创建此 Timeline 时基于的 ClockGets the Timeline from which this Clock was created.

方法

CheckAccess()

确定调用线程是否可以访问此 DispatcherObjectDetermines whether the calling thread has access to this DispatcherObject.

(继承自 DispatcherObject)
DiscontinuousTimeMovement()

在派生类中实现后,每当时钟重复、跳过或查找时就会调用它。When implemented in a derived class, will be invoked whenever a clock repeats, skips, or seeks.

Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
GetCanSlip()

返回 Clock 是否具有可能需要与计时系统同步的自己的外部时间源。Returns whether the Clock has its own external time source, which may require synchronization with the timing system.

GetCurrentTimeCore()

在此时钟的当前迭代中获取它的当前时间。Gets this clock's current time within its current iteration.

GetHashCode()

作为默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
SpeedChanged()

在派生类中实现后,每当时钟启动、跳过、暂停、继续时或时钟的 SpeedRatio 被修改时,就会调用它。When implemented in a derived class, will be invoked whenever a clock begins, skips, pauses, resumes, or when the clock's SpeedRatio is modified.

Stopped()

在派生类中实现后,每当使用 Stop() 方法停止时钟时,就会调用它。When implemented in a derived class, will be invoked whenever a clock is stopped using the Stop() method.

ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(继承自 Object)
VerifyAccess()

强制调用线程具有此 DispatcherObject 的访问权限。Enforces that the calling thread has access to this DispatcherObject.

(继承自 DispatcherObject)

事件

Completed

当此时钟完全播放完毕时发生。Occurs when this clock has completely finished playing.

CurrentGlobalSpeedInvalidated

在更新时钟速度时发生。Occurs when the clock's speed is updated.

CurrentStateInvalidated

当更新时钟的 CurrentState 属性时发生。Occurs when the clock's CurrentState property is updated.

CurrentTimeInvalidated

当此时钟的 CurrentTime 变为无效时发生。Occurs when this clock's CurrentTime becomes invalid.

RemoveRequested

当对此 Remove() 或其父时钟之一调用 Clock 方法时发生。Occurs when the Remove() method is called on this Clock or one of its parent clocks.

适用于