ObservableUndoableTextChangeStack Class
Provides wrapper for an IUndoableTextChangeStack that implements INotifyCollectionChanged, allowing it to be used as an items source in UI controls.
public class ObservableUndoableTextChangeStack : DisposableObject, IDisposable, IUndoableTextChangeStack
- Inheritance:
- object DisposableObject object
- Implements:
- IDisposable IUndoableTextChangeStack
Remarks
Since the IUndoableTextChangeStack interface is defined in a .NET 2.0-based assembly and INotifyCollectionChanged was not added to .NET until 3.0, this class can be used as a wrapper for the core IUndoableTextChangeStack.
Constructors
ObservableUndoableTextChangeStack(IUndoableTextChangeStack)
Initializes a new instance of the ObservableUndoableTextChangeStack
class.
public ObservableUndoableTextChangeStack(IUndoableTextChangeStack stack)
Parameter | Type | Description |
---|---|---|
stack | IUndoableTextChangeStack | The IUndoableTextChangeStack to wrap. |
Properties
Capacity
Gets or sets the capacity of the stack.
public int Capacity { get; set; }
Property Value
- int:
The capacity of the stack.
Remarks
If a new text change added to the stack causes the stack to exceed its capacity, the text changes at the bottom of the stack are removed until the stack no longer exceeds its capacity.
Count
Gets the count of text changes on the stack.
IsAtSavePoint
Gets whether the last text change on the stack is a save point.
public bool IsAtSavePoint { get; }
Property Value
- bool:
true
if the last text change on the stack is a save point; otherwise,false
.
Methods
Contains(IUndoableTextChange)
Returns whether the collection contains the specified IUndoableTextChange.
public bool Contains(IUndoableTextChange textChange)
Parameter | Type | Description |
---|---|---|
textChange | IUndoableTextChange | The IUndoableTextChange to look for in the list. |
Returns
- bool:
true
if the collection contains the specified IUndoableTextChange; otherwise,false
.
CopyTo(IUndoableTextChange[], int)
Copies the entire collection to a compatible one-dimensional Array
,
starting at the specified index of the target array.
public void CopyTo(IUndoableTextChange[] array, int arrayIndex)
Parameter | Type | Description |
---|---|---|
array | IUndoableTextChange[] | The one-dimensional IUndoableTextChange array that is the destination of the elements copied from the collection. The array must have zero-based indexing. |
arrayIndex | int | The zero-based index in |
Dispose(bool)
Releases the unmanaged resources used by the object and optionally releases the managed resources.
protected override void Dispose(bool disposing)
Parameter | Type | Description |
---|---|---|
disposing | bool |
|
Remarks
This method is called by the public Dispose
method and the Finalize
method.
Dispose
invokes this method with the disposing
parameter set to true
.
Finalize
invokes this method with disposing
set to false
.
GetEnumerator()
Retrieves an IEnumerator
object for the entire collection.
public IEnumerator<IUndoableTextChange> GetEnumerator()
Returns
- IEnumerator<IUndoableTextChange>:
An
IEnumerator
object for the entire collection
Remarks
Enumerators are intended to be used only to read data in the collection. Enumerators cannot be used to modify the underlying collection.
The enumerator does not have exclusive access to the collection.
When an enumerator is instantiated, it takes a snapshot of the current state of the collection.
If changes are made to the collection, such as adding, modifying or deleting elements, the
snapshot gets out of sync and the enumerator throws an InvalidOperationException
.
Two enumerators instantiated from the same collection at the same time can have
different snapshots of the collection.
GetTextChange(int)
Gets the IUndoableTextChange that the specified location in the stack.
public IUndoableTextChange GetTextChange(int index)
Parameter | Type | Description |
---|---|---|
index | int | The index of the text change to check. |
Returns
- IUndoableTextChange:
The IUndoableTextChange that the specified location in the stack.
IndexOf(IUndoableTextChange)
Returns the index of the IUndoableTextChange in the list.
public int IndexOf(IUndoableTextChange textChange)
Parameter | Type | Description |
---|---|---|
textChange | IUndoableTextChange | The IUndoableTextChange to look for in the list. |
Returns
- int:
The index of the IUndoableTextChange in the list, or
-1
if not found.
Events
CapacityChanged
Occurs when the capacity of the stack is changed.
CollectionChanged
Occurs when the collection is changed.
public event NotifyCollectionChangedEventHandler CollectionChanged
Event Type
StackChanged
Occurs when the contents of the stack are changed.