using BPA.Helper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.ObjectModel;
using BPA.Model;

namespace BPA.SingleDevice.ViewModel
{
    public class AddRawMaterialDialogViewModel : NotifyBase, IDialogDataContext
    {
        public AddRawMaterialDialogViewModel()
        {
            for (int i = 1; i <= 4; 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 RawMaterResult rm) RawMaterResultInfo = rm;
        }

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

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

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