状态栏优化:测量信息显示到主界面底部状态栏,移除图像窗口状态栏,MainViewModel改为单例注册
This commit is contained in:
@@ -30,7 +30,6 @@ bld/
|
|||||||
lib/
|
lib/
|
||||||
XP.ImageProcessing/
|
XP.ImageProcessing/
|
||||||
ImageProcessing.sln
|
ImageProcessing.sln
|
||||||
ExternalLibraries/
|
|
||||||
|
|
||||||
# 排除 Libs 目录中的 DLL 和 PDB 文件(但保留目录结构)
|
# 排除 Libs 目录中的 DLL 和 PDB 文件(但保留目录结构)
|
||||||
XplorePlane/Libs/Hardware/*.dll
|
XplorePlane/Libs/Hardware/*.dll
|
||||||
|
|||||||
@@ -334,7 +334,7 @@ namespace XplorePlane
|
|||||||
|
|
||||||
// 注册视图和视图模型
|
// 注册视图和视图模型
|
||||||
containerRegistry.RegisterForNavigation<MainWindow>();
|
containerRegistry.RegisterForNavigation<MainWindow>();
|
||||||
containerRegistry.Register<MainViewModel>();
|
containerRegistry.RegisterSingleton<MainViewModel>();
|
||||||
containerRegistry.RegisterSingleton<NavigationPropertyPanelViewModel>();
|
containerRegistry.RegisterSingleton<NavigationPropertyPanelViewModel>();
|
||||||
|
|
||||||
// 注册图像处理服务与视图
|
// 注册图像处理服务与视图
|
||||||
|
|||||||
@@ -571,7 +571,7 @@
|
|||||||
FontFamily="Microsoft YaHei UI"
|
FontFamily="Microsoft YaHei UI"
|
||||||
FontSize="11"
|
FontSize="11"
|
||||||
Foreground="White"
|
Foreground="White"
|
||||||
Text="就绪" />
|
Text="{Binding StatusMessage}" />
|
||||||
|
|
||||||
<!-- 右侧: 鼠标坐标 + RGB -->
|
<!-- 右侧: 鼠标坐标 + RGB -->
|
||||||
<TextBlock
|
<TextBlock
|
||||||
|
|||||||
@@ -45,7 +45,5 @@
|
|||||||
|
|
||||||
<!-- 十字线和测量功能已内置于 PolygonRoiCanvas -->
|
<!-- 十字线和测量功能已内置于 PolygonRoiCanvas -->
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
|
|
||||||
</Grid>
|
</Grid>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
|
|||||||
@@ -15,33 +15,47 @@ namespace XplorePlane.Views
|
|||||||
{
|
{
|
||||||
public partial class ViewportPanelView : UserControl
|
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()
|
public ViewportPanelView()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
DataContextChanged += OnDataContextChanged;
|
DataContextChanged += OnDataContextChanged;
|
||||||
|
|
||||||
// 测量事件 → 更新状态栏
|
// 测量事件 → 更新主界面状态栏
|
||||||
RoiCanvas.MeasureCompleted += (s, e) =>
|
RoiCanvas.MeasureCompleted += (s, e) =>
|
||||||
{
|
{
|
||||||
if (e is MeasureCompletedEventArgs args && DataContext is ViewportPanelViewModel vm)
|
if (e is MeasureCompletedEventArgs args)
|
||||||
{
|
{
|
||||||
string typeLabel = args.MeasureType switch
|
string typeLabel = args.MeasureType switch
|
||||||
{
|
{
|
||||||
"PointToLine" => "点线距",
|
"PointToLine" => "点线距",
|
||||||
"Angle" => "角度",
|
"Angle" => "角度",
|
||||||
|
"FillRate" => "填锡率",
|
||||||
_ => "点点距"
|
_ => "点点距"
|
||||||
};
|
};
|
||||||
string valueText = args.MeasureType == "Angle"
|
string valueText = args.MeasureType switch
|
||||||
? $"{args.Distance:F2}°"
|
{
|
||||||
: $"{args.Distance:F2} px";
|
"Angle" => $"{args.Distance:F2}°",
|
||||||
vm.MeasurementResult = valueText;
|
"FillRate" => $"{args.Distance:F1}%",
|
||||||
vm.ImageInfo = $"{typeLabel}: {valueText} | 共 {args.TotalCount} 条测量";
|
_ => $"{args.Distance:F2} px"
|
||||||
|
};
|
||||||
|
SetStatus($"{typeLabel}: {valueText} | 共 {args.TotalCount} 条测量");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
RoiCanvas.MeasureStatusChanged += (s, e) =>
|
RoiCanvas.MeasureStatusChanged += (s, e) =>
|
||||||
{
|
{
|
||||||
if (e is MeasureStatusEventArgs args && DataContext is ViewportPanelViewModel vm)
|
if (e is MeasureStatusEventArgs args)
|
||||||
vm.ImageInfo = args.Message;
|
SetStatus(args.Message);
|
||||||
};
|
};
|
||||||
|
|
||||||
// 十字辅助线:直接订阅 Prism 事件
|
// 十字辅助线:直接订阅 Prism 事件
|
||||||
@@ -61,6 +75,7 @@ namespace XplorePlane.Views
|
|||||||
MeasurementToolMode.PointDistance => XP.ImageProcessing.RoiControl.Models.MeasureMode.PointDistance,
|
MeasurementToolMode.PointDistance => XP.ImageProcessing.RoiControl.Models.MeasureMode.PointDistance,
|
||||||
MeasurementToolMode.PointLineDistance => XP.ImageProcessing.RoiControl.Models.MeasureMode.PointToLine,
|
MeasurementToolMode.PointLineDistance => XP.ImageProcessing.RoiControl.Models.MeasureMode.PointToLine,
|
||||||
MeasurementToolMode.Angle => XP.ImageProcessing.RoiControl.Models.MeasureMode.Angle,
|
MeasurementToolMode.Angle => XP.ImageProcessing.RoiControl.Models.MeasureMode.Angle,
|
||||||
|
MeasurementToolMode.ThroughHoleFillRate => XP.ImageProcessing.RoiControl.Models.MeasureMode.FillRate,
|
||||||
_ => XP.ImageProcessing.RoiControl.Models.MeasureMode.None
|
_ => XP.ImageProcessing.RoiControl.Models.MeasureMode.None
|
||||||
};
|
};
|
||||||
}, Prism.Events.ThreadOption.UIThread);
|
}, Prism.Events.ThreadOption.UIThread);
|
||||||
@@ -91,10 +106,8 @@ namespace XplorePlane.Views
|
|||||||
{
|
{
|
||||||
RoiCanvas.ClearMeasurements();
|
RoiCanvas.ClearMeasurements();
|
||||||
if (DataContext is ViewportPanelViewModel vm)
|
if (DataContext is ViewportPanelViewModel vm)
|
||||||
{
|
|
||||||
vm.ResetMeasurementState();
|
vm.ResetMeasurementState();
|
||||||
vm.ImageInfo = "已清除所有测量";
|
SetStatus("已清除所有测量");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SaveOriginalImage_Click(object sender, RoutedEventArgs e)
|
private void SaveOriginalImage_Click(object sender, RoutedEventArgs e)
|
||||||
|
|||||||
Reference in New Issue
Block a user