Beispiel #1
0
        /// <summary>
        /// Handles context-click to create a row below the current row.
        /// </summary>
        /// <param name="sender"><c><see cref="rowit_CreateBelow"/></c></param>
        /// <param name="e"></param>
        void rowclick_CreateBelow(object sender, EventArgs e)
        {
            var fields = new string[Table.ColCount];

            for (int c = 0; c != Table.ColCount; ++c)
            {
                fields[c] = gs.Stars;
            }

            Table.Insert(_r + 1, fields);


            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();
            }
        }
Beispiel #2
0
        /// <summary>
        /// Handles context-click to paste into the current row.
        /// </summary>
        /// <param name="sender"><c><see cref="rowit_Paste"/></c></param>
        /// <param name="e"></param>
        void rowclick_Paste(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)
            {
                if (c < _copyr[0].Length)
                {
                    row[c].text = _copyr[0][c];
                }
                else
                {
                    row[c].text = gs.Stars;                     // TODO: perhaps keep any remaining cells as they are.
                }
                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);
        }
Beispiel #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();
            }
        }
Beispiel #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();
            }
        }
Beispiel #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);
        }