using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Prism.Mvvm;
using ComService;

namespace SimpleStm.ViewModels
{
    class StmStatusBarViewModel : BindableBase
    {
        private ConnectionStates _connectionState;
        public ConnectionStates ConnectionState
        {
            get { return _connectionState; }
            set { SetProperty(ref _connectionState, value); }
        }

        private TimeSpan _scanTime;
        public TimeSpan ScanTime
        {
            get { return _scanTime; }
            set { SetProperty(ref _scanTime, value); }
        }

        private readonly ComService.StmService _stmService;

        public StmStatusBarViewModel(ComService.StmService stmService)
        {
            _stmService = stmService;
            _stmService.ValuesRefreshed += OnStmServiceValuesRefreshed;
            OnStmServiceValuesRefreshed(null, EventArgs.Empty);
        }

        private void OnStmServiceValuesRefreshed(object sender, EventArgs e)
        {
            ConnectionState = _stmService.ConnectionState;
            ScanTime = _stmService.ScanTime;
        }


    }
}
