UndoEngine 類別

定義

指定設計階段的一般復原/取消復原功能。Specifies generic undo/redo functionality at design time.

public ref class UndoEngine abstract : IDisposable
public abstract class UndoEngine : IDisposable
type UndoEngine = class
    interface IDisposable
Public MustInherit Class UndoEngine
Implements IDisposable
繼承
UndoEngine
實作

備註

UndoEngine Abstract 類別會在設計階段提供復原功能的預設執行。The UndoEngine abstract class provides a default implementation of undo functionality at design time. 復原單位代表可復原工作的單一單位。An undo unit represents a single unit of undoable work. 這個單元會新增至堆疊, 然後使用者可以逐步執行堆疊來復原每個動作。This unit is added to a stack and the user can then walk the stack to undo each action. 復原單位通常是設計來切換, 這表示呼叫復原兩次會將應用程式還原至其啟動狀態。Undo units typically are designed to toggle, which means that calling undo twice returns the application to its starting state.

UndoEngine類別會利用在設計工具中執行之物件的下列特性:The UndoEngine class takes advantage of the following characteristics of objects running within the designer:

  • 設計工具載入器可以將所有有趣的物件保存成某種格式。All interesting objects can be persisted to some format by the designer loader.

  • 當屬性變更時, 所有物件都會引發屬性變更通知。All objects raise property-change notifications when a property is changed.

  • IDesignerHost提供交易的概念, 可用於製作橫跨多個較小動作的復原動作。IDesignerHost offers the idea of transactions, which can be used to fabricate an undo action that spans multiple smaller actions.

有了這些功能UndoEngine , 就可以製作自動需要的任何復原單位。With these features, UndoEngine can fabricate any undo units it needs automatically.

注意

請勿直接變更屬性值。Do not change property values directly. 類別會要求您使用適當TypeDescriptor的來變更屬性值。 UndoEngineThe UndoEngine class requires you to use the appropriate TypeDescriptor to change property values.

UndoEngine監視變更通知以建立復原單位, 而單位本身則由序列化物件狀態組成。UndoEngine monitors for change notifications to create undo units, and the units themselves consist of serialized object states. 下表顯示建立時UndoEngine必須可使用的服務。The following table shows the services that must be available when UndoEngine is created.

服務Service 說明Description
ComponentSerializationService 在進行變更之前和之後, 儲存元件的屬性和物件值。Saves property and object values for a component before and after a change is made.
IComponentChangeService 通知復原引擎對元件所做的變更。Notifies the undo engine of changes made to components.
IDesignerHost 用來追蹤交易。Used to track transactions.

注意

因為類別需要ComponentSerializationServiceIComponentChangeService, 所以只有在設計階段才可使用。 UndoEngineBecause the UndoEngine class requires ComponentSerializationService and IComponentChangeService, it is available only at design time.

復原引擎會追蹤交易, 並建立包含交易的單一復原單位。The undo engine tracks transactions and creates a single undo unit that encompasses a transaction. 如此一來, 復原引擎就可以控制可復原動作的持續時間。As a result, the undo engine has control over the duration of an undoable action. 此外, 因為交易可以命名, 所以可執行檔動作會從目前的交易繼承其名稱。Also, because transactions can be named, undoable actions inherit their names from the current transaction. 如果沒有可用的交易並回報變更, 則「復原引擎」會根據變更類型 (例如, 「變更屬性 ' 文字 '」) 來建立復原名稱。If no transaction is available and a change is reported, the undo engine creates an undo name based on the type of change (for example, "Change property 'Text'").

建構函式

UndoEngine(IServiceProvider)

初始化 UndoEngine 類別的新執行個體。Initializes a new instance of the UndoEngine class.

屬性

Enabled

啟用或停用 UndoEngineEnables or disables the UndoEngine.

UndoInProgress

指出復原動作是否在進行中。Indicates if an undo action is in progress.

方法

AddUndoUnit(UndoEngine+UndoUnit)

UndoEngine.UndoUnit 加入至復原堆疊。Adds an UndoEngine.UndoUnit to the undo stack.

CreateUndoUnit(String, Boolean)

建立新的 UndoEngine.UndoUnitCreates a new UndoEngine.UndoUnit.

DiscardUndoUnit(UndoEngine+UndoUnit)

捨棄 UndoEngine.UndoUnitDiscards an UndoEngine.UndoUnit.

Dispose()

釋放 UndoEngine 所使用的所有資源。Releases all resources used by the UndoEngine.

Dispose(Boolean)

釋放 UndoEngine 所使用的 Unmanaged 資源,並選擇性地釋放 Managed 資源。Releases the unmanaged resources used by the UndoEngine and optionally releases the managed resources.

Equals(Object)

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

(繼承來源 Object)
GetHashCode()

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

(繼承來源 Object)
GetRequiredService(Type)

取得所要求的服務。Gets the requested service.

GetService(Type)

取得所要求的服務。Gets the requested service.

GetType()

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

(繼承來源 Object)
MemberwiseClone()

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

(繼承來源 Object)
OnUndoing(EventArgs)

引發 Undoing 事件。Raises the Undoing event.

OnUndone(EventArgs)

引發 Undone 事件。Raises the Undone event.

ToString()

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

(繼承來源 Object)

事件

Undoing

緊接在執行復原動作之前發生。Occurs immediately before an undo action is performed.

Undone

緊接在執行復原動作之後發生。Occurs immediately after an undo action is performed.

適用於

另請參閱