diff --git a/.gitignore b/.gitignore index a13a714..0b8391a 100644 --- a/.gitignore +++ b/.gitignore @@ -30,7 +30,6 @@ bld/ lib/ XP.ImageProcessing/ ImageProcessing.sln -ExternalLibraries/ # 排除 Libs 目录中的 DLL 和 PDB 文件(但保留目录结构) XplorePlane/Libs/Hardware/*.dll diff --git a/XplorePlane/App.xaml.cs b/XplorePlane/App.xaml.cs index 26cb81b..a66e158 100644 --- a/XplorePlane/App.xaml.cs +++ b/XplorePlane/App.xaml.cs @@ -334,7 +334,7 @@ namespace XplorePlane // 注册视图和视图模型 containerRegistry.RegisterForNavigation(); - containerRegistry.Register(); + containerRegistry.RegisterSingleton(); containerRegistry.RegisterSingleton(); // 注册图像处理服务与视图 diff --git a/XplorePlane/Views/Main/MainWindow.xaml b/XplorePlane/Views/Main/MainWindow.xaml index 42597af..3342471 100644 --- a/XplorePlane/Views/Main/MainWindow.xaml +++ b/XplorePlane/Views/Main/MainWindow.xaml @@ -571,7 +571,7 @@ FontFamily="Microsoft YaHei UI" FontSize="11" Foreground="White" - Text="就绪" /> + Text="{Binding StatusMessage}" /> - - diff --git a/XplorePlane/Views/Main/ViewportPanelView.xaml.cs b/XplorePlane/Views/Main/ViewportPanelView.xaml.cs index 9438a2f..888c67e 100644 --- a/XplorePlane/Views/Main/ViewportPanelView.xaml.cs +++ b/XplorePlane/Views/Main/ViewportPanelView.xaml.cs @@ -15,33 +15,47 @@ namespace XplorePlane.Views { public partial class ViewportPanelView : UserControl { + private MainViewModel _mainVm; + + private void SetStatus(string msg) + { + if (_mainVm == null) + { + try { _mainVm = ContainerLocator.Current?.Resolve(); } catch { } + } + if (_mainVm != null) _mainVm.StatusMessage = msg; + } + public ViewportPanelView() { InitializeComponent(); DataContextChanged += OnDataContextChanged; - // 测量事件 → 更新状态栏 + // 测量事件 → 更新主界面状态栏 RoiCanvas.MeasureCompleted += (s, e) => { - if (e is MeasureCompletedEventArgs args && DataContext is ViewportPanelViewModel vm) + if (e is MeasureCompletedEventArgs args) { string typeLabel = args.MeasureType switch { "PointToLine" => "点线距", "Angle" => "角度", + "FillRate" => "填锡率", _ => "点点距" }; - string valueText = args.MeasureType == "Angle" - ? $"{args.Distance:F2}°" - : $"{args.Distance:F2} px"; - vm.MeasurementResult = valueText; - vm.ImageInfo = $"{typeLabel}: {valueText} | 共 {args.TotalCount} 条测量"; + string valueText = args.MeasureType switch + { + "Angle" => $"{args.Distance:F2}°", + "FillRate" => $"{args.Distance:F1}%", + _ => $"{args.Distance:F2} px" + }; + SetStatus($"{typeLabel}: {valueText} | 共 {args.TotalCount} 条测量"); } }; RoiCanvas.MeasureStatusChanged += (s, e) => { - if (e is MeasureStatusEventArgs args && DataContext is ViewportPanelViewModel vm) - vm.ImageInfo = args.Message; + if (e is MeasureStatusEventArgs args) + SetStatus(args.Message); }; // 十字辅助线:直接订阅 Prism 事件 @@ -61,6 +75,7 @@ namespace XplorePlane.Views MeasurementToolMode.PointDistance => XP.ImageProcessing.RoiControl.Models.MeasureMode.PointDistance, MeasurementToolMode.PointLineDistance => XP.ImageProcessing.RoiControl.Models.MeasureMode.PointToLine, MeasurementToolMode.Angle => XP.ImageProcessing.RoiControl.Models.MeasureMode.Angle, + MeasurementToolMode.ThroughHoleFillRate => XP.ImageProcessing.RoiControl.Models.MeasureMode.FillRate, _ => XP.ImageProcessing.RoiControl.Models.MeasureMode.None }; }, Prism.Events.ThreadOption.UIThread); @@ -91,10 +106,8 @@ namespace XplorePlane.Views { RoiCanvas.ClearMeasurements(); if (DataContext is ViewportPanelViewModel vm) - { vm.ResetMeasurementState(); - vm.ImageInfo = "已清除所有测量"; - } + SetStatus("已清除所有测量"); } private void SaveOriginalImage_Click(object sender, RoutedEventArgs e)