-
Notifications
You must be signed in to change notification settings - Fork 15
白板名言位置自定义调节 #434
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: beta
Are you sure you want to change the base?
白板名言位置自定义调节 #434
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 |
|---|---|---|
|
|
@@ -1280,6 +1280,163 @@ | |
| await UpdateChickenSoupTextAsync(); | ||
| } | ||
|
|
||
| private bool _isAdjustingWatermarkPosition = false; | ||
| private Point _watermarkDragStartPoint; | ||
| private double _watermarkStartX; | ||
| private double _watermarkStartY; | ||
|
|
||
| private void BtnAdjustWatermarkPosition_Click(object sender, RoutedEventArgs e) | ||
| { | ||
| // 关闭设置面板 | ||
| HideSubPanelsImmediately(); | ||
|
|
||
| // 如果名言没有显示,临时显示出来以便调整 | ||
| if (BlackBoardWaterMark.Visibility != Visibility.Visible) | ||
| { | ||
| BlackBoardWaterMark.Visibility = Visibility.Visible; | ||
| } | ||
|
|
||
| _isAdjustingWatermarkPosition = true; | ||
| WaterMarkCanvas.IsHitTestVisible = true; | ||
| BlackBoardWaterMark.IsHitTestVisible = true; | ||
| BlackBoardWaterMark.Cursor = System.Windows.Input.Cursors.SizeAll; | ||
|
|
||
| // 添加视觉反馈 | ||
| BlackBoardWaterMark.Background = new SolidColorBrush(Color.FromArgb(50, 255, 255, 255)); | ||
|
|
||
| // 绑定事件 | ||
| BlackBoardWaterMark.MouseDown -= BlackBoardWaterMark_MouseDown; | ||
| BlackBoardWaterMark.MouseMove -= BlackBoardWaterMark_MouseMove; | ||
| BlackBoardWaterMark.MouseUp -= BlackBoardWaterMark_MouseUp; | ||
|
|
||
| BlackBoardWaterMark.MouseDown += BlackBoardWaterMark_MouseDown; | ||
| BlackBoardWaterMark.MouseMove += BlackBoardWaterMark_MouseMove; | ||
| BlackBoardWaterMark.MouseUp += BlackBoardWaterMark_MouseUp; | ||
|
|
||
| // 提示用户 | ||
| ShowNotification("进入调整模式:请拖动名言调整位置,双击或点击其他区域完成调整。"); | ||
|
|
||
| // 绑定一个全局的点击事件来退出调整模式 | ||
| inkCanvas.MouseDown += InkCanvas_EndWatermarkAdjustment; | ||
| } | ||
|
|
||
| private void InkCanvas_EndWatermarkAdjustment(object sender, MouseButtonEventArgs e) | ||
| { | ||
| EndWatermarkAdjustment(); | ||
| inkCanvas.MouseDown -= InkCanvas_EndWatermarkAdjustment; | ||
| } | ||
|
|
||
| private void EndWatermarkAdjustment() | ||
| { | ||
| if (!_isAdjustingWatermarkPosition) return; | ||
|
|
||
| _isAdjustingWatermarkPosition = false; | ||
| WaterMarkCanvas.IsHitTestVisible = false; | ||
| BlackBoardWaterMark.IsHitTestVisible = false; | ||
| BlackBoardWaterMark.Cursor = System.Windows.Input.Cursors.Arrow; | ||
| BlackBoardWaterMark.Background = Brushes.Transparent; | ||
|
|
||
| BlackBoardWaterMark.MouseDown -= BlackBoardWaterMark_MouseDown; | ||
| BlackBoardWaterMark.MouseMove -= BlackBoardWaterMark_MouseMove; | ||
| BlackBoardWaterMark.MouseUp -= BlackBoardWaterMark_MouseUp; | ||
|
|
||
| // 如果原本是不应该显示的,则隐藏 | ||
| if (!Settings.Appearance.EnableChickenSoupInWhiteboardMode || currentMode != 1) | ||
| { | ||
| BlackBoardWaterMark.Visibility = Visibility.Collapsed; | ||
| } | ||
|
|
||
| ToastHelper_EndWatermarkAdjustment(); | ||
|
|
||
| // 移除可能存在的全局点击事件 | ||
| inkCanvas.MouseDown -= InkCanvas_EndWatermarkAdjustment; | ||
| } | ||
|
|
||
| private void ToastHelper_EndWatermarkAdjustment() | ||
| { | ||
| ShowNotification("调整完成,名言位置已保存。"); | ||
| } | ||
|
|
||
| private void BlackBoardWaterMark_MouseDown(object sender, MouseButtonEventArgs e) | ||
| { | ||
| if (e.ClickCount == 2) | ||
| { | ||
| EndWatermarkAdjustment(); | ||
| return; | ||
| } | ||
|
|
||
| _watermarkDragStartPoint = e.GetPosition(WaterMarkCanvas); | ||
|
|
||
| // 获取当前位置 | ||
| _watermarkStartX = System.Windows.Controls.Canvas.GetLeft(BlackBoardWaterMark); | ||
| if (double.IsNaN(_watermarkStartX)) | ||
| { | ||
| // 如果没有设置Left,可能是靠Right定位的 | ||
| double right = System.Windows.Controls.Canvas.GetRight(BlackBoardWaterMark); | ||
| if (!double.IsNaN(right)) | ||
| { | ||
| _watermarkStartX = WaterMarkCanvas.ActualWidth - BlackBoardWaterMark.ActualWidth - right; | ||
| // 转换为Left定位 | ||
| System.Windows.Controls.Canvas.SetRight(BlackBoardWaterMark, double.NaN); | ||
| } | ||
| else | ||
| { | ||
| _watermarkStartX = 0; | ||
| } | ||
| } | ||
|
|
||
| _watermarkStartY = System.Windows.Controls.Canvas.GetTop(BlackBoardWaterMark); | ||
| if (double.IsNaN(_watermarkStartY)) | ||
| { | ||
| _watermarkStartY = 0; | ||
| } | ||
|
|
||
| BlackBoardWaterMark.CaptureMouse(); | ||
| e.Handled = true; | ||
| } | ||
|
|
||
| private void BlackBoardWaterMark_MouseMove(object sender, System.Windows.Input.MouseEventArgs e) | ||
| { | ||
| if (BlackBoardWaterMark.IsMouseCaptured) | ||
| { | ||
| Point currentPoint = e.GetPosition(WaterMarkCanvas); | ||
| double offsetX = currentPoint.X - _watermarkDragStartPoint.X; | ||
| double offsetY = currentPoint.Y - _watermarkDragStartPoint.Y; | ||
|
|
||
| double newLeft = _watermarkStartX + offsetX; | ||
| double newTop = _watermarkStartY + offsetY; | ||
|
|
||
| // 边界限制 | ||
| if (newLeft < 0) newLeft = 0; | ||
| if (newTop < 0) newTop = 0; | ||
| if (newLeft + BlackBoardWaterMark.ActualWidth > WaterMarkCanvas.ActualWidth) | ||
| newLeft = WaterMarkCanvas.ActualWidth - BlackBoardWaterMark.ActualWidth; | ||
|
Comment on lines
+1412
to
+1413
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.
The boundary logic can still produce a negative Useful? React with 👍 / 👎. |
||
| if (newTop + BlackBoardWaterMark.ActualHeight > WaterMarkCanvas.ActualHeight) | ||
| newTop = WaterMarkCanvas.ActualHeight - BlackBoardWaterMark.ActualHeight; | ||
|
|
||
| System.Windows.Controls.Canvas.SetLeft(BlackBoardWaterMark, newLeft); | ||
| System.Windows.Controls.Canvas.SetTop(BlackBoardWaterMark, newTop); | ||
|
|
||
| // 保存位置到Settings | ||
| Settings.Appearance.WatermarkPositionX = newLeft; | ||
| Settings.Appearance.WatermarkPositionY = newTop; | ||
| Settings.Appearance.IsWatermarkPositionCustomized = true; | ||
|
|
||
| // 延迟保存避免频繁写盘 | ||
| SaveSettingsToFile(); | ||
|
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.
Calling Useful? React with 👍 / 👎. |
||
| } | ||
| } | ||
|
|
||
| private void BlackBoardWaterMark_MouseUp(object sender, MouseButtonEventArgs e) | ||
| { | ||
| if (BlackBoardWaterMark.IsMouseCaptured) | ||
| { | ||
| BlackBoardWaterMark.ReleaseMouseCapture(); | ||
| SaveSettingsToFile(); // 最终保存 | ||
| e.Handled = true; | ||
| } | ||
| } | ||
|
|
||
| private async void BtnHitokotoCustomize_Click(object sender, RoutedEventArgs e) | ||
| { | ||
| var categories = new Dictionary<string, string> | ||
|
|
@@ -5254,7 +5411,7 @@ | |
| MessageBoxImage.Warning); | ||
|
|
||
| Settings.Startup.UpdateChannel = oldChannel; | ||
| Dispatcher.BeginInvoke(new Action(() => | ||
|
Check warning on line 5414 in Ink Canvas/MainWindow_cs/MW_Settings.cs
|
||
| { | ||
| _isChangingUpdateChannelInternally = true; | ||
| try | ||
|
|
@@ -5305,7 +5462,7 @@ | |
| else | ||
| { | ||
| Settings.Startup.UpdateChannel = oldChannel; | ||
| Dispatcher.BeginInvoke(new Action(() => | ||
|
Check warning on line 5465 in Ink Canvas/MainWindow_cs/MW_Settings.cs
|
||
| { | ||
| _isChangingUpdateChannelInternally = true; | ||
| try | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -536,6 +536,13 @@ private void LoadSettings(bool isStartup = false, bool skipAutoUpdateCheck = fal | |
|
|
||
| ToggleSwitchEnableChickenSoupInWhiteboardMode.IsOn = | ||
| Settings.Appearance.EnableChickenSoupInWhiteboardMode; | ||
|
|
||
| if (Settings.Appearance.IsWatermarkPositionCustomized) | ||
| { | ||
| System.Windows.Controls.Canvas.SetLeft(BlackBoardWaterMark, Settings.Appearance.WatermarkPositionX); | ||
| System.Windows.Controls.Canvas.SetTop(BlackBoardWaterMark, Settings.Appearance.WatermarkPositionY); | ||
|
Comment on lines
+542
to
+543
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.
When loading a customized watermark position, the code applies stored Useful? React with 👍 / 👎. |
||
| System.Windows.Controls.Canvas.SetRight(BlackBoardWaterMark, double.NaN); | ||
| } | ||
|
|
||
| // 浮动栏按钮显示控制开关初始化 | ||
| CheckBoxUseLegacyFloatingBarUI.IsChecked = Settings.Appearance.UseLegacyFloatingBarUI; | ||
|
|
||
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.
The exit handler ends adjustment mode but does not set
e.Handled, so the same click continues through normal canvas input processing. In this app,inkCanvasalready has aMouseDownhandler (inkCanvas_MouseDown) that captures input and starts interaction, so when users click the canvas to finish watermark positioning, that click can also create an unintended stroke/dot in drawing workflows. Consuming the event (or handling this in preview phase) avoids modifying the board when the user is only trying to exit adjustment mode.Useful? React with 👍 / 👎.