This reverts commit f7aa107a62.
This commit is contained in:
@@ -9,7 +9,6 @@ using System.Threading.Tasks;
|
|||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using System.Windows.Ink;
|
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
using System.Windows.Threading;
|
using System.Windows.Threading;
|
||||||
@@ -31,17 +30,15 @@ namespace Ink_Canvas
|
|||||||
public Bitmap CameraImage;
|
public Bitmap CameraImage;
|
||||||
public BitmapSource CameraBitmapSource;
|
public BitmapSource CameraBitmapSource;
|
||||||
public bool AddToWhiteboard;
|
public bool AddToWhiteboard;
|
||||||
public bool IncludeInk;
|
|
||||||
|
|
||||||
public ScreenshotResult(Rectangle area, List<Point> path = null, Bitmap cameraImage = null,
|
public ScreenshotResult(Rectangle area, List<Point> path = null, Bitmap cameraImage = null,
|
||||||
BitmapSource cameraBitmapSource = null, bool addToWhiteboard = false, bool includeInk = true)
|
BitmapSource cameraBitmapSource = null, bool addToWhiteboard = false)
|
||||||
{
|
{
|
||||||
Area = area;
|
Area = area;
|
||||||
Path = path;
|
Path = path;
|
||||||
CameraImage = cameraImage;
|
CameraImage = cameraImage;
|
||||||
CameraBitmapSource = cameraBitmapSource;
|
CameraBitmapSource = cameraBitmapSource;
|
||||||
AddToWhiteboard = addToWhiteboard;
|
AddToWhiteboard = addToWhiteboard;
|
||||||
IncludeInk = includeInk;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,7 +95,7 @@ namespace Ink_Canvas
|
|||||||
else if (screenshotResult.Value.Area.Width > 0 && screenshotResult.Value.Area.Height > 0)
|
else if (screenshotResult.Value.Area.Width > 0 && screenshotResult.Value.Area.Height > 0)
|
||||||
{
|
{
|
||||||
// 屏幕截图
|
// 屏幕截图
|
||||||
using (var originalBitmap = CaptureScreenAreaWithOptionalInk(screenshotResult.Value.Area, screenshotResult.Value.IncludeInk))
|
using (var originalBitmap = CaptureScreenArea(screenshotResult.Value.Area))
|
||||||
{
|
{
|
||||||
if (originalBitmap != null)
|
if (originalBitmap != null)
|
||||||
{
|
{
|
||||||
@@ -210,16 +207,7 @@ namespace Ink_Canvas
|
|||||||
{
|
{
|
||||||
await Application.Current.Dispatcher.InvokeAsync(() =>
|
await Application.Current.Dispatcher.InvokeAsync(() =>
|
||||||
{
|
{
|
||||||
var selectorWindow = new ScreenshotSelectorWindow(shouldIncludeInk =>
|
var selectorWindow = new ScreenshotSelectorWindow();
|
||||||
{
|
|
||||||
if (inkCanvas == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
inkCanvas.Visibility = shouldIncludeInk ? Visibility.Visible : Visibility.Collapsed;
|
|
||||||
Dispatcher.Invoke(() => { }, DispatcherPriority.Render);
|
|
||||||
});
|
|
||||||
if (selectorWindow.ShowDialog() == true)
|
if (selectorWindow.ShowDialog() == true)
|
||||||
{
|
{
|
||||||
// 检查是否是摄像头截图
|
// 检查是否是摄像头截图
|
||||||
@@ -230,8 +218,7 @@ namespace Ink_Canvas
|
|||||||
null, // 摄像头截图不需要路径
|
null, // 摄像头截图不需要路径
|
||||||
null, // 不再使用Bitmap
|
null, // 不再使用Bitmap
|
||||||
selectorWindow.CameraBitmapSource, // 摄像头BitmapSource
|
selectorWindow.CameraBitmapSource, // 摄像头BitmapSource
|
||||||
selectorWindow.ShouldAddToWhiteboard,
|
selectorWindow.ShouldAddToWhiteboard
|
||||||
selectorWindow.ShouldIncludeInk
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else if (selectorWindow.CameraImage != null)
|
else if (selectorWindow.CameraImage != null)
|
||||||
@@ -241,8 +228,7 @@ namespace Ink_Canvas
|
|||||||
null, // 摄像头截图不需要路径
|
null, // 摄像头截图不需要路径
|
||||||
selectorWindow.CameraImage, // 摄像头图像
|
selectorWindow.CameraImage, // 摄像头图像
|
||||||
null,
|
null,
|
||||||
selectorWindow.ShouldAddToWhiteboard,
|
selectorWindow.ShouldAddToWhiteboard
|
||||||
selectorWindow.ShouldIncludeInk
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -252,8 +238,7 @@ namespace Ink_Canvas
|
|||||||
selectorWindow.SelectedPath,
|
selectorWindow.SelectedPath,
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
selectorWindow.ShouldAddToWhiteboard,
|
selectorWindow.ShouldAddToWhiteboard
|
||||||
selectorWindow.ShouldIncludeInk
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -319,108 +304,6 @@ namespace Ink_Canvas
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Bitmap CaptureScreenAreaWithOptionalInk(Rectangle area, bool includeInk)
|
|
||||||
{
|
|
||||||
Bitmap bitmap = null;
|
|
||||||
StrokeCollection strokesForOverlay = null;
|
|
||||||
Point? inkCanvasTopLeftOnScreen = null;
|
|
||||||
System.Windows.Media.Matrix? dpiTransform = null;
|
|
||||||
var originalWindowVisibility = Visibility;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
if (includeInk && inkCanvas != null && inkCanvas.Strokes.Count > 0)
|
|
||||||
{
|
|
||||||
strokesForOverlay = inkCanvas.Strokes.Clone();
|
|
||||||
|
|
||||||
var source = PresentationSource.FromVisual(inkCanvas);
|
|
||||||
if (source?.CompositionTarget != null)
|
|
||||||
{
|
|
||||||
dpiTransform = source.CompositionTarget.TransformToDevice;
|
|
||||||
}
|
|
||||||
|
|
||||||
inkCanvasTopLeftOnScreen = inkCanvas.PointToScreen(new Point(0, 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
// 先隐藏主窗口再截取屏幕,确保基础截图不包含主线程 UI(含墨迹层)。
|
|
||||||
Visibility = Visibility.Hidden;
|
|
||||||
Dispatcher.Invoke(() => { }, DispatcherPriority.Render);
|
|
||||||
|
|
||||||
bitmap = CaptureScreenArea(area);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
LogHelper.WriteLogToFile($"准备截图时处理墨迹失败: {ex.Message}", LogHelper.LogType.Error);
|
|
||||||
bitmap?.Dispose();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
Visibility = originalWindowVisibility;
|
|
||||||
Dispatcher.Invoke(() => { }, DispatcherPriority.Render);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bitmap == null || !includeInk || strokesForOverlay == null || strokesForOverlay.Count == 0)
|
|
||||||
{
|
|
||||||
return bitmap;
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
OverlayInkStrokesOnBitmap(bitmap, area, strokesForOverlay, inkCanvasTopLeftOnScreen, dpiTransform);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
LogHelper.WriteLogToFile($"叠加墨迹到截图失败: {ex.Message}", LogHelper.LogType.Error);
|
|
||||||
}
|
|
||||||
|
|
||||||
return bitmap;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OverlayInkStrokesOnBitmap(
|
|
||||||
Bitmap bitmap,
|
|
||||||
Rectangle area,
|
|
||||||
StrokeCollection strokes,
|
|
||||||
Point? inkCanvasTopLeftOnScreen = null,
|
|
||||||
System.Windows.Media.Matrix? dpiTransform = null)
|
|
||||||
{
|
|
||||||
if (bitmap == null || strokes == null || strokes.Count == 0)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var transform = dpiTransform ?? new System.Windows.Media.Matrix(1, 0, 0, 1, 0, 0);
|
|
||||||
var topLeft = inkCanvasTopLeftOnScreen ?? new Point(area.X, area.Y);
|
|
||||||
var offsetX = topLeft.X * transform.M11 - area.X;
|
|
||||||
var offsetY = topLeft.Y * transform.M22 - area.Y;
|
|
||||||
|
|
||||||
var drawingVisual = new DrawingVisual();
|
|
||||||
using (var drawingContext = drawingVisual.RenderOpen())
|
|
||||||
{
|
|
||||||
drawingContext.PushTransform(new TranslateTransform(offsetX, offsetY));
|
|
||||||
strokes.Draw(drawingContext);
|
|
||||||
drawingContext.Pop();
|
|
||||||
}
|
|
||||||
|
|
||||||
var renderBitmap = new RenderTargetBitmap(bitmap.Width, bitmap.Height, 96, 96, PixelFormats.Pbgra32);
|
|
||||||
renderBitmap.Render(drawingVisual);
|
|
||||||
|
|
||||||
var encoder = new PngBitmapEncoder();
|
|
||||||
encoder.Frames.Add(BitmapFrame.Create(renderBitmap));
|
|
||||||
|
|
||||||
using (var memoryStream = new MemoryStream())
|
|
||||||
{
|
|
||||||
encoder.Save(memoryStream);
|
|
||||||
memoryStream.Position = 0;
|
|
||||||
using (var overlayBitmap = new Bitmap(memoryStream))
|
|
||||||
using (var graphics = Graphics.FromImage(bitmap))
|
|
||||||
{
|
|
||||||
graphics.CompositingMode = CompositingMode.SourceOver;
|
|
||||||
graphics.DrawImage(overlayBitmap, 0, 0, bitmap.Width, bitmap.Height);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 将截图插入到画布
|
/// 将截图插入到画布
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -14,8 +14,6 @@ namespace Ink_Canvas
|
|||||||
{
|
{
|
||||||
public partial class MainWindow : Window
|
public partial class MainWindow : Window
|
||||||
{
|
{
|
||||||
private bool _isAreaScreenshotInProgress;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 在切页/加页场景下使用:先捕获当前画面到内存并克隆墨迹,然后立即返回;截图与墨迹保存在后台异步执行,不阻塞切页。
|
/// 在切页/加页场景下使用:先捕获当前画面到内存并克隆墨迹,然后立即返回;截图与墨迹保存在后台异步执行,不阻塞切页。
|
||||||
/// 调用方应在调用本方法后立即执行 SaveStrokes、ClearStrokes、切页、RestoreStrokes 等逻辑。
|
/// 调用方应在调用本方法后立即执行 SaveStrokes、ClearStrokes、切页、RestoreStrokes 等逻辑。
|
||||||
@@ -159,98 +157,13 @@ namespace Ink_Canvas
|
|||||||
SaveInkCanvasStrokes(false);
|
SaveInkCanvasStrokes(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private struct AnnotationSuspendState
|
|
||||||
{
|
|
||||||
public bool WasInAnnotationMode;
|
|
||||||
public int OriginalMode;
|
|
||||||
public System.Windows.Media.Brush OriginalFakeBackground;
|
|
||||||
public double OriginalFakeBackgroundOpacity;
|
|
||||||
public Visibility OriginalBackgroundCoverHolderVisibility;
|
|
||||||
public Visibility OriginalCanvasControlsVisibility;
|
|
||||||
public object OriginalHideInkCanvasContent;
|
|
||||||
}
|
|
||||||
|
|
||||||
private AnnotationSuspendState SuspendAnnotationForAreaScreenshotIfNeeded()
|
|
||||||
{
|
|
||||||
var state = new AnnotationSuspendState
|
|
||||||
{
|
|
||||||
WasInAnnotationMode = GridTransparencyFakeBackground.Background != System.Windows.Media.Brushes.Transparent,
|
|
||||||
OriginalMode = currentMode,
|
|
||||||
OriginalFakeBackground = GridTransparencyFakeBackground.Background,
|
|
||||||
OriginalFakeBackgroundOpacity = GridTransparencyFakeBackground.Opacity,
|
|
||||||
OriginalBackgroundCoverHolderVisibility = GridBackgroundCoverHolder.Visibility,
|
|
||||||
OriginalCanvasControlsVisibility = StackPanelCanvasControls.Visibility,
|
|
||||||
OriginalHideInkCanvasContent = BtnHideInkCanvas.Content
|
|
||||||
};
|
|
||||||
|
|
||||||
if (!state.WasInAnnotationMode)
|
|
||||||
{
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 仅暂停批注视觉态,避免调用 BtnHideInkCanvas_Click 触发自动截图/上传及白板状态读写。
|
|
||||||
GridTransparencyFakeBackground.Opacity = 0;
|
|
||||||
GridTransparencyFakeBackground.Background = System.Windows.Media.Brushes.Transparent;
|
|
||||||
GridBackgroundCoverHolder.Visibility = Visibility.Collapsed;
|
|
||||||
StackPanelCanvasControls.Visibility = Visibility.Collapsed;
|
|
||||||
CheckEnableTwoFingerGestureBtnVisibility(false);
|
|
||||||
HideSubPanels("cursor");
|
|
||||||
BtnHideInkCanvas.Content = "显示\n画板";
|
|
||||||
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void RestoreAnnotationAfterAreaScreenshot(AnnotationSuspendState state)
|
|
||||||
{
|
|
||||||
if (!state.WasInAnnotationMode || currentMode != state.OriginalMode)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
GridTransparencyFakeBackground.Opacity = state.OriginalFakeBackgroundOpacity;
|
|
||||||
GridTransparencyFakeBackground.Background = state.OriginalFakeBackground;
|
|
||||||
GridBackgroundCoverHolder.Visibility = state.OriginalBackgroundCoverHolderVisibility;
|
|
||||||
StackPanelCanvasControls.Visibility = state.OriginalCanvasControlsVisibility;
|
|
||||||
CheckEnableTwoFingerGestureBtnVisibility(state.OriginalCanvasControlsVisibility == Visibility.Visible);
|
|
||||||
BtnHideInkCanvas.Content = state.OriginalHideInkCanvasContent;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal async Task SaveAreaScreenShotToDesktop()
|
internal async Task SaveAreaScreenShotToDesktop()
|
||||||
{
|
{
|
||||||
if (_isAreaScreenshotInProgress)
|
var originalVisibility = Visibility;
|
||||||
{
|
|
||||||
ShowNotification("截图进行中,请先完成当前截图");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_isAreaScreenshotInProgress = true;
|
|
||||||
|
|
||||||
var annotationState = SuspendAnnotationForAreaScreenshotIfNeeded();
|
|
||||||
var originalFloatingBarVisibility = ViewboxFloatingBar.Visibility;
|
|
||||||
var shouldRestoreFloatingBarVisibility = true;
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (annotationState.WasInAnnotationMode)
|
Visibility = Visibility.Hidden;
|
||||||
{
|
await Task.Delay(200);
|
||||||
// 等待一次 UI 刷新,确保批注暂停状态已完成。
|
|
||||||
await System.Windows.Threading.Dispatcher.Yield(System.Windows.Threading.DispatcherPriority.Render);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 从浮动栏触发选区截图时,临时隐藏浮动栏,避免遮挡选区与误入截图。
|
|
||||||
if (originalFloatingBarVisibility == Visibility.Visible)
|
|
||||||
{
|
|
||||||
ViewboxFloatingBar.Visibility = Visibility.Collapsed;
|
|
||||||
await System.Windows.Threading.Dispatcher.Yield(System.Windows.Threading.DispatcherPriority.Render);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 选区截图时确保墨迹层可见,避免从浮动栏触发时出现“先隐藏再截图”。
|
|
||||||
if (inkCanvas.Visibility != Visibility.Visible)
|
|
||||||
{
|
|
||||||
inkCanvas.Visibility = Visibility.Visible;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 等待一次 UI 刷新,确保可见性状态已生效。
|
|
||||||
await System.Windows.Threading.Dispatcher.Yield(System.Windows.Threading.DispatcherPriority.Render);
|
|
||||||
|
|
||||||
var screenshotResult = await ShowScreenshotSelector();
|
var screenshotResult = await ShowScreenshotSelector();
|
||||||
|
|
||||||
@@ -262,12 +175,7 @@ namespace Ink_Canvas
|
|||||||
|
|
||||||
if (screenshotResult.Value.AddToWhiteboard)
|
if (screenshotResult.Value.AddToWhiteboard)
|
||||||
{
|
{
|
||||||
// 仅在白板接管流程已确认完成时,才跳过本方法对浮动栏可见性的恢复。
|
await AddScreenshotToNewWhiteboardPage(screenshotResult.Value);
|
||||||
var whiteboardHandoffCompleted = await AddScreenshotToNewWhiteboardPage(screenshotResult.Value);
|
|
||||||
if (whiteboardHandoffCompleted)
|
|
||||||
{
|
|
||||||
shouldRestoreFloatingBarVisibility = false;
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -281,7 +189,7 @@ namespace Ink_Canvas
|
|||||||
Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory),
|
Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory),
|
||||||
$"{DateTime.Now:yyyy-MM-dd_HH-mm-ss}.png");
|
$"{DateTime.Now:yyyy-MM-dd_HH-mm-ss}.png");
|
||||||
|
|
||||||
using (var originalBitmap = CaptureScreenAreaWithOptionalInk(screenshotResult.Value.Area, screenshotResult.Value.IncludeInk))
|
using (var originalBitmap = CaptureScreenArea(screenshotResult.Value.Area))
|
||||||
{
|
{
|
||||||
if (originalBitmap == null)
|
if (originalBitmap == null)
|
||||||
{
|
{
|
||||||
@@ -327,16 +235,11 @@ namespace Ink_Canvas
|
|||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
_isAreaScreenshotInProgress = false;
|
Visibility = originalVisibility;
|
||||||
if (shouldRestoreFloatingBarVisibility)
|
|
||||||
{
|
|
||||||
ViewboxFloatingBar.Visibility = originalFloatingBarVisibility;
|
|
||||||
}
|
|
||||||
RestoreAnnotationAfterAreaScreenshot(annotationState);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<bool> AddScreenshotToNewWhiteboardPage(ScreenshotResult screenshotResult)
|
private async Task AddScreenshotToNewWhiteboardPage(ScreenshotResult screenshotResult)
|
||||||
{
|
{
|
||||||
// 先在当前场景准备截图数据,再进白板,避免误截到白板页面
|
// 先在当前场景准备截图数据,再进白板,避免误截到白板页面
|
||||||
BitmapSource bitmapSourceForClipboard = null;
|
BitmapSource bitmapSourceForClipboard = null;
|
||||||
@@ -356,15 +259,15 @@ namespace Ink_Canvas
|
|||||||
if (screenshotResult.Area.Width <= 0 || screenshotResult.Area.Height <= 0)
|
if (screenshotResult.Area.Width <= 0 || screenshotResult.Area.Height <= 0)
|
||||||
{
|
{
|
||||||
ShowNotification("未选择有效截图区域");
|
ShowNotification("未选择有效截图区域");
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
using (var originalBitmap = CaptureScreenAreaWithOptionalInk(screenshotResult.Area, screenshotResult.IncludeInk))
|
using (var originalBitmap = CaptureScreenArea(screenshotResult.Area))
|
||||||
{
|
{
|
||||||
if (originalBitmap == null)
|
if (originalBitmap == null)
|
||||||
{
|
{
|
||||||
ShowNotification("截图失败");
|
ShowNotification("截图失败");
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Bitmap finalBitmap = originalBitmap;
|
Bitmap finalBitmap = originalBitmap;
|
||||||
@@ -393,7 +296,7 @@ namespace Ink_Canvas
|
|||||||
if (bitmapSourceForClipboard == null)
|
if (bitmapSourceForClipboard == null)
|
||||||
{
|
{
|
||||||
ShowNotification("截图转换失败");
|
ShowNotification("截图转换失败");
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 图像已拷贝到内存后再进入白板
|
// 图像已拷贝到内存后再进入白板
|
||||||
@@ -408,7 +311,6 @@ namespace Ink_Canvas
|
|||||||
BtnWhiteBoardAdd_Click(null, EventArgs.Empty);
|
BtnWhiteBoardAdd_Click(null, EventArgs.Empty);
|
||||||
|
|
||||||
await InsertBitmapSourceToCanvas(bitmapSourceForClipboard);
|
await InsertBitmapSourceToCanvas(bitmapSourceForClipboard);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -140,17 +140,6 @@
|
|||||||
Margin="8,0"
|
Margin="8,0"
|
||||||
Background="#404040" />
|
Background="#404040" />
|
||||||
|
|
||||||
<!-- 选项开关 -->
|
|
||||||
<CheckBox Name="IncludeInkCheckBox"
|
|
||||||
Content="包含墨迹"
|
|
||||||
IsChecked="True"
|
|
||||||
Margin="8,0"
|
|
||||||
VerticalAlignment="Center"
|
|
||||||
Foreground="White"
|
|
||||||
FontWeight="Medium"
|
|
||||||
Checked="IncludeInkCheckBox_Checked"
|
|
||||||
Unchecked="IncludeInkCheckBox_Unchecked" />
|
|
||||||
|
|
||||||
<!-- 操作按钮 -->
|
<!-- 操作按钮 -->
|
||||||
<Button Name="ConfirmButton"
|
<Button Name="ConfirmButton"
|
||||||
Content="确认截图"
|
Content="确认截图"
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ namespace Ink_Canvas
|
|||||||
private Bitmap _capturedCameraImage = null;
|
private Bitmap _capturedCameraImage = null;
|
||||||
private DateTime _lastBlankClickTime = DateTime.MinValue;
|
private DateTime _lastBlankClickTime = DateTime.MinValue;
|
||||||
private WpfPoint _lastBlankClickPosition;
|
private WpfPoint _lastBlankClickPosition;
|
||||||
private readonly Action<bool> _includeInkPreviewChanged;
|
|
||||||
|
|
||||||
private const int DoubleClickTimeThresholdMs = 300; // 双击判定时间阈值(常见范围 200~500ms)
|
private const int DoubleClickTimeThresholdMs = 300; // 双击判定时间阈值(常见范围 200~500ms)
|
||||||
private const double DoubleClickDistanceThresholdPx = 12; // 双击判定位置阈值(像素)
|
private const double DoubleClickDistanceThresholdPx = 12; // 双击判定位置阈值(像素)
|
||||||
@@ -56,17 +55,10 @@ namespace Ink_Canvas
|
|||||||
public Bitmap CameraImage { get; private set; }
|
public Bitmap CameraImage { get; private set; }
|
||||||
public System.Windows.Media.Imaging.BitmapSource CameraBitmapSource { get; private set; }
|
public System.Windows.Media.Imaging.BitmapSource CameraBitmapSource { get; private set; }
|
||||||
public bool ShouldAddToWhiteboard { get; private set; }
|
public bool ShouldAddToWhiteboard { get; private set; }
|
||||||
public bool ShouldIncludeInk { get; private set; } = true;
|
|
||||||
|
|
||||||
public ScreenshotSelectorWindow()
|
public ScreenshotSelectorWindow()
|
||||||
: this(null)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public ScreenshotSelectorWindow(Action<bool> includeInkPreviewChanged)
|
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_includeInkPreviewChanged = includeInkPreviewChanged;
|
|
||||||
|
|
||||||
// 设置窗口覆盖所有屏幕
|
// 设置窗口覆盖所有屏幕
|
||||||
SetupFullScreenOverlay();
|
SetupFullScreenOverlay();
|
||||||
@@ -92,8 +84,6 @@ namespace Ink_Canvas
|
|||||||
timer.Stop();
|
timer.Stop();
|
||||||
};
|
};
|
||||||
timer.Start();
|
timer.Start();
|
||||||
|
|
||||||
ApplyIncludeInkPreviewState(ShouldIncludeInk);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitializeFreehandMode()
|
private void InitializeFreehandMode()
|
||||||
@@ -539,30 +529,6 @@ namespace Ink_Canvas
|
|||||||
ConfirmSelection();
|
ConfirmSelection();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void IncludeInkCheckBox_Checked(object sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
ShouldIncludeInk = true;
|
|
||||||
ApplyIncludeInkPreviewState(ShouldIncludeInk);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void IncludeInkCheckBox_Unchecked(object sender, RoutedEventArgs e)
|
|
||||||
{
|
|
||||||
ShouldIncludeInk = false;
|
|
||||||
ApplyIncludeInkPreviewState(ShouldIncludeInk);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ApplyIncludeInkPreviewState(bool shouldIncludeInk)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_includeInkPreviewChanged?.Invoke(shouldIncludeInk);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
LogHelper.WriteLogToFile($"更新“包含墨迹”实时预览失败: {ex.Message}", LogHelper.LogType.Warning);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ConfirmCameraCapture()
|
private void ConfirmCameraCapture()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -1514,9 +1480,6 @@ namespace Ink_Canvas
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// 关闭窗口时恢复墨迹预览状态
|
|
||||||
ApplyIncludeInkPreviewState(true);
|
|
||||||
|
|
||||||
// 清理摄像头资源
|
// 清理摄像头资源
|
||||||
if (_cameraService != null)
|
if (_cameraService != null)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user