From edac024ad942698cef9224dc14c90797da31befb Mon Sep 17 00:00:00 2001 From: CJKmkp <2564608840@qq.com> Date: Fri, 20 Feb 2026 12:06:11 +0800 Subject: [PATCH] =?UTF-8?q?improve:=E5=B1=95=E5=8F=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Ink Canvas/MainWindow_cs/MW_VideoPresenter.cs | 25 ++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/Ink Canvas/MainWindow_cs/MW_VideoPresenter.cs b/Ink Canvas/MainWindow_cs/MW_VideoPresenter.cs index 599fe93f..0398988f 100644 --- a/Ink Canvas/MainWindow_cs/MW_VideoPresenter.cs +++ b/Ink Canvas/MainWindow_cs/MW_VideoPresenter.cs @@ -171,15 +171,27 @@ namespace Ink_Canvas catch { } } + private const double VideoPresenterLiveFrameScreenRatio = 0.75; + private System.Windows.Controls.Image EnsureLiveFrameElementForPage(int page) { if (_liveFrameImageByPage.TryGetValue(page, out var existing) && existing != null) return existing; + double canvasW = inkCanvas?.ActualWidth ?? 0; + double canvasH = inkCanvas?.ActualHeight ?? 0; + double w = canvasW > 10 && canvasH > 10 + ? canvasW * VideoPresenterLiveFrameScreenRatio + : 520; + double h = canvasW > 10 && canvasH > 10 + ? canvasH * VideoPresenterLiveFrameScreenRatio + : 390; + var img = new System.Windows.Controls.Image { Tag = VideoPresenterLiveFrameTag, Stretch = System.Windows.Media.Stretch.Uniform, - Width = 520, + Width = w, + Height = h, Visibility = Visibility.Visible, Opacity = 1.0 }; @@ -206,9 +218,16 @@ namespace Ink_Canvas return; } - // 默认位置:居中偏上 + // 默认尺寸:画布宽高的 75%;位置居中 + double cw = inkCanvas?.ActualWidth ?? 0; + double ch = inkCanvas?.ActualHeight ?? 0; + if (cw > 10 && ch > 10) + { + img.Width = cw * VideoPresenterLiveFrameScreenRatio; + img.Height = ch * VideoPresenterLiveFrameScreenRatio; + } double x = (inkCanvas?.ActualWidth ?? 0) / 2 - img.Width / 2; - double y = (inkCanvas?.ActualHeight ?? 0) / 2 - 200; + double y = (inkCanvas?.ActualHeight ?? 0) / 2 - img.Height / 2; if (double.IsNaN(x) || double.IsInfinity(x)) x = 100; if (double.IsNaN(y) || double.IsInfinity(y)) y = 100; InkCanvas.SetLeft(img, Math.Max(0, x));