avoidNode

hi Water
one Problem…
I want reshaped link, it save (XML)
I try
void MyView_LinkCreated(


l.AvoidsNodes = true;
Load…
else if (item.Name == “link2”)
{
GoLabeledLink l = new GoLabeledLink();
l.Orthogonal = true;
l.Style = GoStrokeStyle.RoundedLine;
l.ToArrow = true;
l.RealLink.CalculateStroke();
l.AvoidsNodes = true;
this case problem is…
MyView… aviod node
But after Save and Loading
Link is not avoid, drawn through another node

How to do…be worried

A link with AvoidsNodes true can’t know how to route itself (i.e. GoLink.CalculateStroke doesn’t know what points to assign in the stroke) until it knows what nodes to avoid.
It can’t know what nodes to avoid until the link has been added to a document, because then it can recognize the collection of nodes (actually GoObjects that satisfy GoDocument.IsAvoidable) that are in the document.
So there’s no point in calling CalculateStroke() when you have just constructed the link.
I guess you aren’t saving the points of the stroke in your file or database. If that is the case, then it does make sense to wait until all of the nodes have been added to the document at the desired positions, and then iterate over all of the links and call CalculateStroke() on each one.
[On the other hand, if you are saving and restoring the points of each link stroke, you would not want to call CalculateStroke() afterwards, since that would lose whatever points you had just restored. But note that setting the FromPort or the ToPort of a link will call CalculateStroke(), so you would need to restore the points after otherwise re-initializing the link.]

Yes, I can’t saving the points of the stroke.
yet i don’t know xml saving method…
I read Q&A, this code input,

if (l != null && l.RealLink.PointsCount == 2) {

PointF a = l.RealLink.GetPoint(0);

PointF b = l.RealLink.GetPoint(1);

l.RealLink.InsertPoint(1, new PointF((a.X+b.X)/2,

(a.Y+b.Y)/2));

}

and add avoid property true.

The present I try saving and loading the points of the stroke with XML

finallym I want Controlling the Link Path, and save, load with xml, and Link's avoid node..

Help Plz

You’ll probably want to save and restore an array of PointFs. You can call GoStroke.CopyPointsArray() and .SetPoints(PointF[]).
Remember to call GoStroke.SetPoints after you have done all the other initialization of the GoLink.

T.T
store

writer.WriteStartElement(“link2”);
writer.WriteAttributeString(“nid”, XmlConvert.ToString(l.PartID));
PointF[] po = new PointF[l.RealLink.PointsCount];
po = l.RealLink.CopyPointsArray();
writer.WriteAttributeString???
I don’t know, how xmlwriter…
I System.xml.xmltextwriter using

array type attribute exist?
Help water…

You could make use of GoXmlTransformer. Here’s one way:
using Northwoods.Go.Xml;
public class XForm : GoXmlTransformer {
private XForm() { this.Writer = new GoXmlWriter(); }
private static XForm Global = new XForm();
public static String ToString(PointF[] arr) { return Global.WriteAttrVal(null, arr); }
public static PointF[] FromString(String s, PointF[] def) { return Global.PointFArrayFromString(s, def); }
}
Example use, converting both ways:
PointF[] test = new PointF[2] { new PointF(2, 3), new PointF(-3, -2) };
String teststring = XForm.ToString(test);
PointF[] testresult = XForm.FromString(teststring, null);
The second argument to XForm.FromString is the default value to return in case there is a parsing exception.
Of course, you can extend this helper class by defining more conversion methods for different data types.
Alternatively, you could just use GoXml to handle the conversion between GoDocument and XML. There are several examples of this in the sample applications. For the simplest applications just writing the Xml code directly should be OK. But for more complicated applications you will find useful the additional facilities that GoXml offers.

thx water, I can do it !!!