/// <summary> 插入Item到指定位置 </summary> /// <param name="AItemNo">操作发生时的ItemNo</param> /// <param name="AOffset">操作发生时的Offset</param> protected void UndoAction_InsertItem(int aItemNo, int aOffset) { HCUndoList vUndoList = GetUndoList(); if ((vUndoList != null) && vUndoList.Enable) { HCUndo vUndo = vUndoList.Last; if (vUndo != null) { HCItemUndoAction vItemAction = vUndo.ActionAppend(UndoActionTag.uatInsertItem, aItemNo, aOffset, Items[aItemNo].ParaFirst) as HCItemUndoAction; SaveItemToStreamAlone(Items[aItemNo], vItemAction.ItemStream); } } }
protected void UndoAction_ItemMirror(int aItemNo, int aOffset) { HCUndoList vUndoList = GetUndoList(); if ((vUndoList != null) && vUndoList.Enable) { HCUndo vUndo = vUndoList.Last; if (vUndo != null) { HCItemUndoAction vItemAction = vUndo.ActionAppend(HCAction.actItemMirror, aItemNo, aOffset, Items[aItemNo].ParaFirst) as HCItemUndoAction; SaveItemToStreamAlone(vItemAction.ItemStream, Items[aItemNo]); } } }
private void UndoRedoInsertItem(HCCustomUndo aUndo, HCCustomUndoAction aAction, bool aIsUndo, ref int aCaretItemNo, ref int aCaretOffset, ref int aCaretDrawItemNo) { HCItemUndoAction vAction = aAction as HCItemUndoAction; aCaretItemNo = vAction.ItemNo; if (aIsUndo) { Items.RemoveAt(vAction.ItemNo); FItemAddCount--; if (aCaretItemNo > 0) { aCaretItemNo--; if (Items[aCaretItemNo].StyleNo > HCStyle.Null) { aCaretOffset = Items[aCaretItemNo].Length; } else { aCaretOffset = HC.OffsetAfter; } } else { aCaretOffset = 0; } } else // 重做 { HCCustomItem vItem = null; LoadItemFromStreamAlone(vAction.ItemStream, ref vItem); Items.Insert(vAction.ItemNo, vItem); FItemAddCount++; aCaretItemNo = vAction.ItemNo; if (Items[aCaretItemNo].StyleNo > HCStyle.Null) { aCaretOffset = Items[aCaretItemNo].Length; } else { aCaretOffset = HC.OffsetAfter; } aCaretDrawItemNo = (aUndo as HCDataUndo).CaretDrawItemNo + 1; } }
private void UndoRedoItemMirror(HCCustomUndoAction aAction, bool aIsUndo, ref int aCaretItemNo, ref int aCaretOffset) { HCItemUndoAction vAction = aAction as HCItemUndoAction; aCaretItemNo = vAction.ItemNo; aCaretOffset = vAction.Offset; HCCustomItem vItem = Items[aCaretItemNo]; if (aIsUndo) { LoadItemFromStreamAlone(vAction.ItemStream, ref vItem); } else { LoadItemFromStreamAlone(vAction.ItemStream, ref vItem); } }
public HCCustomUndoAction ActionAppend(HCAction aTag, int aItemNo, int aOffset, bool aParaFirst) { HCCustomUndoAction Result = null; switch (aTag) { case HCAction.actBackDeleteText: case HCAction.actDeleteText: case HCAction.actInsertText: Result = new HCTextUndoAction(); break; case HCAction.actSetItemText: Result = new HCSetItemTextUndoAction(); break; case HCAction.actDeleteItem: case HCAction.actInsertItem: case HCAction.actItemMirror: Result = new HCItemUndoAction(); break; //case HCAction.actItemProperty: // Result = new HCItemParaFirstUndoAction(); // break; case HCAction.actItemSelf: Result = new HCItemSelfUndoAction(); break; default: Result = new HCCustomUndoAction(); break; } Result.Tag = aTag; Result.ItemNo = aItemNo; Result.Offset = aOffset; Result.ParaFirst = aParaFirst; this.Actions.Add(Result); return(Result); }
public HCCustomUndoAction ActionAppend(UndoActionTag ATag, int AItemNo, int AOffset) { HCCustomUndoAction Result = null; switch (ATag) { case UndoActionTag.uatDeleteText: case UndoActionTag.uatInsertText: Result = new HCTextUndoAction(); break; case UndoActionTag.uatDeleteItem: case UndoActionTag.uatInsertItem: Result = new HCItemUndoAction(); break; case UndoActionTag.uatItemProperty: Result = new HCItemParaFirstUndoAction(); break; case UndoActionTag.uatItemSelf: Result = new HCItemSelfUndoAction(); break; default: Result = new HCCustomUndoAction(); break; } Result.Tag = ATag; Result.ItemNo = AItemNo; Result.Offset = AOffset; this.Actions.Add(Result); return(Result); }
private void UndoRedoInsertItem(HCCustomUndo aUndo, HCCustomUndoAction aAction, bool aIsUndo, ref int aCaretItemNo, ref int aCaretOffset, ref int aCaretDrawItemNo) { HCItemUndoAction vAction = aAction as HCItemUndoAction; aCaretItemNo = vAction.ItemNo; if (aIsUndo) { if (aCaretItemNo < Items.Count - 1) // 不是最后一个 { if (Items[aCaretItemNo].ParaFirst) // 段首删除了,光标为下一个开始 { aCaretOffset = 0; aCaretDrawItemNo = Items[aCaretItemNo + 1].FirstDItemNo; } else // 删除的不是段首 //if (Items[aCaretItemNo + 1].ParaFirst) // 下一个是段首,光标保持在同段最后 { aCaretItemNo--; if (Items[aCaretItemNo].StyleNo > HCStyle.Null) { aCaretOffset = Items[aCaretItemNo].Length; } else { aCaretOffset = HC.OffsetAfter; } aCaretDrawItemNo = (aUndo as HCDataUndo).CaretDrawItemNo;// - 1; } } else if (aCaretItemNo > 0) // 不是第一个 { aCaretItemNo--; if (Items[aCaretItemNo].StyleNo > HCStyle.Null) { aCaretOffset = Items[aCaretItemNo].Length; } else { aCaretOffset = HC.OffsetAfter; } aCaretDrawItemNo = (aUndo as HCDataUndo).CaretDrawItemNo - 1; } else { aCaretOffset = 0; } Items.RemoveAt(vAction.ItemNo); FItemAddCount--; } else // 重做 { HCCustomItem vItem = null; LoadItemFromStreamAlone(vAction.ItemStream, ref vItem); Items.Insert(vAction.ItemNo, vItem); FItemAddCount++; aCaretItemNo = vAction.ItemNo; if (Items[aCaretItemNo].StyleNo > HCStyle.Null) { aCaretOffset = Items[aCaretItemNo].Length; } else { aCaretOffset = HC.OffsetAfter; } aCaretDrawItemNo = (aUndo as HCDataUndo).CaretDrawItemNo + 1; } }