Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Control Node creation very slow (Read 3701 times)
David Long
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 153
Location: England
Joined: Oct 23rd, 2006
Control Node creation very slow
Mar 1st, 2012 at 3:46pm
Print Post  
Each box in my chart has two attached Control Nodes that host simple windows forms edit boxes.  It seems very slow to create such boxes.  If I create 3 such boxes (3 boxes plus 6 control nodes in total) it seems to take about 2-3 seconds.  The contructor for these control nodes is doing very little and charts without control nodes seem to be fine.

Any help gratefully received.
DavidL

I'm using version 5.3.5
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Control Node creation very slow
Reply #1 - Mar 2nd, 2012 at 8:34am
Print Post  
This takes about 4800 milliseconds without the SuspendLayout and ResumeLayout calls, and 1600 with them, so you might try adding suspend/resume calls around your code that creates nodes.

Code
Select All
string text = "";
for (int i = 0; i < 100; i++)
	text += "test ";

DateTime start = DateTime.Now;

diagramView.SuspendLayout();
for (int i = 0; i < 100; i++)
{
	TextBox t = new TextBox();
	t.Text = text;
	t.Multiline = true;

	ControlNode node = new ControlNode(diagramView, t);
	node.Bounds = new RectangleF((i % 6) * 30, (i / 6) * 30, 20, 20);
	diagram.Nodes.Add(node);
}
diagramView.ResumeLayout();

MessageBox.Show((DateTime.Now - start).TotalMilliseconds.ToString());
 



If you also have auto-routed links in the diagram, you can call diagram.LinkRouter.Suspend / Resume to prevent link re-routing while creating new nodes.

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


I love YaBB 1G - SP1!

Posts: 153
Location: England
Joined: Oct 23rd, 2006
Re: Control Node creation very slow
Reply #2 - Mar 8th, 2012 at 10:05am
Print Post  
Thank you, this does seem to help.  Another thing is that scrolling a view with a lot of control nodes left/right or up/down is also very slow - I can see the control nodes being repainted multiple times. Can this be improved in the same way?

David L
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Control Node creation very slow
Reply #3 - Mar 11th, 2012 at 8:13am
Print Post  
From what I can see, the view is not fully repainted while scrolling and the textboxes leave some traces on it. You could force it to refresh while the scrollbars are being dragged:

Code
Select All
(diagramView.HScrollBar as ScrollBar).Scroll += OnScroll;
(diagramView.VScrollBar as ScrollBar).Scroll += OnScroll;

void OnScroll(object sender, ScrollEventArgs e)
{
	diagramView.Refresh();
} 



There's still some flicker, but I think that's the best you can get using ControlNodes, which involve moving controls' windows around when scrolling the view. If you are using them only to display editable text, you could replace ControlNodes with CompositeNodes that contain EditComponents, or simple ShapeNodes that invoke BeginEdit from the NodeClicked handler.

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


I love YaBB 1G - SP1!

Posts: 153
Location: England
Joined: Oct 23rd, 2006
Re: Control Node creation very slow
Reply #4 - Mar 12th, 2012 at 10:14am
Print Post  
Thanks, adding the diagramView.Refresh() does help.  I've also added it to the event handler for the mouse wheel event.

Thanks for all help
David
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint