957157ae80
## Compilation fixes - Fix XAML namespace reference XplorePlane.Converters → XplorePlane.Helpers (EventLogView, StateDisplayView) - Add missing using for ISampleTypeRepository / JsonSampleTypeRepository in App.xaml.cs - Fix ILoggerService.Warn() calls using Exception as first arg instead of message string - Serialize CncProgram to JSON when passing to MatrixLayout (expects string, not CncProgram object) - Suppress CS8632 nullable annotation warnings project-wide ## BGA wizard fixes - Fix preview not showing on step 3: force RefreshBgaPreview() when entering final step - Add step validation in CanNext() to prevent skipping to preview with invalid inputs - Notify NextCommand.CanExecuteChanged when inputs change - Fix RunProgress runtime binding error: set Mode=OneWay for ProgressBar.Value ## Operator toolbox: prevent duplicate insertion - Add static OperatorTarget property for direct dispatch to active pipeline - PipelineEditorView registers as toolbox target on load (floating window only) - CNC page sets initial target; PipelineEditorWindow resets to CNC pipeline on close - '+' button inserts only to the active pipeline instead of broadcasting to all subscribers ## Pipeline editor status bar messages - Add StatusBarMessageEvent / StatusBarMessagePayload to CommonEvents.cs - PipelineEditorViewModel publishes status on all ops (add/remove/reorder/save/execute) - MainViewModel subscribes and displays on main window bottom status bar - Auto-clear after timeout (3s info, 5s error) ## docs - Merge three architecture docs into consolidated XplorePlane-架构与结构说明.md
63 lines
2.4 KiB
C#
63 lines
2.4 KiB
C#
using System.Collections.Specialized;
|
|
using System.ComponentModel;
|
|
using System.Windows;
|
|
using XP.Common.Logging.Interfaces;
|
|
using XP.Hardware.Plc.Abstractions;
|
|
using XP.Hardware.PLC.ViewModels;
|
|
|
|
namespace XP.Hardware.PLC.Views
|
|
{
|
|
/// <summary>
|
|
/// PLC 测试工具窗口 Code-Behind | PLC Test Bench Window Code-Behind
|
|
/// </summary>
|
|
public partial class PlcTestBenchWindow : Window
|
|
{
|
|
private readonly PlcTestBenchViewModel _viewModel;
|
|
|
|
/// <summary>
|
|
/// 构造函数 | Constructor
|
|
/// </summary>
|
|
/// <param name="plcClient">PLC 客户端接口 | PLC client interface</param>
|
|
/// <param name="logger">日志服务 | Logger service</param>
|
|
public PlcTestBenchWindow(IPlcClient plcClient, ILoggerService logger)
|
|
{
|
|
InitializeComponent();
|
|
_viewModel = new PlcTestBenchViewModel(plcClient, logger);
|
|
DataContext = _viewModel;
|
|
|
|
// 继承主窗口图标
|
|
if (Application.Current?.MainWindow != null)
|
|
{
|
|
Icon = Application.Current.MainWindow.Icon;
|
|
}
|
|
|
|
// 订阅日志集合变化,自动滚动到最新条目 | Subscribe to log collection changes for auto-scroll
|
|
_viewModel.LogEntries.CollectionChanged += LogEntries_CollectionChanged;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 日志集合变化时自动滚动到最新条目 | Auto-scroll to latest entry on collection change
|
|
/// </summary>
|
|
private void LogEntries_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
|
|
{
|
|
if (e.Action == NotifyCollectionChangedAction.Add && _viewModel.LogEntries.Count > 0)
|
|
{
|
|
// 使用 Dispatcher 延迟执行,确保 UI 渲染完成后再滚动 | Use Dispatcher to ensure UI rendering is complete before scrolling
|
|
Dispatcher.InvokeAsync(() =>
|
|
{
|
|
LogListBox.ScrollIntoView(_viewModel.LogEntries[_viewModel.LogEntries.Count - 1]);
|
|
}, System.Windows.Threading.DispatcherPriority.Background);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 窗口关闭时释放资源 | Release resources on window closing
|
|
/// </summary>
|
|
protected override void OnClosing(CancelEventArgs e)
|
|
{
|
|
_viewModel?.Cleanup();
|
|
base.OnClosing(e);
|
|
}
|
|
}
|
|
}
|