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


I love YaBB 1G - SP1!

Posts: 12
Joined: Aug 1st, 2011
NetDiagram ImageMap mode-how to make nodes icons
Aug 1st, 2011 at 9:24pm
Print Post  
I'm working with NetDiagram Trial Version in ClientSideMode="ImageMap" using ImageGen.aspx.

What we want to do is style the nodes.  We either want to load the Shapenodes from bitmaps (.png) and then write text on them or somehow insert icons into rectangular nodes and then write node text on them.

We're simply looking to make the nodes look more graphically pleasing for our application instead of straight shape nodes.

We are using ImageMap mode so that users do not have to download/use a java app, silverlight or anything else.

Is there some way I can design some .png graphics or something like that and use those?

Thanks!

-- Bob
  
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 #1 - Aug 2nd, 2011 at 6:35am
Print Post  
You need to add the images to a folder in your project. Let's assume that the image you want to use is named '0.png' and this image is located in a folder 'Images' in your project. Let's also assume that your DiagramView is identified by the view variable. Then the following code creates a new node on the server side using the above image as appearance:

Code
Select All
ShapeNode node = view.Diagram.Factory.CreateShapeNode(50, 50, 20, 20);
node.Transparent = true;
node.Image = new Bitmap(MapPath(@"Images/0.png"));
node.ImageAlign = MindFusion.Drawing.ImageAlign.Center;
node.Text = "Some text"; 


Let me know if 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 #2 - Aug 2nd, 2011 at 4:48pm
Print Post  
That helped tremendously but when I load the 64x64 pixel image that I create into the node, it displays much larger than 64x64 pixels. We tried using another method to resize the image (the commented out line of code in the code below) but when you click on the node, the png image background turns black is no longer transparent like it's supposed to be.

Also, how do I place the node text precisely where I want it in the node?

Here's the code:

[code]
//n.Image = new Bitmap(System.Drawing.Image.FromFile(MapPath(@"CallFlowImages/CallFlow_Node_WIP01.png")), new Size(64, 64));
ShapeNode n = DiagramView1.Diagram.Factory.CreateShapeNode(0, 0, 81, 51);
n.Image = new Bitmap(MapPath(@"CallFlowImages/CallFlow_Node_WIP01.png"));
n.ImageAlign = MindFusion.Drawing.ImageAlign.TopLeft;
n.Transparent = true;

n.PolygonalTextLayout = true;
n.EnableStyledText = true;

n.Text = "<b><i> Call Answered </i><b>";
//TODO: store our internal CALL FLOW NODE ID in the ID field of the node
n.Id = "Call_Answered";
[/code]
  
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 #3 - Aug 2nd, 2011 at 8:21pm
Print Post  
What we're doing is working with Netdiagram to create a web-based, interactive call flow system for our customers.

We're currently working with the trial version and evaluating it.  We plan on purchasing if we can get past some of these issues. I'm the designer and my partner is the coder.  So, I'm trying to figure things out the best I can. Smiley

A customer uses this part of the system to create a call flow for an incoming call by clicking on nodes and making selections from the modal popups.  It's not your typical use but it seems like it will work for our purpose. 

Here are some images to help show the issues. Smiley

Image one is what happens when I load my PNG file using a straight load like your example.  The PNG graphic is larger than it really is when displayed.

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

The next image shows us using the code that set a "new Size(230, 143)" which is the actual size of the PNG bitmap.

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

As you can see the above image shows the PNG file at the size it's actually supposed to be.

Now the last image shows what happens when the diagram refreshes.  In this case I clicked on the node and it pops up my modal popup with options for that node type.

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

As you can see, the image now loses it's alpha channel and the transparent part of the PNG is shown as black.

I probably just need a little push in the right direction. Smiley

Thanks!

-- Bob
  
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 #4 - Aug 3rd, 2011 at 7:10am
Print Post  
1. The node size should be irrelevant when the ImageAlign is set to Center (as it is in my code) or TopLeft (as it is in yours). The node size should matter only when the ImageAlign is set to Stretch or Fill. What's more, the size of the node is expressed in the current units of measure (which by default is Millimeters). Thus if you set 230x143 as the size of the node, it is interpreted as mm instead of pixels. As you can see in one of your images, the node is actually larger than the image displayed within. It looks like the node on the first image has its ImageAlign set to Stretch.

To make the size of the node match exactly the physical dimensions of the image, use the code below. The current unit of measure is taken into consideration.

