GoDiagram Win Reference
ChangeValue Method (GoDocument)

this value's Hint property identifies the kind of document change
true if this method should restore the older/previous state from before the change event; false if this method should restore the newer/next state from after the change event
This method is called by GoChangedEventArgs in order to perform the Undo or Redo or a particular document change.
Syntax
'Declaration
 
Public Overridable Sub ChangeValue( _
   ByVal e As GoChangedEventArgs, _
   ByVal undo As Boolean _
) 
public virtual void ChangeValue( 
   GoChangedEventArgs e,
   bool undo
)

Parameters

e
this value's Hint property identifies the kind of document change
undo
true if this method should restore the older/previous state from before the change event; false if this method should restore the newer/next state from after the change event
Remarks

This handles changes to the document, such as ChangedAllowMove; to the collection of document layers, such as GoLayerCollection.InsertedLayer; and to any document layer, such as GoLayer.InsertedObject. For a GoLayer.ChangedObject event hint, this just calls GoObject.ChangeValue on the GoObject, to handle all the changes for objects such as GoObject.ChangedMovable. This method will raise an ArgumentException if the argument e's Hint value is not recognized.

If you add a property to a class inheriting from GoDocument, you may want to override this method in order to handle undo/redo. Be sure to call the base method for all Hint values that your override does not handle.

Although properties should be designed so that setting one property does not modify other properties, this is sometimes not practical. Nevertheless it is important to avoid having side-effects when the value is changing due to an undo or redo. One way of doing this is to copy the needed code, but not the auxiliary side-effecting code, from the property setter to the ChangeValue override. Or similarly, you could define a method called from both the setter and the ChangeValue method, parameterized by whether the caller is the setter or not.

But a more convenient way to achieve this is to check the Initializing property that is set to true when the ChangeValue method is being called on this document. You should check this property before making "unrelated" side-effects.

public bool MaintainsPartID { get { return myMaintainsPartID; } set { // only set the value and do other things if the value has changed bool old = myMaintainsPartID; if (old != value) { myMaintainsPartID = value; // notify about the change RaiseChanged(ChangedMaintainsPartID, 0, null, 0, old, NullRect, 0, value, NullRect); // when set to true, and when not undoing/redoing, make sure all parts have unique IDs if (!this.Initializing) { if (value) EnsureUniquePartID(); else ClearPartIDTable(); } } } } public override void ChangeValue(GoChangedEventArgs e, bool undo) { switch (e.SubHint) { case ChangedMaintainsPartID: this.MaintainsPartID = (bool)e.GetValue(undo); return; default: base.ChangeValue(e, undo); return; } }
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

GoDocument Class
GoDocument Members
ChangeValue Method

 

 


© 2015. Northwoods Software Corporation. All Rights Reserved.

Send Feedback