Protoapp nodeinfo


#1

I tried adding an extra property to nodeinfo in the protoapp example.
Everything works except Undo which raises an exception
Detail
Code added to graphnode
public string myAlias = “”;
public const int ChangedAlias = LastChangedHint+1000;

public override void ChangeValue(GoChangedEventArgs e,bool undo)
{
switch (e.Hint)
{
case ChangedAlias:
{
this.myAlias = (String)e.GetValue(undo);
break;
}
default:
base.ChangeValue(e, undo);
return;
}
}
Code added to graphnodeinfo
public static readonly System.Drawing.RectangleF NullRect = new System.Drawing.RectangleF(0,0,0,0);
[Category(“Identity”)]
[Description(“The node’s text label alias”)]
public String Alias
{
get { return this.GraphNode.myAlias; }
set
{
string oldval = this.GraphNode.myAlias;
this.GraphNode.myAlias = value;
this.GraphNode.Changed(GraphNode.ChangedAlias,0,oldval,NullR ect,0,value,NullRect);
}
}
on undo causes
An unhandled exception of type ‘System.ArgumentOutOfRangeException’ occurred in northwoods.go.dll
Additional information: Specified argument was out of the range of valid values.
at
public override void Undo() {
==> base.Undo();
GoView view = MainForm.App.GetCurrentGoView();
if (view != null && view.Document == this)
MainForm.App.EnableToolBarUndoButtons(view);
}

Can you tell what I have done wrong


#2

That error is caused when our mechanism detects a change that wasn’t handled by ChangeValue.
At first glance I thought your code was fine, but then I noticed a little typo:
switch (e.Hint) …
should be:
switch (e.SubHint) …
instead. The Hint value is used for GoDocument or GoLayer or GoLayerCollection changes. The SubHint value is used for discriminating particular cases in one of those Hint cases. All the ones for GoObject changes fall under the Hint GoLayer.ChangedObject.
We have improved the error message for future releases.


#3

How to avoid this case on currently version?


#4

Brilliant - thank you