Code
Select All
PointF a = fc.ClientToDoc(new Point(0, 0));
PointF b = fc.ClientToDoc(new Point(node.Image.Width, node.Image.Height));
node.Bounds = new RectangleF(node.Bounds.X, node.Bounds.Y, b.X - a.X, b.Y - a.Y); 


Note, that when the node and image sizes are the same, the image alignment will be irrelevant.

2. To position the text of the node more precisely, you can use a custom shape with defined text area. Text areas are specified in coordinates relative to the bounding rectangle of the node. Here is a text area which occupies the rectangle (Left: 10%, Top: 10%, Right: 50%, Bottom: 30%):

Code
Select All
node.Shape = new Shape(
      null,
      null,
      new ElementTemplate[]
      {
            new LineTemplate(10, 10, 50, 10),
            new LineTemplate(50, 10, 50, 30),
            new LineTemplate(50, 30, 10, 30),
            new LineTemplate(10, 30, 10, 10),
      },
      System.Drawing.Drawing2D.FillMode.Winding, "myShape"); 


3. The background transparency getting lost between postbacks is related to the PNG encoder installed on the computer. A possible workaround would be to reassign the images after postback. You can also check this topic: http://mindfusion.eu/Forum/YaBB.pl?board=fcnet_disc;action=display;num=116366417....

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 #5 - Aug 3rd, 2011 at 2:27pm
Print Post  
Ok.. what is "fc" in your "fc.CLientToDoc"? Is that the diagram?
  
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 #6 - Aug 3rd, 2011 at 2:50pm
Print Post  
This is the DiagramView object.

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 #7 - Aug 3rd, 2011 at 3:00pm
Print Post  
Thanks! I did figure that out. One last thing, what would my shape coordinates be if I wanted Top 20%, Left 10%, Right 90%, Bottom 80%?

Thanks!

Nevermind, I figured it out.  Made the top 30%.

new LineTemplate(10, 30, 90, 30),
new LineTemplate(90, 30, 90, 80),
new LineTemplate(90, 80, 10, 80),
new LineTemplate(10, 80, 10, 30),

Thanks again!
  
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 #8 - Aug 3rd, 2011 at 3:16pm
Print Post  
If you are asking about the coordinates of the text area in your custom shape, they will correspond exactly to those numbers since text area coordinates are expressed as percents:

Code
Select All
...
new ElementTemplate[]
{
      new LineTemplate(10, 20, 90, 20),
      new LineTemplate(90, 20, 90, 80),
      new LineTemplate(90, 80, 10, 80),
      new LineTemplate(10, 80, 10, 20),
},
... 


The above code will define a text area inside the node with top and bottom margins equal to 20% of node's height and left and right margins equal to 10% of node's width.

Regards,
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 #9 - Aug 3rd, 2011 at 3:16pm
Print Post  
Ah, way to go!
  
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 #10 - Aug 8th, 2011 at 8:24pm
Print Post  
Ok.. next question. Smiley

I have a batch of nodes that are created by the user as they make selections on some drop-downs and select Apply.  These nodes are Keypress Options for a phone keypad. So, they can select actions for keypress number 0-9 and a default time-out action.

The below graphic shows nodes created using the modal popup. 

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

We wish to show the option numbers on the treeview but we want the text centered over the arrows pointing to the nodes.

I still haven't figured out how to make that happen. Smiley

Thanks for the help in advance!
  
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 #11 - Aug 9th, 2011 at 7:30am
Print Post  
As far as I can see on your image, the texts of the links are centered. Can you elaborate on "the text centered over the arrows" part? If you want the texts to be displayed on top of the link contour, you can set the DiagramLink.TextStyle property to OverLongestSegment. Other than that, you can employ custom drawing to position the text of the link exactly where you want it.

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 #12 - Aug 9th, 2011 at 6:13pm
Print Post  
The words Option 0, Option 2, Option 5 and Time-Out need to be centered over the corresponding DOWN arrows. They are in the correct position vertically but not horizonatally.

That's what we're looking for.

I'll keep fiddling with it but maybe you know a way to make that happen.

Thanks!
  
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 #13 - Aug 10th, 2011 at 5:40am
Print Post  
Can you provide me with a picture of what you want to achieve? These text appear exactly in the middle of the arrows (horizontally) to me.

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 #14 - Aug 10th, 2011 at 1:08pm
Print Post  
Here is where I want the text to be:

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

The text in question is highlighted in yellow in the diagramview.  I've moved the text in the graphic to show where I want it.

Below that in the overview, the red dots show where the text should be centered.

Thanks!
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: [1] 2 
Send TopicPrint