Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 10 Replies) How do I get a list of shapes? (Read 7565 times)
jagdipa
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 52
Joined: Jun 23rd, 2011
How do I get a list of shapes?
Jun 23rd, 2011 at 2:24pm
Print Post  
I am new to this, and just trying to test the controls for a project.

I have managed to get a diagram on the page, and I am able to create shapes or links.

What I would like to do is have a list of shapes, and the user selects the shape he wants from this list. So I click on the little blue arrow on the diagram, and select Add Extenders. From here, I add a ShapeListBox extender.

When I run this, I get the following error (I have pasted only the first 3 lines):
[NullReferenceException: Object reference not set to an instance of an object.]
MindFusion.Diagramming.WebForms.ShapeListBoxExtender.GetScriptDescriptors(Contro
l targetControl) +303
System.Web.UI.ExtenderControl.System.Web.UI.IExtenderControl.GetScriptDescriptor
s(Control targetControl) +10
System.Web.UI.ScriptControlManager.RegisterScriptDescriptors(IExtenderControl extenderControl) +232



Here is my source code. Can someone help me?


<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>



<ndiag: DiagramView ID="diagView" runat="server" Height="500px" Width="750px"


Behavior="DrawShapes"


AllowInplaceEdit="true"


LinkCreatedScript="onLinkCreated"


LinkCreatingScript="onLinkCreating" DelKeyAction="DeleteSelectedItems">


<Diagram BackBrush="s:#FFFFFFFF"


LinkHeadShape="Triangle"


AllowUnconnectedLinks="True" />

</ndiag: DiagramView>




<ndiag:ShapeListBoxExtender ID="diagView_ShapeListBoxExtender"

runat="server" TargetControlID="diagView" />




<asp:Button ID="btnLayout" runat="server" Text="Layout" Width="200px" />



<asp:Button ID="btnExportPdf" runat="server" Text="Export PDF" Width="200px" />


<asp:HiddenField ID="pdfURL" runat="server" />



<asp:Label ID="lblTest" runat="server"></asp:Label>


<script>

function onLinkCreated(diagram, args)
{
/*var scriptHelper = < %= diagView.AppletElement % >.getScriptHelper();

// get info about the DiagramLink just created
var link = args.getLink();
var points = link.getControlPoints();
var destPoint = points.get(points.size() - 1);

// create a new ShapeNode
var destNode = diagram.getFactory().createShapeNode(

destPoint.getX() - 12, destPoint.getY() - 7, 24, 14);
destNode.setText("node " + diagram.getNodes().size());
destNode.setBrush(scriptHelper.createSolidBrush(170, 210, 240));

// connect the link to the node and set its properties
link.setDestination(destNode);
link.setDynamic(true);
link.setAllowMoveStart(false);
link.setAllowMoveEnd(false);
link.setBrush(scriptHelper.createSolidBrush(220, 240, 250));*/
}

function onLinkCreating(diagram, args)
{/*
var link = args.getLink();
var origin = args.getOrigin();

// allow links start only from ShapeNodes
if (!origin.getClass().toString().match("ShapeNode"))

args.cancelDrag();*/
}

function onLoad()
{/*
var url = document.getElementById("pdfUrl");
if (url.value != "")
{

window.open(url.value);

url.value = "";
}*/
}

</script>

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How do I get a list of shapes?
Reply #1 - Jun 23rd, 2011 at 2:56pm
Print Post  
You must use a ShapeListBox control for that and set the extender's TargetControlID to the id of that control.

Also note that the Script events you have on the page will be raised only in Java mode. Image map mode supports only mouse click and hover events on the client side.

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: How do I get a list of shapes?
Reply #2 - Jun 23rd, 2011 at 3:12pm
Print Post  
Hi Stoyo,

Thank you for the reply. From the code I posted, you can see that the TargetControlID has been set to the id of the DiagramView control.

I am trying to get this working in Java as I believe this is the one that looks and works the best.

So I am still stuck, and not sure what I am doing wrong.
  
Back to top
 
IP Logged
 
jagdipa
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 52
Joined: Jun 23rd, 2011
Re: How do I get a list of shapes?
Reply #3 - Jun 23rd, 2011 at 3:29pm
Print Post  
Okay, I found out what I was doing wrong.

