Files
Toolkit2/Toolkit.UI.Controls.Avalonia/ContentCropper/ContentCropper.axaml
T
TheXamlGuy 4439e399fd Fix 1
2024-10-10 23:03:07 +01:00

128 lines
7.0 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="ContentCropperThumbBackground" ResourceKey="AccentFillColorDefaultBrush" />
<StaticResource x:Key="ContentCropperThumbBrush" ResourceKey="ControlElevationBorderBrush" />
<StaticResource x:Key="ContentCropperOuterThumbBackground" ResourceKey="ControlSolidFillColorDefaultBrush" />
</ResourceDictionary>
<ResourceDictionary x:Key="Dark">
<StaticResource x:Key="ContentCropperThumbBackground" ResourceKey="AccentFillColorDefaultBrush" />
<StaticResource x:Key="ContentCropperThumbBrush" ResourceKey="ControlElevationBorderBrush" />
<StaticResource x:Key="ContentCropperOuterThumbBackground" ResourceKey="ControlSolidFillColorDefaultBrush" />
</ResourceDictionary>
</ResourceDictionary.ThemeDictionaries>
<CornerRadius x:Key="ContentCropperThumbCornerRadius">10</CornerRadius>
<x:Double x:Key="ContentCropperInnerThumbWidth">12</x:Double>
<x:Double x:Key="ContentCropperInnerThumbHeight">12</x:Double>
<x:Double x:Key="ContentCropperThumbWidth">18</x:Double>
<x:Double x:Key="ContentCropperThumbHeight">18</x:Double>
<ControlTheme x:Key="ContentCropperThumbStyle" TargetType="Thumb">
<Setter Property="BorderThickness" Value="1" />
<Setter Property="Background" Value="{DynamicResource ContentCropperThumbBackground}" />
<Setter Property="BorderBrush" Value="{DynamicResource ContentCropperThumbBrush}" />
<Setter Property="ClipToBounds" Value="False" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<Border
Margin="-2"
Background="{DynamicResource ContentCropperOuterThumbBackground}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{DynamicResource ContentCropperOuterThumbCornerRadius}">
<Ellipse
Name="InnerThumb"
Width="{DynamicResource ContentCropperInnerThumbWidth}"
Height="{DynamicResource ContentCropperInnerThumbHeight}"
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 ContentCropper}" TargetType="ContentCropper">
<Setter Property="Template">
<ControlTemplate>
<Grid>
<ZoomBorder
x:Name="ZoomBorder"
ClipToBounds="True"
PanButton="Left">
<ContentPresenter
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}" />
</ZoomBorder>
<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 ContentCropperThumbWidth}"
Height="{DynamicResource ContentCropperThumbHeight}"
Theme="{StaticResource ContentCropperThumbStyle}" />
<Thumb
x:Name="TopRightButton"
Width="{DynamicResource ContentCropperThumbWidth}"
Height="{DynamicResource ContentCropperThumbHeight}"
Theme="{StaticResource ContentCropperThumbStyle}" />
<Thumb
x:Name="BottomLeftButton"
Width="{DynamicResource ContentCropperThumbWidth}"
Height="{DynamicResource ContentCropperThumbHeight}"
Theme="{StaticResource ContentCropperThumbStyle}" />
<Thumb
x:Name="BottomRightButton"
Width="{DynamicResource ContentCropperThumbWidth}"
Height="{DynamicResource ContentCropperThumbHeight}"
Theme="{StaticResource ContentCropperThumbStyle}" />
</Canvas>
</Grid>
</ControlTemplate>
</Setter>
</ControlTheme>
</ResourceDictionary>