Customize node adornments and ResizeAdornment

Hello,

I’d like to custumize the node adornments and ResizeAdornment.

I’ve seen in Generic.xaml that you use
go:ToolHandle, then I tried this :

  <Style TargetType="{x:Type go:ToolHandle}"
                   x:Key="MyToolHandle">
                <Setter Property="Stroke"  Value="LightSlateGray" />
                <Setter Property="StrokeThickness"  Value=".5" />
                <Setter Property="Width" Value="7" />
                <Setter Property="Height" Value="7" />
                <Setter Property="Margin" Value="-2" />
                <Setter Property="go:NodePanel.Figure" Value="Ellipse" />
                <Setter Property="Fill">
                    <Setter.Value>
                        <RadialGradientBrush Center="0.3, 0.3"
                                             GradientOrigin="0.3, 0.3"
                                             RadiusX="0.7"
                                             RadiusY="0.7">
                            <GradientStop Color="White"
                                          Offset="0" />
                            <GradientStop Color="DarkSlateGray"
                                          Offset="0.9" />
                        </RadialGradientBrush>
                    </Setter.Value>
                </Setter>
            </Style>

       <DataTemplate x:Key="PartSelectedTemplate">
                <go:SpotPanel SnapsToDevicePixels="True" Margin="4">
                    <go:ToolHandle go:SpotPanel.Spot="0.0 0.0"
                                   Style="{StaticResource MyToolHandle}" />
                    <go:ToolHandle go:SpotPanel.Spot="0.5 0.0"
                                   Style="{StaticResource MyToolHandle}" />
                    <go:ToolHandle go:SpotPanel.Spot="1.0 0.0"
                                   Style="{StaticResource MyToolHandle}" />

                    <go:ToolHandle go:SpotPanel.Spot="0.0 0.5"
                                   Style="{StaticResource MyToolHandle}" />
                    <go:ToolHandle go:SpotPanel.Spot="1.0 0.5"
                                   Style="{StaticResource MyToolHandle}" />

                    <go:ToolHandle go:SpotPanel.Spot="0.0 1.0"
                                   Style="{StaticResource MyToolHandle}" />
                    <go:ToolHandle go:SpotPanel.Spot="0.5 1.0"
                                   Style="{StaticResource MyToolHandle}" />
                    <go:ToolHandle go:SpotPanel.Spot="1.0 1.0"
                                   Style="{StaticResource MyToolHandle}" />
                    <go:SelectionHandle  StrokeThickness="1"    >
                        <go:SelectionHandle.Stroke>
                            <LinearGradientBrush StartPoint="0, 0"
                                                 EndPoint="1, .3"
                                                 Opacity=".7">
                                <GradientStop Color="SlateGray"
                                              Offset="0" />
                                <GradientStop Color="LightGray"
                                              Offset=".5" />
                                <GradientStop Color="SlateGray"
                                              Offset="1" />
                            </LinearGradientBrush>
                        </go:SelectionHandle.Stroke>
                    </go:SelectionHandle>
                </go:SpotPanel>
                  <DataTemplate x:Key="Part">
                <go:SpotPanel Style="{StaticResource SpotPanelStyle}"                              
                              MouseEnter="Node_MouseEnter"
                              MouseLeave="Node_MouseLeave" go:Part.Resizable="True"
                              go:Node.Location="{Binding Path=Data.Location, Mode=TwoWay}" 
                              go:Part.SelectionAdornmentTemplate="{StaticResource PartSelectedTemplate}">
                    <Grid Name="MyElt"
                          MinWidth="50"
                          MinHeight="30">

       (...)
            </DataTemplate>

It doesn’t work. I’ve got my right selection border, but when I modify the Part element the size of SelectionHandle is not up to date.

Maybe I should bind width with Part.Width. but I don’t know how to do that.

The second problem is that I see my toolHandle but also the default blue ones. And the only active one are the default one, not the mine.Cry

I’m sorry for these basic question, i began with wpf technology.

Thanks
Aurore

There are separate adornments, and thus separate adornment templates, for selection and for resizing. Each is independent of the other. So you can’t mix the two together.

This worked for me:

[code]







<Setter.Value>




</Setter.Value>



<go:SelectionHandle StrokeThickness=“1”>
go:SelectionHandle.Stroke





</go:SelectionHandle.Stroke>
</go:SelectionHandle>


<go:SpotPanel SnapsToDevicePixels=“True”>
<go:ToolHandle go:SpotPanel.Spot=“0.0 0.0” Style="{StaticResource MyToolHandle}" />
<go:ToolHandle go:SpotPanel.Spot=“0.5 0.0” Style="{StaticResource MyToolHandle}" />
<go:ToolHandle go:SpotPanel.Spot=“1.0 0.0” Style="{StaticResource MyToolHandle}" />

    <go:ToolHandle go:SpotPanel.Spot="0.0 0.5" Style="{StaticResource MyToolHandle}" />
    <go:ToolHandle go:SpotPanel.Spot="1.0 0.5" Style="{StaticResource MyToolHandle}" />

    <go:ToolHandle go:SpotPanel.Spot="0.0 1.0" Style="{StaticResource MyToolHandle}" />
    <go:ToolHandle go:SpotPanel.Spot="0.5 1.0" Style="{StaticResource MyToolHandle}" />
    <go:ToolHandle go:SpotPanel.Spot="1.0 1.0" Style="{StaticResource MyToolHandle}" />
  </go:SpotPanel>
</DataTemplate>[/code]

with these declarations on the root element of the node:

go:Part.SelectionAdornmentTemplate="{StaticResource PartSelectionTemplate}" go:Part.ResizeAdornmentTemplate="{StaticResource PartResizeTemplate}"
As you might expect, given the names, the SelectionHandle is used for selection, and ToolHandles are used by tools, such as the ResizingTool in this case.