Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 10 Replies) Bug : Mouse position not correct when drawing link (Read 6393 times)
rajesh_patil74
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 220
Joined: Sep 3rd, 2009
Bug : Mouse position not correct when drawing link
Dec 28th, 2010 at 12:56pm
Print Post  
Hi Stoyo

I have a container node and contains two nodes. For the container node outgoing and incoming links are not possible ( Set the respective properties to false)

Now when user is trying to create a link between the two nodes which are inside the container, the link arrow always points to the one of the edges of the container node and mouse is showing "rotating cursor in window 7 OS since the destination node is not valid/selected.

Instead of this when the links are not possible then also the arrow position should be at the mouse location instead of the container edge.

Any idea, how this can be fixed with custom solution and is it possible to get this fixed in next build ?

-Rajesh
  
Back to top
WWW  
IP Logged
 
rajesh_patil74
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 220
Joined: Sep 3rd, 2009
Re: Bug : Mouse position not correct when drawing
Reply #1 - Jan 3rd, 2011 at 1:40pm
Print Post  
Hi Stoyo

Any update on this issue ?

-Rajesh
  
Back to top
WWW  
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Bug : Mouse position not correct when drawing
Reply #2 - Jan 3rd, 2011 at 2:25pm
Print Post  
Hi Rajesh,

You can find a fix on the PM page.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
rajesh_patil74
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 220
Joined: Sep 3rd, 2009
Re: Bug : Mouse position not correct when drawing
Reply #3 - Jan 19th, 2011 at 11:25am
Print Post  
Hi Stoyo

With the new dlls the issue is resolved.

Here I need similar behavior at another situation -

I have two nodes (rectangle shapes) and anchor point is set for both nodes. Now when user tries to create a link he need to establish the link only on anchor points. Here it should be possible that user can drop the link other than the anchor point and in such case the link created should have "Dynamic" property set to true.

-Rajesh
  
Back to top
WWW  
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Bug : Mouse position not correct when drawing
Reply #4 - Jan 19th, 2011 at 7:49pm
Print Post  
Hi Rajesh,

If you mean the anchor points should act only as some kind of visual indicators, set their AllowIncoming and AllowOutgoing properties to false. If the links should still align to anchor points in some situations, you'd have to override their UpdateDrag method or handle the LinkModifying event to control that.

Stoyan
  
Back to top
 
IP Logged
 
rajesh_patil74
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 220
Joined: Sep 3rd, 2009
Re: Bug : Mouse position not correct when drawing
Reply #5 - Jan 21st, 2011 at 1:40pm
Print Post  
Hi Stoyo

Can you provide me the UpdateDrag method which achive the behavior that in some case links should be established between anchor points and in some cases it should not.

When user tries to pick the anchor point for drawing line, it should be created from anchor point and destination should be anchor point when it is dropped on anchor point.
The above case results following three posibilities between lines -
1. Anchor point to any point in destination node.
2. Anchor point to anchor point.
3. Any point to anchor point in destination node.

Regards
Rajesh


  
Back to top
WWW  
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Bug : Mouse position not correct when drawing
Reply #6 - Jan 25th, 2011 at 1:03pm
Print Post  
Hi,

Please find an updated version on the PM page, it now implements the ValidateAnchorPoint event we have in the controls for other platforms.

Now add this to the diagram Xaml:
Code
Select All
DynamicLinks="True"
ValidateAnchorPoint="OnValidateAnchorPoint" 



and the handler to the code-behind:
Code
Select All
private void OnValidateAnchorPoint(object sender, LinkValidationEventArgs e)
{
	if (e.ChangingOrigin && e.Node == e.Link.Origin && e.AnchorIndex == e.Link.OriginAnchor)
		e.Cancel = false;
	else if (e.ChangingDestination && e.Node == e.Link.Destination && e.AnchorIndex == e.Link.DestinationAnchor)
		e.Cancel = false;
	else
		e.Cancel = true;
} 



The logic of the code above is to disallow using any anchor point if the link is not connected to an anchor point, thus the link will connect to the nearest border point, or otherwise allow only the current anchor point to be used, and so dynamic links won't jump to a different anchor point.

