using MainShell.Common;
using MainShell.Hardware;
using MainShell.Manual.Model;
using MainShell.ProcessResult;
using MainShell.Recipe.Models;
using Stylet;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MainShell.Manual.ViewModel
{
    public class WaferAngleAdjustmentViewModel : OperateViewModelBase
    {
        private readonly RecipeManager _recipeManager;
        private readonly IEventAggregator _eventAggregator; // 引用 EventAggregator
        private readonly ProcessResultManager _processResultManager;
        private readonly HardwareManager _hardwareManager;
        public WaferAngleAdjustmentViewModel(IEventAggregator eventAggregator,RecipeManager recipeManager,
            ProcessResultManager processResultManager, HardwareManager hardwareManager)
        {
            _eventAggregator = eventAggregator ?? throw new ArgumentNullException(nameof(eventAggregator));
            _recipeManager = recipeManager ?? throw new ArgumentNullException(nameof(recipeManager));
            _processResultManager = processResultManager ?? throw new ArgumentNullException(nameof(processResultManager));
            _hardwareManager = hardwareManager ?? throw new ArgumentNullException(nameof(hardwareManager));
            _cameraAxisViewModel = IoC.Get<Common.Display.ViewModel.CameraAxisViewModel>();
            _cameraAxisViewModel.CameraAxisDevices.HardwareDeviceList = hardwareManager.CameraAxisManager.TopCameraAxisDevices;
        }

        public async Task StartProcess()
        {
            var context = new MW.WorkFlow.WorkflowContext();
            context[WorkflowContextKeys.EventAggregator] = _eventAggregator;
            context[WorkflowContextKeys.RecipeManager] = _recipeManager;
            context[WorkflowContextKeys.ProcessResultManager] = _processResultManager;
            context[WorkflowContextKeys.WorkflowName] = MainShell.Process.ProcessFlowName.ChipStraighteningFlow;

            await RunManualActivityAsync(new MainShell.Process.WaferAngleAdjustmentActivity(MainShell.Process.ProcessFlowName.ChipStraighteningFlow), context);
        }
    }
}
