merge similar BeginEdit overloads using null default parameter value

This commit is contained in:
Michael Becker 2020-05-14 23:42:47 -04:00
parent 2eb9ed0146
commit fff6444593
No known key found for this signature in database
GPG Key ID: 506F54899E2BFED7

View File

@ -431,7 +431,7 @@ namespace UniversalEditor.UserInterface
}
public bool InEdit { get { return mvarEditing > 0; } }
public void BeginEdit()
public void BeginEdit(string PropertyName = null, object Value = null, object ParentObject = null, Control editingControl = null)
{
if (mvarUpdating > 0) return;
@ -442,63 +442,47 @@ namespace UniversalEditor.UserInterface
}
mvarEditing++;
// check to see if this property has been edited before
if (undo.Count > 0)
{
EDITINFO oldedit = undo.Pop();
if (oldedit.closed) undo.Push(oldedit);
}
// push the new edit
EDITINFO edit = new EDITINFO(null, null, mvarObjectModel.Clone() as ObjectModel);
undo.Push(edit);
// clear out all the redos
redo.Clear();
}
public void ContinueEdit()
{
if (undo.Count > 0)
{
EDITINFO edit = undo.Pop();
edit.oldValue = mvarObjectModel.Clone() as ObjectModel;
undo.Push(edit);
}
}
public void BeginEdit(string PropertyName, object Value = null, object ParentObject = null, Control editingControl = null)
{
if (mvarEditing > 0)
{
mvarEditing++;
return;
}
mvarEditing++;
if (ParentObject == null) ParentObject = ObjectModel;
// check to see if this property has been edited before
if (undo.Count > 0)
{
EDITINFO oldedit = undo.Pop();
if (oldedit.propertyName != PropertyName || oldedit.closed) undo.Push(oldedit);
if ((PropertyName != null && oldedit.propertyName != PropertyName) || oldedit.closed) undo.Push(oldedit);
}
// push the new edit
if (Value == null)
if (PropertyName != null)
{
System.Reflection.PropertyInfo pi = ParentObject.GetType().GetProperty(PropertyName);
if (pi != null)
if (Value == null)
{
Value = ParentObject.GetType().GetProperty(PropertyName).GetValue(ParentObject, null);
System.Reflection.PropertyInfo pi = ParentObject.GetType().GetProperty(PropertyName);
if (pi != null)
{
Value = ParentObject.GetType().GetProperty(PropertyName).GetValue(ParentObject, null);
}
}
}
EDITINFO edit = new EDITINFO(ParentObject, PropertyName, Value, editingControl);
if (PropertyName == null)
{
edit.oldValue = mvarObjectModel.Clone() as ObjectModel;
}
undo.Push(edit);
// clear out all the redos
redo.Clear();
}
public void ContinueEdit()
{
if (undo.Count > 0)
{
EDITINFO edit = undo.Pop();
edit.oldValue = mvarObjectModel.Clone() as ObjectModel;
undo.Push(edit);
}
}
public void EndEdit()
{
if (mvarUpdating > 0) return;