Page Index Toggle Pages: [1] 2  Send TopicPrint
Hot Topic (More than 10 Replies) Need Customized Node (Read 7285 times)
Anshul
Senior Member
****
Offline


I love YaBB 1G - SP1!

Posts: 316
Joined: Apr 3rd, 2009
Need Customized Node
Nov 30th, 2009 at 10:33am
Print Post  
Hi Stoyan ,

I have mailed the images regarding this on support mail ID.

Currently we are using node in "Figure1" format. Now we want format in "Figure2" format.

We are using following code for getting "Figure1" format.

textOnTheRight = new MindFusion.Diagramming.Wpf.Shape(
                Shapes.Rectangle.Outline,// reuse the rectangular shape
                null,// no decorations
                new ElementTemplate[]// define text region
                   {
                       new LineTemplate(25, 19, 90, 19),
                       new LineTemplate(90,19, 90, 79),
                       new LineTemplate(90, 79, 25, 80),
                       new LineTemplate(25, 79, 25, 19)
                   },
                    FillRule.EvenOdd,// doesn't matter here
                    "TextOnTheRight"// to access the shape later using Shape.FromId
                );

We want to access the "Target Region" Directly , so that we can set "target regions" background explicitaly.

Please suggest modified code for this.

Thanks and Regards,
Anshul
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Need Customized Node
Reply #1 - Nov 30th, 2009 at 12:36pm
Print Post  
Hi,

If all nodes in "figure 2" format will show that region in the same color, you could add filled ShapeDecoration objects to the Shape definition. For an example, see how the predefined BpmnIntermediateRule is defined here:

http://mindfusion.eu/_samples/BpmnIntermediateRule.txt

This won't let you change the ShapeDecoration color of individual nodes. If you need that, you will have to use custom-drawing or grouping to implement it.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Anshul
Senior Member
****
Offline


I love YaBB 1G - SP1!

Posts: 316
Joined: Apr 3rd, 2009
Re: Need Customized Node
Reply #2 - Nov 30th, 2009 at 1:21pm
Print Post  
Hi Stoyan,

In our Shape(Figure1) there is a ImageRectangle to display images and a TextArea to show text. As you can see by Figure two we want a region between this ImageRectangle and TextArea, It could be another imageRectangle or TextArea itself if possible.

We want to fill some forground color in this region that can be treated as foreground color of the ShapeNode.

1). Is it possible to have multiple TextArea/ImageRectangle in a single node?
2). If not, can we make a region like that so that this region can display some foreground color for that node?

Please suggest.

Regards,
Anshul
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Need Customized Node
Reply #3 - Dec 1st, 2009 at 7:09am
Print Post  
Hi,

1) It's not possible.
2) You could do that using a ShapeDecoration as shown in the code above. However this does not let you change the decoration color of individual nodes. If you need only a few distinct colors, you could create a Shape for each of them.

Consider using TableNodes for such kinds of shapes. Each table cell could display image, text or just show some fill color.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Anshul
Senior Member
****
Offline


I love YaBB 1G - SP1!

Posts: 316
Joined: Apr 3rd, 2009
Re: Need Customized Node
Reply #4 - Dec 1st, 2009 at 10:05am
Print Post  
Hi Stoyan,

If I want to use TableNode instead of Shapenode to achieve this.
1)How much efforts will be required for change?
2)And what will be the effect on performance?

Regards,
Anshul
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Need Customized Node
Reply #5 - Dec 1st, 2009 at 3:25pm
Print Post  
1) You will mostly have to replace assignments to ShapeNode properties with ones that assign to the properties of a specific cell in the table. If you set the table's ConnectionStyle to Table, connecting links to it will behave in the same way as for ShapeNodes (otherwise links connect to individual cells by default).

2) It shouldn't be much different if you show only a few cells in tables.

There are other ways to implement this, which might be easier if you already have a lot of code that relies on ShapeNodes. One is to create a helper node to show the fill color and attach it to the main node. Another one is to derive from ShapeNode and call DrawRectangle from the node.Draw override.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Anshul
Senior Member
****
Offline


