Exemplo n.º 1
0
        /// <summary>
        /// Deletes a single or multiple <c><see cref="Row">Rows</see></c>.
        /// </summary>
        /// <remarks>Called by
        /// <c><see cref="Yata"/>.editrowsclick_DeleteRange()</c>.</remarks>
        internal void DeleteRows()
        {
            _f.Obfuscate();
            DrawRegulator.SuspendDrawing(this);


            int selr = getSelectedRow();

            int        range = Math.Abs(RangeSelect);
            Restorable rest  = UndoRedo.createArray(range + 1, UndoRedo.UrType.rt_ArrayInsert);

            int rFirst, rLast;

            if (RangeSelect > 0)
            {
                rFirst = selr;
                rLast  = selr + RangeSelect;
            }
            else
            {
                rFirst = selr + RangeSelect;
                rLast  = selr;
            }

            while (rLast >= rFirst)             // reverse delete.
            {
                rest.array[range--] = Rows[rLast].Clone() as Row;
                Delete(rLast, false);

                --rLast;
            }

            if (RowCount == 1 && rLast == -1)             // ie. if grid was blanked -> ID #0 was auto-inserted.
            {
                rLast = 0;
            }
            else
            {
                rLast = -1;               // calibrate all extant rows.
            }
            Calibrate(rLast);             // delete key

            if (selr < RowCount)
            {
                EnsureDisplayedRow(selr);
            }


            if (!Changed)
            {
                Changed      = true;
                rest.isSaved = UndoRedo.IsSavedType.is_Undo;
            }
            _ur.Push(rest);


            DrawRegulator.ResumeDrawing(this);
            _f.Obfuscate(false);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Pastes a range of rows.
        /// </summary>
        /// <param name="sender"><c><see cref="it_PasteRange"/></c></param>
        /// <param name="e"></param>
        /// <remarks>Fired by
        /// <list type="bullet">
        /// <item>Rows|Paste <c>[Ctrl+Shift+v]</c></item>
        /// </list></remarks>
        void editrowsclick_PasteRange(object sender, EventArgs e)
        {
            Obfuscate();
            DrawRegulator.SuspendDrawing(Table);


            Restorable rest = UndoRedo.createArray(_copyr.Count, UndoRedo.UrType.rt_ArrayDelete);

            int selr = Table.getSelectedRow();

            if (selr == -1)
            {
                selr = Table.RowCount;
            }

            int r = selr;

            for (int i = 0; i != _copyr.Count; ++i, ++r)
            {
                Table.Insert(r, _copyr[i], false);
                rest.array[i] = Table.Rows[r].Clone() as Row;
            }

            Table.Calibrate(selr, _copyr.Count - 1);             // paste range

            Table.ClearSelects(false, true);
            Table.Rows[selr].selected = true;
            Table.RangeSelect         = _copyr.Count - 1;
            Table.EnsureDisplayedRow(selr);


            if (!Table.Changed)
            {
                Table.Changed = true;
                rest.isSaved  = UndoRedo.IsSavedType.is_Undo;
            }
            Table._ur.Push(rest);


            DrawRegulator.ResumeDrawing(Table);
            Obfuscate(false);

            if (Settings._autorder && order() != 0)
            {
                layout();
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Instantiates <c><see cref="RowCreatorDialog"/></c> for
        /// inserting/creating multiple rows.
        /// </summary>
        /// <param name="sender"><c><see cref="it_CreateRows"/></c></param>
        /// <param name="e"></param>
        /// <remarks>Fired by
        /// <list type="bullet">
        /// <item>Rows|Create ... <c>[F2]</c></item>
        /// </list></remarks>
        void editrowsclick_CreateRows(object sender, EventArgs e)
        {
            int selr = Table.getSelectedRowOrCells();

            using (var rcd = new RowCreatorDialog(this, selr, _copyr.Count != 0))
            {
                if (rcd.ShowDialog(this) == DialogResult.OK)
                {
                    Obfuscate();
                    DrawRegulator.SuspendDrawing(Table);


                    Restorable rest = UndoRedo.createArray(_lengthCr, UndoRedo.UrType.rt_ArrayDelete);

                    var cells = new string[Table.ColCount];
                    switch (_fillCr)
                    {
                    case CrFillType.Stars:
                        for (int i = 0; i != Table.ColCount; ++i)
                        {
                            cells[i] = gs.Stars;
                        }
                        break;

                    case CrFillType.Selected:
                        for (int i = 0; i != Table.ColCount; ++i)
                        {
                            cells[i] = Table[selr, i].text;
                        }
                        break;

                    case CrFillType.Copied:
                        for (int i = 0; i != Table.ColCount; ++i)
                        {
                            if (i < _copyr[0].Length)
                            {
                                cells[i] = _copyr[0][i];
                            }
                            else
                            {
                                cells[i] = gs.Stars;
                            }
                        }
                        break;
                    }

                    int r = _startCr;
                    for (int i = 0; i != _lengthCr; ++i, ++r)
                    {
                        cells[0] = r.ToString(CultureInfo.InvariantCulture);

                        Table.Insert(r, cells, false);
                        rest.array[i] = Table.Rows[r].Clone() as Row;
                    }

                    Table.Calibrate(_startCr, _lengthCr - 1);                     // insert range

                    Table.ClearSelects(false, true);
                    Table.Rows[_startCr].selected = true;
                    Table.RangeSelect             = _lengthCr - 1;
                    Table.EnsureDisplayedRow(_startCr);


                    if (!Table.Changed)
                    {
                        Table.Changed = true;
                        rest.isSaved  = UndoRedo.IsSavedType.is_Undo;
                    }
                    Table._ur.Push(rest);


                    DrawRegulator.ResumeDrawing(Table);
                    Obfuscate(false);

                    if (Settings._autorder && order() != 0)
                    {
                        layout();
                    }
                }
            }
        }