状态栏优化:测量信息显示到主界面底部状态栏,移除图像窗口状态栏,MainViewModel改为单例注册
This commit is contained in:
@@ -30,7 +30,6 @@ bld/
|
||||
lib/
|
||||
XP.ImageProcessing/
|
||||
ImageProcessing.sln
|
||||
ExternalLibraries/
|
||||
|
||||
# 排除 Libs 目录中的 DLL 和 PDB 文件(但保留目录结构)
|
||||
XplorePlane/Libs/Hardware/*.dll
|
||||
|
||||
@@ -334,7 +334,7 @@ namespace XplorePlane
|
||||
|
||||
// 注册视图和视图模型
|
||||
containerRegistry.RegisterForNavigation<MainWindow>();
|
||||
containerRegistry.Register<MainViewModel>();
|
||||
containerRegistry.RegisterSingleton<MainViewModel>();
|
||||
containerRegistry.RegisterSingleton<NavigationPropertyPanelViewModel>();
|
||||
|
||||
// 注册图像处理服务与视图
|
||||
|
||||
@@ -571,7 +571,7 @@
|
||||
FontFamily="Microsoft YaHei UI"
|
||||
FontSize="11"
|
||||
Foreground="White"
|
||||
Text="就绪" />
|
||||
Text="{Binding StatusMessage}" />
|
||||
|
||||
<!-- 右侧: 鼠标坐标 + RGB -->
|
||||
<TextBlock
|
||||
|
||||
@@ -45,7 +45,5 @@
|
||||
|
||||
<!-- 十字线和测量功能已内置于 PolygonRoiCanvas -->
|
||||
</Grid>
|
||||
|
||||
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
||||
@@ -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<MainViewModel>(); } 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)
|
||||
|
||||
Reference in New Issue
Block a user