using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPA.SingleDevice.ViewModel
{
    public class SetBindingMaterialViewModel : NotifyBase, IDialogDataContext
    {
        public SetBindingMaterialViewModel()
        {
            for (int i = 1; i <= 2; i++)
            { DeviceNums.Add(i); }
            for (int i = 4; i <= 5; i++)
            { DeviceNums.Add(i); }
            for (int i = 1; i <= 14; i++)
            { ChNum.Add(i); }
            SaveCommand = new BPARelayCommand(() => { RequestClose?.Invoke(RawMaterResultInfo); });
            CancelCommand = new BPARelayCommand(() => { RequestClose?.Invoke(null); });
        }

        public string Title => "绑定物料";

        public event Action<object> RequestClose;

        public void OnDialogOpened(object parameters)
        {
            if (parameters is MaterialBindTB rm)
                RawMaterResultInfo = rm;
        }

        public ObservableCollection<int> DeviceNums { get; set; } = new ObservableCollection<int>();
        public ObservableCollection<int> ChNum { get; set; } = new ObservableCollection<int>();

        public MaterialBindTB RawMaterResultInfo
        { get { return _mRawMaterResultInfo; } set { _mRawMaterResultInfo = value; OnPropertyChanged(); } }
        private MaterialBindTB _mRawMaterResultInfo = new MaterialBindTB();

        public BPARelayCommand SaveCommand { get; set; }
        public BPARelayCommand CancelCommand { get; set; }
    }
}
