-
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
feat: 主窗口自定义背景图片与图片编辑功能 #3533
Changes from 1 commit
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" | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+103
to
+105
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. 严重程度:P2。问题位置:图片编辑窗口底部的“使用原图”和“保存并使用”按钮。问题原因:两个固定宽度的 Useful? React with 👍 / 👎. |
||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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。问题位置:拉伸方式
ComboBox的各个ComboBoxItem.Tag。问题原因:绑定源MainBackgroundStretch的类型是System.Windows.Media.Stretch,但这些Tag是字符串;SelectedValue初始化时按对象值匹配,枚举值不会与字符串相等,仓库中同类枚举选择器也使用{x:Static ...}保持类型一致。可能造成的影响:打开设置页时当前拉伸方式没有选中项,用户无法从界面确认已保存的配置。推荐修复方案:引入媒体命名空间,并将各个Tag改为对应的{x:Static media:Stretch.Fill}、UniformToFill、Uniform和None。Useful? React with 👍 / 👎.