the entire undo/redo system in Universal Editor needs a MAJOR overhaul
This commit is contained in:
parent
4a8cc6f516
commit
c3a1516811
@ -399,6 +399,7 @@ namespace UniversalEditor.UserInterface
|
||||
mvarUpdating--;
|
||||
}
|
||||
|
||||
public bool InEdit { get { return mvarEditing > 0; } }
|
||||
public void BeginEdit()
|
||||
{
|
||||
if (mvarUpdating > 0) return;
|
||||
@ -424,6 +425,15 @@ namespace UniversalEditor.UserInterface
|
||||
// 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)
|
||||
|
||||
@ -26,6 +26,7 @@ using UniversalEditor.UserInterface;
|
||||
using MBS.Framework.UserInterface;
|
||||
using MBS.Framework.UserInterface.Controls;
|
||||
using MBS.Framework.UserInterface.Layouts;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace UniversalEditor.Editors.Text.Plain
|
||||
{
|
||||
@ -62,18 +63,35 @@ namespace UniversalEditor.Editors.Text.Plain
|
||||
return _er;
|
||||
}
|
||||
|
||||
bool working = false;
|
||||
|
||||
private void txt_Changed(object sender, EventArgs e)
|
||||
{
|
||||
PlainTextObjectModel om = (this.ObjectModel as PlainTextObjectModel);
|
||||
|
||||
BeginEdit();
|
||||
om.Text = txt.Text;
|
||||
EndEdit();
|
||||
if (!working)
|
||||
{
|
||||
if (!InEdit)
|
||||
{
|
||||
BeginEdit();
|
||||
}
|
||||
om.Text = txt.Text;
|
||||
|
||||
txt.ResetChangedByUser();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnObjectModelSaving(CancelEventArgs e)
|
||||
{
|
||||
base.OnObjectModelSaving(e);
|
||||
|
||||
if (InEdit)
|
||||
EndEdit();
|
||||
}
|
||||
|
||||
public PlainTextEditor ()
|
||||
{
|
||||
txt = new TextBox();
|
||||
txt = new TextBox();
|
||||
txt.Changed += txt_Changed;
|
||||
txt.Multiline = true;
|
||||
|
||||
@ -85,12 +103,16 @@ namespace UniversalEditor.Editors.Text.Plain
|
||||
{
|
||||
base.OnObjectModelChanged(e);
|
||||
|
||||
working = true;
|
||||
txt.Text = String.Empty;
|
||||
working = false;
|
||||
|
||||
PlainTextObjectModel om = (this.ObjectModel as PlainTextObjectModel);
|
||||
if (om == null) return;
|
||||
|
||||
working = true;
|
||||
txt.Text = om.Text;
|
||||
working = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user