Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 10 Replies) Difficulties with Custom Shapes (Read 7594 times)
sutek99
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 9
Joined: Jan 15th, 2008
Difficulties with Custom Shapes
May 1st, 2008 at 5:36pm
Print Post  
Hello,

I'm trying to create a custom shape in my code-behind and am having a great deal of difficuly. I found this sample code (from the help) and when I run it I am able to pull the pre-defined shape (using ShapeTemplate.FromId()), but second box just shows up as a regular old square every time instead of displaying the custom shape.

The only difference between the code from the example below and mine is that I use fc.CreateBox(x,y, w, h) instead of using boxes already in the flowchart.

What gives?

private void example_Click(object sender, System.EventArgs e)

{

Box box0 = fc.CreateBox(0,0, 200, 200);

Box box1 = fc.CreateBox(0, 250, 200, 200);



// use one of the predefined shapes

box0.Shape = ShapeTemplate.FromId("MultiDocument");



// create a custom shape

box1.Shape = new ShapeTemplate(

new ElementTemplate[] {

new LineTemplate( 0, 100, 60, 100),

new BezierTemplate( 60, 100, 80, 100, 100, 75, 100, 50),

new BezierTemplate(100, 50, 100, 25, 80, 0, 60, 0),

new LineTemplate( 60, 0, 0, 0),

new LineTemplate( 0, 0, 0, 100) },

FillMode.Winding);

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Difficulties with Custom Shapes
Reply #1 - May 1st, 2008 at 6:19pm
Print Post  
Hi,

With Flowchart.NET V4 you must set box.Style to BoxStyle.Shape in order to use custom shapes - have you done that?

Stoyan
  
Back to top
 
IP Logged
 
sutek99
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 9
Joined: Jan 15th, 2008
Re: Difficulties with Custom Shapes
Reply #2 - May 1st, 2008 at 7:31pm
Print Post  
My Box Object doesn't seem to have that property.  I get this compilation error....

Error5'MindFusion.Diagramming.WebForms.Box' does not contain a definition for 'Style' and no extension method 'Style' accepting a first argument of type 'MindFusion.Diagramming.WebForms.Box' could be found (are you missing a using directive or an assembly reference?)


Perhaps I don't have version 4?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Difficulties with Custom Shapes
Reply #3 - May 1st, 2008 at 8:16pm
Print Post  
So you are using our ASP.NET control? You must save all your customs shapes in a shape library file, and assign the URL to that file as a value of the ShapeLibraryLocation property. The applet downloads the shape definitions from the specified URL, and then you will be able to use custom shapes.

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


I love YaBB 1G - SP1!

Posts: 9
Joined: Jan 15th, 2008
Re: Difficulties with Custom Shapes
Reply #4 - May 1st, 2008 at 8:18pm
Print Post  
I don't understand, why would I have to save the shape in a shape file if I'm defining the ShapeTemplate at runtime as the code above shows?

box0 displays correctly, its the dynamically created box1 that does not.

Yes I am using the ASP.Net control.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Difficulties with Custom Shapes
Reply #5 - May 2nd, 2008 at 8:43am
Print Post  
That code sample will work only in Imagemap mode. As for applet mode, using a custom shape on the client-side involves creating a Java ShapeTemplate object equivalent to the .NET one on the server. Our developers decided that custom shapes will be created mostly through the shape designer tool and saved in shape-library files, and so far we haven't implemented any other way to transfer custom shape definitions to the applet. We'll try to do that for shapes defined in the code-behind in the next release.

Stoyan
  
Back to top
 
IP Logged
 
sutek99
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 9
Joined: Jan 15th, 2008
Re: Difficulties with Custom Shapes
Reply #6 - May 2nd, 2008 at 1:30pm
Print Post  
Okay Stoyan, that makes sense.  However it brings me to a new issue....

I set a number of properties via code-behind on the diagram such as enabling the grid, changing background colors, etc...

This works fine provided that I don't set ShapeLibraryLocation equal to anything in the tag. 

However, when I do set this value, I loose all of those settings and it defaults to the standard background, etc....

In addition if I try to add a shape programatically with code like:

box0.Shape = ShapeTemplate.FromId("Actor");

I don't get anything at all.

Can you explain how I can utilize the ShapeLibrary in this manner and keep my FlowChart settings and create that shape dynamically?

Thanks for your help!
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Difficulties with Custom Shapes
Reply #7 - May 2nd, 2008 at 2:56pm
Print Post  
This could happen if there is an exception thrown while the applet downloads the shape definitions. Can you see any exceptions shown in the Java console? To what value have you set the ShapeLibraryLocation?

Stoyan
  
Back to top
 
IP Logged
 
sutek99
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 9
Joined: Jan 15th, 2008
Re: Difficulties with Custom Shapes
Reply #8 - May 2nd, 2008 at 3:04pm
Print Post  
Sure enough, that was it!

I had the value set to "/Content/Diagram.shl" does the path have to be in a specific format?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Difficulties with Custom Shapes
Reply #9 - May 2nd, 2008 at 3:15pm
Print Post  
Try to add "." at the front of the string, or if it does not work - specify the full URL.

And what is the exception message? If it's something about security, you might have to keep the .shl file in the same folder where the .jar file is.

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


I love YaBB 1G - SP1!

Posts: 9
Joined: Jan 15th, 2008
Re: Difficulties with Custom Shapes
Reply #10 - May 2nd, 2008 at 4:01pm
Print Post  
Full URL worked like a charm thanks!  It's a little annoying that I have to specify the whole path, but it gets me over this one problem.

While I've got your attention, one quick unrelated question:

Is there any way to programaticaly access with javascript the Id value that shows up in the diagram's XML (<node id="X">)?  I have seen others track ID's in the Tag element, but then you have to do all of this cross-referencing when dealing with the links.  If I could get at the node's id at runtime it would greatly help.

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Difficulties with Custom Shapes
Reply #11 - May 4th, 2008 at 7:33am
Print Post  
The ID used in the diagram's XML is actually the value of the item's ZIndex property. You might also find this relation useful:

Flowchart.Objects[item.ZIndex] == item

holds true for each item in the flowchart. So by knowing that id / ZIndex, you can use it as an index in the Objects collection to get the corresponding item.

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