Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Custom Shape Nodes (Read 6333 times)
charu
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 6
Joined: Jul 6th, 2009
Custom Shape Nodes
Jul 23rd, 2009 at 7:16am
Print Post  
Hi Stoyo,

For my application i need some custom node shapes which are outside of the predefined shapes. I tried making some using the shape designer. My problem is that I dont have any idea on how to use these. right now I am using the predefined nodes (in both XAML and C# code). I need to access their properties programatically since since they used for data binding , especially shapes.tag and shapes.Id.



I was wondering if there is a tutorial where I can see how to use this custom shape nodes in the application. Or if you can guide em how to use these .



Thank you very much

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Custom Shape Nodes
Reply #1 - Jul 23rd, 2009 at 7:29am
Print Post  
Hi Charu,

You could run the ShapeDesigner tool and press Ctrl+L to create a new library. Press Ctrl+N to create new shapes, and draw their elements on the canvas area to the left.

Right clicking on the shape elements on the left will let you insert new outline elements or toggle an element between a line and curve. Right clicking on an empty area will let you insert decoration elements - ones that do not affect fill and hit-testing.

Once you have drawn the shapes you need, press Ctrl+S to save to shape definition to a shape library file. Add the generated file to your project and in the properties pane set "Content" and "Copy if Newer". In your window_loaded handler call ShapeLibrary.LoadFrom("linrary.shl") and the shape definitions will be available for use in the application, you can access them by calling Shape.FromId().

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


I love YaBB 1G - SP1!

Posts: 6
Joined: Jul 6th, 2009
Re: Custom Shape Nodes
Reply #2 - Jul 24th, 2009 at 2:26am
Print Post  
Hi Stoyo,

Thank you very much for your help. Right now I am able to make custom node using the shape designer and have seen how to access it using Shape.FromId. However when I use it in the node list my code crashes.
Here is what I am doing.

SHAPE CODE-

Shape test = new Shape(
     new ElementTemplate[]
      {
           new LineTemplate(30, 100, 100, 100),
           new LineTemplate(100, 100, 70, 0),
           new LineTemplate(70, 0, 0, 0),
           new LineTemplate(0, 0, 30, 100)
      },
     new ElementTemplate[]
      {
           new LineTemplate(1, 3, 60, 60),
           new LineTemplate(59, 74, 80, 100)
      },null,
       FillRule.EvenOdd, "test");

I am calling it like this-
public Window1()
{
           
InitializeComponent();
         Shape test = new Shape(
     new ElementTemplate[]
      {
           new LineTemplate(30, 100, 100, 100),
           new LineTemplate(100, 100, 70, 0),
           new LineTemplate(70, 0, 0, 0),
           new LineTemplate(0, 0, 30, 100)
      },
     new ElementTemplate[]
      {
           new LineTemplate(1, 3, 60, 60),
           new LineTemplate(59, 74, 80, 100)
      },null,
       FillRule.EvenOdd, "test");
         nodeListView.Items.Add(Shape.Shapes.Equals(test.Id));

and XAML is-

<d:ShapeNode Shape="test" Bounds="2,2,25,25" Brush="DeepSkyBlue" d:NodeListView.Label="test" />


However this never shows up in my NodeList View and my application crash.

I would really appreciate if you can tell me what should i do to sort htis.

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Custom Shape Nodes
Reply #3 - Jul 24th, 2009 at 8:21am
Print Post  
This line of code adds a boolean to the list view, and that's not supported:

nodeListView.Items.Add(Shape.Shapes.Equals(test.Id));

You can add your custom shape like this:

nodeListView.Items.Add(new ShapeNode { Shape = test });

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


I love YaBB 1G - SP1!

Posts: 6
Joined: Jul 6th, 2009
Re: Custom Shape Nodes
Reply #4 - Aug 10th, 2009 at 7:50pm
Print Post  
Hi Stoyan,

Thankyou for the reply. It hepls.

Now I am able to add some of these shapes using
nodeListView.Items.Add(new ShapeNode { Shape = test }) to nodelist View control.

However I am not able to specify bounds. Also do i need to write a XAML code for this or this gets added automatically?

How can change its properties so that it can work as droppable on canvas?

Thanks,
Charu
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Custom Shape Nodes
Reply #5 - Aug 11th, 2009 at 6:43am
Print Post  
You could do that also from Xaml, but you have to make sure the custom shapes are loaded before the NodeListView. E.g. if the NodeListView is displayed in the main window, you could load the shapes in the MainWindow constructor before the InitializeComponent() call, or in the application's constructor. You can set the node's Bounds in Xaml as shown below.

Code
Select All
<Wpf:NodeListView Name="nodeListView">
	<Wpf:ShapeNode Text="node1" Bounds="10,0,20,30" Shape="Decision" />
	<Wpf:ShapeNode Text="node2" Bounds="0,0,30,30" Image= "{StaticResource img1}"  />
</Wpf:NodeListView>
 



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


I love YaBB 1G - SP1!

Posts: 6
Joined: Jul 6th, 2009
Re: Custom Shape Nodes
Reply #6 - Aug 24th, 2009 at 5:34am
Print Post  
Hi Stoyan,

I am sorry but none of things above are working for me Sad.
I have build the application absed on the flowcharter. I was wodering if I can send you the code which I hae modified and you can guide me how can I add custom shapes. Also, since I am binding with data using the tag property I hope it would be OK even if I use the custom shape nodes.

Can you please let me know email at which I can send it.

Thanks in advance and sorry to bother you.

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Custom Shape Nodes
Reply #7 - Aug 24th, 2009 at 10:00am
Print Post  
Hi,

You can send it to support@mindfusion.eu.

Stoyan
  
Back to top
 
IP Logged
 
charu
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 6
Joined: Jul 6th, 2009
Re: Custom Shape Nodes
Reply #8 - Sep 17th, 2009 at 1:01am
Print Post  
Hi Stoyan,

Thank you for your reply. I have sent my code on the support email yesterday.

Thanks.
Charu
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Custom Shape Nodes
Reply #9 - Sep 21st, 2009 at 2:47pm
Print Post  
Hi Charu,

I couldn’t build your application. This is a small sample project that defines two of the shapes in the PDF and adds them to the node listbox:
https://mindfusion.eu/_samples/wpfdiag_CustomNodesList.zip

You can then drag-and-drop them to the diagram canvas to create new nodes with the same shape.

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