using MainShell.AlgorithmCalib.Service; using MainShell.Hardware; using MaxwellFramework.Core.Interfaces; using MwFramework.Controls.Components; using MwFramework.ManagerService; using Stylet; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Input; namespace MainShell.AlgorithmCalib.ViewModel { public class FusionCalibViewModel:Screen,IPage { private HardwareManager _hardware; private FusionCalibMotionService _fusionCalibMotionService; public ICommand PrevCommand { get; set; } public ICommand NextCommand { get; set; } private IParameterManager _parameterManager; public string Name { get; set; } = "FusionCalib"; private bool _isInit = false; private ObservableCollection _Screens; /// /// 需要显示的界面 /// public ObservableCollection Screens { get { return _Screens; } set { SetAndNotify(ref _Screens, value); } } private Screen _ShowScreenVM; /// /// 当前显示界面的VM /// public Screen ShowScreenVM { get { return _ShowScreenVM; } set { SetAndNotify(ref _ShowScreenVM, value); } } private string _currentCalibName; /// /// 当前标定名称,供UI标定 /// public string CurrentCalibName { get { return _currentCalibName; } set { SetAndNotify(ref _currentCalibName, value); } } private string _progressText; /// /// 进度提示 /// public string ProgressText { get { return _progressText; } set { SetAndNotify(ref _progressText, value); } } private int _showIndex; /// /// 当前显示界面的下标 /// public int ShowIndex { get { return _showIndex; } set { SetAndNotify(ref _showIndex, value); } } private bool _isEnablePrev; /// /// 上一个按钮是否启用 /// public bool IsEnablePrev { get { return _isEnablePrev; } set { SetAndNotify(ref _isEnablePrev, value); } } private bool _isEnableNext = true; /// /// 下一个按钮是否启用 /// public bool IsEnableNext { get { return _isEnableNext; } set { SetAndNotify(ref _isEnableNext, value); } } public FusionCalibViewModel(IParameterManager paraManager) { _hardware = IoC.Get(); _fusionCalibMotionService=IoC.Get(); this._parameterManager = paraManager; PrevCommand = new DelegateCommand(() => { OnPrev(); }); NextCommand = new DelegateCommand(() => { OnNext(); }); } protected override void OnViewLoaded() { base.OnViewLoaded(); if (!_isInit) { Screens = new ObservableCollection(); var cameraConfigs = new List<(string Name, string FileSaveName, List Device)> { ("Die融合标定","topWsCameraFusion", _hardware.CameraAxisManager.TopCameraWsAxisDevices), ("Map相机融合标定","wideCameraFusion", _hardware.CameraAxisManager.WideCameraAxisDevices), }; Screens.Add(FusionMenuCalibViewModel.Create("Pad融合标定", "topCameraFusion", _hardware.CameraAxisManager.TopCameraAxisDevices,_hardware,_fusionCalibMotionService)); foreach (var (name, fileSaveName, device) in cameraConfigs) { Screens.Add(CameraFusionCalibViewModel.Create(name, fileSaveName, device, _hardware, _fusionCalibMotionService)); } // 默认显示第一个 ShowIndex = 0; ShowScreenVM = Screens[0]; UpdateNavigationState(); _isInit = true; } } public void viewUnLoad() { //_device.ChangeCameraMode(CameraTriggerMode.On); //_pLCControlOperation.CyliderPress(true); } private void OnPrev() { if (ShowIndex <= 0) return; ShowIndex--; ShowScreenVM = Screens[ShowIndex]; UpdateNavigationState(); // ← 加上这行 } private void OnNext() { if (ShowIndex >= Screens.Count - 1) return; ShowIndex++; ShowScreenVM = Screens[ShowIndex]; UpdateNavigationState(); // ← 加上这行 } /// /// 统一更新导航状态和当前相机信息 /// private void UpdateNavigationState() { IsEnablePrev = ShowIndex > 0; IsEnableNext = ShowIndex < Screens.Count - 1; // 更新当前相机名称 if (ShowScreenVM is CameraFusionCalibViewModel camVm) { CurrentCalibName = camVm.CalibName; } if (ShowScreenVM is FusionMenuCalibViewModel Vm) { CurrentCalibName = Vm.CalibName; } // 更新进度 ProgressText = $"{ShowIndex + 1} / {Screens.Count}"; } } }