Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 10 Replies) Problem display ShapeNode as a custom shape, not working (Canvas Mode) (Read 7894 times)
CrushJelly
Junior Member
**
Offline


I Love MindFusion!

Posts: 59
Joined: Oct 20th, 2016
Problem display ShapeNode as a custom shape, not working (Canvas Mode)
Oct 24th, 2016 at 2:18pm
Print Post  
I try to draw ShapeNode, that has a custom Shape (ex . Rounded rectangle).

ShapeNode.Shape = new Shape(...);

It's not working, seems that every shape is picked from the Mindfusion library, I can't even adjust shapes size.

Doe's the trial version not allow to draw custom shapes or I am just missing something?

  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: Problem display ShapeNode as a custom shape, not working (Canvas Mode)
Reply #1 - Oct 25th, 2016 at 7:52am
Print Post  
It allows it, but in Canvas mode you must save custom shapes in a shape library file and assign it to the ShapeLibraryLocation property.

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
CrushJelly
Junior Member
**
Offline


I Love MindFusion!

Posts: 59
Joined: Oct 20th, 2016
Re: Problem display ShapeNode as a custom shape, not working (Canvas Mode)
Reply #2 - Oct 25th, 2016 at 2:59pm
Print Post  
Slavcho wrote on Oct 25th, 2016 at 7:52am:
It allows it, but in Canvas mode you must save custom shapes in a shape library file and assign it to the ShapeLibraryLocation property.

Regards,
Slavcho
Mindfusion


I created library and attached it. But it doesn't work, I tried to debug and I saw that it load the shape, but i just see plain old Rounded rectangle and not my custom rectangle.

My .cs code:

Code
Select All
diagramView.ShapeLibraryLocation = @"C:\Temp\test.shl";
ShapeNode shape = new ShapeNode();
shape.Shape = Shape.FromId("MyRectangle");
nodeListView.AddNode(shape, "Test");
 



Library:

Code
Select All
<?xml version="1.0" encoding="utf-8"?>
<shapes version="2">
  <shape id="MyRectangle" fill-mode="Winding" display-name="MyRectangle">
    <outline>
      <round-rectangle dash-style="Custom" width="-1" x="14" y="40" w="80" h="40" r="15" />
    </outline>
    <decorations />
    <shape-decorations />
    <enable-outline>True</enable-outline>
  </shape>
</shapes> 



And I'm adding picture of the diagram what I see.

I don't understand what is the problem.
  

Shape.PNG ( 11 KB | 183 Downloads )
Shape.PNG
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: Problem display ShapeNode as a custom shape, not working (Canvas Mode)
Reply #3 - Oct 26th, 2016 at 8:17am
Print Post  
Hi,

