Clock Clock Clock Clock Class

定義

維護 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
繼承
衍生

備註

Timeline: 它本身並不會實際執行除了描述時間區段以外的任何專案。A 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) Clock(Timeline) 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 Controller Controller Controller

取得 ClockController,可用於啟動、暫停、繼續、搜尋、略過、停止或移除這個 ClockGets a ClockController that can be used to start, pause, resume, seek, skip, stop, or remove this Clock.

CurrentGlobalSpeed CurrentGlobalSpeed CurrentGlobalSpeed CurrentGlobalSpeed

取得時鐘目前行進速率,與實際時間相比較。Gets the rate at which the clock's time is currently progressing, compared to real-world time.

CurrentGlobalTime CurrentGlobalTime CurrentGlobalTime CurrentGlobalTime

取得目前全域時間,由 WPFWPF 計時系統建立。Gets the current global time, as established by the WPFWPF timing system.

CurrentIteration CurrentIteration CurrentIteration CurrentIteration

取得這個時鐘的目前反覆項目。Get the current iteration of this clock.

CurrentProgress CurrentProgress CurrentProgress CurrentProgress

取得這個 Clock 在其目前反覆項目內的目前進度。Gets the current progress of this Clock within its current iteration.

CurrentState CurrentState CurrentState CurrentState

取得值,指出時鐘目前為 ActiveFillingStoppedGets a value indicating whether the clock is currently Active, Filling, or Stopped.

CurrentTime CurrentTime CurrentTime CurrentTime

取得這個時鐘在其目前反覆項目內的目前時間。Gets this clock's current time within its current iteration.

Dispatcher Dispatcher Dispatcher Dispatcher

取得與這個 Dispatcher 關聯的 DispatcherObjectGets the Dispatcher this DispatcherObject is associated with.

(Inherited from DispatcherObject)
HasControllableRoot HasControllableRoot HasControllableRoot HasControllableRoot

取得值,這個值表示這個 Clock 是否為可控制之時鐘樹狀結構的一部分。Gets a value that indicates whether this Clock is part of a controllable clock tree.

IsPaused IsPaused IsPaused IsPaused

取得值,這個值表示這個 Clock 或任何其父代是否暫停。Gets a value that indicates whether this Clock, or any of its parents, is paused.

NaturalDuration NaturalDuration NaturalDuration NaturalDuration

取得這個時鐘之 Timeline 的自然持續時間。Gets the natural duration of this clock's Timeline.

Parent Parent Parent Parent

取得這個時鐘的父時鐘。Gets the clock that is the parent of this clock.

Timeline Timeline Timeline Timeline

取得在其中建立這個 TimelineClockGets the Timeline from which this Clock was created.

方法

CheckAccess() CheckAccess() CheckAccess() CheckAccess()

判斷呼叫的執行是否可以存取這個 DispatcherObjectDetermines whether the calling thread has access to this DispatcherObject.

(Inherited from DispatcherObject)
DiscontinuousTimeMovement() DiscontinuousTimeMovement() DiscontinuousTimeMovement() DiscontinuousTimeMovement()

在衍生類別中實作時,每當時鐘重複、略過或搜尋,就會叫用 (Invoke)。When implemented in a derived class, will be invoked whenever a clock repeats, skips, or seeks.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetCanSlip() GetCanSlip() GetCanSlip() GetCanSlip()

傳回值指出 Clock 是否具有自己的外部時間來源,該來源可能需要與計時系統同步。Returns whether the Clock has its own external time source, which may require synchronization with the timing system.

GetCurrentTimeCore() GetCurrentTimeCore() GetCurrentTimeCore() GetCurrentTimeCore()

取得這個時鐘在其目前反覆項目內的目前時間。Gets this clock's current time within its current iteration.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

(Inherited from Object)
SpeedChanged() SpeedChanged() SpeedChanged() 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() Stopped() Stopped() Stopped()

在衍生類別中實作時,每當使用 Stop() 方法停止時鐘時,就會叫用。When implemented in a derived class, will be invoked whenever a clock is stopped using the Stop() method.

ToString() ToString() ToString() ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(Inherited from Object)
VerifyAccess() VerifyAccess() VerifyAccess() VerifyAccess()

請強制執行可以存取這個 DispatcherObject 的呼叫執行緒。Enforces that the calling thread has access to this DispatcherObject.

(Inherited from DispatcherObject)

事件

Completed Completed Completed Completed

當這個時鐘完成播放時發生。Occurs when this clock has completely finished playing.

CurrentGlobalSpeedInvalidated CurrentGlobalSpeedInvalidated CurrentGlobalSpeedInvalidated CurrentGlobalSpeedInvalidated

時鐘速度更新時發生。Occurs when the clock's speed is updated.

CurrentStateInvalidated CurrentStateInvalidated CurrentStateInvalidated CurrentStateInvalidated

時鐘的 CurrentState 屬性更新時發生。Occurs when the clock's CurrentState property is updated.

CurrentTimeInvalidated CurrentTimeInvalidated CurrentTimeInvalidated CurrentTimeInvalidated

當這個時鐘的 CurrentTime 變成無效時發生。Occurs when this clock's CurrentTime becomes invalid.

RemoveRequested RemoveRequested RemoveRequested RemoveRequested

當在這個 Remove() 或它的一個父時鐘上呼叫 Clock 方法時發生。Occurs when the Remove() method is called on this Clock or one of its parent clocks.

適用於