DragAndDrop core
This commit is contained in:
44
Lattice.UI.DragDrop.WinUI/Themes/DragAdorner.xaml
Normal file
44
Lattice.UI.DragDrop.WinUI/Themes/DragAdorner.xaml
Normal file
@@ -0,0 +1,44 @@
|
||||
<ResourceDictionary
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:controls="using:Lattice.UI.DragDrop.WinUI.Controls"
|
||||
xmlns:media="using:Microsoft.UI.Xaml.Media">
|
||||
|
||||
<Style TargetType="controls:DragAdorner">
|
||||
<Setter Property="Background" Value="{ThemeResource Lattice.Brush.Background.Secondary}" />
|
||||
<Setter Property="BorderBrush" Value="{ThemeResource Lattice.Brush.Border.Primary}" />
|
||||
<Setter Property="BorderThickness" Value="{ThemeResource Lattice.BorderThickness.Thin}" />
|
||||
<Setter Property="Padding" Value="{ThemeResource Lattice.Spacing.Medium}" />
|
||||
<Setter Property="CornerRadius" Value="{ThemeResource Lattice.CornerRadius.Medium}" />
|
||||
<Setter Property="Opacity" Value="{ThemeResource Lattice.Opacity.Drag}" />
|
||||
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="controls:DragAdorner">
|
||||
<Grid>
|
||||
<!-- Фон с тенью -->
|
||||
<Rectangle
|
||||
x:Name="Background"
|
||||
Fill="{TemplateBinding Background}"
|
||||
Opacity="{TemplateBinding Opacity}"
|
||||
RadiusX="{TemplateBinding CornerRadius}"
|
||||
RadiusY="{TemplateBinding CornerRadius}">
|
||||
<Rectangle.Shadow>
|
||||
<media:ThemeShadow />
|
||||
</Rectangle.Shadow>
|
||||
</Rectangle>
|
||||
|
||||
<!-- Контент -->
|
||||
<ContentPresenter
|
||||
x:Name="PART_ContentPresenter"
|
||||
Margin="{TemplateBinding Padding}"
|
||||
Content="{TemplateBinding DragData}"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center" />
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
</ResourceDictionary>
|
||||
153
Lattice.UI.DragDrop.WinUI/Themes/DragDropStyles.xaml
Normal file
153
Lattice.UI.DragDrop.WinUI/Themes/DragDropStyles.xaml
Normal file
@@ -0,0 +1,153 @@
|
||||
<ResourceDictionary
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
|
||||
<!-- Стиль для элементов с поддержкой перетаскивания -->
|
||||
<Style x:Key="Lattice.DragDrop.DragSourceStyle" TargetType="Control">
|
||||
<Setter Property="Background" Value="{ThemeResource Lattice.Brush.Background.Secondary}" />
|
||||
<Setter Property="BorderBrush" Value="{ThemeResource Lattice.Brush.Border.Primary}" />
|
||||
<Setter Property="BorderThickness" Value="{ThemeResource Lattice.BorderThickness.Thin}" />
|
||||
<Setter Property="Padding" Value="{ThemeResource Lattice.Spacing.Medium}" />
|
||||
<Setter Property="CornerRadius" Value="{ThemeResource Lattice.CornerRadius.Small}" />
|
||||
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="Control">
|
||||
<Border
|
||||
x:Name="RootBorder"
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
CornerRadius="{TemplateBinding CornerRadius}"
|
||||
Padding="{TemplateBinding Padding}">
|
||||
<ContentPresenter x:Name="ContentPresenter" />
|
||||
<VisualStateManager.VisualStateGroups>
|
||||
<VisualStateGroup x:Name="DragDropStates">
|
||||
<VisualState x:Name="Normal" />
|
||||
<VisualState x:Name="Dragging">
|
||||
<VisualState.Setters>
|
||||
<Setter Target="RootBorder.Opacity" Value="{ThemeResource Lattice.Opacity.Drag}" />
|
||||
<Setter Target="RootBorder.RenderTransform">
|
||||
<Setter.Value>
|
||||
<ScaleTransform ScaleX="0.95" ScaleY="0.95" />
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Target="RootBorder.Background">
|
||||
<Setter.Value>
|
||||
<SolidColorBrush Color="{ThemeResource Lattice.Color.Accent}" Opacity="0.1" />
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</VisualState.Setters>
|
||||
</VisualState>
|
||||
<VisualState x:Name="DragOver">
|
||||
<VisualState.Setters>
|
||||
<Setter Target="RootBorder.Background">
|
||||
<Setter.Value>
|
||||
<SolidColorBrush Color="{ThemeResource Lattice.Color.Accent}" Opacity="0.2" />
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Target="RootBorder.BorderBrush">
|
||||
<Setter.Value>
|
||||
<SolidColorBrush Color="{ThemeResource Lattice.Color.Accent}" />
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</VisualState.Setters>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
</VisualStateManager.VisualStateGroups>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<!-- Стиль для целей сброса -->
|
||||
<Style x:Key="Lattice.DragDrop.DropTargetStyle" TargetType="Control">
|
||||
<Setter Property="Background" Value="{ThemeResource Lattice.Brush.Background.Tertiary}" />
|
||||
<Setter Property="BorderBrush" Value="{ThemeResource Lattice.Brush.Border.Secondary}" />
|
||||
<Setter Property="BorderThickness" Value="{ThemeResource Lattice.BorderThickness.Medium}" />
|
||||
<Setter Property="Padding" Value="{ThemeResource Lattice.Spacing.Large}" />
|
||||
<Setter Property="CornerRadius" Value="{ThemeResource Lattice.CornerRadius.Medium}" />
|
||||
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="Control">
|
||||
<Border
|
||||
x:Name="RootBorder"
|
||||
Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}"
|
||||
CornerRadius="{TemplateBinding CornerRadius}"
|
||||
Padding="{TemplateBinding Padding}">
|
||||
<ContentPresenter x:Name="ContentPresenter" />
|
||||
<VisualStateManager.VisualStateGroups>
|
||||
<VisualStateGroup x:Name="DropTargetStates">
|
||||
<VisualState x:Name="Normal" />
|
||||
<VisualState x:Name="DragOver">
|
||||
<VisualState.Setters>
|
||||
<Setter Target="RootBorder.Background">
|
||||
<Setter.Value>
|
||||
<SolidColorBrush Color="{ThemeResource Lattice.Color.Accent}" Opacity="0.1" />
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Target="RootBorder.BorderBrush">
|
||||
<Setter.Value>
|
||||
<SolidColorBrush Color="{ThemeResource Lattice.Color.Accent}" />
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Target="RootBorder.BorderThickness" Value="3" />
|
||||
</VisualState.Setters>
|
||||
</VisualState>
|
||||
<VisualState x:Name="DropValid">
|
||||
<VisualState.Setters>
|
||||
<Setter Target="RootBorder.Background">
|
||||
<Setter.Value>
|
||||
<SolidColorBrush Color="{ThemeResource Lattice.Color.Success}" Opacity="0.1" />
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Target="RootBorder.BorderBrush">
|
||||
<Setter.Value>
|
||||
<SolidColorBrush Color="{ThemeResource Lattice.Color.Success}" />
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</VisualState.Setters>
|
||||
</VisualState>
|
||||
<VisualState x:Name="DropInvalid">
|
||||
<VisualState.Setters>
|
||||
<Setter Target="RootBorder.Background">
|
||||
<Setter.Value>
|
||||
<SolidColorBrush Color="{ThemeResource Lattice.Color.Error}" Opacity="0.1" />
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Target="RootBorder.BorderBrush">
|
||||
<Setter.Value>
|
||||
<SolidColorBrush Color="{ThemeResource Lattice.Color.Error}" />
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</VisualState.Setters>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
</VisualStateManager.VisualStateGroups>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<!-- Бруши для визуальной обратной связи -->
|
||||
<SolidColorBrush x:Key="Lattice.DragDrop.DragOverBackgroundBrush"
|
||||
Color="{ThemeResource Lattice.Color.Accent}"
|
||||
Opacity="0.3" />
|
||||
|
||||
<SolidColorBrush x:Key="Lattice.DragDrop.DragOverBorderBrush"
|
||||
Color="{ThemeResource Lattice.Color.Accent}" />
|
||||
|
||||
<SolidColorBrush x:Key="Lattice.DragDrop.DropValidBrush"
|
||||
Color="{ThemeResource Lattice.Color.Success}"
|
||||
Opacity="0.5" />
|
||||
|
||||
<SolidColorBrush x:Key="Lattice.DragDrop.DropInvalidBrush"
|
||||
Color="{ThemeResource Lattice.Color.Error}"
|
||||
Opacity="0.5" />
|
||||
|
||||
</ResourceDictionary>
|
||||
52
Lattice.UI.DragDrop.WinUI/Themes/DropPreviewAdorner.xaml
Normal file
52
Lattice.UI.DragDrop.WinUI/Themes/DropPreviewAdorner.xaml
Normal file
@@ -0,0 +1,52 @@
|
||||
<ResourceDictionary
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:controls="using:Lattice.UI.DragDrop.WinUI.Controls"
|
||||
xmlns:media="using:Microsoft.UI.Xaml.Media">
|
||||
|
||||
<Style TargetType="controls:DropPreviewAdorner">
|
||||
<Setter Property="PreviewBrush" Value="{ThemeResource Lattice.Brush.Accent}" />
|
||||
<Setter Property="PreviewThickness" Value="{ThemeResource Lattice.BorderThickness.Medium}" />
|
||||
<Setter Property="PreviewColor" Value="{ThemeResource Lattice.Color.Accent}" />
|
||||
<Setter Property="CornerRadius" Value="{ThemeResource Lattice.CornerRadius.Medium}" />
|
||||
<Setter Property="Opacity" Value="{ThemeResource Lattice.Opacity.DropPreview}" />
|
||||
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="controls:DropPreviewAdorner">
|
||||
<Border
|
||||
x:Name="PreviewBorder"
|
||||
BorderBrush="{TemplateBinding PreviewBrush}"
|
||||
BorderThickness="{TemplateBinding PreviewThickness}"
|
||||
CornerRadius="{TemplateBinding CornerRadius}"
|
||||
Opacity="{TemplateBinding Opacity}">
|
||||
<Border.Background>
|
||||
<SolidColorBrush
|
||||
Color="{TemplateBinding PreviewColor}"
|
||||
Opacity="0.1" />
|
||||
</Border.Background>
|
||||
<VisualStateManager.VisualStateGroups>
|
||||
<VisualStateGroup x:Name="CommonStates">
|
||||
<VisualState x:Name="Normal" />
|
||||
<VisualState x:Name="Highlighted">
|
||||
<VisualState.Setters>
|
||||
<Setter Target="PreviewBorder.Opacity" Value="0.9" />
|
||||
<Setter Target="PreviewBorder.BorderThickness" Value="3" />
|
||||
<Setter Target="PreviewBorder.Background">
|
||||
<Setter.Value>
|
||||
<SolidColorBrush
|
||||
Color="{TemplateBinding PreviewColor}"
|
||||
Opacity="0.15" />
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</VisualState.Setters>
|
||||
</VisualState>
|
||||
</VisualStateGroup>
|
||||
</VisualStateManager.VisualStateGroups>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
</ResourceDictionary>
|
||||
19
Lattice.UI.DragDrop.WinUI/Themes/Generic.xaml
Normal file
19
Lattice.UI.DragDrop.WinUI/Themes/Generic.xaml
Normal file
@@ -0,0 +1,19 @@
|
||||
<ResourceDictionary
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<!-- Стили компонентов DragDrop -->
|
||||
<ResourceDictionary Source="DragAdorner.xaml" />
|
||||
<ResourceDictionary Source="DropPreviewAdorner.xaml" />
|
||||
<ResourceDictionary Source="DragDropStyles.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
<!-- Алиасы для обратной совместимости -->
|
||||
<Style x:Key="DragEnabledStyle" TargetType="Control"
|
||||
BasedOn="{StaticResource Lattice.DragDrop.DragSourceStyle}" />
|
||||
|
||||
<Style x:Key="DropTargetStyle" TargetType="Control"
|
||||
BasedOn="{StaticResource Lattice.DragDrop.DropTargetStyle}" />
|
||||
|
||||
</ResourceDictionary>
|
||||
Reference in New Issue
Block a user