Exemple #1
0
        public IUndoRedoCmd Execute()
        {
            var inverse = new RestoreBGColor(Current, Current.BGColor); // Creates the inverse class -> restores to this

            Current.BGColor = ARBGColor;                                // restores the cell's color to the contained color
            return(inverse);
        }
 public IUndoRedoCmd Execute()
 {
     var inverse = new RestoreBGColor(Current, Current.BGColor); // Creates the inverse class -> restores to this
     Current.BGColor = ARBGColor; // restores the cell's color to the contained color
     return inverse;
 }
Exemple #3
0
        private void color_changing(object sender, bool custom)
        {
            ColorDialog SelectColor = new ColorDialog();
            if (custom) // user wants to select their own color -> prompts color dialogue
            {
                if (SelectColor.ShowDialog() != DialogResult.OK)
                    return;
            }
            else // the user chose one of the pre-selected colors
            {
                if (sender.ToString() == "Reset")
                    SelectColor.Color = System.Drawing.Color.FromArgb(-1); 
                if (sender.ToString() == "Green")
                    SelectColor.Color = System.Drawing.Color.FromArgb(192, 255, 192);
                else if (sender.ToString() == "Red")
                    SelectColor.Color = System.Drawing.Color.FromArgb(255, 128, 128);
                else if (sender.ToString() == "Orange")
                    SelectColor.Color = System.Drawing.Color.FromArgb(255, 192, 128);
                else if (sender.ToString() == "Grey")
                    SelectColor.Color = System.Drawing.Color.FromArgb(131, 130, 120);
            }

            DataGridViewSelectedCellCollection CellsChanging = dataGridView1.SelectedCells; // Gets the collection of selected cells
            CmdCollection BGRestore = new CmdCollection();

            if (CellsChanging != null) // Ensures that there is at least one selected cell
            {
                foreach (DataGridViewCell cell in CellsChanging) // Foreach cell that has been selected, notify the spreadsheet of that cells property change
                {
                    SpreadsheetCell Changing = mainSS[cell.RowIndex, cell.ColumnIndex];
                    RestoreBGColor newRestore = new RestoreBGColor(Changing, Changing.BGColor);

                    Changing.BGColor = SelectColor.Color.ToArgb(); // Converts the chosen color to ARBG integer format
                    BGRestore.Add(newRestore); 
                }

                mainSS.PushUndo(BGRestore); // Adds the new restore collection
                undoToolStripMenuItem.Text = "Undo - " + mainSS.PeekUndo; // Tells the UI which property will be undone
                redoToolStripMenuItem.Enabled = false;
                redoToolStripMenuItem.Text = "Redo";
            }
        }