using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using Microsoft.Extensions.DependencyInjection;
using SlnMesnac.Business;
using SlnMesnac.Repository;
using SlnMesnac.Repository.service;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

#region << 版 本 注 释 >>
/*--------------------------------------------------------------------
* 版权所有 (c) 2024 WenJY 保留所有权利。
* CLR版本：4.0.30319.42000
* 机器名称：T14-GEN3-7895
* 命名空间：SlnMesnac.WPF.ViewModel
* 唯一标识：82a9c020-20a4-4f1a-8a87-2081004da0c9
*
* 创建者：WenJY
* 电子邮箱：
* 创建时间：2024-11-29 9:36:57
* 版本：V1.0.0
* 描述：
*
*--------------------------------------------------------------------
* 修改人：
* 时间：
* 修改说明：
*
* 版本：V1.0.0
*--------------------------------------------------------------------*/
#endregion << 版 本 注 释 >>
namespace SlnMesnac.WPF.ViewModel
{
    public partial class FixedPointViewModel : ObservableObject
    {
        private readonly BusbarInfoBusiness busbarInfoBusiness;
        private readonly FixedPointBusiness fixedPointBusiness;

        public FixedPointViewModel(int fixedPointTitle)
        {
            busbarInfoBusiness = App.ServiceProvider.GetService<BusbarInfoBusiness>();
            fixedPointBusiness = App.ServiceProvider.GetService<FixedPointBusiness>();
            FixedPointTitle = $"{fixedPointTitle}#电柜定点巡检";
        }

        public string _fixedPointTitle = "定点巡检";
        public string FixedPointTitle
        {
            get => _fixedPointTitle;
            set => SetProperty(ref _fixedPointTitle, value);
        }

        private ObservableCollection<base_busbar_info> _busbarInfoItems = new ObservableCollection<base_busbar_info>();
        public ObservableCollection<base_busbar_info> BusbarInfoItems
        {
            get => _busbarInfoItems;
            set => SetProperty(ref _busbarInfoItems, value);
        }

        public void QueryBusbarInfo(int cabinetCode)
        {
            busbarInfoBusiness.QueryBusbarInfo(cabinetCode, out List<base_busbar_info> info,false);
            BusbarInfoItems = new ObservableCollection<base_busbar_info>(info);
        }

        private bool isFlag = false;

        [RelayCommand]
        public void StartFixedPoint(base_busbar_info busbar_Info)
        {
            var code = busbar_Info.busbarCode;
            fixedPointBusiness.StartFixedPoint(busbar_Info);
        }

        [RelayCommand]
        public void EndFixedPoint(base_busbar_info busbar_Info)
        {
            var code = busbar_Info.busbarCode;
            fixedPointBusiness.EndFixedPoint(busbar_Info);
        }
    }
}
