Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Multiple selection of nodes using mouse (Read 2169 times)
rajesh_patil74
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 220
Joined: Sep 3rd, 2009
Multiple selection of nodes using mouse
Jun 17th, 2010 at 8:03am
Print Post  
Hi Stoyo

I have place Diagram control inside the scrollviewer control and aligned this control vertical and horizontally central.

The background diagram control is same as scrollviewer control and i don't have enabled the grid style.

Because of above setting, it seems that the white region of scrollviewer where actually diagram control is not placed is also a part of diagram control.

Now user presses the left mouse button down and tries to move the mouse on right side of the diagram to select few nodes but no selection rectanagle gets drawn.

If user presses the mouse button down in the diagram regioin and move it starts drawing the selection rectangle and with mouse up even select all diagram items which are within a rectangle region.

I have also noticed that , once the selection rectangle is drawn it is possible to move the mouse out of diagram region and selection rectangle is also drawn out side the diagram region. But mouse up event outside the diagram region doesn't select any items.

[In short - to select items mouse down and mouse up events needs to be in diagram region only.  How it can be possible in the above situation.]

Regards
Rajesh

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


MindFusion team

Posts: 511
Joined: Jun 17th, 2010
Re: Multiple selection of nodes using mouse
Reply #1 - Jun 17th, 2010 at 2:58pm
Print Post  
Hi Rajesh,

Unfortunately, currently it's not possible that the diagram handles click events on the ScrollViewer.

What you could try, is to handle the ScrollViewer SizeChanged event and make sure that the diagram resezes itself to fully occupy the ScrollViewer's area.
One possible implementation is this:

Code
Select All
private void ScrollViewer_SizeChanged(object sender, SizeChangedEventArgs e)
{
    ScrollViewer sv = sender as ScrollViewer;
    Rect newBounds = sv.GetRect();

    //Account for any applied ZoomFactor on the diagram
    if (diagram.ZoomFactor != 100)
    {
        newBounds.Width *= 100 / diagram.ZoomFactor;
        newBounds.Height *= 100 / diagram.ZoomFactor;
    }

    Rect r = diagram.Bounds;
    r.Union(newBounds);
    diagram.Bounds = r;
}
 



Regards,
Lyubo
  
Back to top
 
IP Logged
 
rajesh_patil74
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 220
Joined: Sep 3rd, 2009
Re: Multiple selection of nodes using mouse
Reply #2 - Jun 24th, 2010 at 9:41am
Print Post  
Hi Lyubo

with sv.GetRect() I always get vertical and horizontal scrollbar visible.

Instead of sv.GetRect() I used
new Rect(0,0, sv.ActualWidth-50, sv.ActualHeight - 50) the diagram covers the complete scrollviewer region but my diagram nodes are visible in top-left corner ( Previously my diagram node is visible in the center)

The another issue with this is that, my scrollviewer control is placed is grid which is resizable. If initially i increase the size of my grid region and later on descreases it , the diagram region still occupies same area since union is used and diagram bounds are already high than the scrollviewer area.

I guess, some change in diagram control is required for same.

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


MindFusion team

Posts: 511
Joined: Jun 17th, 2010
Re: Multiple selection of nodes using mouse
Reply #3 - Jun 24th, 2010 at 11:39am
Print Post  
Hi Rajesh,

Could you try if the below code fixes your issue (replace the last three lines in the previous sample):

Code
Select All
Rect r = diagram.GetContentBounds(false, false);
double wDiff = newBounds.Width - r.Width;
double hDiff = newBounds.Height - r.Height;

if (r.Width < newBounds.Width)
{
    r.X -= wDiff / 2;
    r.Width += wDiff;
}
if (r.Height < newBounds.Height)
{
    r.Y -= hDiff / 2;
    r.Height += hDiff;
}
diagram.Bounds = r;
 



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