I love YaBB 1G - SP1!

Posts: 316
Joined: Apr 3rd, 2009
Re: Need Customized Node
Reply #6 - Dec 2nd, 2009 at 5:04am
Print Post  
Hi Stoyan,

We already tried attached node , but we had performance issues related to that.

And other as you suggested.
"Deriving from ShapeNode and call DrawRectangle from the node.Draw override"

Could you please elaborate this?

Thanks and Regards,
Anshul.



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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Need Customized Node
Reply #7 - Dec 2nd, 2009 at 10:28am
Print Post  
Actually the easiest solution is to use some custom drawing. Set mainNode.CustomDraw = Additional, and in the DrawNode handler call e.Graphics.DrawRectangle to render a rectangle between the node's text and image.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Anshul
Senior Member
****
Offline


I love YaBB 1G - SP1!

Posts: 316
Joined: Apr 3rd, 2009
Re: Need Customized Node
Reply #8 - Dec 2nd, 2009 at 11:53am
Print Post  
Hi Stoyan,

I have tried this code to draw a rect but its not working.

Code
Select All
void diagram_DrawNode(object sender, DrawNodeEventArgs e)
	  {
		ShapeNode node = e.Node as ShapeNode;
		if (node != null)
		{
		    e.Graphics.DrawRectangle(Brushes.Black, new Pen(Brushes.Gray, 2), new Rect(node.Bounds.X , node.Bounds.Y, node.Bounds.Width / 10, node.Bounds.Height));
		}
	  } 



Please correct me if I am doing anything wrong.

Regards,
Anshul
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Need Customized Node
Reply #9 - Dec 3rd, 2009 at 9:13am
Print Post  
Hi Anshul,

You should specify local coordinates for the nodes. (0,0) is the top left corner. The last project you sent us had already had a DrawNode handler that renders several rectangles.

Stoyan
  
Back to top
 
IP Logged
 
Anshul
Senior Member
****
Offline


I love YaBB 1G - SP1!

Posts: 316
Joined: Apr 3rd, 2009
Re: Need Customized Node
Reply #10 - Dec 3rd, 2009 at 10:48am
Print Post  
Thanks Stoyan,

Can we change its foreground color(Brush) at runtime?

Regards,
Anshul
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Need Customized Node
Reply #11 - Dec 3rd, 2009 at 11:56am
Print Post  
Try calling node.Repaint(). This should repaint the node and raise the DrawNode event again.

Stoyan
  
Back to top
 
IP Logged
 
Anshul
Senior Member
****
Offline


I love YaBB 1G - SP1!

Posts: 316
Joined: Apr 3rd, 2009
Re: Need Customized Node
Reply #12 - Dec 3rd, 2009 at 1:59pm
Print Post  
Thanks Stoyan.

However the event(diagram_DrawNode) is called every time we mouse over the node. We want it only to be called initially when nodes are created and when we call node.Repaint().

Please suggest on this.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Need Customized Node
Reply #13 - Dec 3rd, 2009 at 2:35pm
Print Post  
It will be raised every time the node appearance changes, and in your case it is probably raised because of the changes you are doing in the MouseEnter event handler. What's wrong with the event being raised anyway - the node will always be repainted in such cases, even if you are not custom-drawing it.
  
Back to top
 
IP Logged
 
Anshul
Senior Member
****
Offline


I love YaBB 1G - SP1!

Posts: 316
Joined: Apr 3rd, 2009
Re: Need Customized Node
Reply #14 - Dec 8th, 2009 at 10:16am
Print Post  
Hi Stoyan,

We want to display an Image at LeftCenter of the node. It should be placed such that half image should be inside the node and half image should be outside the node.

We have tried following code to acheive this.

e.Graphics.DrawImage(img, new Rect(-6,6,18,18 ));

By this, we are getting image at LeftCenter but only half image is displaying inside the node(right portion of the image), it is getting cut by the node border.

Please suggest how we can get full image at LeftCenter(half inside the node, half outside the node).


Regards,
Anshul
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: [1] 2 
Send TopicPrint