增强打印预览功能,新增离线打印功能,新增缩放控制按钮以提升用户体验。优化打印数据准备逻辑,支持实时预览缩放,确保打印效果的一致性。同时,重构相关视图和服务以增强系统的可维护性和扩展性。

This commit is contained in:
geht
2026-05-14 11:25:17 +08:00
parent 8bcc34aee0
commit 296bc2a4b2
7 changed files with 702 additions and 109 deletions

View File

@@ -49,10 +49,22 @@ public partial class RawMaterialEntryOperationView : UserControl
// null/空 表示“所有属性”通知Prism/BindableBase 批量刷新时),需同步分割布局
if (!string.IsNullOrEmpty(e.PropertyName)
&& e.PropertyName is not nameof(RawMaterialEntryOperationViewModel.IsRightPanelExpanded)
&& e.PropertyName is not nameof(RawMaterialEntryOperationViewModel.ExpandedRightPanelWidth))
&& e.PropertyName is not nameof(RawMaterialEntryOperationViewModel.ExpandedRightPanelWidth)
&& e.PropertyName is not nameof(RawMaterialEntryOperationViewModel.PrintPreviewZoomFactor))
return;
_ = Dispatcher.InvokeAsync(ApplySplitLayout);
if (string.IsNullOrEmpty(e.PropertyName)
|| e.PropertyName is nameof(RawMaterialEntryOperationViewModel.IsRightPanelExpanded)
|| e.PropertyName is nameof(RawMaterialEntryOperationViewModel.ExpandedRightPanelWidth))
{
_ = Dispatcher.InvokeAsync(ApplySplitLayout);
}
if (string.IsNullOrEmpty(e.PropertyName)
|| e.PropertyName is nameof(RawMaterialEntryOperationViewModel.PrintPreviewZoomFactor))
{
_ = Dispatcher.InvokeAsync(ApplyPrintPreviewZoom);
}
}
/// <summary>按钮 Click 在 Command 之后执行,用于兜底刷新列宽(不重复切换状态)。</summary>
@@ -66,6 +78,7 @@ public partial class RawMaterialEntryOperationView : UserControl
EnsureVmAttached();
ApplySplitLayout();
ApplyPrintPreviewZoom();
if (DataContext is RawMaterialEntryOperationViewModel vm && !_initialized)
{
@@ -92,6 +105,7 @@ public partial class RawMaterialEntryOperationView : UserControl
try
{
await PrintPreviewWebView.EnsureCoreWebView2Async();
ApplyPrintPreviewZoom();
PrintPreviewWebView.NavigateToString(html ?? string.Empty);
}
catch
@@ -100,6 +114,15 @@ public partial class RawMaterialEntryOperationView : UserControl
}
}
private void ApplyPrintPreviewZoom()
{
var vm = _vm ?? DataContext as RawMaterialEntryOperationViewModel;
if (vm == null) return;
if (PrintPreviewWebView?.CoreWebView2 == null) return;
// 实时预览已关闭 HTML 内部 fitPage自定义缩放直接映射到 WebView2 即可(+ 放大,- 缩小)。
PrintPreviewWebView.ZoomFactor = vm.PrintPreviewZoomFactor;
}
/// <summary>
/// 根据 ViewModel 同步右侧栏与分割条:展开时使用持久化宽度;折叠时右栏与分割条占宽均为 0完全隐藏
/// </summary>