Esempio n. 1
0
        private int GetActionAffectFirst(HCCustomUndoAction aAction, bool aIsUndo)
        {
            int Result = aAction.ItemNo;

            switch (aAction.Tag)
            {
            case UndoActionTag.uatDeleteItem:
            {
                if (Result > 0)
                {
                    Result--;
                }
            }
            break;

            case UndoActionTag.uatInsertItem:
            {
                if (aIsUndo)
                {
                    if (Result > 0)
                    {
                        Result--;
                    }
                }
                else
                {
                    if (Result > Items.Count - 1)
                    {
                        Result--;
                    }
                }
            }
            break;

            case UndoActionTag.uatItemProperty:
                if (aAction.Tag == UndoActionTag.uatItemProperty)
                {
                    HCItemPropertyUndoAction vPropAction = aAction as HCItemPropertyUndoAction;
                    if (vPropAction.ItemProperty == ItemProperty.uipParaFirst)
                    {
                        if (Result > 0)
                        {
                            Result--;
                        }
                    }
                }
                break;

            default:
            {
                if (Result > Items.Count - 1)
                {
                    Result = Items.Count - 1;
                }
            }
            break;
            }

            return(Result);
        }
Esempio n. 2
0
        private int GetActionAffectFirst(HCCustomUndoAction aAction, bool aIsUndo)
        {
            int Result = aAction.ItemNo;

            switch (aAction.Tag)
            {
            case HCAction.actDeleteItem:
            {
                if (Result > 0)
                {
                    Result--;
                }
            }
            break;

            case HCAction.actInsertItem:
            {
                if (aIsUndo)
                {
                    if (Result > 0)
                    {
                        Result--;
                    }
                }
                else
                {
                    if (Result > Items.Count - 1)
                    {
                        Result--;
                    }
                }
            }
            break;

            case HCAction.actItemProperty:
                HCItemPropertyUndoAction vPropAction = aAction as HCItemPropertyUndoAction;
                if ((vPropAction.ItemProperty == ItemProperty.uipParaFirst) ||
                    (vPropAction.ItemProperty == ItemProperty.uipPageBreak) ||
                    (vPropAction.ItemProperty == ItemProperty.uipStyleNo)
                    )
                {
                    if (Result > 0)
                    {
                        Result--;
                    }
                }
                break;
            }

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

            return(Result);
        }
Esempio n. 3
0
        private void UndoRedoItemProperty(HCCustomUndoAction aAction, bool aIsUndo, ref int aCaretItemNo, ref int aCaretOffset)
        {
            HCItemPropertyUndoAction vAction = aAction as HCItemPropertyUndoAction;

            aCaretItemNo = vAction.ItemNo;
            aCaretOffset = vAction.Offset;
            HCCustomItem vItem = Items[vAction.ItemNo];

            switch (vAction.ItemProperty)
            {
            case ItemProperty.uipStyleNo:
            {
                if (aIsUndo)
                {
                    vItem.StyleNo = (vAction as HCItemStyleUndoAction).OldStyleNo;
                }
                else
                {
                    vItem.StyleNo = (vAction as HCItemStyleUndoAction).NewStyleNo;
                }
            }
            break;

            case ItemProperty.uipParaNo:
            {
                if (aIsUndo)
                {
                    vItem.ParaNo = (vAction as HCItemParaUndoAction).OldParaNo;
                }
                else
                {
                    vItem.ParaNo = (vAction as HCItemParaUndoAction).NewParaNo;
                }
            }
            break;

            case ItemProperty.uipParaFirst:
            {
                if (aIsUndo)
                {
                    vItem.ParaFirst = (vAction as HCItemParaFirstUndoAction).OldParaFirst;
                }
                else
                {
                    vItem.ParaFirst = (vAction as HCItemParaFirstUndoAction).NewParaFirst;
                }
            }
            break;
            }
        }
Esempio n. 4
0
        private void UndoRedoItemProperty(HCCustomUndoAction aAction, bool aIsUndo, ref int aCaretItemNo, ref int aCaretOffset)
        {
            HCItemPropertyUndoAction vAction = aAction as HCItemPropertyUndoAction;

            aCaretItemNo = vAction.ItemNo;
            aCaretOffset = vAction.Offset;
            HCCustomItem vItem = Items[vAction.ItemNo];

            switch (vAction.ItemProperty)
            {
            case ItemProperty.uipStyleNo:
            {
                if (aIsUndo)
                {
                    vItem.StyleNo = (vAction as HCItemStyleUndoAction).OldStyleNo;
                }
                else
                {
                    vItem.StyleNo = (vAction as HCItemStyleUndoAction).NewStyleNo;
                }
            }
            break;

            case ItemProperty.uipParaNo:
            {
                int vParaLastItemNo = GetParaLastItemNo(vAction.ItemNo);
                if (aIsUndo)
                {
                    for (int i = vAction.ItemNo; i <= vParaLastItemNo; i++)
                    {
                        Items[i].ParaNo = (vAction as HCItemParaUndoAction).OldParaNo;
                    }
                }
                else
                {
                    for (int i = vAction.ItemNo; i <= vParaLastItemNo; i++)
                    {
                        Items[i].ParaNo = (vAction as HCItemParaUndoAction).NewParaNo;
                    }
                }
            }
            break;

            case ItemProperty.uipParaFirst:
            {
                if (aIsUndo)
                {
                    vItem.ParaFirst = (vAction as HCItemParaFirstUndoAction).OldParaFirst;
                }
                else
                {
                    vItem.ParaFirst = (vAction as HCItemParaFirstUndoAction).NewParaFirst;
                }
            }
            break;

            case ItemProperty.uipPageBreak:
            {
                FForceClearExtra = true;

                if (aIsUndo)
                {
                    vItem.PageBreak = (vAction as HCItemPageBreakUndoAction).OldPageBreak;
                }
                else
                {
                    vItem.PageBreak = (vAction as HCItemPageBreakUndoAction).NewPageBreak;
                }
            }
            break;
            }
        }