Files
ShrlAlgoToolkit/NeuWPF/NeoUI/Controls/UploadArea.xaml
ShrlAlgo 955a01f564 整理
2025-08-20 12:10:35 +08:00

186 lines
13 KiB
XML

<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:conv="clr-namespace:NeoUI.Converters"
xmlns:local="clr-namespace:NeoUI.Controls"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Style TargetType="Button" x:Key="AntDeleteButtonStyle">
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" />
<Setter Property="Cursor" Value="Hand" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border Background="{TemplateBinding Background}" Padding="4">
<Path
Data="M896 166.4l-28.8-28.8c-12.8-12.8-32-12.8-44.8 0l-160 160-160-160c-12.8-12.8-32-12.8-44.8 0l-28.8 28.8c-12.8 12.8-12.8 32 0 44.8l160 160-160 160c-12.8 12.8-12.8 32 0 44.8l28.8 28.8c12.8 12.8 32 12.8 44.8 0l160-160 160 160c12.8 12.8 32 12.8 44.8 0l28.8-28.8c12.8-12.8 12.8-32 0-44.8l-160-160 160-160c12.8-12.8 12.8-32 0-44.8z"
Fill="{TemplateBinding Foreground}"
Height="12"
Stretch="Uniform"
Width="12" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Foreground" Value="{DynamicResource ErrorBrush}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type local:UploadArea}">
<Setter Property="AllowDrop" Value="True" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderBrush" Value="{DynamicResource BorderNormalBrush}" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Padding" Value="8" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:UploadArea}">
<Grid>
<StackPanel>
<!-- 上传区域 -->
<Border
Background="{DynamicResource BackgroundContainerBrush}"
Cursor="Hand"
SnapsToDevicePixels="True"
x:Name="PART_DropArea">
<Border.InputBindings>
<MouseBinding Command="{Binding SelectCommand, RelativeSource={RelativeSource TemplatedParent}}" MouseAction="LeftClick" />
</Border.InputBindings>
<Border
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="1"
CornerRadius="2"
Padding="16"
x:Name="DropAreaBorder">
<Border.Style>
<Style TargetType="Border">
<Setter Property="BorderBrush" Value="{DynamicResource BorderNormalBrush}" />
<!--<Setter Property="BorderDashArray" Value="4 4"/>-->
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="BorderBrush" Value="{DynamicResource PrimaryNormalBrush}" />
</Trigger>
</Style.Triggers>
</Style>
</Border.Style>
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
<Path
Data="M488.704 294.592L488.704 294.592 488.704 294.592zM895.872 448.128L548.16 100.416C535.552 87.808 516.352 80.064 494.848 80.064S454.144 87.808 441.536 100.416L93.824 448.128C81.216 460.736 74.304 479.552 74.304 499.904C74.304 547.2 112.192 585.088 159.488 585.088L320 585.088 320 896.128C320 913.664 334.336 928.064 352 928.064L640 928.064C657.664 928.064 672 913.664 672 896.128L672 585.088 832.512 585.088C879.808 585.088 917.696 547.2 917.696 499.904C917.696 479.552 909.888 460.736 895.872 448.128ZM608 585.088L608 864.064 384 864.064 384 585.088 214.592 585.088C209.664 585.088 205.632 583.04 202.432 579.84C199.232 576.64 197.248 572.672 197.248 567.808C197.248 561.6 199.68 555.872 204.224 551.328L475.904 279.648C480.832 274.72 487.36 272.064 494.848 272.064C502.336 272.064 508.864 274.72 513.792 279.648L785.472 551.328C790.016 555.872 792.448 561.6 792.448 567.808C792.448 572.672 790.464 576.64 787.264 579.84C784.064 583.04 780.032 585.088 775.104 585.088L608 585.088Z"
Fill="{DynamicResource PrimaryNormalBrush}"
Height="48"
Stretch="Uniform" />
<TextBlock
FontSize="14"
FontWeight="SemiBold"
Foreground="{DynamicResource TextPrimaryBrush}"
HorizontalAlignment="Center"
Margin="0,12,0,0"
Text="{TemplateBinding HintText}" />
<!--<TextBlock Text="支持单个或批量上传,严禁上传公司内部资料及其他违禁文件"
Foreground="{DynamicResource TextSecondaryBrush}"
FontSize="12"
HorizontalAlignment="Center" Margin="0,4,0,0" />-->
</StackPanel>
</Border>
</Border>
<!-- 已选文件列表 -->
<ItemsControl ItemsSource="{TemplateBinding FileList}" Margin="0,8,0,0">
<ItemsControl.ItemTemplate>
<DataTemplate DataType="{x:Type local:UploadFileItem}">
<Border
Background="{DynamicResource BackgroundContainerBrush}"
BorderBrush="{DynamicResource BorderNormalBrush}"
BorderThickness="1"
CornerRadius="2"
Margin="0,4"
Padding="8"
x:Name="ItemBorder">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<!-- 文件图标 -->
<Path
Data="M854.6 288.6L639.4 73.4c-6-6-14.1-9.4-22.6-9.4H192c-17.7 0-32 14.3-32 32v832c0 17.7 14.3 32 32 32h640c17.7 0 32-14.3 32-32V311.3c0-8.5-3.4-16.7-9.4-22.7zM624 135.5L778.5 290H624V135.5zM832 928H192V96h400v224h224v608z"
Fill="{DynamicResource TextSecondaryBrush}"
Grid.Column="0"
Height="14"
Margin="0,0,8,0"
Stretch="Uniform"
VerticalAlignment="Center"
Width="14" />
<TextBlock
Foreground="{DynamicResource TextPrimaryBrush}"
Grid.Column="1"
Text="{Binding FileName}"
TextTrimming="CharacterEllipsis"
VerticalAlignment="Center" />
<Button
Command="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:UploadArea}}, Path=RemoveItemCommand}"
CommandParameter="{Binding}"
Grid.Column="2"
Style="{StaticResource AntDeleteButtonStyle}" />
</Grid>
</Border>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding FileList, RelativeSource={RelativeSource Mode=TemplatedParent}, Converter={x:Static conv:NullOrEmptyConverter.Instance}}">
<Setter Property="Visibility" Value="Collapsed" />
</DataTrigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" TargetName="ItemBorder" Value="{DynamicResource ControlBackgroundHoverBrush}" />
</Trigger>
<!-- 可以根据文件状态显示不同样式 -->
<DataTrigger Binding="{Binding Status}" Value="Error">
<!--<Setter Property="Foreground" Value="#ff4d4f"/>-->
<Setter Property="BorderBrush" TargetName="ItemBorder" Value="{DynamicResource ErrorBrush}" />
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</StackPanel>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />
<VisualState x:Name="Disabled">
<Storyboard>
<DoubleAnimation
Duration="0:0:0.2"
Storyboard.TargetName="PART_DropArea"
Storyboard.TargetProperty="Opacity"
To="0.5" />
</Storyboard>
</VisualState>
</VisualStateGroup>
<VisualStateGroup x:Name="DragDropStates">
<VisualState x:Name="DragLeave" />
<VisualState x:Name="DragOver">
<Storyboard>
<ColorAnimation
Duration="0:0:0.2"
Storyboard.TargetName="DropAreaBorder"
Storyboard.TargetProperty="(Border.BorderBrush).(SolidColorBrush.Color)"
To="{DynamicResource PrimaryNormalColor}" />
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>