Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic How to color total shape when Elements templates are used in it (Read 8386 times)
Chetna Tumme
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 10
Joined: Nov 28th, 2012
How to color total shape when Elements templates are used in it
Dec 11th, 2012 at 6:50am
Print Post  
I have created a Shape as follows:
var shape = new Shape(
new ElementTemplate[]
{
new LineTemplate(3, 27, 95, 27),
new LineTemplate(95, 27, 95, 100),
new LineTemplate(95, 100, 3, 100),
new LineTemplate(3, 100, 3, 27)
},
new ElementTemplate[]
{
new LineTemplate(17, 15, 107, 15),
new LineTemplate(107, 15, 107, 88),
new LineTemplate(3, 27, 17, 14),
new LineTemplate(107, 15, 95, 27),
new LineTemplate(106, 88, 95, 100)
},
null,
FillRule.EvenOdd, "Node");

and then assigned to to ShapeNode & added into the diagram:
var shapeNode = new ShapeNode
{
Shape = shape,
Bounds = new Rect(60, 60, 50, 50),
Name = "Node",
Text = "Node",
Brush = new SolidColorBrush(){Color = Colors.Magenta}
};
mindFusionDiagram.Nodes.Add(shapeNode);

My issue is as Follows:---
1. When there are two Element Template []in shape constructor, I think those many regions are created.
2. When I try to color the ShapeNode, only one Rectangle gets colored, other part remians white.

Please let me know the issue in my code or the solution to it as soon as possible.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to color total shape when Elements templates are used in it
Reply #1 - Dec 11th, 2012 at 8:12am
Print Post  
The second array contains so called decoration lines, which are not parts of the shape outline and are drawn independently from each other. Rearrange the arrays a bit to move most of the elements to the outline and leave only three internal lines as decorations:

Code
Select All
var shape = new Shape(
    new ElementTemplate[]
        {
            new LineTemplate(3, 27, 3, 100),
            new LineTemplate(3, 100, 95, 100),
            new LineTemplate(95, 100, 107, 88),
            new LineTemplate(107, 88, 107, 15),
            new LineTemplate(107, 15, 17, 15),
            new LineTemplate(17, 15, 3, 27)
        },
        new ElementTemplate[]
        {
            new LineTemplate(3, 27, 95, 27),
            new LineTemplate(95, 27, 95, 100),
            new LineTemplate(95, 27, 107, 15)
        },
    null,
    FillRule.EvenOdd, "Node"); 



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


I Love MindFusion!

Posts: 10
Joined: Nov 28th, 2012
Re: How to color total shape when Elements templates are used in it
Reply #2 - Dec 11th, 2012 at 9:00am
Print Post  
Hello Stoyan,
your solution hepled a lot. But one thing I am confused about is,

1. WHat is the use of two Element Templates in Shape...
Because I am facing issue in applying dash style in to Line Template in First Element Template of Shape constructor.

Where as Line Template in Second Template gets applied in correct ways.


2. Second issue is, now we had all Line templates in Element Templates. But what if I have Round Rect in first Element Template, and second Element Template contains Line Templates.
Then how I can draw the bounderies...
My shape of "Device" is as follows...
var shape = new Shape(
                        new ElementTemplate[]
                            {
                                new RoundRectangleTemplate(3, 2, 100, 100, 6f),
                                new LineTemplate(2, 116, 103, 116),
                                new LineTemplate(103, 116, 89, 102),
                                new LineTemplate(1, 116, 15, 102)
                            },
                        new ElementTemplate[]
                            {
                                new LineTemplate(2, 116, 103, 116),
                                new LineTemplate(103, 116, 89, 102),
                                new LineTemplate(1, 116, 15, 102)
                            },
                        null,
                        FillRule.Nonzero, "Device");

Please tell me how I can create the shape.. Because in above shape, color given was applied only to Round Rect and not to below part.

Please see into it.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to color total shape when Elements templates are used in it
Reply #3 - Dec 11th, 2012 at 11:39am
Print Post  
1. The first array is used to specify the node's outline / contour, which is considered the main part of the node and is used for hit-testing, aligning links to it, etc. It's also the part filled using the node's Brush. The second array defines decoration lines; they are not considered when hit-testing and are drawn independently from each other; they won't be filled even if the array defines a closed figure. There's an optional third array that can be specified to define text area; if you omit it, the text is drawn inside the outline area defined through first array. You can also specify additional filled figures via the ShapeDecoration arrays accepted by some overloaded Shape constructors.

2. The outline array should specify a closed figure, try the code below:

Code
Select All
new Shape(
            new ElementTemplate[]
            {
                        new LineTemplate(10, 0, 90, 0),
                        new ArcTemplate(80, 0, 20, 20, -90, 90),
                        new LineTemplate(100, 10, 100, 90),
                        new ArcTemplate(80, 80, 20, 20, 0, 90),
                        new LineTemplate(90, 100, 80, 100),
                        new LineTemplate(80, 100, 100, 115),
                        new LineTemplate(100, 115, 0, 115),
                        new LineTemplate(0, 115, 20, 100),
                        new LineTemplate(20, 100, 10, 100),
                        new ArcTemplate(0, 80, 20, 20, 90, 90),
                        new LineTemplate(0, 90, 0, 10),
                        new ArcTemplate(0, 0, 20, 20, 180, 90)
            },
            null, null,
            FillRule.Nonzero, "Device"); 



Add a single decoration line as second argument if you need to delimit the round rectangle from the base figure.

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


I Love MindFusion!

Posts: 10
Joined: Nov 28th, 2012
Re: How to color total shape when Elements templates are used in it
Reply #4 - Dec 11th, 2012 at 11:48am
Print Post  
Thanks a lot Stoyan for your solution.
  
Back to top
 
IP Logged
 
Chetna Tumme
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 10
Joined: Nov 28th, 2012
Re: How to color total shape when Elements templates are used in it
Reply #5 - Dec 11th, 2012 at 12:30pm
Print Post  
Hello Stoyan,

I really need help in creating shape as there in attached file.
Please reply asap.
  

circles.png (Attachment deleted)
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How to color total shape when Elements templates are used in it
Reply #6 - Dec 11th, 2012 at 1:04pm
Print Post  
Code
Select All
var shape = new Shape(
        new ElementTemplate[]
        {
            new ArcTemplate(0, 0, 60, 100, -62, 360),
            new ArcTemplate(40, 0, 60, 100, -118, 360),
        },
        FillRule.Nonzero, "Circles"); 



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