I was adding a ShapeListBoxExtender when I should have been adding a ShapeListBox !!

Next question is, how do I get the list to be displayed horizontally?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How do I get a list of shapes?
Reply #4 - Jun 23rd, 2011 at 5:50pm
Print Post  
There's no property in the server-side component for setting the listbox orientation, but it seems the base JList Java class supports some kind of horizontal orientation. Try calling this from the AppletStartedScript on the client:

shapeList.setVisibleRowCount(1);   
shapeList.setLayoutOrientation(2 /*JList.HORIZONTAL_WRAP*/);   

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: How do I get a list of shapes?
Reply #5 - Jun 27th, 2011 at 9:31am
Print Post  
Hi Stoyan,

Thank you for your help. Is the following code correct? I just cant get it to work.



    <ndiag:ShapeListBox ID="ShapeListBox1" runat="server" name="ShapeListBox1Name"
     AppletStartedScript="onAppletStarted"
       style="background-color: white" >
    </ndiag:ShapeListBox>


    <ndiag:DiagramView ID="diagView" runat="server" Height="500px" Width="750px"
           Behavior="DrawLinks"
           AllowInplaceEdit="true"
           DelKeyAction="DeleteSelectedItems">
           <Diagram BackBrush="s:#FFFFFFFF"
               LinkHeadShape="Triangle"
               AllowUnconnectedLinks="True" />
       </ndiag:DiagramView>




<script type="text/javascript">

       function onAppletStarted() {
           var shapeList = <%= ShapeListBox1.AppletElement %>;
           
           shapeList.setVisibleRowCount(1);
           shapeList.setLayoutOrientation(2 /*JList.HORIZONTAL_WRAP*/);   
       }
    </script>
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How do I get a list of shapes?
Reply #6 - Jun 27th, 2011 at 10:33am
Print Post  
Hi,

This should work:

Code
Select All
var applet = <%= shapeList.AppletElement %>;
var shapeList = applet.getShapeListBox();
shapeList.setVisibleRowCount(1);
shapeList.setLayoutOrientation(2 /*JList.HORIZONTAL_WRAP*/);
 



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: How do I get a list of shapes?
Reply #7 - Jun 28th, 2011 at 8:43am
Print Post  
Thanks Stoyan,

I still have a load of stuff to do with this and I appreciate the help.

Rather than ask every single question I have, I was wondering whether you could teach me how to find this information out.

For example, my next task is to make it so that, when the user adds a shape and creates a link, the diagram should automatically refresh the layout to a FlowChartLayout.

How would you go about looking at the help file and finding out which javascript and vb.net function to use to get this behaviour? How do you know what to pass into this function?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: How do I get a list of shapes?
Reply #8 - Jun 28th, 2011 at 10:33am
Print Post  
You will need this version of the jar file for running FlowchartLayout:
https://mindfusion.eu/_temp/applet_flowcharthelper.zip

It adds a ScriptHelper.createFlowchartLayout method that you could use like this:
Code
Select All
function onLinkCreated(sender, args)
{
	var applet = <%= diagramView.AppletElement %>;
	var diagram = applet.getDiagram();
	var script = applet.getScriptHelper();

	var layout = script.createFlowchartLayout();
	layout.arrange(diagram);
} 



As for when to call what member, check the Tutorial, PdfExporter and OrgBrowser sample projects. They show how to handle events and apply layouts in Java mode.

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


I love YaBB 1G - SP1!

Posts: 5
Joined: Aug 5th, 2011
Diagram is not editable but can select shape ?
Reply #9 - Aug 10th, 2011 at 6:12am
Print Post  
Hi Stoyo

1)diagram view is not editable(using mouse anybody can draw a flowchart it is not possible how to do)  and flowchart diagram also is also not editable(like size of shape is fixed,not move shapes) but can select ashape.

bottom point is  flowchart is only see by user can select perticuler shape but cant edit diagram and cant draw shape  using mouse in   diagramview


Its urgent...
please help me

Thanks
Anjana
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: How do I get a list of shapes?
Reply #10 - Aug 10th, 2011 at 7:47am
Print Post  
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint