Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Getting the custom shape (Read 3466 times)
jagdipa
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 52
Joined: Jun 23rd, 2011
Getting the custom shape
Jul 21st, 2011 at 1:38pm
Print Post  
I have created a custom library of shapes. For example, I have called one 'Plan' and its Id is 'plan'.

What I am trying to do is save these into a database. So I need to retrieve the Id.

My problem is, when I drag and drop the Plan and hit save, the codebehind always returns the Id as empty. How do I find out the type of shape? Is it using the Id, or using some other property?
  
Back to top
 
IP Logged
 
jagdipa
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 52
Joined: Jun 23rd, 2011
Re: Getting the custom shape
Reply #1 - Jul 21st, 2011 at 4:06pm
Print Post  
Okay, managed to find something.

In javascript, I can get the type of custom shape being added like this:


function onNodeCreated(sender, args)
{
alert(args.getNode().getShape().getId());
}

This gives the expected result - with an alert for 'plan'.

My problem is when I try to do the same thing in my code behind:

Dim shapenode As ShapeNode
For Each shapenode In DiagramView1.Diagram.Nodes

  'Get the shape type
Select Case shapenode.Shape.Id.ToLower
  Case "plan"
    .....
    Case "sequence"
    ......
  End Select

  .....

Next
End If

My problem is that I always received an Id of 'Rectangle' instead of 'Plan'.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Getting the custom shape
Reply #2 - Jul 21st, 2011 at 4:24pm
Print Post  
Hi,

The custom shapes will be available on the server only if you specify ShapeLibraryLocation as a relative / local path. If you have set a full http url as location, it can't be opened from the server, I think due to security limitations. In such case you will have to load the library on the server explicitly by calling ShapeLibrary.LoadFrom(local_path), e.g. from Page_Load.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
jagdipa
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 52
Joined: Jun 23rd, 2011
Re: Getting the custom shape
Reply #3 - Jul 22nd, 2011 at 8:25am
Print Post  
Hi Stoyo,

Thanks for that. I am able to get the correct shape Id now.

But, lets say I have the data in the database and I want to create the diagram from this. How do I set the shape to the custom shape:

Dim shapenode As ShapeNode = diagram.Factory.CreateShapeNode(50, 50, 24, 14)
shapenode.Shape = ??????????(should be plan)
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Getting the custom shape
Reply #4 - Jul 22nd, 2011 at 8:55am
Print Post  
Hi,

Set node.Shape = Shape.FromId(shapeId);

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
jagdipa
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 52
Joined: Jun 23rd, 2011
Re: Getting the custom shape
Reply #5 - Jul 22nd, 2011 at 10:14am
Print Post  
Hi Stoyo,

Thanks for your help. This is a brilliant product, and I am very close to getting authorisation to purchase it.

But I have more questions !!

Lets say I drag and drop three custom shapes (call them plans) onto the page. Do these three plans get Ids automatically assigned to them so that I can reference them through the code? At the moment the plans Ids are all coming back empty.

What I am trying to do is store the plans and links in a database. So I am trying to store the plan and, if it has any incoming links, the link's origin's shape Id. Since this shape Id is always empty, the reloading is coming back wrong.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Getting the custom shape
Reply #6 - Jul 22nd, 2011 at 11:08am
Print Post  
Hi,

There are no automatically generated ids, the Id property only lets you store custom data. You could either set it from onNodeCreated and onLinkCreated handlers, or assign identifiers while saving to the database for items that don't have an id yet. If you prefer to set ids on the client side, you can associate the max id value used so far with Diagram.Tag, increment it and assign it to each new item from the onCreated handler.

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