public static bool CancelPushUndoStackIfNoChanges(DataGridView dataGridView)
        {
            if (IsDoingUndoRedo)
            {
                return(true);
            }
            if (dataGridView.TopLeftHeaderCell.Tag == null)
            {
                dataGridView.TopLeftHeaderCell.Tag = new DataGridViewGenericData();
            }
            if (dataGridView.TopLeftHeaderCell.Tag.GetType() != typeof(DataGridViewGenericData))
            {
                return(true);
            }

            DataGridViewGenericData undoAndRedo = (DataGridViewGenericData)dataGridView.TopLeftHeaderCell.Tag;
            Dictionary <CellLocation, DataGridViewGenericCell> peekCells = undoAndRedo.UndoCellsStack.Count == 0 ? null : undoAndRedo.UndoCellsStack.Peek();

            bool isEqual = true;

            if (peekCells == null)
            {
                isEqual = false;
            }

            if (isEqual)
            {
                foreach (CellLocation cellLocation in peekCells.Keys)
                {
                    DataGridViewGenericCell dataGridViewGenericCell =
                        DataGridViewHandler.CopyCellDataGridViewGenericCell(dataGridView, cellLocation.ColumnIndex, cellLocation.RowIndex);

                    if (peekCells[cellLocation] != dataGridViewGenericCell)
                    {
                        isEqual = false;
                        break;
                    }
                }
            }
            if (isEqual)
            {
                undoAndRedo.UndoCellsStack.Pop();
            }

            return(isEqual);
        }
示例#2
0
 public DataGridViewGenericRowAndValue(string headerName, PropertyKey propertyKey, bool cellReadOnly)
 {
     DataGridViewGenericRow  = new DataGridViewGenericRow(headerName);
     DataGridViewGenericCell = new DataGridViewGenericCell(null, new DataGridViewGenericCellStatus(cellReadOnly));
 }
示例#3
0
 public DataGridViewGenericRowAndValue(DataGridViewGenericRow dataGridViewGenericRow, DataGridViewGenericCell dataGridViewGenericCell)
 {
     DataGridViewGenericRow  = dataGridViewGenericRow;
     DataGridViewGenericCell = dataGridViewGenericCell;
 }
示例#4
0
 public DataGridViewGenericCell(DataGridViewGenericCell dataGridViewGenericCell) : this(dataGridViewGenericCell.Value, dataGridViewGenericCell.CellStatus)
 {
 }
示例#5
0
 public DataGridViewGenericRowAndValue(string headerName, string rowName, PropertyKey propertyKey, ReadWriteAccess readWriteAccess, bool isMultiLine, bool cellReadyOnly, object value)
 {
     DataGridViewGenericRow  = new DataGridViewGenericRow(headerName, rowName, readWriteAccess, isMultiLine, propertyKey);
     DataGridViewGenericCell = new DataGridViewGenericCell(value, new DataGridViewGenericCellStatus(cellReadyOnly));
 }