Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Composite node - Some Questions ... (Read 4280 times)
moelski
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 50
Joined: Feb 28th, 2011
Composite node - Some Questions ...
May 15th, 2011 at 6:40pm
Print Post  
Hi !

At the moment we are testing with the table nodes. But to create more powerful and customized nodes we want to switch to composite nodes (as you suggest us).

So here are some questions about that:
1) Is there a way to place an AnchorPoint within a GridPanel and not with absolute positions?
2) Is it possible to enrich a composite node after its creation?
We need several Output AnchorPoints at a composite node. In some cases we need to increase or decrease the number of AnchorPoints for a node. Is this possible?

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Composite node - Some Questions ...
Reply #1 - May 16th, 2011 at 6:51am
Print Post  
Hi,

1) You will have to inherit from ConnectionPoint and override its GetAnchor and GetAnchorPos methods to implement link alignment to anchor points. Then override CompositeNode.CreateConnectionPoint to return an instance of the connection class, and DrawAnchors to draw the anchor points where you want them relatively to the grid.

2) You could either add the points dynamically to the AnchorPattern object, or implement a different AnchorPattern for each cell in your grid (similar to TableNodes' rows) and have the custom ConnectionPoint class detect which one to use.

Another possibility is to directly set the links' first and last points in ControlPoints in response to some events instead of relying on AnchorPoints.

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


I love YaBB 1G - SP1!

Posts: 50
Joined: Feb 28th, 2011
Re: Composite node - Some Questions ...
Reply #2 - May 16th, 2011 at 8:16am
Print Post  
Hi Stoyan,

Quote:
Another possibility is to directly set the links' first and last points in ControlPoints in response to some events instead of relying on AnchorPoints

That´s a good point for starting. And I think it´s easier to implement.

Actually I´m using this code to create my testnodes:
Code
Select All
	  static public CompositeNode EntityCompCreate(Diagram diagram, ImageList images, string EntityName)
	  {
		string content = @"
	<SimplePanel>

	  <Shape Name=""Shape"" Shape=""Rectangle"" />

	    <Border Padding=""2"">
		<GridPanel>
		    <GridPanel.Rows>
			<GridRow Height=""5"" />
		    </GridPanel.Rows>
		    <GridPanel.Columns>

			  <GridColumn Width=""10"" />

			<GridColumn Width=""Auto"" />
		    </GridPanel.Columns>
<Border Name=""myBorder"" Padding=""1"" Background=""#808000"">
		    <Text Text=""Hello world!"" TextColor=""Green""  GridColumn=""1""/>
 </Border>
		</GridPanel>
	  </Border>

	</SimplePanel>";

		CompositeNode node = new CompositeNode(diagram);
		node.Bounds = new RectangleF(10, 10, 60, 10);
		node.Components.Add(XmlLoader.Load(content));
		node.Brush = new LinearGradientBrush(Color.RoyalBlue, Color.LightSkyBlue, 45);

		diagram.Nodes.Add(node);

		return node;
	  }
 



If I create two of these nodes in my diagram.
But I´m not able to wire them with the mouse.

So what must I do in order to do this with the mouse:
Code
Select All
diagram1.Factory.CreateDiagramLink(node1, node2) 



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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Composite node - Some Questions ...
Reply #3 - May 16th, 2011 at 10:13am
Print Post  
Hi,

I was able to draw links between such nodes with all settings at their default values. Check if you are not stopping the draw operation from LinkCreating handler, or if you haven't set AllowUnanchoredLinks to false.

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


I love YaBB 1G - SP1!

Posts: 50
Joined: Feb 28th, 2011
Re: Composite node - Some Questions ...
Reply #4 - May 17th, 2011 at 12:46pm
Print Post  
Hi !

Quote:
or if you haven't set AllowUnanchoredLinks to false

That was the trick ...

Can you give me a short hint for designing the GridPanel? I need something like this:
Code
Select All
--------
|HEADER|
--------
|T|GR|T|
--------
 


Header is a Text, T is a small Text ("In", "Out") and GR is a small Graphic.

But actually I´m a little bit confused how to use the Gridpanel - especially how to design the columns and rows.

I tried this for the |T|GR|T| Part but that would show nothing:
Code
Select All
		string content = @"
	<SimplePanel  Width=""30"" Height=""30"">
		<StackPanel Orientation=""Horizontal"">
		  <Text Name=""IN"" Font=""Arial, 8pt, style=Bold"" TextAlignment=""Near"" />
		  <Text Name=""FullName"" TextColor=""Blue"" TextAlignment=""Near"" />
		  <Text Name=""OUT"" Font=""Arial, 8pt"" TextAlignment=""Near"" />
		</StackPanel>
	</SimplePanel>"; 



???
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Composite node - Some Questions ...
Reply #5 - May 17th, 2011 at 2:45pm
Print Post  
Here is the code which will help you achieve your goal:

Code
Select All
<SimplePanel>
      <Border Background=""LightSteelBlue"" Pen=""DarkBlue"" />
      <GridPanel>
            <GridPanel.Columns>
                  <GridColumn />
            </GridPanel.Columns>
            <GridPanel.Rows>
                  <GridRow />
                  <GridRow />
            </GridPanel.Rows>

            <Text Text=""Header"" TextAlignment=""Center"" />

            <GridPanel GridRow=""1"">
                  <GridPanel.Columns>
                        <GridColumn Width=""10"" />
                        <GridColumn />
                        <GridColumn Width=""10"" />
                  </GridPanel.Columns>
                  <GridPanel.Rows>
                        <GridRow />
                  </GridPanel.Rows>

                  <Text Text=""In"" TextAlignment=""Near"" />
                  <Image ImageAlign=""Fit"" GridColumn=""1"" IsHitTestVisible=""False"">
                        <Image.Image>
                              <Bitmap>D:\Media\Images\Movies\Avatar.jpg</Bitmap>
                        </Image.Image>
                  </Image>
                  <Text Text=""Out"" TextAlignment=""Far"" GridColumn=""2"" />

            </GridPanel>

      </GridPanel>
</SimplePanel> 


Several notes:
  • Our Grid panel does not support cell spanning therefore the sample uses two embedded grid panels.
  • The image of the Image component is a bit tedious to set in XML (as can be observed above). As an alternative you can name the Image component and set its image in code. To obtain a reference to a component given its name, use the FindComponent method of the CompositeNode class.
  • The Image component is hit-test-able by default (and will consume all mouse clicks), therefore this is explicitly turned off.
  • If you want to add a margin around the content, wrap the parent Grid panel in a Border component and set the Padding of this border to the desired value.
  • It is usually not recommended to explicitly set the Width or Height of the root component unless this is intended. If you omit the width and height, the component will try to resize itself to fit its containing node.

Let me know if this helps.

Regards,
Meppy
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint