Example #1
0
        public override void Undo(object p_args)
        {
            SubTitleCmdArgs args   = (SubTitleCmdArgs)p_args;
            RptMtxSubtitle  title  = args.SubTitle;
            RptItemBase     parent = args.Parent;
            RptMatrix       mtx    = null;

            if (parent is RptMtxLevel)
            {
                RptMtxLevel pLevel = parent as RptMtxLevel;
                mtx = pLevel.Matrix;
                args.BackMtxRow();
                pLevel.SubTitles.Insert(args.TilteIndex, title);
            }
            else
            {
                RptMtxSubtitle pTotal = parent as RptMtxSubtitle;
                mtx = pTotal.Level.Matrix;
                args.BackMtxRow();
                pTotal.SubTitles.Insert(args.TilteIndex, title);
            }
            mtx.Update(true);
        }
Example #2
0
        public override object Execute(object p_args)
        {
            SubTitleCmdArgs  args       = (SubTitleCmdArgs)p_args;
            RptItemBase      parent     = args.Parent;
            RptMtxHeaderType headerType = RptMtxHeaderType.Col;
            RptMtxSubtitle   title      = args.SubTitle;
            RptMatrix        mtx        = null;

            if (title == null)
            {
                title = new RptMtxSubtitle(parent);
                args.InitData();
                if (parent is RptMtxLevel)
                {
                    RptMtxLevel pLevel = parent as RptMtxLevel;
                    mtx = pLevel.Matrix;
                    if (pLevel.Parent is RptMtxRowHeader)
                    {
                        headerType = RptMtxHeaderType.Row;
                    }
                    title.Item.Val = string.Format("subtitle{0}", mtx.GetMaxTitle());

                    RptMtxHeader header = pLevel.Parent as RptMtxHeader;
                    if (pLevel.SubTitles.Count > 0 || header.Levels.Count > header.Levels.IndexOf(pLevel) + 1)
                    {
                        int curIndex = 0;
                        if (headerType == RptMtxHeaderType.Row)
                        {
                            int subLevelSpan = 0;
                            if (header.Levels.Count > header.Levels.IndexOf(pLevel) + 1)
                            {
                                subLevelSpan = header.Levels[header.Levels.IndexOf(pLevel) + 1].RowSpan;
                            }

                            curIndex = pLevel.Row - mtx.ColHeader.Row - mtx.ColHeader.RowSpan + subLevelSpan + pLevel.GetTitleSpan(pLevel.SubTitles);
                            args.OpsRows.Add(InsertNewRow(mtx, curIndex));
                        }
                        else
                        {
                            int subLevelSpan = 0;
                            if (header.Levels.Count > header.Levels.IndexOf(pLevel) + 1)
                            {
                                subLevelSpan = header.Levels[header.Levels.IndexOf(pLevel) + 1].ColSpan;
                            }

                            curIndex = pLevel.Col - mtx.RowHeader.Col - mtx.RowHeader.ColSpan + subLevelSpan + pLevel.GetTitleSpan(pLevel.SubTitles);
                            foreach (RptMtxRow row in mtx.Rows)
                            {
                                args.OpsCells.Add(row, InsertNewCell(mtx, row, curIndex).ToList());
                            }
                        }
                        args.CurIndex = curIndex;
                    }
                    pLevel.SubTitles.Add(title);
                }
                else
                {
                    RptMtxSubtitle pTitle = parent as RptMtxSubtitle;
                    mtx = pTitle.Level.Matrix;
                    if (pTitle.Level.Parent is RptMtxRowHeader)
                    {
                        headerType = RptMtxHeaderType.Row;
                    }
                    title.Item.Val = string.Format("subtitle{0}", mtx.GetMaxTitle());
                    if (pTitle.SubTitles.Count > 0)
                    {
                        int curIndex = 0;
                        if (headerType == RptMtxHeaderType.Row)
                        {
                            curIndex = pTitle.Row + pTitle.RowSpan - mtx.ColHeader.Row - mtx.ColHeader.RowSpan;
                            args.OpsRows.Add(InsertNewRow(mtx, curIndex));
                        }
                        else
                        {
                            curIndex = pTitle.Col + pTitle.ColSpan - mtx.RowHeader.Col - mtx.RowHeader.ColSpan;
                            foreach (RptMtxRow row in mtx.Rows)
                            {
                                args.OpsCells.Add(row, InsertNewCell(mtx, row, curIndex).ToList());
                            }
                        }
                        args.CurIndex = curIndex;
                    }
                    pTitle.SubTitles.Add(title);
                }
                args.SubTitle = title;
            }
            else
            {
                mtx = title.Level.Matrix;
                if (parent is RptMtxLevel)
                {
                    args.BackMtxRow();
                    (parent as RptMtxLevel).SubTitles.Add(title);
                }
                else
                {
                    (parent as RptMtxSubtitle).SubTitles.Add(title);
                }
            }
            mtx.Update(true);
            return(title);
        }