Esempio n. 1
0
        protected HCUndoList GetSelfUndoList()
        {
            if (FOnGetMainUndoList == null)
            {
                return(null);
            }

            HCUndoList Result = FOnGetMainUndoList();

            if ((Result != null) && Result.Enable &&
                Result.Count > 0 &&
                Result.Last.Actions.Count > 0 &&
                (Result.Last.Actions.Last is HCItemSelfUndoAction))
            {
                HCItemSelfUndoAction vItemAction = Result.Last.Actions.Last as HCItemSelfUndoAction;
                if (vItemAction.Object == null)
                {
                    vItemAction.Object = new HCUndoList();
                    SelfUndoListInitializate(vItemAction.Object as HCUndoList);
                }

                Result = vItemAction.Object as HCUndoList;
            }

            return(Result);
        }
Esempio n. 2
0
        protected void DoRedo(HCUndo sender)
        {
            if (sender is HCEditUndo)
            {
                FHScrollBar.Position = (sender as HCEditUndo).HScrollPos;
                FVScrollBar.Position = (sender as HCEditUndo).VScrollPos;
            }
            else
            if (sender is HCUndoEditGroupBegin)
            {
                FHScrollBar.Position = (sender as HCUndoEditGroupBegin).HScrollPos;
                FVScrollBar.Position = (sender as HCUndoEditGroupBegin).VScrollPos;
            }

            HCUndoList vUndoList = DoGetUndoList();

            if (!vUndoList.GroupWorking)
            {
                HCFunction vEvent = delegate()
                {
                    FData.Redo(sender);
                    return(true);
                };

                DataChangeByAction(vEvent);
            }
            else
            {
                FData.Redo(sender);
            }
        }
Esempio n. 3
0
 protected void SelfUndoListInitializate(HCUndoList aUndoList)
 {
     aUndoList.OnUndoNew     = DoSelfUndoNew;
     aUndoList.OnUndo        = DoSelfUndo;
     aUndoList.OnRedo        = DoSelfRedo;
     aUndoList.OnUndoDestroy = DoSelfUndoDestroy;
 }
Esempio n. 4
0
        protected void Undo_GroupEnd(int aItemNo, int aOffset)
        {
            HCUndoList vUndoList = GetUndoList();

            if ((vUndoList != null) && vUndoList.Enable)
            {
                vUndoList.UndoGroupEnd(aItemNo, aOffset);
            }
        }
Esempio n. 5
0
        protected void SelfUndo_New()
        {
            HCUndoList vUndoList = GetSelfUndoList();

            if ((vUndoList != null) && vUndoList.Enable)
            {
                vUndoList.UndoNew();
            }
        }
Esempio n. 6
0
        protected void Undo_New()
        {
            HCUndoList vUndoList = GetUndoList();

            if ((vUndoList != null) && vUndoList.Enable)
            {
                HCUndo vUndo = vUndoList.UndoNew();
                if (vUndo is HCDataUndo)
                {
                    (vUndo as HCDataUndo).CaretDrawItemNo = CaretDrawItemNo;
                }
            }
        }
Esempio n. 7
0
        protected void UndoAction_ItemSelf(int aItemNo, int aOffset)
        {
            HCUndoList vUndoList = GetUndoList();

            if ((vUndoList != null) && vUndoList.Enable)
            {
                HCUndo vUndo = vUndoList.Last;
                if (vUndo != null)
                {
                    vUndo.ActionAppend(HCAction.actItemSelf, aItemNo, aOffset, Items[aItemNo].ParaFirst);
                }
            }
        }
Esempio n. 8
0
        protected void UndoAction_InsertText(int aItemNo, int aOffset, string aText)
        {
            HCUndoList vUndoList = GetUndoList();

            if ((vUndoList != null) && vUndoList.Enable)
            {
                HCUndo vUndo = vUndoList.Last;
                if (vUndo != null)
                {
                    HCTextUndoAction vTextAction = vUndo.ActionAppend(HCAction.actInsertText, aItemNo, aOffset,
                                                                      Items[aItemNo].ParaFirst) as HCTextUndoAction;
                    vTextAction.Text = aText;
                }
            }
        }
