Files
Toolkit2/Toolkit.UI.Controls.Avalonia/ImageCropper/ImageCropper.axaml
T
2024-10-06 21:15:02 +01:00

116 lines
6.2 KiB
XML

<ResourceDictionary
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:Toolkit.UI.Controls.Avalonia">
<ResourceDictionary.ThemeDictionaries>
<ResourceDictionary x:Key="Light">
<StaticResource x:Key="ImageCropperThumbBackground" ResourceKey="AccentFillColorDefaultBrush" />
<StaticResource x:Key="ImageCropperThumbBrush" ResourceKey="ControlElevationBorderBrush" />
<StaticResource x:Key="ImageCropperOuterThumbBackground" ResourceKey="ControlSolidFillColorDefaultBrush" />
</ResourceDictionary>
<ResourceDictionary x:Key="Dark">
<StaticResource x:Key="ImageCropperThumbBackground" ResourceKey="AccentFillColorDefaultBrush" />
<StaticResource x:Key="ImageCropperThumbBrush" ResourceKey="ControlElevationBorderBrush" />
<StaticResource x:Key="ImageCropperOuterThumbBackground" ResourceKey="ControlSolidFillColorDefaultBrush" />
</ResourceDictionary>
</ResourceDictionary.ThemeDictionaries>
<CornerRadius x:Key="ImageCropperThumbCornerRadius">10</CornerRadius>
<x:Double x:Key="ImageCropperInnerThumbWidth">12</x:Double>
<x:Double x:Key="ImageCropperInnerThumbHeight">12</x:Double>
<x:Double x:Key="ImageCropperThumbWidth">18</x:Double>
<x:Double x:Key="ImageCropperThumbHeight">18</x:Double>
<ControlTheme x:Key="ImageCropperThumbStyle" TargetType="Thumb">
<Setter Property="BorderThickness" Value="1" />
<Setter Property="Background" Value="{DynamicResource ImageCropperThumbBackground}" />
<Setter Property="BorderBrush" Value="{DynamicResource ImageCropperThumbBrush}" />
<Setter Property="ClipToBounds" Value="False" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Border
Margin="-2"
Background="{DynamicResource ImageCropperOuterThumbBackground}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{DynamicResource ImageCropperOuterThumbCornerRadius}">
<Ellipse
Name="InnerThumb"
Width="{DynamicResource ImageCropperInnerThumbWidth}"
Height="{DynamicResource ImageCropperInnerThumbHeight}"
Fill="{TemplateBinding Background}"
RenderTransform="scaleX(0.86) scaleY(0.86)">
<Ellipse.Transitions>
<Transitions>
<TransformOperationsTransition
Easing="0,0 0,1"
Property="RenderTransform"
Duration="00:00:00.167" />
</Transitions>
</Ellipse.Transitions>
</Ellipse>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style Selector="^:pointerover /template/ Ellipse#InnerThumb">
<Setter Property="RenderTransform" Value="scaleX(1.167) scaleY(1.167)" />
</Style>
<Style Selector="^:pressed /template/ Ellipse#InnerThumb">
<Setter Property="RenderTransform" Value="scaleX(0.71) scaleY(0.71)" />
</Style>
<Style Selector="^:disabled /template/ Ellipse#InnerThumb">
<Setter Property="RenderTransform" Value="scaleX(1.167) scaleY(1.167)" />
</Style>
</ControlTheme>
<ControlTheme x:Key="{x:Type ImageCropper}" TargetType="ImageCropper">
<Setter Property="Template">
<ControlTemplate>
<Canvas x:Name="Canvas">
<Rectangle
x:Name="RectangleLeft"
Fill="{DynamicResource SmokeFillColorDefaultBrush}"
UseLayoutRounding="True" />
<Rectangle
x:Name="RectangleTop"
Fill="{DynamicResource SmokeFillColorDefaultBrush}"
UseLayoutRounding="True" />
<Rectangle
x:Name="RectangleRight"
Fill="{DynamicResource SmokeFillColorDefaultBrush}"
UseLayoutRounding="True" />
<Rectangle
x:Name="RectangleBottom"
Fill="{DynamicResource SmokeFillColorDefaultBrush}"
UseLayoutRounding="True" />
<Border
x:Name="Border"
Background="Transparent"
BorderBrush="Transparent"
BorderThickness="2"
Cursor="SizeAll" />
<Thumb
x:Name="TopLeftButton"
Width="{DynamicResource ImageCropperThumbWidth}"
Height="{DynamicResource ImageCropperThumbHeight}"
Theme="{StaticResource ImageCropperThumbStyle}" />
<Thumb
x:Name="TopRightButton"
Width="{DynamicResource ImageCropperThumbWidth}"
Height="{DynamicResource ImageCropperThumbHeight}"
Theme="{StaticResource ImageCropperThumbStyle}" />
<Thumb
x:Name="BottomLeftButton"
Width="{DynamicResource ImageCropperThumbWidth}"
Height="{DynamicResource ImageCropperThumbHeight}"
Theme="{StaticResource ImageCropperThumbStyle}" />
<Thumb
x:Name="BottomRightButton"
Width="{DynamicResource ImageCropperThumbWidth}"
Height="{DynamicResource ImageCropperThumbHeight}"
Theme="{StaticResource ImageCropperThumbStyle}" />
</Canvas>
</ControlTemplate>
</Setter>
</ControlTheme>
</ResourceDictionary>