GoDiagram Win Reference
ChangeValue Method (GoObject)

The particular GoChangedEventArgs edit.
If true, restore the old value, otherwise restore the new value.
Perform an undo or redo, given a GoChangedEventArgs representing a change on this object.
Syntax
'Declaration
 
Public Overridable Sub ChangeValue( _
   ByVal e As GoChangedEventArgs, _
   ByVal undo As Boolean _
) 
public virtual void ChangeValue( 
   GoChangedEventArgs e,
   bool undo
)

Parameters

e
The particular GoChangedEventArgs edit.
undo
If true, restore the old value, otherwise restore the new value.
Remarks

If you override this method, be sure to call the base method for all SubHint values that your override method 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 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 object. You should check this property before making "unrelated" side-effects.

public bool Orthogonal { get { return myOrthogonal; } set { // only set the value and do other things if the value has changed bool old = myOrthogonal; if (old != value) { myOrthogonal = value; // maybe clear out some internal cached state too ResetStuff(); // notify about the change Changed(ChangedOrthogonal, 0, old, NullRect, 0, value, NullRect); // when set to true, and when not undoing/redoing, recalculate the stroke if (value && !this.Initializing) { ClearPoints(); CalculateRoute(); } } } } public override void ChangeValue(GoChangedEventArgs e, bool undo) { switch (e.SubHint) { case ChangedOrthogonal: { this.Orthogonal = (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

GoObject Class
GoObject Members
ChangeValue Method

 

 


© 2015. Northwoods Software Corporation. All Rights Reserved.

Send Feedback