Esempio n. 9
0
        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]);
                }
            }
        }
Esempio n. 10
0
        /// <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);
                }
            }
        }
Esempio n. 11
0
        protected void UndoAction_SetItemText(int aItemNo, int aOffset, string aNewText)
        {
            HCUndoList vUndoList = GetUndoList();

            if ((vUndoList != null) && vUndoList.Enable)
            {
                HCUndo vUndo = vUndoList.Last;
                if (vUndo != null)
                {
                    HCSetItemTextUndoAction vTextAction = vUndo.ActionAppend(UndoActionTag.uatSetItemText, aItemNo, aOffset,
                                                                             Items[aItemNo].ParaFirst) as HCSetItemTextUndoAction;
                    vTextAction.NewText = aNewText;
                }
            }
        }
Esempio n. 12
0
        public override void Clear()
        {
            if (Items.Count > 0)
            {
                HCUndoList vUndoList = GetUndoList();
                if ((vUndoList != null) && vUndoList.Enable)
                {
                    Undo_New();
                    for (int i = Items.Count - 1; i >= 0; i--)
                    {
                        UndoAction_DeleteItem(i, 0);
                    }
                }
            }

            base.Clear();
        }
Esempio n. 13
0
 // 撤销恢复相关方法
 protected void Undo_Resize(int ANewWidth, int ANewHeight)
 {
     if (OwnerData.Style.EnableUndo)
     {
         Undo_StartRecord();
         HCUndoList vUndoList = GetSelfUndoList();
         HCUndo     vUndo     = vUndoList[vUndoList.Count - 1];
         if (vUndo != null)
         {
             HCUndoSize vUndoSize = new HCUndoSize();
             vUndoSize.OldWidth  = this.Width;
             vUndoSize.OldHeight = this.Height;
             vUndoSize.NewWidth  = ANewWidth;
             vUndoSize.NewHeight = ANewHeight;
             vUndo.Data          = vUndoSize;
         }
     }
 }
Esempio n. 14
0
        protected void UndoAction_ItemStyle(int aItemNo, int aOffset, int aNewStyleNo)
        {
            HCUndoList vUndoList = GetUndoList();

            if ((vUndoList != null) && vUndoList.Enable)
            {
                HCUndo vUndo = vUndoList.Last;
                if (vUndo != null)
                {
                    HCItemStyleUndoAction vItemAction = new HCItemStyleUndoAction();
                    vItemAction.ItemNo     = aItemNo;
                    vItemAction.Offset     = aOffset;
                    vItemAction.OldStyleNo = Items[aItemNo].StyleNo;
                    vItemAction.NewStyleNo = aNewStyleNo;

                    vUndo.Actions.Add(vItemAction);
                }
            }
        }
Esempio n. 15
0
        /// <summary> 修改Item的分页属性(修改前调用) </summary>
        protected void UndoAction_ItemPageBreak(int aItemNo, int aOffset, bool aNewPageBreak)
        {
            HCUndoList vUndoList = GetUndoList();

            if ((vUndoList != null) && vUndoList.Enable)
            {
                HCUndo vUndo = vUndoList.Last;
                if (vUndo != null)
                {
                    HCItemPageBreakUndoAction vItemAction = new HCItemPageBreakUndoAction();
                    vItemAction.ItemNo       = aItemNo;
                    vItemAction.Offset       = aOffset;
                    vItemAction.OldPageBreak = Items[aItemNo].PageBreak;
                    vItemAction.NewPageBreak = aNewPageBreak;

                    vUndo.Actions.Add(vItemAction);
                }
            }
        }
Esempio n. 16
0
 // 撤销重做相关方法
 public override void Undo(HCCustomUndoAction aUndoAction)
 {
     if (aUndoAction is HCItemSelfUndoAction)
     {
         HCUndoList vUndoList = (aUndoAction as HCItemSelfUndoAction).Object as HCUndoList;
         if (vUndoList != null)
         {
             vUndoList.Undo();
         }
         else
         {
             base.Undo(aUndoAction);
         }
     }
     else
     {
         base.Undo(aUndoAction);
     }
 }
