plcsharp/PLCSharpWpf/Core/UserControls/ROI/RotateRectROI.xaml
2026-07-04 19:27:04 +08:00

100 lines
6.6 KiB
XML

<UserControl x:Class="PLCSharp.Core.UserControls.ROI.RotateRectROI"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:PLCSharp.Core.UserControls"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:s="clr-namespace:PLCSharp.Core.UserControls.ROI.DiagramDesigner"
mc:Ignorable="d" d:DesignHeight="100" d:DesignWidth="100">
<UserControl.Resources>
<Style x:Key="ThumbCorner" TargetType="{x:Type Shape}">
<Setter Property="Fill">
<Setter.Value>
<RadialGradientBrush Center="0.3, 0.3" GradientOrigin="0.3, 0.3" RadiusX="0.8" RadiusY="0.8">
<GradientStop Offset="0.1" Color="White" />
<GradientStop Offset="0.9" Color="Black" />
</RadialGradientBrush>
</Setter.Value>
</Setter>
<Setter Property="Height" Value="15" />
<Setter Property="Margin" Value="-4" />
<Setter Property="Opacity" Value="1" />
<!--<Setter Property="SnapsToDevicePixels" Value="true" />-->
<Setter Property="Stroke" Value="#FFC8C8C8" />
<Setter Property="StrokeThickness" Value=".5" />
<Setter Property="Width" Value="15" />
</Style>
<Style x:Key="rotate" TargetType="{x:Type Control}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Control}">
<Grid>
<Grid Margin="-3" Opacity="0">
<s:RotateThumb Width="15" Height="15" Margin="0,-20,0,0"
HorizontalAlignment="Center" VerticalAlignment="Top"
Cursor="Wait" />
<s:ResizeThumb Height="7" HorizontalAlignment="Stretch" VerticalAlignment="Top" Cursor="SizeNS" />
<s:ResizeThumb Width="7" HorizontalAlignment="Left" VerticalAlignment="Stretch" Cursor="SizeWE" />
<s:ResizeThumb Width="7" HorizontalAlignment="Right" VerticalAlignment="Stretch" Cursor="SizeWE" />
<s:ResizeThumb Height="7" HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Cursor="SizeNS" />
<s:ResizeThumb Width="15" Height="15" Margin="-2"
HorizontalAlignment="Left" VerticalAlignment="Top"
Cursor="SizeNWSE" />
<s:ResizeThumb Width="15" Height="15" Margin="-2"
HorizontalAlignment="Right" VerticalAlignment="Top"
Cursor="SizeNESW" />
<s:ResizeThumb Width="15" Height="15" Margin="-2"
HorizontalAlignment="Left" VerticalAlignment="Bottom"
Cursor="SizeNESW" />
<s:ResizeThumb Width="15" Height="15" Margin="-2"
HorizontalAlignment="Right" VerticalAlignment="Bottom"
Cursor="SizeNWSE" />
</Grid>
<Grid Margin="-3" IsHitTestVisible="False" Opacity="1">
<Rectangle Margin="1" SnapsToDevicePixels="True" Stroke="Fuchsia" StrokeThickness="4" />
<Line Margin="0,-19,0,0"
HorizontalAlignment="Center" VerticalAlignment="Top"
Stroke="Fuchsia" StrokeThickness="4" X1="0" X2="0" Y1="0" Y2="20" />
<Ellipse Margin="-2,-23,0,0" HorizontalAlignment="Center" VerticalAlignment="Top" Style="{StaticResource ThumbCorner}" />
<Ellipse HorizontalAlignment="Left" VerticalAlignment="Top" Style="{StaticResource ThumbCorner}" />
<Ellipse HorizontalAlignment="Right" VerticalAlignment="Top" Style="{StaticResource ThumbCorner}" />
<Ellipse HorizontalAlignment="Left" VerticalAlignment="Bottom" Style="{StaticResource ThumbCorner}" />
<Ellipse HorizontalAlignment="Right" VerticalAlignment="Bottom" Style="{StaticResource ThumbCorner}" />
</Grid>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<ControlTemplate x:Key="MoveThumbTemplate" TargetType="{x:Type s:MoveThumb}">
<Rectangle Fill="Transparent" />
</ControlTemplate>
<Style x:Key="DesignerItemStyle" TargetType="ContentControl">
<Setter Property="MinHeight" Value="1" />
<Setter Property="MinWidth" Value="1" />
<Setter Property="RenderTransformOrigin" Value="0.5,0.5" />
<Setter Property="SnapsToDevicePixels" Value="true" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ContentControl">
<Grid DataContext="{Binding RelativeSource={RelativeSource TemplatedParent}}">
<!-- 移动 -->
<s:MoveThumb Cursor="SizeAll" Template="{StaticResource MoveThumbTemplate}" />
<ContentPresenter Margin="{TemplateBinding Padding}" Content="{TemplateBinding ContentControl.Content}" />
<Control Style="{StaticResource rotate}" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</UserControl.Resources>
<Canvas>
<ContentControl x:Name="ROI"
Canvas.Left="0" Canvas.Top="0"
Width="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}, AncestorLevel=1}, Path=ActualWidth}"
Height="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}, AncestorLevel=1}, Path=ActualHeight}"
Style="{StaticResource DesignerItemStyle}" />
</Canvas>
</UserControl>