Undo/Redo basic question

Hello,

I begin to implement undo/redo for my custom object field, and for now the behavior works great but i want to make sure i do not do anything which is not needed (useless or incorrect with GoDiagram).
The following code works like expectation for me, but when i compare it to your GoDiagram sample (like ItemWidth field in Demo1) i remark you do not need to call "StartTransaction" and "FinishTransaction" in your sample. If i do not make these call my "Undo" stay disable and do not contains anything. My question: am i correct? or what you do differently (which i do not see) to avoid these calls.
My code:
public Int32 MaximumDisplacement
{
get { return maximumDisplacement; }
set {
Int32 old = maximumDisplacement;
if (old != value && this.Document != null)
{
this.Document.StartTransaction(); //correct?
maximumDisplacement = value;
Changed(ChangedMaximumDisplacement, old, null,
NullRect, value, null, NullRect);
this.Document.FinishTransaction("MaximumDisplacement"); //correct?

}
}
}
private Int32 maximumDisplacement;

public override void ChangeValue(GoChangedEventArgs e, bool
undo) {
switch (e.SubHint) {
case ChangedMaximumDisplacement:
this.MaximumDisplacement = e.GetInt(undo);
return;
....
default:
base.ChangeValue(e, undo);
return;
}
}

You don’t want the StartTransaction/FinishTransaction. Looks good other than that.



The Start/Finish wants to be called from the Application level that is changing the properties. Note that a LOT of things might change between a Start/Finish. Search the samples for StartTransaction and you’ll see how it is used.

I known how to use StartTransaction/FinishTransaction normally, but i do not known why a change in my properties field do not flag the Undo/Redo…in fact, even a change in GoDiagram properties field (like a change of “BrushStyle” or “Color” in my propertiesgrid) do not flag the Undo/Redo manager. So, i am lost…

Do you have guess where is my problem?
PS: i note property like "Location" and "Size" pop the Undo/Redo flag normally when user change it by dragging the GoObject in my GoView but if the change is made from my propertiesgrid no Unde/Redo appears...so, i guess something different from a change of GoObject properties from my propertiesgrid vs my GoView...the DirtyFlag of my GoDocument works in both scenario but not the Undo/Redo except if i force a StartTransaction which seems bad :(

The properties grid changes aren’t undoable… you see that in our samples apps as well.

But they do support undo in those samples where there’s code to start a transaction when the window containing the PropertyGrid gets focus and finishing the transaction when that window loses focus.

The “gets focus”/“loses focus” ideas seems pretty interesting for my needs, thanks!