Page Index Toggle Pages: 1 [2]  Send TopicPrint
Hot Topic (More than 10 Replies) NetDiagram ImageMap mode-how to make nodes icons (Read 14234 times)
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: NetDiagram ImageMap mode-how to make nodes ico
Reply #15 - Aug 10th, 2011 at 3:41pm
Print Post  
It is clear now. I will look for a solution and get back to you soon.

Regards,
Meppy
  
Back to top
 
IP Logged
 
rlindabury
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 12
Joined: Aug 1st, 2011
Re: NetDiagram ImageMap mode-how to make nodes ico
Reply #16 - Aug 10th, 2011 at 4:15pm
Print Post  
Fantastic!  Thank you so much Meppy!
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: NetDiagram ImageMap mode-how to make nodes ico
Reply #17 - Aug 11th, 2011 at 6:23am
Print Post  
I was able to achieve the desired result using custom drawing of links. First, in order to prevent the default text from appearing, either set DiagramLink.Text to an empty string or DiagramLink.TextColor to Transparent. Then set the CustomDraw property of each link to CustomDraw.Additional. Finally, handle the Diagram.DrawLink event and use the following event handler:

Code
Select All
void diagram_DrawLink(object sender, DrawLinkEventArgs e)
{
      if (e.Shadow)
            return;
      if (e.Points.Count != 3)
            return;

      DiagramLink link = e.Link;
      string text = Convert.ToString(link.Tag);
      PointF at = e.Points[2];

      if (string.IsNullOrEmpty(text))
            return;
      if (link.Font == null)
            return;

      SizeF size = e.Graphics.MeasureString(text, link.Font);
      using (Brush textBrush = new SolidBrush(link.TextColor))
            e.Graphics.DrawString(text, link.Font, textBrush, at.X - size.Width / 2, at.Y - size.Height - 0.5f);
} 


Because the link's Text is now an empty string (to prevent its default rendering) the text of each link is supplied through the Tag parameter. In addition the event handler above expects that the link has at least three control points and renders the text above the third point.

I hope this helps.

Regards,
Meppy
  
Back to top
 
IP Logged
 
rlindabury
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 12
Joined: Aug 1st, 2011
Re: NetDiagram ImageMap mode-how to make nodes ico
Reply #18 - Aug 22nd, 2011 at 10:27pm
Print Post  
Meppy,

Thanks for the help!  This is how it looks!

https://s3.amazonaws.com/SwiftreachTesting/CallFlow_New.png

I still have some final touches to make so the text looks better but it works!

I appreciate the time you spent.

We'll be placing an order soon!

-- Bob
  
Back to top
 
IP Logged
 
rlindabury
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 12
Joined: Aug 1st, 2011
Re: NetDiagram ImageMap mode-how to make nodes ico
Reply #19 - Sep 2nd, 2011 at 4:37pm
Print Post  
Seems I have yet one more question.  As a designer and not a coder I'm having difficulty removing the shadow from the link text generated in the code below. I can remove the shadow from the whole diagram but that's not what I want. I'm also looking to make the text for those links bold.

Seems like no matter what I do I can't make any of the link text bold.  Here's the code so far:

[code]
       protected void DiagramView1_OnDrawLink(object sender, DrawLinkEventArgs e)
       {
           if (e.Shadow)
               return;

           DiagramLink link = e.Link;
           string text = Convert.ToString(link.Tag);
           PointF at = e.Points[2];

           if (string.IsNullOrEmpty(text))
               return;
           if (link.Font == null)
               return;
           
           SizeF size = e.Graphics.MeasureString(text, link.Font);
           using (Brush textBrush = new SolidBrush(link.TextColor))
               e.Graphics.DrawString(text, link.Font, textBrush, at.X - size.Width / 2, at.Y - size.Height - 0.5f);
       }
[/code]

Thanks in advance for the help yet again!
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: NetDiagram ImageMap mode-how to make nodes ico
Reply #20 - Sep 2nd, 2011 at 5:46pm
Print Post  
Our bad - that's a bug in the code that raises DrawLink, giving you incorrect e.Shadow value when actually called for drawing shadows. For the time being replace the e.Shadow condition with the following as a workaround:

if (e.Points != e.Link.ControlPoints)
     return;

This should draw bold text:

e.Graphics.DrawString(text, new Font(link.Font, FontStyle.Bold) ...);

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


I love YaBB 1G - SP1!

Posts: 12
Joined: Aug 1st, 2011
Re: NetDiagram ImageMap mode-how to make nodes ico
Reply #21 - Sep 2nd, 2011 at 8:53pm
Print Post  
Thanks! That worked!
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1 [2] 
Send TopicPrint