Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Custom Control with Shapes (Read 4173 times)
rajesh_patil74
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 220
Joined: Sep 3rd, 2009
Custom Control with Shapes
Nov 5th, 2009 at 7:38am
Print Post  
Hi Stoyo

With custom control, I don't have issue with border and image ( as queried in my previous post).

With the sample custom control provided, I see that I can create my own custom control and in the sample, I can position the text as per my requirment.

Is it possible that, with custom control, I can use Shape ? So I can create my own control in which center area is assigned to shape display and whenever I resize the custom control, my shape gets resized automatically.

Can you provide me some sample with same.

Regards
Rajesh
  
Back to top
WWW  
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Custom Control with Shapes
Reply #1 - Nov 5th, 2009 at 8:57am
Print Post  
Hi,

You can derive from ShapeNode and use a custom control template to place the image and text where you need them. Check Tutorial 3 in the latest 1.2 beta:
https://mindfusion.eu/_beta/DiagramLite.1.2.beta.zip

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
rajesh_patil74
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 220
Joined: Sep 3rd, 2009
Re: Custom Control with Shapes
Reply #2 - Nov 5th, 2009 at 9:33am
Print Post  
Hi Stoyo

Thanks for your quick reply. I was already looking in the Tutorial 3 and found one issue with it.

If I change my template as following, the Shape gets clipped ( You need to resize the node to view the shape )

Following the partial updated xaml  code from generic.xml file


<Canvas x:Name="Adorner">

<Grid Width="{TemplateBinding Width}" Height="{TemplateBinding Height}" ShowGridLines="True">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="80" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
                           <Grid.RowDefinitions>
                               <RowDefinition Height="80" />
                               <RowDefinition Height="*" />
                           </Grid.RowDefinitions>
                           <Image
Source="{TemplateBinding Image}"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Stretch="Uniform">
</Image>

<StackPanel Margin="4,8,0,0"  Orientation="Vertical" Grid.Column="1">
<TextBlock Text="{TemplateBinding Title}" FontWeight="800" />
<TextBlock Text="{TemplateBinding FullName}" Foreground="Blue" />
<TextBlock Text="{TemplateBinding Text}" FontSize="9" />
</StackPanel>

                           <Path Grid.Row="1" Grid.ColumnSpan="2" Margin="10"
Data="{TemplateBinding ShapeGeometry}"
Stroke="{TemplateBinding Stroke}"
Fill="{TemplateBinding Brush}" />


                       </Grid>

</Canvas>


- Rajesh
  
Back to top
WWW  
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Custom Control with Shapes
Reply #3 - Nov 5th, 2009 at 9:44am
Print Post  
Hi Rajesh,

The Geometry object returned by the ShapeGeometry property has the size of the whole node, so if you need to show it in a grid's cell, add a Stretch="Fill" attribute to the Path element. You might still have to resize the tutorials3 nodes to see the shape, because of the Margin value.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
rajesh_patil74
Full Member
***
Offline


I love YaBB 1G - SP1!

Posts: 220
Joined: Sep 3rd, 2009
Re: Custom Control with Shapes
Reply #4 - Nov 5th, 2009 at 10:33am
Print Post  
Hi,

Thanks, Stretch=Fill works.

With this templating functionality, I am able to show gradient color also. Nice functionality :)

I am also able to draw the border for complete canvas used for custom control.

The new issue with this is that, the link drawn between these two controls is not on border.

How one can indicate where the links should be drawn -
For eq. If i draw borders, then I want to draw link end points on borders.

And if borders are not drawn, i would like to draw the links on borders of shapes.

-Rajesh
  
Back to top
WWW  
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Custom Control with Shapes
Reply #5 - Nov 5th, 2009 at 11:01am
Print Post  
Hi,

Try overriding the ShapeNode.GetOutlinePoly method. The links are aligned to the outline defined by the returned points.

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