Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Problem with Zoom and multiple selection (Read 4903 times)
vtortola
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 104
Joined: Nov 26th, 2008
Problem with Zoom and multiple selection
Feb 9th, 2009 at 10:40am
Print Post  
Hi there,

I've found a problem when you apply a zoom factor and try to do a multiple selection with drag selection (not using Ctrl+LeftClick), this is the exception is thrown:

System.IndexOutOfRangeException occurred
Message="Index was outside the bounds of the array."
Source="MindFusion.Diagramming.Wpf"
StackTrace:
at MindFusion.Utilities.ApproxBezier(Point[] points, Int32 startIdx, Int32 quality)
at MindFusion.Diagramming.Wpf.DiagramLink.x506928df783c0c72(Int32 x949108ddd7122fd3)
at MindFusion.Diagramming.Wpf.DiagramLink.xa170bf38e993d468(Rect x26545669838eb36e)
at MindFusion.Diagramming.Wpf.Diagram.x98d300fb770bf5ec(Rect x26545669838eb36e, Boolean x201ab38fe5644146)
at MindFusion.Diagramming.Wpf.Selection.AllowCreate(Point current, InteractionState ist)
at MindFusion.Diagramming.Wpf.InteractionState.ValidateAndSetCursor(Point point, Diagram diagram)
at MindFusion.Diagramming.Wpf.Diagram.OnPreviewMouseMove(MouseEventArgs e)
at System.Windows.UIElement.OnPreviewMouseMoveThunk(Object sender, MouseEventArgs e)
at System.Windows.Input.MouseEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
at System.Windows.Input.InputManager.ProcessStagingArea()
at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.WrappedInvoke(Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Boolean isSingleParameter)
at System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNat
iveMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.RunDialog(Form form)
at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
at System.Windows.Forms.Form.ShowDialog()
at DK.Client.OSPDbDiagramming.ShowDialog(I_UserConf user, DataRow drow, IEnumerable`1 tables) in C:\Users\auser\Documents\DK\Client\DkCore\PageClasses.cs:line 739
InnerException:
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Problem with Zoom and multiple selection
Reply #1 - Feb 10th, 2009 at 9:55am
Print Post  
Have you changed the ControlPoints collection of some link without updating SegmentCount? Could you email a diagram file with which that happens to support@mindfusion.eu?
  
Back to top
 
IP Logged
 
vtortola
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 104
Joined: Nov 26th, 2008
Re: Problem with Zoom and multiple selection
Reply #2 - Feb 10th, 2009 at 11:18am
Print Post  
When I'm loading the data from the XML, I've added before link.UpdateControlPoints:

link.SegmentCount = (short)link.ControlPoints.Count;

And seems like correct the problem, but... is there any reason for have to do that explicity?

Cheers.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Problem with Zoom and multiple selection
Reply #3 - Feb 10th, 2009 at 11:47am
Print Post  
The correct should be SegmentCount = ControlPoints.Count - 1 for polyline and cascading links, but is this the only place you are setting ControlPoints? Are you doing this selection after running the OrthogonalRouter? - it might be a bug in the last update we did there.

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


I love YaBB 1G - SP1!

Posts: 104
Joined: Nov 26th, 2008
Re: Problem with Zoom and multiple selection
Reply #4 - Feb 10th, 2009 at 12:21pm
Print Post  
Humm... I ran the othogonalrouter and save the layout in a XML (with a custom method), and after when I open the saved diagram, the app creates a new diagram with that XML. The XML contains all the information, including links and their control points.

If I load the diagram from the XML and try to zoom and select dragging... the error happens. If I load the diagram, apply the layout wityh orthogonalrouter, zoom and select dragging.. the error doesn't happen. So seems like the orthogonalrouter fix the problem, but when I load the diagram again, if I try to do the multiselect dragging in a zoommed area... the error happen.

With ControlPoints.Count -1 the error happens again (I'm not using beizer links).

Cheers.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Problem with Zoom and multiple selection
Reply #5 - Feb 10th, 2009 at 12:24pm
Print Post  
With what code are you recreating the links when loading with the custom method?
  
Back to top
 
IP Logged
 
vtortola
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 104
Joined: Nov 26th, 2008
Re: Problem with Zoom and multiple selection
Reply #6 - Feb 10th, 2009 at 4:57pm
Print Post  
The links are saved in this way:

XElement linksXml = new XElement( "Links",
from l in DatabaseDiagram.Links.OfType<DiagramLink>()
select new XElement( "Link",
new XAttribute( "FkColumn", ((DataDiagramRelation)l.Tag).FkColumn ),
new XAttribute( "FromTableName", ((DataTable)l.Origin.Tag).TableName ),
new XAttribute( "ToTableName", ((DataTable)l.Destination.Tag).TableName),
new XAttribute( "LinkStyle", l.Style.ToString() ),
new XAttribute( "LinkHeader", l.HeadShape.ToString() ),
new XElement( "ControlPoints",
new XAttribute( "SegmentCount", l.SegmentCount ),
from p in l.ControlPoints.OfType<Point>()
select new XElement( "Point",
new XAttribute( "X", p.X ),
new XAttribute( "Y", p.Y ) ) )
) );



The links are recreated in this way:

foreach ( XElement xlink in diagram.Elements( "Links" ).Descendants( "Link" ) )
{
String sfrom =(String)xlink.Attribute("FromTableName");
String sto=(String)xlink.Attribute("ToTableName");
String sColumn = (String)xlink.Attribute( "FkColumn" );

TableNode from = GetTableNodeFromTableName(sfrom);
TableNode to = GetTableNodeFromTableName(sto);
DataDiagramRelation rel = _relations.Where( r => r.TableFrom == sfrom && r.TableTo == sto && r.FkColumn == sColumn ).SingleOrDefault();

if ( from != null && to != null && rel !=null )
{
DiagramLink link = DatabaseDiagram.Factory.CreateDiagramLink(from,to);
link.Font = _linkFont;
link.Tag = rel;
link.TextBrush = _linkTextBrush;
link.ToolTip = rel.FkColumn;
link.Text = rel.FkColumn;
Object style = Enum.Parse( typeof( LinkStyle ), xlink.Attribute( "LinkStyle" ).Value );
link.Style = style != null ? (LinkStyle)style : LinkStyle.Polyline;

Object header = Enum.Parse( typeof( ArrowHead ), xlink.Attribute( "LinkHeader" ).Value );
link.HeadShape = header != null ? (ArrowHead)header : ArrowHead.None;

link.AutoRoute = true;

link.SegmentCount = Int16.Parse( xlink.Element( "ControlPoints" ).Attribute( "SegmentCount" ).Value );

link.ControlPoints.Clear();
foreach ( XElement controlPoint in xlink.Element( "ControlPoints" ).Descendants( "Point" ) )
link.ControlPoints.Add( new Point( Double.Parse( controlPoint.Attribute( "X" ).Value ),
Double.Parse( controlPoint.Attribute( "Y" ).Value ) ) );
link.SegmentCount = (short)(link.ControlPoints.Count);
link.UpdateFromPoints();
}
}
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Problem with Zoom and multiple selection
Reply #7 - Feb 10th, 2009 at 5:15pm
Print Post  
Quote:
link.AutoRoute = true;


Make it the last line, or otherwise the control completely ignores your efforts to set SegmentCount, and that would make the segment count out of sync with point count, and lead to that exception.

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


I love YaBB 1G - SP1!

Posts: 104
Joined: Nov 26th, 2008
Re: Problem with Zoom and multiple selection
Reply #8 - Feb 11th, 2009 at 11:08am
Print Post  
thanks.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint