private void SetReadyToUndo() { _undo = true; btnUndoRedo.Image = _undoImage; _undoneChanges = null; btnUndoRedo.Text = "Undo"; }
private OfferChanceToSaveDialogUI(IRevertable revertable, RevertableObjectReport differences) { _revertable = revertable; InitializeComponent(); if (revertable == null) { return; } Text = "Save changes to " + revertable.GetType().Name + " " + revertable + " (ID = " + revertable.ID + ")"; lblFirstPrompt.Text = "Would you like to save changes to " + revertable.GetType().Name + " '" + revertable + "' (ID=" + revertable.ID + ")"; tableLayoutPanel1.RowCount = differences.Differences.Count; for (int index = 0; index < differences.Differences.Count; index++) { var d = differences.Differences[index]; var toAdd = new RevertablePropertyDifferenceUI(d); toAdd.Dock = DockStyle.Fill; tableLayoutPanel1.Controls.Add(toAdd, 0, index); } for (int i = 0; i < tableLayoutPanel1.RowStyles.Count; i++) { tableLayoutPanel1.RowStyles[i].SizeType = SizeType.AutoSize; } }
private void SetReadyToRedo(RevertableObjectReport changes) { //record the changes prior to the revert _undoneChanges = changes; _undo = false; btnUndoRedo.Image = _redoImage; }
/// <inheritdoc/> public RevertableObjectReport HasLocalChanges(IMapsDirectlyToDatabaseTable localCopy) { IMapsDirectlyToDatabaseTable dbCopy = null; var toReturn = new RevertableObjectReport(); toReturn.Evaluation = ChangeDescription.NoChanges; try { dbCopy = GetObjectByID(localCopy.GetType(), localCopy.ID); } catch (KeyNotFoundException) { toReturn.Evaluation = ChangeDescription.DatabaseCopyWasDeleted; return(toReturn); } foreach (PropertyInfo propertyInfo in GetPropertyInfos(localCopy.GetType())) { var local = propertyInfo.GetValue(localCopy); var db = propertyInfo.GetValue(dbCopy); //don't decided that "" vs null is a legit change if (local is string && string.IsNullOrWhiteSpace((string)local)) { local = null; } if (db is string && string.IsNullOrWhiteSpace((string)db)) { db = null; } if (!object.Equals(local, db)) { toReturn.Differences.Add(new RevertablePropertyDifference(propertyInfo, local, db)); toReturn.Evaluation = ChangeDescription.DatabaseCopyDifferent; } } return(toReturn); }