Finally add this to the custom link class so that the link explicitly sets its anchor points if its ends are within the specified distance. If you don't do that, the ValidateAnchorPoint handler prevents the base code from automatically connecting to an anchor point:

Code
Select All
private const double MaxAnchorDist = 15;

static int GetAnchorAt(DiagramNode node, Point point, out Point absPos)
{
	absPos = new Point();
	if (node.AnchorPattern == null)
		return -1;
	for (int i = 0; i < node.AnchorPattern.Points.Count; ++i)
	{
		var ap = node.AnchorPattern.Points[i];
		var r = node.Bounds;
		absPos = new Point(
			r.Width * ap.X / 100 + r.X,
			r.Height * ap.Y / 100 + r.Y);

		if (absPos.Distance(point) < MaxAnchorDist)
			return i;
	}

	absPos = point;
	return -1;
}

protected override void EndDrag(InteractionState ist)
{
	var start = StartPoint;
	var end = EndPoint;
	base.EndDrag(ist);

	if (ist.Action == Action.Create)
	{
		OriginAnchor = GetAnchorAt(Origin, start, out start);
		StartPoint = start;
		DestinationAnchor = GetAnchorAt(Destination, end, out end);
		EndPoint = end;
		UpdateFromPoints();
	}
} 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
rajesh_patil74
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 220
Joined: Sep 3rd, 2009
Re: Bug : Mouse position not correct when drawing
Reply #7 - Jan 27th, 2011 at 8:46am
Print Post  
Hi Stoyo

Thanks for your new updates.

I think, I am almost there with my requirment except one thing which is not working.

In one of my post, I requested for one end of link dynamic and another fixed.
http://mindfusion.eu/Forum/YaBB.pl?board=diaglite_disc;action=display;num=128997...

With this I am facing some issue.

As of now, with the new dlls with implementation of "OnValidateAnchorPoint" I am able to achive following things by providing some value in links tag.

When link is not dynamic -
1. Anchor points of link doesn't change with nodes are re-positioned.

2. Non-anchor points of link doesn't change when nodes are re-positioned.

Above two points are by design and correct.

When link is dynamic , following points implemented -
1. Possible to control either origin/destination of link assigned to anchor point as fixed and other end of link is dynamic (always from center of another node)

2. Possible to control both origin/destination assinged to anchor point as auto changeable.

3. Possible to control both origin/desitnation always from center of node.

The thing which is not possilbe is -
One end of link is dynamic ( always from center of node) but the other end at fixed position of node which is not a anchor point.

Is it possible for you to provide me the dlls of internal build with the fix for same? 

Or any possible date for next release in which this issue gets fixed ?

Let me know, whether you need a source code of sample application with this issue ?

Regards
Rajesh
  
Back to top
WWW  
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Bug : Mouse position not correct when drawing
Reply #8 - Jan 28th, 2011 at 9:09am
Print Post  
Hi Rajesh,

If you mean the Dynamic property should affect only one of the link ends without using anchor points - we don't plan implementing anything similar. If using anchor points, you can achieve that through the validation event. Otherwise we could make virtual the method that chooses new end points for Dynamic links, so you would be able to override it to fix one of the points.

Stoyan
  
Back to top
 
IP Logged
 
rajesh_patil74
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 220
Joined: Sep 3rd, 2009
Re: Bug : Mouse position not correct when drawing
Reply #9 - Feb 1st, 2011 at 9:21am
Print Post  
Hi Stoyo

Yes. You understood my requirment properly. To explain my concerns I tried to make a sample in which I am not able to cover all the expected things.

In the attached document, I tried to explain why I need fixed end point and at the same time user should be able to control what point should be fixed and which should change by changing properties run-time.

http://cid-2b9bf77533900b84.office.live.com/self.aspx/.Public/Need%20of%20fix%20...


Please let me know your views on same.

Regards
Rajesh
  
Back to top
WWW  
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Bug : Mouse position not correct when drawing
Reply #10 - Feb 3rd, 2011 at 11:45am
Print Post  
Hi Rajesh,

Our developers' view is that in the short term we can only make the method called by dynamic links virtual so you can override it and fix the positions of some points. For future releases we will think of some way to express all scenarios you need through properties.

Regards,
Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint