using MainShell.Models;
using MainShell.ParaSetting.Model;
using MaxwellFramework.Core.Interfaces;
using MwFramework.ManagerService;
using Stylet;
using System;

namespace MainShell.ParaSetting.ViewModel
{
    public class DeviceSafetyViewModel : BaseScreen
    {
        private readonly IParamList _paramList;

        private EquipmentParaSysSetting _equipmentParaSysSetting;

        public DeviceSafetyViewModel(IParameterManager parameterManager)
        {
            _paramList = parameterManager as IParamList;
            if (_paramList == null)
            {
                throw new ArgumentNullException(nameof(parameterManager));
            }
        }

        protected override void OnViewLoaded()
        {
            base.OnViewLoaded();
            _equipmentParaSysSetting = _paramList.GetParameter<EquipmentParaSysSetting>();
            if (_equipmentParaSysSetting != null)
            {
                SafeParaSysItem = _equipmentParaSysSetting.SafeParaSysItem;
            }
        }

        private SafeParaSysItem _safeParaSysItem = new SafeParaSysItem();

        public SafeParaSysItem SafeParaSysItem
        {
            get { return _safeParaSysItem; }
            set
            {
                _safeParaSysItem = value;
                OnPropertyChanged(nameof(SafeParaSysItem));
            }
        }
    }
}