Esempio n. 17
0
        // 撤销恢复相关方法
        protected void SelfUndo_Resize(int aNewWidth, int aNewHeight)
        {
            HCUndoList vUndoList = GetSelfUndoList();

            if ((vUndoList != null) && vUndoList.Enable)
            {
                SelfUndo_New();
                HCUndo vUndo = vUndoList.Last;
                if (vUndo != null)
                {
                    HCSizeUndoData vSizeUndoData = new HCSizeUndoData();
                    vSizeUndoData.OldWidth  = this.Width;
                    vSizeUndoData.OldHeight = this.Height;
                    vSizeUndoData.NewWidth  = aNewWidth;
                    vSizeUndoData.NewHeight = aNewHeight;

                    vUndo.Data = vSizeUndoData;
                }
            }
        }
Esempio n. 18
0
        public HCEdit()
        {
            HCUnitConversion.Initialization();
            //this.DoubleBuffered = true;
            //Create();  // 便于子类在构造函数前执行
            FHCExtFormat = DataFormats.GetFormat(HC.HC_EXT);
            SetStyle(ControlStyles.Selectable, true);  // 可接收焦点

            FStyle = new HCStyle(true, true);

            FUndoList                  = new HCUndoList();
            FUndoList.OnUndo           = DoUndo;
            FUndoList.OnRedo           = DoRedo;
            FUndoList.OnUndoNew        = DoUndoNew;
            FUndoList.OnUndoGroupStart = DoUndoGroupBegin;
            FUndoList.OnUndoGroupEnd   = DoUndoGroupEnd;

            FData                      = new HCViewData(FStyle);
            FData.Width                = 200;
            FData.OnGetUndoList        = DoGetUndoList;
            FData.OnCreateItemByStyle  = DoDataCreateStyleItem;
            FData.OnDrawItemPaintBefor = DoDrawItemPaintBefor;
            FData.OnInsertItem         = DoDataInsertItem;
            FData.OnRemoveItem         = DoDataRemoveItem;

            // 垂直滚动条,范围在Resize中设置
            FVScrollBar             = new HCScrollBar();
            FVScrollBar.Orientation = Orientation.oriVertical;
            FVScrollBar.OnScroll    = DoVScrollChange;
            // 水平滚动条,范围在Resize中设置
            FHScrollBar             = new HCScrollBar();
            FHScrollBar.Orientation = Orientation.oriHorizontal;
            FHScrollBar.OnScroll    = DoVScrollChange;

            this.Controls.Add(FHScrollBar);
            this.Controls.Add(FVScrollBar);

            FChanged = false;
            this.ResumeLayout();
        }
Esempio n. 19
0
        protected HCUndoList GetSelfUndoList()
        {
            HCUndoList         Result        = null;
            HCUndoList         vMainUndoList = FOnGetMainUndoList();
            int                vActionCount  = vMainUndoList[vMainUndoList.Count - 1].Actions.Count;
            HCCustomUndoAction vLastAction   = vMainUndoList[vMainUndoList.Count - 1].Actions[vActionCount - 1];

            if (vLastAction is HCItemSelfUndoAction)
            {
                HCItemSelfUndoAction vItemAction = vLastAction as HCItemSelfUndoAction;
                if (vItemAction.Object == null)
                {
                    vItemAction.Object = new HCUndoList();
                    (vItemAction.Object as HCUndoList).OnNewUndo = DoNewUndo;
                    (vItemAction.Object as HCUndoList).OnUndo    = DoUndo;
                    (vItemAction.Object as HCUndoList).OnRedo    = DoRedo;
                }

                Result = vItemAction.Object as HCUndoList;
            }

            return(Result);
        }
Esempio n. 20
0
        public override void Redo(HCCustomUndoAction aRedoAction)
        {
            if (aRedoAction is HCItemSelfUndoAction)
            {
                HCUndoList vUndoList = (aRedoAction as HCItemSelfUndoAction).Object as HCUndoList;
                if (vUndoList != null)
                {
                    if (vUndoList.Seek < 0)
                    {
                        SelfUndoListInitializate(vUndoList);
                    }

                    vUndoList.Redo();
                }
                else
                {
                    base.Redo(aRedoAction);
                }
            }
            else
            {
                base.Redo(aRedoAction);
            }
        }
