<Window xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:loc="using:NewLife.XCoder.Services"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="clr-namespace:NewLife.XCoder.ViewModels"
mc:Ignorable="d" d:DesignWidth="1100" d:DesignHeight="750"
x:Class="NewLife.XCoder.Views.IconToolWindow"
x:DataType="vm:IconToolViewModel"
Title="{loc:Tr 'Icon watermark tool'}" Width="1100" Height="750"
WindowStartupLocation="CenterOwner">
<Window.Styles>
<Style Selector="Border.GroupBorder">
<Setter Property="Background" Value="{DynamicResource BgSurface2}"/>
<Setter Property="BorderBrush" Value="{DynamicResource BorderDefault}"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="CornerRadius" Value="10"/>
<Setter Property="Padding" Value="8"/>
<Setter Property="Margin" Value="0"/>
</Style>
<Style Selector="TextBlock.SectionTitle">
<Setter Property="FontWeight" Value="Bold"/>
<Setter Property="Margin" Value="4,3"/>
<Setter Property="FontSize" Value="13"/>
</Style>
<Style Selector="TextBox.ConfigTextBox">
<Setter Property="Margin" Value="2"/>
<Setter Property="Height" Value="32"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="BorderBrush" Value="{DynamicResource BorderDefault}"/>
</Style>
<Style Selector="TextBox.SmallNumeric">
<Setter Property="Width" Value="70"/>
<Setter Property="Height" Value="26"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="HorizontalContentAlignment" Value="Right"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="BorderBrush" Value="{DynamicResource BorderDefault}"/>
<Setter Property="Margin" Value="2"/>
</Style>
<Style Selector="Button.ActionButton">
<Setter Property="Height" Value="32"/>
<Setter Property="Padding" Value="12,0"/>
<Setter Property="Margin" Value="2"/>
</Style>
</Window.Styles>
<Grid Margin="16" RowSpacing="10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="260"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<!-- ============ 左侧:配置面板 ============ -->
<ScrollViewer Grid.Column="0" VerticalScrollBarVisibility="Auto" Margin="0,0,4,0">
<StackPanel>
<!-- 图片加载 -->
<Border Classes="GroupBorder">
<StackPanel>
<TextBlock Text="{loc:Tr 'Image loading'}" Classes="SectionTitle"/>
<Button Content="{loc:Tr 'Select image'}" Command="{Binding LoadImageCommand}"
Classes="ActionButton" Margin="4,2"/>
<TextBlock Text="{loc:Tr 'Tip: drag and drop images into the preview area on the right'}" Margin="4,0,4,4"
Foreground="{DynamicResource TextTertiary}" FontSize="11"/>
</StackPanel>
</Border>
<!-- 水印设置 -->
<Border Classes="GroupBorder">
<StackPanel>
<TextBlock Text="{loc:Tr 'Watermark settings'}" Classes="SectionTitle"/>
<TextBlock Text="{loc:Tr 'Text content'}" Margin="4,2,4,0"/>
<TextBox Text="{Binding WatermarkText}" Classes="ConfigTextBox"/>
<Grid Margin="4,2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Grid.Column="0" Text="{loc:Tr 'Font'}" VerticalAlignment="Center" Margin="0,0,4,0"/>
<ComboBox Grid.Row="0" Grid.Column="1" ItemsSource="{Binding FontNames}"
SelectedItem="{Binding FontName}" Height="32"/>
<TextBlock Grid.Row="1" Grid.Column="0" Text="{loc:Tr 'Size'}" VerticalAlignment="Center" Margin="0,0,4,0"/>
<TextBox Grid.Row="1" Grid.Column="1" Text="{Binding FontSize}" Classes="SmallNumeric"/>
<TextBlock Grid.Row="2" Grid.Column="0" Text="{loc:Tr 'X position'}" VerticalAlignment="Center" Margin="0,0,4,0"/>
<TextBox Grid.Row="2" Grid.Column="1" Text="{Binding WatermarkX}" Classes="SmallNumeric"/>
<TextBlock Grid.Row="3" Grid.Column="0" Text="{loc:Tr 'Y position'}" VerticalAlignment="Center" Margin="0,0,4,0"/>
<TextBox Grid.Row="3" Grid.Column="1" Text="{Binding WatermarkY}" Classes="SmallNumeric"/>
</Grid>
<Button Content="{loc:Tr 'Apply watermark'}" Command="{Binding MakeWaterCommand}"
Classes="ActionButton" Margin="4,2"/>
</StackPanel>
</Border>
<!-- ICO 设置 -->
<Border Classes="GroupBorder">
<StackPanel>
<TextBlock Text="{loc:Tr 'ICO icon'}" Classes="SectionTitle"/>
<ItemsControl ItemsSource="{Binding IconSizes}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<CheckBox Content="{Binding Name}" IsChecked="{Binding IsSelected}" Margin="4,2"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<Button Content="{loc:Tr 'Generate ICO'}" Command="{Binding MakeIcoCommand}"
Classes="ActionButton" Margin="4,2"/>
</StackPanel>
</Border>
<!-- 保存 -->
<Border Classes="GroupBorder">
<StackPanel>
<TextBlock Text="{loc:Tr 'Save'}" Classes="SectionTitle"/>
<Button Content="{loc:Tr 'Save image'}" Command="{Binding SaveImageCommand}"
Classes="ActionButton" Margin="4,2"/>
</StackPanel>
</Border>
<!-- 批量处理 -->
<Border Classes="GroupBorder">
<StackPanel>
<TextBlock Text="{loc:Tr 'Batch processing'}" Classes="SectionTitle"/>
<TextBlock Text="{loc:Tr 'Process the whole directory with the current watermark text and size; output goes to the watermarked subdirectory under the source directory'}"
TextWrapping="Wrap" FontSize="11" Foreground="{DynamicResource TextTertiary}" Margin="4,0,4,4"/>
<Button Content="{loc:Tr 'Select directory and process'}" Command="{Binding BatchProcessCommand}"
Classes="ActionButton" Margin="4,2"/>
</StackPanel>
</Border>
</StackPanel>
</ScrollViewer>
<!-- ============ 右侧:预览区 ============ -->
<Border Grid.Column="1" BorderBrush="{DynamicResource BorderDefault}" BorderThickness="1" Padding="4">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Text="{loc:Tr 'Preview'}" FontWeight="Bold" Margin="4,2"/>
<ScrollViewer Grid.Row="1" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
<Image Source="{Binding PreviewImage}" MaxWidth="800" MaxHeight="500" Stretch="Uniform"/>
</ScrollViewer>
<Border Grid.Row="2" BorderBrush="{DynamicResource BorderDefault}" BorderThickness="0,1,0,0" Padding="4,2">
<TextBlock Text="{Binding Status, Converter={x:Static loc:LocalizedTextConverter.Instance}}"/>
</Border>
</Grid>
</Border>
</Grid>
</Window>
|