Moving Resize Anchors

With the dynamic ports set up I am using - http://www.nwoods.com/forum/forum_posts.asp?TID=5141&title=dynamic-ports-not-extending-past-edge-of-node - there is a margin around the outside of the object, and I would like to move the resize handles in from the edge of the node.

This is the template I am using:


<span style="font-size: 12px; line-height: 1.4;">   </span><span style="font-size: 12px; line-height: 1.4;"> </span><DataTemplate x:Key="ResizeTemplate">
        <go:SpotPanel>
            <go:ToolHandle go:SpotPanel.Spot="0.1296 0.0522" go:NodePanel.Figure="Rectangle" Width="8" Height="8" Fill="DeepSkyBlue" Stroke="Black" StrokeThickness="1" />
            <go:ToolHandle go:SpotPanel.Spot="0.8704 0.0522" go:NodePanel.Figure="Rectangle" Width="8" Height="8" Fill="DeepSkyBlue" Stroke="Black" StrokeThickness="1" />

            <go:ToolHandle go:SpotPanel.Spot="0.1296 0.9478" go:NodePanel.Figure="Rectangle" Width="8" Height="8" Fill="DeepSkyBlue" Stroke="Black" StrokeThickness="1" />
            <go:ToolHandle go:SpotPanel.Spot="0.8704 0.9478" go:NodePanel.Figure="Rectangle" Width="8" Height="8" Fill="DeepSkyBlue" Stroke="Black" StrokeThickness="1" />
        </go:SpotPanel>
    </DataTemplate>

These anchors position the way I want them, but they no longer work for resizing. The cursor doesn’t change to a resize anchor when the mouse is over the handles and clicking on them and dragging has no effect. Is there something I am missing?

Thanks
Ryan

Have you set the go:Part.ResizeElementName on the root visual element to name the particular FrameworkElement that you want to be resized by the user?

Also, you haven’t set the Cursor. I suggest you look at the built-in definition, which is available as Generic.XAML in the docs subdirectory.

Here is the template I am seeing in Generic.xaml:


<DataTemplate x:Key="{ComponentResourceKey TypeInTargetAssembly={x:Type go:Diagram}, ResourceId=DefaultResizeAdornmentTemplate}">
    <go:SpotPanel SnapsToDevicePixels="True">
      <go:ToolHandle go:SpotPanel.Spot="0.0 0.0" go:NodePanel.Figure="Rectangle" Width="6" Height="6" Fill="{x:Static SystemColors.HighlightBrush}" Stroke="Black" StrokeThickness="1" />
      <go:ToolHandle go:SpotPanel.Spot="0.5 0.0" go:NodePanel.Figure="Rectangle" Width="6" Height="6" Fill="{x:Static SystemColors.HighlightBrush}" Stroke="Black" StrokeThickness="1" />
      <go:ToolHandle go:SpotPanel.Spot="1.0 0.0" go:NodePanel.Figure="Rectangle" Width="6" Height="6" Fill="{x:Static SystemColors.HighlightBrush}" Stroke="Black" StrokeThickness="1" />

      <go:ToolHandle go:SpotPanel.Spot="0.0 0.5" go:NodePanel.Figure="Rectangle" Width="6" Height="6" Fill="{x:Static SystemColors.HighlightBrush}" Stroke="Black" StrokeThickness="1" />
      <go:ToolHandle go:SpotPanel.Spot="1.0 0.5" go:NodePanel.Figure="Rectangle" Width="6" Height="6" Fill="{x:Static SystemColors.HighlightBrush}" Stroke="Black" StrokeThickness="1" />

      <go:ToolHandle go:SpotPanel.Spot="0.0 1.0" go:NodePanel.Figure="Rectangle" Width="6" Height="6" Fill="{x:Static SystemColors.HighlightBrush}" Stroke="Black" StrokeThickness="1" />
      <go:ToolHandle go:SpotPanel.Spot="0.5 1.0" go:NodePanel.Figure="Rectangle" Width="6" Height="6" Fill="{x:Static SystemColors.HighlightBrush}" Stroke="Black" StrokeThickness="1" />
      <go:ToolHandle go:SpotPanel.Spot="1.0 1.0" go:NodePanel.Figure="Rectangle" Width="6" Height="6" Fill="{x:Static SystemColors.HighlightBrush}" Stroke="Black" StrokeThickness="1" />
    </go:SpotPanel>
  </DataTemplate>

This looks basically the same as my template. Also, it doesn’t seem like setting the cursor is necessary since if I change the template back to the edge of the nodes:


<span style="font-size: 12px; line-height: 1.4;">       </span><span style="font-size: 12px; line-height: 1.4;"> </span><go:SpotPanel>
            <go:ToolHandle go:SpotPanel.Spot="0 0" go:NodePanel.Figure="Rectangle" Width="8" Height="8" Fill="DeepSkyBlue" Stroke="Black" StrokeThickness="1" />
            <go:ToolHandle go:SpotPanel.Spot="1 0" go:NodePanel.Figure="Rectangle" Width="8" Height="8" Fill="DeepSkyBlue" Stroke="Black" StrokeThickness="1" />

            <go:ToolHandle go:SpotPanel.Spot="0 1" go:NodePanel.Figure="Rectangle" Width="8" Height="8" Fill="DeepSkyBlue" Stroke="Black" StrokeThickness="1" />
            <go:ToolHandle go:SpotPanel.Spot="1 1" go:NodePanel.Figure="Rectangle" Width="8" Height="8" Fill="DeepSkyBlue" Stroke="Black" StrokeThickness="1" />
        </go:SpotPanel>

Then the cursor updates when over the handles and the resizing works again.

Ah, right – it’s different because ResizingTool.UpdateAdornments changes the cursor dynamically depending on the angle. And it decides which “side” the handle is on by the value of the SpotPanel.Spot attached property. As it so happens, when the value isn’t along an edge, it doesn’t recognize the handle as needing a cursor.

I suppose you could override ResizingTool.UpdateAdornments to call the base method and then find the individual resize handles in the Adornment so that you can set the appropriate Cursor on them.

Similarly, the ResizingTool.ComputeResize method is looking at the handles and also deciding that they aren’t the standard handles at the edges, so it doesn’t do anything, causing the ResizingTool to do nothing. Again, you could override that method to do what you want.