Esempio n. 1
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();
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Handles context-click to clear the current row.
        /// </summary>
        /// <param name="sender"><c><see cref="rowit_Clear"/></c></param>
        /// <param name="e"></param>
        void rowclick_Clear(object sender, EventArgs e)
        {
            // - store the row's current state to 'rPre' in the Restorable
            Restorable rest = UndoRedo.createRow(Table.Rows[_r]);


            YataGrid._init = true;             // bypass EnableGotoLoadchanged() in Cell.setter_loadchanged

            Row row = Table.Rows[_r];

            int c = 0;

            if (Settings._autorder)
            {
                row[c].text            = _r.ToString(CultureInfo.InvariantCulture);
                row[c].diff            =
                    row[c].loadchanged = false;

                ++c;
            }

            for (; c != Table.ColCount; ++c)
            {
                row[c].text            = gs.Stars;
                row[c].diff            =
                    row[c].loadchanged = false;
            }
            row._brush = Brushes.Created;

            YataGrid._init = false;
            EnableGotoLoadchanged(Table.anyLoadchanged());

            Table.Calibrate(_r);

            Table.Invalidator(YataGrid.INVALID_GRID);


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

            // - store the row's changed state to 'rPos' in the Restorable
            rest.rPos = Table.Rows[_r].Clone() as Row;
            Table._ur.Push(rest);
        }
Esempio n. 3
0
        /// <summary>
        /// Handles context-click to paste below the current row.
        /// </summary>
        /// <param name="sender"><c><see cref="rowit_PasteBelow"/></c></param>
        /// <param name="e"></param>
        void rowclick_PasteBelow(object sender, EventArgs e)
        {
            Table.Insert(_r + 1, _copyr[0]);


            Restorable rest = UndoRedo.createRow(Table.Rows[_r + 1], UndoRedo.UrType.rt_Delete);

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

            if (Settings._autorder && order() != 0)
            {
                layout();
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Handles context-click to delete the current row.
        /// </summary>
        /// <param name="sender">
        /// <list type="bullet">
        /// <item><c><see cref="rowit_Delete"/></c></item>
        /// <item><c><see cref="rowit_Cut"/></c></item>
        /// </list></param>
        /// <param name="e"></param>
        void rowclick_Delete(object sender, EventArgs e)
        {
            Restorable rest = UndoRedo.createRow(Table.Rows[_r], UndoRedo.UrType.rt_Insert);


            Table.Delete(_r);

            EnableRoweditOperations();


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

            if (Settings._autorder && order() != 0)
            {
                layout();
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Handles a single-row merge operation.
        /// </summary>
        /// <param name="sender"><c><see cref="cellit_MergeRo"/></c></param>
        /// <param name="e"></param>
        void cellclick_MergeRo(object sender, EventArgs e)
        {
            YataGrid table;

            if (Table == _diff1)
            {
                table = _diff2;
            }
            else
            {
                table = _diff1;
            }

            int r = _sel.y;

            // - store the row's current state to 'rPre' in the Restorable
            Restorable rest = UndoRedo.createRow(table.Rows[r]);


            int c = 0;

            for (; c != table.ColCount && c != Table.ColCount; ++c)
            {
                table[r, c].text = Table[r, c].text;
                table[r, c].diff = false;

                Table[r, c].diff = false;
            }

            if (Settings._autorder)
            {
                table[r, 0].text = table[r, 0].y.ToString(CultureInfo.InvariantCulture);                // not likely to happen. user'd have to load a table w/
            }
            // an out of order id then merge that row to another table.
            if (table.ColCount > Table.ColCount)
            {
                for (; c != table.ColCount; ++c)
                {
                    table[r, c].text = gs.Stars;
                    table[r, c].diff = false;
                }
            }
            else if (table.ColCount < Table.ColCount)
            {
                for (; c != Table.ColCount; ++c)
                {
                    Table[r, c].diff = false;
                }
            }

            Table.Invalidator(YataGrid.INVALID_GRID | YataGrid.INVALID_FROZ);

            // TODO: test if this funct needs to re-width a bunch of stuff


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

            // - store the row's changed state to 'rPos' in the Restorable
            rest.rPos = table.Rows[r].Clone() as Row;
            table._ur.Push(rest);
        }
Esempio n. 6
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();
                    }
                }
            }
        }