Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic the performance of diagramLinkStyle (Read 3303 times)
ricman400
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 4
Joined: Jun 15th, 2015
the performance of diagramLinkStyle
Jun 15th, 2015 at 5:33am
Print Post  
i has 5000 node and links, that is the code

Code
Select All
  foreach (var item in diagram.Nodes)
            {
                item.RenderNode(Color.Black);
            }
            foreach (var item in diagram.Links.ToList())
            {
                item.RenderLink(Color.Black);
            }

     public static void RenderLink(this DiagramLink link, Color color)
        {
            if (link == null)
            {
                return;
            }
            if (link.Style == null)
            {
                link.Style = new DiagramLinkStyle();
            }
            DiagramLinkStyle style = link.Style as DiagramLinkStyle;
            style.Stroke = new SolidBrush(color);
            style.HeadStroke = new SolidBrush(color);
            style.Brush = new SolidBrush(color);
        }

   public static void RenderNode(this DiagramNode node, Color color)
        {
            if (node == null)
            {
                return;
            }


            node.Brush = new SolidBrush(color);
            node.Pen = new MPen(color);
        }

 



but The CPU at 50%

why? what kind of solution?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: the performance of diagramLinkStyle
Reply #1 - Jun 15th, 2015 at 5:41am
Print Post  
At what time can you see CPU at 50%?
  
Back to top
 
IP Logged
 
ricman400
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 4
Joined: Jun 15th, 2015
Re: the performance of diagramLinkStyle
Reply #2 - Jun 15th, 2015 at 5:46am
Print Post  
Stoyo wrote on Jun 15th, 2015 at 5:41am:
At what time can you see CPU at 50%?


When it was running the code.

you can test create 5000 nodes and links ,winform ,button click run this code .the result is cpu at 50%
My machine dual-core CPU,intel core I3
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: the performance of diagramLinkStyle
Reply #3 - Jun 15th, 2015 at 6:04am
Print Post  
If all of your nodes and links will be painted in same colors, you could avoid creating the thousands of style and brush objects. E.g. add a "DiagramLinkStyle linkStyle" field to your form and assign it to all links from the loop instead of calling DiagramLinkStyle and Brush constructors from each iteration. You could avoid these loops altogether if you set the default styles through the Diagram's DiagramLinkStyle and ShapeNodeStyle properties.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
ricman400
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 4
Joined: Jun 15th, 2015
Re: the performance of diagramLinkStyle
Reply #4 - Jun 16th, 2015 at 2:46am
Print Post  
Stoyo wrote on Jun 15th, 2015 at 6:04am:
If all of your nodes and links will be painted in same colors, you could avoid creating the thousands of style and brush objects. E.g. add a "DiagramLinkStyle linkStyle" field to your form and assign it to all links from the loop instead of calling DiagramLinkStyle and Brush constructors from each iteration. You could avoid these loops altogether if you set the default styles through the Diagram's DiagramLinkStyle and ShapeNodeStyle properties.

I hope that helps,
Stoyan


Thank you Stoyan,that helps
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint