-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat: 主窗口自定义背景图片与图片编辑功能 #3533
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: 主窗口自定义背景图片与图片编辑功能 #3533
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,118 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| <ui:FluentWindow x:Class="BetterGenshinImpact.View.Windows.ImageEditWindow" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Title="编辑背景图片" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Width="920" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Height="680" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| MinWidth="640" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| MinHeight="480" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Background="#202020" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| ExtendsContentIntoTitleBar="True" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| FontFamily="{DynamicResource TextThemeFontFamily}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| WindowBackdropType="Auto" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| WindowStartupLocation="CenterOwner" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| mc:Ignorable="d"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| <!-- | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| 背景图片编辑对话框: | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| - 左右旋转 90°(TransformedBitmap 实现) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| - 鼠标拖拽绘制/移动/边缘缩放裁剪框(CroppedBitmap 实现) | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| - 三种退出路径:保存并使用(编辑后副本)/ 使用原图 / 取消 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| --> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Grid> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| <ui:Grid Margin="0,48,0,0" RowDefinitions="Auto,*,Auto"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| <!-- 工具栏 --> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| <StackPanel Grid.Row="0" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Margin="16,4,16,8" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| HorizontalAlignment="Left" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Orientation="Horizontal"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| <ui:Button MinWidth="96" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Margin="0,0,8,0" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Click="RotateLeft_Click" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Content="↺ 左转 90°" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| ToolTip="逆时针旋转 90 度" /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| <ui:Button MinWidth="96" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Margin="0,0,8,0" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Click="RotateRight_Click" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Content="↻ 右转 90°" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| ToolTip="顺时针旋转 90 度" /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| <ui:Button MinWidth="96" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Margin="0,0,16,0" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Click="ResetCrop_Click" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Content="□ 重置裁剪" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| ToolTip="清除裁剪区域,保留整张图片" /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| <ui:TextBlock Name="InfoText" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Margin="8,0,0,0" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| VerticalAlignment="Center" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| FontSize="12" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Text="在图片上拖拽可框选裁剪区域;拖动框内移动、贴边缩放" /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| </StackPanel> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| <!-- 图片预览 + 裁剪框覆盖层 --> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Border Grid.Row="1" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Margin="16,0,16,8" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Background="#141414" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| BorderBrush="#3A3A3A" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| BorderThickness="1" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| ClipToBounds="True"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Grid> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Image Name="PreviewImage" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| HorizontalAlignment="Stretch" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| VerticalAlignment="Stretch" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Stretch="Uniform" /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| <!-- 透明 Canvas 负责捕获鼠标事件并绘制裁剪矩形 --> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Canvas Name="CropCanvas" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Background="Transparent" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| MouseLeftButtonDown="CropCanvas_MouseLeftButtonDown" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| MouseLeftButtonUp="CropCanvas_MouseLeftButtonUp" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| MouseMove="CropCanvas_MouseMove" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| SizeChanged="CropCanvas_SizeChanged"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Rectangle Name="CropRect" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Canvas.Left="0" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Canvas.Top="0" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Fill="#224FC3F7" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| IsHitTestVisible="False" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Stroke="#4FC3F7" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| StrokeDashArray="4 2" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| StrokeThickness="1.5" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Visibility="Collapsed" /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| </Canvas> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| </Grid> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| </Border> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| <!-- 底部操作区 --> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Grid Grid.Row="2" Margin="16,0,16,16"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Grid.ColumnDefinitions> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| <ColumnDefinition Width="Auto" /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| <ColumnDefinition Width="*" /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| <ColumnDefinition Width="Auto" /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| </Grid.ColumnDefinitions> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| <ui:Button Grid.Column="0" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Width="88" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Click="CancelButton_Click" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Content="取消" /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| <ui:Button Grid.Column="2" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Margin="0,0,8,0" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Width="110" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Click="UseOriginalButton_Click" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Content="使用原图" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| ToolTip="不做任何修改,直接使用选择的图片" /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| <ui:Button Grid.Column="2" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Margin="0,0,130,0" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Width="120" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Appearance="Primary" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Click="SaveButton_Click" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| Content="保存并使用" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| ToolTip="应用旋转与裁剪,另存为副本后使用" /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+97
to
+109
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win 修复底部按钮重叠。 “使用原图”和“保存并使用”都在 将两个按钮放入同一个水平 建议修改- <ui:Button Grid.Column="2"
- Margin="0,0,8,0"
- Width="110"
- Click="UseOriginalButton_Click"
- Content="使用原图"
- ToolTip="不做任何修改,直接使用选择的图片" />
- <ui:Button Grid.Column="2"
- Margin="0,0,130,0"
- Width="120"
- Appearance="Primary"
- Click="SaveButton_Click"
- Content="保存并使用"
- ToolTip="应用旋转与裁剪,另存为副本后使用" />
+ <StackPanel Grid.Column="2" Orientation="Horizontal">
+ <ui:Button Width="110"
+ Margin="0,0,8,0"
+ Click="UseOriginalButton_Click"
+ Content="使用原图" />
+ <ui:Button Width="120"
+ Appearance="Primary"
+ Click="SaveButton_Click"
+ Content="保存并使用" />
+ </StackPanel>📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||
| </Grid> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| </ui:Grid> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| <ui:TitleBar Title="编辑背景图片"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| <ui:TitleBar.Icon> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| <ui:ImageIcon Source="pack://application:,,,/Resources/Images/logo.png" /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| </ui:TitleBar.Icon> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| </ui:TitleBar> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| </Grid> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
| </ui:FluentWindow> | ||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
严重程度:P2。问题位置:图片编辑窗口底部的“使用原图”和“保存并使用”按钮。问题原因:两个固定宽度的
ui:Button都放在同一个Grid.Column="2"中,仅通过不同的右边距尝试错开;该自动宽度列按较大的Width + Margin分配空间,而两个控件仍在同一单元格内排列,实际渲染边界会发生重叠。可能造成的影响:“保存并使用”会遮挡“使用原图”的一部分,重叠区域的命中目标还取决于后声明控件的层级,导致按钮文字或点击操作异常。推荐修复方案:为两个按钮分别增加列,或在第 2 列中使用水平StackPanel并通过间距排列。Useful? React with 👍 / 👎.