Class ChangesStream
Represents a class that provides data for the stream, that tracks changes.
Inheritance
Inherited Members
Namespace: Syncfusion.Windows.Forms.Edit.Implementation.IO
Assembly: Syncfusion.Edit.Windows.dll
Syntax
public class ChangesStream : Stream, IDisposable, IChangesStream, IStream
Constructors
ChangesStream(Stream)
Initializes a new instance of the ChangesStream class.
Declaration
public ChangesStream(Stream input)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | input | Source stream, must support Read and Seek operations |
ChangesStream(String, FileMode, FileAccess)
Initializes a new instance of the ChangesStream class.
Declaration
public ChangesStream(string FileName, FileMode mode, FileAccess access)
Parameters
Type | Name | Description |
---|---|---|
System.String | FileName | Name of the file. |
System.IO.FileMode | mode | Mode of file opening. |
System.IO.FileAccess | access | File access type. |
Fields
DATA_WINDOW_SEARCH_COMPARER
Comparer for DataWindows.
Declaration
protected static IComparer DATA_WINDOW_SEARCH_COMPARER
Field Value
Type |
---|
System.Collections.IComparer |
DEF_BUFFER_SIZE
Default buffer size.
Declaration
protected const int DEF_BUFFER_SIZE = 8192
Field Value
Type |
---|
System.Int32 |
DEF_FLUSH_BLOCK_LENGTH
Length of the block of data for flushing.
Declaration
protected const int DEF_FLUSH_BLOCK_LENGTH = 51200
Field Value
Type |
---|
System.Int32 |
Properties
AutoPush
Gets or sets the count of changes that can be done before state will be automatically pushed to stack.
Declaration
public int AutoPush { get; set; }
Property Value
Type |
---|
System.Int32 |
CanRead
Gets a value indicating whether the user can read data from stream.
Declaration
public override bool CanRead { get; }
Property Value
Type |
---|
System.Boolean |
Overrides
CanRedo
Gets a value indicating whether the user can redo some actions in stream or not.
Declaration
public bool CanRedo { get; }
Property Value
Type |
---|
System.Boolean |
CanSeek
Gets a value indicating whether the user can seek position in stream.
Declaration
public override bool CanSeek { get; }
Property Value
Type |
---|
System.Boolean |
Overrides
CanUndo
Gets a value indicating whether the user can Undo some actions in stream or not.
Declaration
public bool CanUndo { get; }
Property Value
Type |
---|
System.Boolean |
CanWrite
Gets a value indicating whether the user can write the data to stream.
Declaration
public override bool CanWrite { get; }
Property Value
Type |
---|
System.Boolean |
Overrides
Changes
Gets list of changes.
Declaration
protected ArrayList Changes { get; }
Property Value
Type |
---|
System.Collections.ArrayList |
DataWindows
Gets list of active windows.
Declaration
protected ArrayList DataWindows { get; }
Property Value
Type |
---|
System.Collections.ArrayList |
LastSavedChangesCount
Looks for the last saved count of changes in the stack of Saved States
Declaration
protected int LastSavedChangesCount { get; }
Property Value
Type | Description |
---|---|
System.Int32 | Integer value of count or -1 if stack is empty |
LastSavedDataWindows
Looks for the last saved list of DataWindows in the stack of Saved States
Declaration
protected IList LastSavedDataWindows { get; }
Property Value
Type | Description |
---|---|
System.Collections.IList | List of data windows or null if stack is empty |
Length
Gets the length of the stream
Declaration
public override long Length { get; }
Property Value
Type |
---|
System.Int64 |
Overrides
Position
Gets or sets the current position in the stream.
Declaration
public override long Position { get; set; }
Property Value
Type |
---|
System.Int64 |
Overrides
SyncObject
Gets synchronization object.
Declaration
protected object SyncObject { get; }
Property Value
Type |
---|
System.Object |
Methods
AddChange(ChangeContext)
Applies change in current position.
Declaration
public void AddChange(ChangeContext context)
Parameters
Type | Name | Description |
---|---|---|
ChangeContext | context | Context of the change. |
AddChange(Int64, ChangeContext)
Add change to the specified position.
Declaration
public void AddChange(long position, ChangeContext context)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | position | Position in stream, where change is to be applied. |
ChangeContext | context | Context of the change. |
ChangeDelete(Int32, DataWindow, Int64, Int64, ref Int64, ChangeContext)
Make update of DataWindows according to Delete operation type logic
Declaration
protected void ChangeDelete(int index, DataWindow change, long start, long end, ref long posChange, ChangeContext context)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | Index of first DataWindow in update range |
DataWindow | change | DataWindow with chages |
System.Int64 | start | Start position of update region |
System.Int64 | end | End position of update region |
System.Int64 | posChange | influence on current stream position |
ChangeContext | context | Changes to context object |
ChangeInsert(Int32, DataWindow, Int64, Int64, ref Int64, DataWindow)
Make update of DataWindows according to Insert operation type logic
Declaration
protected void ChangeInsert(int index, DataWindow change, long start, long end, ref long posChange, DataWindow firstPart)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | Index of first DataWindow in update range |
DataWindow | change | DataWindow with chages |
System.Int64 | start | Start position of update region |
System.Int64 | end | End position of update region |
System.Int64 | posChange | influence on current stream position |
DataWindow | firstPart | DataWindow to which start position belong |
ChangeReplace(Int32, DataWindow, Int64, Int64, ref Int64, DataWindow, ChangeContext)
Make update of DataWindows according to Replace operation type logic
Declaration
protected void ChangeReplace(int index, DataWindow change, long start, long end, ref long posChange, DataWindow firstPart, ChangeContext context)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | Index of first DataWindow in update range |
DataWindow | change | DataWindow with chages |
System.Int64 | start | Start position of update region |
System.Int64 | end | End position of update region |
System.Int64 | posChange | influence on current stream position |
DataWindow | firstPart | DataWindow to which start position belong |
ChangeContext | context | Changes to context object |
Close()
Implemented for avoiding PEVerify warnings.
Declaration
public override void Close()
Overrides
CopyTo(Stream)
Writes current stream data to output stream.
Declaration
public void CopyTo(Stream stream)
Parameters
Type | Name | Description |
---|---|---|
System.IO.Stream | stream | Output stream. |
Dispose()
Frees used memory.
Declaration
public void Dispose()
ExtractLastState()
Restores datawindows and changes to the last state, saved in stack. WARNING: Method always must be called in lock( m_sync ) scope!!!
Declaration
protected void ExtractLastState()
Finalize()
Declaration
protected void Finalize()
Flush()
Saves output stream to input stream.
Declaration
public override void Flush()
Overrides
FlushChanges()
Saves all changes.
Declaration
public void FlushChanges()
GetDataWindowsInRange(Int64, Int64)
Searches for all data windwos in specified range.
Declaration
protected ArrayList GetDataWindowsInRange(long start, long end)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | start | Start position |
System.Int64 | end | End position |
Returns
Type | Description |
---|---|
System.Collections.ArrayList | Array of DataWindows which contains data from start to end points |
OnPositionChanged()
Method, that is raised on every change of m_position. It means that cache must be reloaded.
Declaration
protected virtual void OnPositionChanged()
PopState()
Restores datawindows and changes to the last state, saved in stack. Last saved state is removed from stack.
Declaration
public void PopState()
PushState()
Saves current datawindows and changes to stack.
Declaration
public void PushState()
RaiseDataChangedEvent()
Raiser for DataChanged event.
Declaration
protected virtual void RaiseDataChangedEvent()
RaiseDataPositionChanged(Int64, Int64)
Raiser for DataPositionChanged event
Declaration
protected virtual void RaiseDataPositionChanged(long OldPosition, long NewPosition)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | OldPosition | Old position. |
System.Int64 | NewPosition | New position. |
RaiseRedoBufferFlushedEvent()
Raises RedoBufferFlushed event.
Declaration
protected virtual void RaiseRedoBufferFlushedEvent()
RaiseUndoBufferFlushedEvent()
Raises UndoBufferFlushed event.
Declaration
protected virtual void RaiseUndoBufferFlushedEvent()
Read(Byte[], Int32, Int32)
Reads data from stream to buffer. Reading is started from the current position.
Declaration
public override int Read(byte[] buffer, int offset, int count)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | buffer | Array of bytes, where data must be put. |
System.Int32 | offset | Offset in buffer. |
System.Int32 | count | Count of bytes to be read. |
Returns
Type | Description |
---|---|
System.Int32 | Count of bytes, actually read. |
Overrides
ReadByte()
Implemented for avoiding PEVerify warnings.
Declaration
public override int ReadByte()
Returns
Type | Description |
---|---|
System.Int32 | Parent value. |
Overrides
Redo()
Performs Redo operation to last undone change.
Declaration
public void Redo()
ResetCache()
Resets cache. Cache will be reloaded on next position change or read from stream.
Declaration
protected void ResetCache()
Seek(Int64, SeekOrigin)
Sets the current position in the stream.
Declaration
public override long Seek(long offset, SeekOrigin origin)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | offset | Offset, that position must be moved for. |
System.IO.SeekOrigin | origin | Specifies point, where offset must be applied. |
Returns
Type | Description |
---|---|
System.Int64 | Current position. |
Overrides
SetLength(Int64)
Sets the length of the stream.
Declaration
public override void SetLength(long value)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | value | new length of stream |
Overrides
SetNewLineStyle(NewLineStyle)
Sets new line style to the underlying stream.
Declaration
public void SetNewLineStyle(NewLineStyle style)
Parameters
Type | Name | Description |
---|---|---|
NewLineStyle | style | Style of new line. |
SplitDataWindow(DataWindow, Int64)
Divides one window into two in some position.
Declaration
protected DataWindow SplitDataWindow(DataWindow window, long position)
Parameters
Type | Name | Description |
---|---|---|
DataWindow | window | Window to be divided |
System.Int64 | position | Position in stream of division point |
Returns
Type | Description |
---|---|
DataWindow | Second data window, that is cut |
TrimDataWindows(Int32, Int64, DataWindow)
Trims datawindows in specified range.
Declaration
protected void TrimDataWindows(int index, long position, DataWindow change)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | Index of the first datawindow, that must be cut. Can be 0, then scan of entire list will occure. |
System.Int64 | position | Start position of trimming. |
DataWindow | change | DataWindow, which size will be used for trimming. |
Undo()
Undo last change. WARNING: it simply redos all operation except the last one.
Declaration
public void Undo()
UpdateDataWindowsPositions()
Updates all window's positions. Length is also updated.
Declaration
protected void UpdateDataWindowsPositions()
UpdateDataWindowsPositions(Int32)
Updates all window's positions starting from some index. Length is also updated.
Declaration
protected void UpdateDataWindowsPositions(int start)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | start | Index of the first windwo to be updated |
Write(Byte[], Int32, Int32)
Writes data to stream from current position. It executes AddChange method with Insert change type.
Declaration
public override void Write(byte[] buffer, int offset, int count)
Parameters
Type | Name | Description |
---|---|---|
System.Byte[] | buffer | Data to be written. |
System.Int32 | offset | Offset of data to be written in buffer. |
System.Int32 | count | Count of bytes to be written. |
Overrides
WriteByte(Byte)
Implemented for avoiding PEVerify warnings.
Declaration
public override void WriteByte(byte value)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | value | Byte to write. |
Overrides
Events
AutoPushChanged
Occurs when AutoPush property value is changed.
Declaration
public event ValueChangedEventHandler AutoPushChanged
Event Type
Type |
---|
ValueChangedEventHandler |
DataChanged
Occurs after the data has changed in stream.
Declaration
public event EventHandler DataChanged
Event Type
Type |
---|
System.EventHandler |
DataPositionChanged
Occurs when position of some data was changed. Example: if some data was deleted, data, that is after deleted block, will be moved back for the length of deleted data, so it`s position will be changed.
Declaration
public event ValueChangedEventHandler DataPositionChanged
Event Type
Type |
---|
ValueChangedEventHandler |
RedoBufferFlushed
Occurs when redo buffer is flushed.
Declaration
public event EventHandler RedoBufferFlushed
Event Type
Type |
---|
System.EventHandler |
UndoBufferFlushed
Occurs when undo buffer is flushed.
Declaration
public event EventHandler UndoBufferFlushed
Event Type
Type |
---|
System.EventHandler |