Set ShapeLibraryLocation from the aspx markup, assigning a relative url to it. Then DiagramView.OnInit will load the shape library automatically if MapPath can find the file (otherwise you'd need to call ShapeLibrary.LoadFrom(absolutePath) on server before using the shape). The URL is also transferred via JSON to let the client script load it automatically too, so you'll need to publish the file with your web server.

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
CrushJelly
Junior Member
**
Offline


I Love MindFusion!

Posts: 59
Joined: Oct 20th, 2016
Re: Problem display ShapeNode as a custom shape, not working (Canvas Mode)
Reply #4 - Oct 27th, 2016 at 8:04am
Print Post  
Slavcho wrote on Oct 26th, 2016 at 8:17am:
Hi,

Set ShapeLibraryLocation from the aspx markup, assigning a relative url to it. Then DiagramView.OnInit will load the shape library automatically if MapPath can find the file (otherwise you'd need to call ShapeLibrary.LoadFrom(absolutePath) on server before using the shape). The URL is also transferred via JSON to let the client script load it automatically too, so you'll need to publish the file with your web server.

Regards,
Slavcho
Mindfusion



Well I tried this method ShapeLibrary.LoadFrom(absolutePath) and in debug mode I see that it loads the shape outline template (look picture. 2).

But still I see just a plain old rectangle.

My code:

Code
Select All
ShapeLibrary.LoadFrom(@"C:\Temp\test.shl");

ShapeNode shape = new ShapeNode();
shape.Shape = Shape.FromId("MyEllipse"); // In debug mode I see that it loads
nodeListView.AddNode(shape, "MyEllipseNode");
 


  

1.PNG ( 7 KB | 190 Downloads )
1.PNG
2_004.png ( 28 KB | 194 Downloads )
2_004.png
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: Problem display ShapeNode as a custom shape, not working (Canvas Mode)
Reply #5 - Oct 27th, 2016 at 8:11am
Print Post  
This will be enough to show the shape only in ImageMap mode, which draws on server side. In Canvas mode you must set ShapeLibraryLocation to load shape definitions on client side too - you can assign a relative URL from aspx file to it, which will let you use the shapes both from client and server sides without having to call ShapeLibrary.load methods.

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
CrushJelly
Junior Member
**
Offline


I Love MindFusion!

Posts: 59
Joined: Oct 20th, 2016
Re: Problem display ShapeNode as a custom shape, not working (Canvas Mode)
Reply #6 - Oct 27th, 2016 at 8:50am
Print Post  
Slavcho wrote on Oct 27th, 2016 at 8:11am:
This will be enough to show the shape only in ImageMap mode, which draws on server side. In Canvas mode you must set ShapeLibraryLocation to load shape definitions on client side too - you can assign a relative URL from aspx file to it, which will let you use the shapes both from client and server sides without having to call ShapeLibrary.load methods.

Regards,
Slavcho
Mindfusion



Ok I did that, is this correct?,
If yes I still get the same result, it loads the template, but shoes rectangle, maybe I need to set some property

Code
Select All
<ndiag:DiagramView
                            ID="diagramView"
                            runat="server"
                            ClientSideMode="Canvas"
                            JsLibraryLocation="../../Scripts/MindFusion/MindFusion.Diagramming.js"
                            [b]ShapeLibraryLocation="~/Workflow/Designer/Dependencies/test.shl"[/b]
                            style="position: absolute; left: 201px; top: 0px; right: 0px; bottom: 0px;">
                            <Diagram GridStyle="Lines" AlignToGrid="True" ShowGrid="True" GridColor="#1B000000" GridSizeY="10" GridSizeX="10"></Diagram>
                        </ndiag:DiagramView>
 



  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: Problem display ShapeNode as a custom shape, not working (Canvas Mode)
Reply #7 - Oct 27th, 2016 at 10:47am
Print Post  
It seems recent versions of Visual Studio's web server do not serve shl-extension files, changing it to xml loads correctly for me -

Code
Select All
ShapeLibraryLocation="~/Workflow/Designer/Dependencies/test.xml" 



Also note that the coordinates in shape library specify percentage, so the shape fills only a portion of its bounding rectangle when you set Y and Height to 40.

Regards,
Slavcho
  

Untitled_019.png ( 20 KB | 186 Downloads )
Untitled_019.png
Back to top
 
IP Logged
 
CrushJelly
Junior Member
**
Offline


I Love MindFusion!

Posts: 59
Joined: Oct 20th, 2016
Re: Problem display ShapeNode as a custom shape, not working (Canvas Mode)
Reply #8 - Oct 27th, 2016 at 12:04pm
Print Post  
Slavcho wrote on Oct 27th, 2016 at 10:47am:
It seems recent versions of Visual Studio's web server do not serve shl-extension files, changing it to xml loads correctly for me -

Code
Select All
ShapeLibraryLocation="~/Workflow/Designer/Dependencies/test.xml" 



Also note that the coordinates in shape library specify percentage, so the shape fills only a portion of its bounding rectangle when you set Y and Height to 40.

Regards,
Slavcho



Cant you show me a snap of your ShapeNode creation code?, because it didn't work for me, I changed to xml, but nothing happend


  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: Problem display ShapeNode as a custom shape, not working (Canvas Mode)
Reply #9 - Oct 27th, 2016 at 12:57pm
Print Post  
I used your code but with different shape id, which was in shl file you posted above -

Code
Select All
var diagram = diagramView.Diagram;
if (!IsPostBack)
{
    ShapeNode shape = new ShapeNode();
    shape.Shape = Shape.FromId("MyRectangle"); // In debug mode I see that it loads
    nodeListView.AddNode(shape, "MyRectangle");
} 



Maybe also try to enter url to shape library in the browser to verify it's being served.

Regards,
Slavcho
  
Back to top
 
IP Logged
 
CrushJelly
Junior Member
**
Offline


I Love MindFusion!

Posts: 59
Joined: Oct 20th, 2016
Re: Problem display ShapeNode as a custom shape, not working (Canvas Mode)
Reply #10 - Oct 28th, 2016 at 8:24am
Print Post  
Slavcho wrote on Oct 27th, 2016 at 12:57pm:
I used your code but with different shape id, which was in shl file you posted above -

Code
Select All
var diagram = diagramView.Diagram;
if (!IsPostBack)
{
    ShapeNode shape = new ShapeNode();
    shape.Shape = Shape.FromId("MyRectangle"); // In debug mode I see that it loads
    nodeListView.AddNode(shape, "MyRectangle");
} 



Maybe also try to enter url to shape library in the browser to verify it's being served.

Regards,
Slavcho



Something must be different, because I changed shl file to xml, and the server serves the file, but still I see the same shape.

Maybe there are other settings that I need to set, do I need anything for the NodeListView?

Maybe it's the problem that I am using trial version?

  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3147
Joined: Oct 19th, 2005
Re: Problem display ShapeNode as a custom shape, not working (Canvas Mode)
Reply #11 - Oct 28th, 2016 at 12:12pm
Print Post  
Does it work if you add this script to the aspx file?

Code
Select All
<script type="text/javascript">
	Sys.Application.add_init(function ()
	{
		MindFusion.Diagramming.Shape.loadFromLibPending = true;
	});
</script> 



By looking at the code I think the NodeListView might not refresh correctly if it's defined before the DiagramView. If that's the problem really, that script should refresh it once the DiagramView's library loads.

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
CrushJelly
Junior Member
**
Offline


I Love MindFusion!

Posts: 59
Joined: Oct 20th, 2016
Re: Problem display ShapeNode as a custom shape, not working (Canvas Mode)
Reply #12 - Oct 28th, 2016 at 1:02pm
Print Post  
Slavcho wrote on Oct 28th, 2016 at 12:12pm:
Does it work if you add this script to the aspx file?

Code
Select All
<script type="text/javascript">
	Sys.Application.add_init(function ()
	{
		MindFusion.Diagramming.Shape.loadFromLibPending = true;
	});
</script> 



By looking at the code I think the NodeListView might not refresh correctly if it's defined before the DiagramView. If that's the problem really, that script should refresh it once the DiagramView's library loads.

Regards,
Slavcho
Mindfusion



It works! Thank you!

Yep, it didn't work because it was defined before DiagramView, but with a script it works without changing definition places, I tried changing the definition places and it worked without script.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint