using MaxwellFramework.Core.Common;
using MwFramework.Controls.ControlCanvas.Model;
using MwFramework.ManagerService;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MainShell.Common.Display.Models
{
    public class CameraAxisDevices : ViewModelBase
    {
        List<HardwareDevice> _hardwareDeviceList = new List<HardwareDevice>();
        HardwareDevice _selectedHardwareDevice = new HardwareDevice();
        private ObservableCollection<object> _shapes = new ObservableCollection<object>();
        private int _selectedIndex = 0;
        private bool _cameraSwitchEnable = true;

        public List<HardwareDevice> HardwareDeviceList
        {
            get { return _hardwareDeviceList; }
            set
            {
                if (_hardwareDeviceList == value)
                {
                    return;
                }

                _hardwareDeviceList = value;

                if (_hardwareDeviceList != null && _hardwareDeviceList.Count > 0)
                {
                    _selectedIndex = 0;
                    SelectedHardwareDevice = _hardwareDeviceList[_selectedIndex];
                    RaisePropertyChanged(nameof(SelectedIndex));
                }

                RaisePropertyChanged(nameof(HardwareDeviceList));
            }
        }
        public HardwareDevice SelectedHardwareDevice
        {
            get { return _selectedHardwareDevice; }
            set
            {
                if (_selectedHardwareDevice != null && _selectedHardwareDevice.Camera != null && value != null && value.Camera != null)
                {

                }
                _selectedHardwareDevice = value; RaisePropertyChanged(nameof(SelectedHardwareDevice));
            }
        }

        public ObservableCollection<object> Shapes
        {
            get { return _shapes; }
            set
            {
                if (_shapes != value) { _shapes = value; RaisePropertyChanged(nameof(Shapes)); }
            }
        }
        private ObservableCollection<PrimShape> _regions = new ObservableCollection<PrimShape>();
        public ObservableCollection<PrimShape> Regions
        {
            get { return _regions; }
            set
            {
                SetAndNotify(ref _regions, value);
            }
        }
        public int SelectedIndex
        {
            get { return _selectedIndex; }
            set
            {
                _selectedIndex = value;
                if (HardwareDeviceList != null && HardwareDeviceList.Count > 0 && _selectedIndex >= 0)
                {
                    if (_selectedIndex < HardwareDeviceList.Count)
                    {
                        SelectedHardwareDevice = HardwareDeviceList[_selectedIndex];
                    }

                }
                RaisePropertyChanged(nameof(SelectedIndex));
            }
        }

        public bool CameraSwitchEnable
        {
            get { return _cameraSwitchEnable; }
            set { _cameraSwitchEnable = value; RaisePropertyChanged(nameof(CameraSwitchEnable)); }
        }
    }
}
