/// <summary> /// change color button clicked handle. /// </summary> /// <param name="sender">sender.</param> /// <param name="e">e.</param> private void ChangeColor_Clicked(object sender, EventArgs e) { List <SpreadsheetCell> colorCollect = new List <SpreadsheetCell>(); ColorDialog MyDialog = new ColorDialog(); List <uint> prevColor = new List <uint>(); // Keeps the user from selecting a custom color. MyDialog.AllowFullOpen = false; // Allows the user to get help. (The default is false.) MyDialog.ShowHelp = true; // Update the text box color if the user clicks OK if (MyDialog.ShowDialog() == DialogResult.OK) { foreach (DataGridViewTextBoxCell cell in this.dataGridView1.SelectedCells) { colorCollect.Add(this.table.GetCell(cell.RowIndex, cell.ColumnIndex)); prevColor.Add(this.table.GetCell(cell.RowIndex, cell.ColumnIndex).Color); this.table.GetCell(cell.RowIndex, cell.ColumnIndex).Color = (uint)MyDialog.Color.ToArgb(); } UndoRedoCollection UndoCommand = new UndoRedoCollection("Color Changes"); UndoCommand.SetColortVarible(colorCollect, prevColor, (uint)MyDialog.Color.ToArgb()); this.table.AddUndo(UndoCommand); this.undoToolStripMenuItem.Text = this.table.UndoText; } }
private void backgroundColorToolStripMenuItem_Click(object sender, EventArgs e) { if (CDialog.ShowDialog() == DialogResult.OK) { var undos = new UndoRedoCollection(UndoRedoType.Color); foreach (DataGridViewCell dgCell in dataGridView1.SelectedCells) { var cell = Sheet.GetCell(dgCell.RowIndex, dgCell.ColumnIndex); undos.Add(new UndoRedoColor(cell, cell.BGColor)); cell.BGColor = (uint)CDialog.Color.ToArgb(); } Sheet.AddUndo(undos); } updateUndoRedoMenuItems(); }
/// <summary> /// End to edit handle. /// </summary> /// <param name="sender">sender.</param> /// <param name="e">e.</param> private void DataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e) { string msg = string.Format("Finished Editing Cell at ({0}, {1})", e.ColumnIndex, e.RowIndex); this.Text = msg; SpreadsheetCell index = this.table.GetCell(e.RowIndex, e.ColumnIndex); if (this.dataGridView1.CurrentCell.Value != null) { string prevText = index.Text; index.Text = this.dataGridView1.CurrentCell.Value.ToString(); UndoRedoCollection UndoCommand = new UndoRedoCollection("Text Changes"); UndoCommand.SetTextVariable(index, prevText, index.Text); this.table.AddUndo(UndoCommand); this.undoToolStripMenuItem.Text = this.table.UndoText; } else { this.dataGridView1.CurrentCell.Value = string.Empty; } }
public TalkComponent(ObservableCollection <CharacterImage> characterImages) { CharacterImages = characterImages; TalkElements = new UndoRedoCollection <BaseTalkElement>(); TalkElements.CollectionChanged += TalkElements_CollectionChanged; }