Esempio n. 21
0
        private void DoUndoRedo(HCCustomUndo aUndo)
        {
            if (aUndo is HCUndoGroupEnd)
            {
                if (aUndo.IsUndo)
                {
                    if (FUndoGroupCount == 0)
                    {
                        HCUndoList vUndoList = GetUndoList();
                        FFormatFirstItemNo = (vUndoList[vUndoList.CurGroupBeginIndex] as HCUndoGroupBegin).ItemNo;
                        FFormatLastItemNo  = (vUndoList[vUndoList.CurGroupEndIndex] as HCUndoGroupEnd).ItemNo;

                        if (FFormatLastItemNo < Items.Count - 1)
                        {
                            FFormatLastItemNo++;
                        }

                        if (FFormatFirstItemNo != FFormatLastItemNo)
                        {
                            FFormatFirstItemNo     = GetParaFirstItemNo(FFormatFirstItemNo);
                            FFormatFirstDrawItemNo = Items[FFormatFirstItemNo].FirstDItemNo;
                            FFormatLastItemNo      = GetParaLastItemNo(FFormatLastItemNo);
                        }
                        else
                        {
                            GetFormatRange(FFormatFirstItemNo, 1, ref FFormatFirstDrawItemNo, ref FFormatLastItemNo);
                        }

                        FormatPrepare(FFormatFirstDrawItemNo, FFormatLastItemNo);

                        SelectInfo.Initialize();
                        this.InitializeField();
                        FItemAddCount = 0;
                    }

                    FUndoGroupCount++;
                }
                else  // 组恢复结束
                {
                    FUndoGroupCount--;

                    if (FUndoGroupCount == 0)
                    {
                        ReFormatData(FFormatFirstDrawItemNo, FFormatLastItemNo + FItemAddCount, FItemAddCount);

                        SelectInfo.StartItemNo     = (aUndo as HCUndoGroupEnd).ItemNo;
                        SelectInfo.StartItemOffset = (aUndo as HCUndoGroupEnd).Offset;
                        CaretDrawItemNo            = (aUndo as HCUndoGroupEnd).CaretDrawItemNo;

                        Style.UpdateInfoReCaret();
                        Style.UpdateInfoRePaint();
                    }
                }

                return;
            }
            else
            if (aUndo is HCUndoGroupBegin)
            {
                if (aUndo.IsUndo)
                {
                    FUndoGroupCount--;

                    if (FUndoGroupCount == 0)
                    {
                        ReFormatData(FFormatFirstDrawItemNo, FFormatLastItemNo + FItemAddCount, FItemAddCount);

                        SelectInfo.StartItemNo     = (aUndo as HCUndoGroupBegin).ItemNo;
                        SelectInfo.StartItemOffset = (aUndo as HCUndoGroupBegin).Offset;
                        CaretDrawItemNo            = (aUndo as HCUndoGroupBegin).CaretDrawItemNo;

                        Style.UpdateInfoReCaret();
                        Style.UpdateInfoRePaint();
                    }
                }
                else  // 组恢复(无Action)
                {
                    if (FUndoGroupCount == 0)
                    {
                        FFormatFirstItemNo     = (aUndo as HCUndoGroupBegin).ItemNo;
                        FFormatFirstDrawItemNo = GetFormatFirstDrawItem(Items[FFormatFirstItemNo].FirstDItemNo);

                        HCUndoList vUndoList = GetUndoList();
                        FFormatLastItemNo = (vUndoList[vUndoList.CurGroupEndIndex] as HCUndoGroupEnd).ItemNo;
                        if (FFormatLastItemNo > Items.Count - 1)  // 防止在最后插入Item的撤销后恢复访问越界
                        {
                            FFormatLastItemNo--;
                        }

                        FormatPrepare(FFormatFirstDrawItemNo, FFormatLastItemNo);

                        SelectInfo.Initialize();
                        this.InitializeField();
                        FItemAddCount = 0;
                    }

                    FUndoGroupCount++;
                }

                return;
            }

            if (aUndo.Actions.Count == 0)
            {
                return;
            }

            int vCaretDrawItemNo = -1, vCaretItemNo = -1, vCaretOffset = -1;;

            if (FUndoGroupCount == 0)
            {
                SelectInfo.Initialize();
                this.InitializeField();
                FItemAddCount    = 0;
                vCaretDrawItemNo = (aUndo as HCDataUndo).CaretDrawItemNo;

                if (aUndo.Actions[0].ItemNo > aUndo.Actions[aUndo.Actions.Count - 1].ItemNo)
                {
                    FFormatFirstItemNo = GetParaFirstItemNo(GetActionAffectFirst(aUndo.Actions.Last, aUndo.IsUndo));
                    FFormatLastItemNo  = GetParaLastItemNo(GetActionAffectLast(aUndo.Actions.First, aUndo.IsUndo));
                }
                else
                {
                    FFormatFirstItemNo = GetParaFirstItemNo(GetActionAffectFirst(aUndo.Actions.First, aUndo.IsUndo));
                    FFormatLastItemNo  = GetParaLastItemNo(GetActionAffectLast(aUndo.Actions.Last, aUndo.IsUndo));
                }

                FFormatFirstDrawItemNo = Items[FFormatFirstItemNo].FirstDItemNo;
                FormatPrepare(FFormatFirstDrawItemNo, FFormatLastItemNo);
            }

            if (aUndo.IsUndo)
            {
                for (int i = aUndo.Actions.Count - 1; i >= 0; i--)
                {
                    DoUndoRedoAction(aUndo, aUndo.Actions[i], true, ref vCaretItemNo, ref vCaretOffset, ref vCaretDrawItemNo);
                }
            }
            else
            {
                for (int i = 0; i <= aUndo.Actions.Count - 1; i++)
                {
                    DoUndoRedoAction(aUndo, aUndo.Actions[i], false, ref vCaretItemNo, ref vCaretOffset, ref vCaretDrawItemNo);
                }
            }

            if (FUndoGroupCount == 0)
            {
                ReFormatData(FFormatFirstDrawItemNo, FFormatLastItemNo + FItemAddCount, FItemAddCount);

                if (vCaretDrawItemNo < 0)
                {
                    vCaretDrawItemNo = GetDrawItemNoByOffset(vCaretItemNo, vCaretOffset);
                }
                else
                if (vCaretDrawItemNo > this.DrawItems.Count - 1)
                {
                    vCaretDrawItemNo = this.DrawItems.Count - 1;
                }

                CaretDrawItemNo = vCaretDrawItemNo;

                Style.UpdateInfoReCaret();
                Style.UpdateInfoRePaint();
            }

            SelectInfo.StartItemNo     = vCaretItemNo;
            SelectInfo.StartItemOffset = vCaretOffset;
        }
