Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Resizing of Custom nodes created (Read 3761 times)
padmavathi
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 23
Joined: Jun 29th, 2010
Resizing of Custom nodes created
Jul 6th, 2010 at 12:44pm
Print Post  
Hi
I have created few custom nodes and I have set the Handles Style to SquareHandles2.
My problem is when i try to resize the node , I could not able to do that.

Is it possible to resize custom nodes.

One of my custom nodes created is:
public SwitchNode(SwitchNode prototype)
           : base(prototype)
       {
           DefaultStyleKey = typeof(SwitchNode);
           Title = prototype.Title;
           FullName = prototype.FullName;         
           this.HandlesStyle = HandlesStyle.SquareHandles2;

           SolidColorBrush blue = new SolidColorBrush(Color.FromArgb(200, 0, 0, 255));
           SolidColorBrush green = new SolidColorBrush(Color.FromArgb(200, 0, 255, 0));
           SolidColorBrush red = new SolidColorBrush(Color.FromArgb(200, 255, 0, 0));

           AnchorPattern apat2 = new AnchorPattern(new AnchorPoint[]
{
      
                   new AnchorPoint(0, 50, true, true, MarkStyle.Cross),
                   new AnchorPoint(85,50, true, true, MarkStyle.Cross)
                 
});

           this.AnchorPattern = apat2;
                 }


How can I resize my Switch node on the diagram.

Thanks & Regards
Padma

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Resizing of Custom nodes created
Reply #1 - Jul 6th, 2010 at 1:40pm
Print Post  
Does the resize handle position change when you drag it?
  
Back to top
 
IP Logged
 
padmavathi
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 23
Joined: Jun 29th, 2010
Re: Resizing of Custom nodes created
Reply #2 - Jul 6th, 2010 at 2:14pm
Print Post  
Yes the handle position is being changed when I drag it and the anchor points are getting re positioned but the node remains as is. I mean no change in the size of the node.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Resizing of Custom nodes created
Reply #3 - Jul 6th, 2010 at 3:10pm
Print Post  
Bind the visuals in your template to the node's Width and Height, for example see the Grid element in tutorial 3.
  
Back to top
 
IP Logged
 
padmavathi
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 23
Joined: Jun 29th, 2010
Re: Resizing of Custom nodes created
Reply #4 - Jul 7th, 2010 at 7:32am
Print Post  
You mean this one:

<Grid Width="{TemplateBinding Width}" Height="{TemplateBinding Height}"> <Grid.ColumnDefinitions>
<ColumnDefinition Width="80" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
</Grid>
-------------------------------------------------------------
I tried this giving in the following, but still not able to resize my switch node.

<Style TargetType="local:SwitchNode">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="local:SwitchNode">
<Canvas x:Name="Adorner">
<Path Width="50" Height="50" MinWidth="20" MinHeight="20" Stroke="Black"
StrokeThickness="2" Fill="LightSlateGray" >
<Path.Data>
<GeometryGroup>
<LineGeometry StartPoint="-15,20" EndPoint="5,20"/>
<EllipseGeometry RadiusX="5" RadiusY="5" Center="5,20"/>
<LineGeometry StartPoint="5,20" EndPoint="35,10" >
<LineGeometry.Transform>
<RotateTransform Angle="-15"/>
</LineGeometry.Transform>
</LineGeometry>
<EllipseGeometry RadiusX="5" RadiusY="5" Center="35,20"/>
<!--<EllipseGeometry RadiusX="2.5" RadiusY="2.5" Center="21,-12"/>-->
<LineGeometry StartPoint="35,20" EndPoint="45,20"/>

</GeometryGroup>
</Path.Data>
</Path>
<Grid Width="{TemplateBinding Width}" Height="{TemplateBinding Height}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="80" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
</Grid>

</Canvas>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

---------------------------------------------------------
In fact my requirement is a line should be able resized (either increase/decrease)
Here is code for my LineCode:

<Style TargetType="local:LineNode">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="local:LineNode">
<Canvas x:Name="Adorner">
<Border BorderBrush="Black" BorderThickness="2">
<StackPanel Orientation="Vertical">
<Line Stroke="Black" StrokeThickness="0" Height="80">

</Line>
</StackPanel>
</Border>
</Canvas>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>

In my example, this line node is added to the pallete(Node list view) and when we drag and drop onto the diagram,it should be resizable.

Can you tell me for this line how to put resize ability?

Thanks & Regards
Padma.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Resizing of Custom nodes created
Reply #5 - Jul 7th, 2010 at 7:46am
Print Post  
Adding an empty grid won't help of course. In the sample it works because the alignment of child elements depends on the grid size.

In this case you will have to bind the Path coordinates to the node's size if you wish your shape to resize with the node. Or if you are using Silverlight 4, you can place the path inside a Viewbox control that scales the Path, where the Viewbox size is bounds to the node's size.

Another option is to define a Shape object for your switch shape and add a ShapeGeometry to the template to render it depending on the node size.

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


I love YaBB 1G - SP1!

Posts: 23
Joined: Jun 29th, 2010
Re: Resizing of Custom nodes created
Reply #6 - Jul 7th, 2010 at 9:25am
Print Post  
Is this same for even a line Node.
We need to have a line node/control in the Nodelist view and this line should be resizable when it is placed onto the diagram/canvas?
How to do this?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Resizing of Custom nodes created
Reply #7 - Jul 7th, 2010 at 11:06am
Print Post  
If you need strictly horizontal / vertical lines, you can implement them using two node types where one binds the end point position to the node width and the other one binds it to the height. You might also set the respective bits in EnabledHandles to disable resizing the node horizontally or vertically.

If you need the lines drawn at arbitrary angles, you could use unconnected DiagramLinks.

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