Hi Stoyan,
A) Perfect
B) In addition to the code I sent you about the "ApproxBezier" crash I still get (see
http://mindfusion.eu/Forum/YaBB.pl?board=fcnet_brep;action=display;num=124576041...), here is the LinkCreating code:
void Diagram_LinkCreating(object sender, LinkValidationEventArgs e)
{
if (e.Link == null || e.Link.Origin == null || !(e.Link.Origin is TableNode))
{
e.Cancel = true;
return;
}
// Draw bezier curve
// Uses e.MousePosition as the endPt instead of calculating if from the link.
this.Diagram.RouteLink(e.Link, e.MousePosition);
// Equivalent to AllowUnconnectedLinks=TRUE, but with nice bezier links painting ;)
if (e.Destination == null)
{
e.Cancel = true;
return;
}
// Checks if the link is allowed
bool linkValid = ValidateLink(e.Link, e.Destination, e.AnchorIndex, e.TableRow, false, false);
e.Cancel = !linkValid;
e.Link.ShadowColor = Color.Transparent;
}
My (B) problem happens in RouteLink when I do UpdateFromPoints. In my test sample (lightly modified Entities sample), I don't get the crash, but the links don't get updated as a bezier (i.e. the links are straight instead of bezier curves when creating them). Once the're created, everything is fine (In my sample only since my real application crashes if the LinkCreating code is activate).
In my real application, even though the LinkCreating code and other related codes are almost the same (but not the anchor point's code), the links don't get updated while creating them (i.e. I get cascading links somehow but no bezier) and I also get a crash every time I am creating a link and go over an anchor point:
System.NullReferenceException was unhandled
Message="La référence d'objet n'est pas définie à une instance d'un objet."
Source="MindFusion.Diagramming"
StackTrace:
à MindFusion.Diagramming.DiagramLink.x0d5905a18dc24aa7(Boolean x1c5ff8c3c1ac16ad)
à MindFusion.Diagramming.DiagramLink.UpdateFromPoints(Boolean updateGroups)
à MindFusion.Diagramming.DiagramLink.UpdateFromPoints()
à [...].RouteLink(DiagramLink link, PointF endPt, Boolean verbose) dans [...]
à [...].Diagram_LinkCreating(Object sender, LinkValidationEventArgs e) dans [...]
à MindFusion.Diagramming.Diagram.OnLinkCreating(LinkValidationEventArgs e)
So my problems are
(1) The crash in UpdateFromPoints
(2) The fact that I can't have bezier-looking links while creating them.
(3) The crash as described in my other post (in MindFusion.Utilities.ApproxBezier(PointF[] points, Int32 startIdx, Int32 quality))
Thanks!
Marie
Edit: I forgot to set Diagram.AllowUnconnectedLinks to true... When it is, I get the UpdateFromPoints crash every time LinkCreating gets called (i.e. almost at the moment I start creating a link), not just when over an anchor point (I don't event get there anymore).