Esempio n. 22
0
        private void DoUndoRedo(HCCustomUndo aUndo)
        {
            FForceClearExtra = false;

            if (aUndo is HCUndoGroupEnd)
            {
                if (aUndo.IsUndo)
                {
                    if (FUndoGroupCount == 0)
                    {
                        HCUndoList vUndoList = GetUndoList();
                        FFormatFirstItemNo = (vUndoList[vUndoList.CurGroupBeginIndex] as HCUndoGroupBegin).ItemNo;
                        FFormatLastItemNo  = (vUndoList[vUndoList.CurGroupEndIndex] as HCUndoGroupEnd).ItemNo;

                        // 如果是序号0、1在一行,1删除后,又插入2个,其中第一个和序号0合并,第2个换行,
                        // 撤销时FFormatFirstItemNo为1从而FFormatFirstDrawItemNo为1,而此时1为行首,
                        // 撤销完后格式化会按在行首开始,导致原来的序号1撤销后换行。所以暴力回退1个
                        if (FFormatFirstItemNo > 0)
                        {
                            FFormatFirstItemNo--;
                        }

                        if (FFormatLastItemNo < Items.Count - 1)
                        {
                            FFormatLastItemNo++;
                        }

                        if (FFormatFirstItemNo != FFormatLastItemNo)
                        {
                            FFormatFirstItemNo     = GetParaFirstItemNo(FFormatFirstItemNo);
                            FFormatFirstDrawItemNo = Items[FFormatFirstItemNo].FirstDItemNo;
                            FFormatLastItemNo      = GetParaLastItemNo(FFormatLastItemNo);
                        }
                        else
                        {
                            GetFormatRange(FFormatFirstItemNo, 1, ref FFormatFirstDrawItemNo, ref FFormatLastItemNo);
                        }

                        FormatPrepare(FFormatFirstDrawItemNo, FFormatLastItemNo);

                        SelectInfo.Initialize();
                        this.InitializeField();
                        FItemAddCount = 0;
                    }

                    FUndoGroupCount++;
                }
                else  // 组恢复结束
                {
                    FUndoGroupCount--;

                    if (FUndoGroupCount == 0)
                    {
                        ReFormatData(FFormatFirstDrawItemNo, FFormatLastItemNo + FItemAddCount, FItemAddCount, FForceClearExtra);

                        SelectInfo.StartItemNo     = (aUndo as HCUndoGroupEnd).ItemNo;
                        SelectInfo.StartItemOffset = (aUndo as HCUndoGroupEnd).Offset;
                        CaretDrawItemNo            = (aUndo as HCUndoGroupEnd).CaretDrawItemNo;

                        Style.UpdateInfoReCaret();
                        Style.UpdateInfoRePaint();
                    }
                }

                return;
            }
            else
            if (aUndo is HCUndoGroupBegin)
            {
                if (aUndo.IsUndo)
                {
                    FUndoGroupCount--;

                    if (FUndoGroupCount == 0)
                    {
                        ReFormatData(FFormatFirstDrawItemNo, FFormatLastItemNo + FItemAddCount, FItemAddCount, FForceClearExtra);

                        SelectInfo.StartItemNo     = (aUndo as HCUndoGroupBegin).ItemNo;
                        SelectInfo.StartItemOffset = (aUndo as HCUndoGroupBegin).Offset;
                        CaretDrawItemNo            = (aUndo as HCUndoGroupBegin).CaretDrawItemNo;

                        Style.UpdateInfoReCaret();
                        Style.UpdateInfoRePaint();
                    }
                }
                else  // 组恢复(无Action)
                {
                    if (FUndoGroupCount == 0)  // 组恢复开始
                    {
                        HCUndoList vUndoList = GetUndoList();
                        FFormatFirstItemNo = -1;
                        FFormatLastItemNo  = -1;
                        int vItemNo = -1;

                        for (int i = vUndoList.CurGroupBeginIndex; i <= vUndoList.CurGroupEndIndex; i++)
                        {
                            if (vUndoList[i] is HCUndoGroupBegin)
                            {
                                if (FFormatFirstItemNo > ((vUndoList[i] as HCUndoGroupBegin).ItemNo))
                                {
                                    FFormatFirstItemNo = (vUndoList[i] as HCUndoGroupBegin).ItemNo;
                                }
                            }
                            else
                            if (vUndoList[i] is HCUndoGroupEnd)
                            {
                                if (FFormatLastItemNo < ((vUndoList[i] as HCUndoGroupEnd).ItemNo))
                                {
                                    FFormatLastItemNo = (vUndoList[i] as HCUndoGroupEnd).ItemNo;
                                }
                            }
                            else
                            {
                                vItemNo = GetParaFirstItemNo(GetActionAffectFirst(vUndoList[i].Actions.First, vUndoList[i].IsUndo));
                                if (FFormatFirstItemNo > vItemNo)
                                {
                                    FFormatFirstItemNo = vItemNo;
                                }

                                vItemNo = GetParaLastItemNo(GetActionAffectLast(vUndoList[i].Actions.Last, vUndoList[i].IsUndo));
                                if (FFormatLastItemNo < vItemNo)
                                {
                                    FFormatLastItemNo = vItemNo;
                                }
                            }
                        }

                        if (FFormatFirstItemNo < 0)
                        {
                            FFormatFirstItemNo = 0;
                        }

                        if (FFormatLastItemNo > Items.Count - 1)
                        {
                            FFormatLastItemNo = Items.Count - 1;
                        }

                        FFormatFirstDrawItemNo = GetFormatFirstDrawItem(Items[FFormatFirstItemNo].FirstDItemNo);

                        /*FFormatFirstItemNo = (aUndo as HCUndoGroupBegin).ItemNo;
                         * FFormatFirstDrawItemNo = GetFormatFirstDrawItem(Items[FFormatFirstItemNo].FirstDItemNo);
                         *
                         * HCUndoList vUndoList = GetUndoList();
                         * FFormatLastItemNo = (vUndoList[vUndoList.CurGroupEndIndex] as HCUndoGroupEnd).ItemNo;
                         * if (FFormatLastItemNo > Items.Count - 1)  // 防止在最后插入Item的撤销后恢复访问越界
                         *  FFormatLastItemNo--; */

                        FormatPrepare(FFormatFirstDrawItemNo, FFormatLastItemNo);

                        SelectInfo.Initialize();
                        this.InitializeField();
                        FItemAddCount = 0;
                    }

                    FUndoGroupCount++;
                }

                return;
            }

            if (aUndo.Actions.Count == 0)
            {
                return;
            }

            int vCaretDrawItemNo = -1, vCaretItemNo = -1, vCaretOffset = -1;;

            if (FUndoGroupCount == 0)
            {
                SelectInfo.Initialize();
                this.InitializeField();
                FItemAddCount    = 0;
                vCaretDrawItemNo = (aUndo as HCDataUndo).CaretDrawItemNo;

                if (aUndo.Actions[0].ItemNo > aUndo.Actions[aUndo.Actions.Count - 1].ItemNo)
                {
                    FFormatFirstItemNo = GetParaFirstItemNo(GetActionAffectFirst(aUndo.Actions.Last, aUndo.IsUndo));
                    FFormatLastItemNo  = GetParaLastItemNo(GetActionAffectLast(aUndo.Actions.First, aUndo.IsUndo));
                }
                else
                {
                    FFormatFirstItemNo = GetParaFirstItemNo(GetActionAffectFirst(aUndo.Actions.First, aUndo.IsUndo));
                    FFormatLastItemNo  = GetParaLastItemNo(GetActionAffectLast(aUndo.Actions.Last, aUndo.IsUndo));
                }

                FFormatFirstDrawItemNo = Items[FFormatFirstItemNo].FirstDItemNo;
                FormatPrepare(FFormatFirstDrawItemNo, FFormatLastItemNo);
            }

            if (aUndo.IsUndo)
            {
                for (int i = aUndo.Actions.Count - 1; i >= 0; i--)
                {
                    DoUndoRedoAction(aUndo, aUndo.Actions[i], true, ref vCaretItemNo, ref vCaretOffset, ref vCaretDrawItemNo);
                }
            }
            else
            {
                for (int i = 0; i <= aUndo.Actions.Count - 1; i++)
                {
                    DoUndoRedoAction(aUndo, aUndo.Actions[i], false, ref vCaretItemNo, ref vCaretOffset, ref vCaretDrawItemNo);
                }
            }

            if (FUndoGroupCount == 0)
            {
                ReFormatData(FFormatFirstDrawItemNo, FFormatLastItemNo + FItemAddCount, FItemAddCount, FForceClearExtra);

                int vCaretDIItem = GetDrawItemNoByOffset(vCaretItemNo, vCaretOffset);  // 因为多个Action不一定每个会有有效的CaretDrawItem,所以需要重新计算一下

                if ((vCaretDrawItemNo < 0) || (vCaretDrawItemNo > this.DrawItems.Count - 1))
                {
                    vCaretDrawItemNo = vCaretDIItem;
                }
                else
                if (vCaretDIItem != vCaretDrawItemNo)
                {
                    if ((DrawItems[vCaretDrawItemNo].ItemNo == vCaretItemNo) && (DrawItems[vCaretDrawItemNo].CharOffs == vCaretOffset))  // 换行
                    {
                    }
                    else
                    {
                        vCaretDrawItemNo = vCaretDIItem;  // 纠正
                    }
                }

                CaretDrawItemNo = vCaretDrawItemNo;

                Style.UpdateInfoReCaret();
                Style.UpdateInfoRePaint();
            }

            SelectInfo.StartItemNo     = vCaretItemNo;
            SelectInfo.StartItemOffset = vCaretOffset;
        }