using System; using System.Collections.Generic; using System.Text; using System.IO.Ports; using RGBController2.Boards; using System.ComponentModel; using RGBController2.ViewModels.LightingModes; using CUE.NET.Devices.Generic.Enums; namespace RGBController2.ViewModels.Tabs { public class CueDeviceTab : Tab, INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged; private enum LightingModes { StaticMode = 0, AnimationMode, QuakeMode } private CUEDeviceBoard _cueDeviceBoard; private CorsairDeviceType[] _availableDevices; public CorsairDeviceType[] AvailableDevices { get { return _availableDevices; } } private CorsairDeviceType _selectedDevice; public CorsairDeviceType SelectedDevice { get { return _selectedDevice; } set { if (value != _selectedDevice) { // Connect to the device _cueDeviceBoard.ConnectToDevice(value); if (_cueDeviceBoard.Connected) { ConnectionStatus = "Device Connected"; // Set the page to static lighting mode to allow the user to change the // lighting mode now that we are connected to the CUE Device SelectedLightingMode = new StaticViewModel(_cueDeviceBoard); OnPropertyChanged(nameof(SelectedLightingMode)); } else ConnectionStatus = "Failed to connect to device"; OnPropertyChanged(nameof(ConnectionStatus)); } } } private string _conntectionStatus; public string ConnectionStatus { get { return _conntectionStatus; } set { _conntectionStatus = value; } } private LightingModes _lightingMode; public int LightingMode { get { return (int)_lightingMode; } set { _lightingMode = (LightingModes) value; } } private BaseViewModel _selectedLightingMode; public CueDeviceTab(string name) { TabType = tabType.CUE; Name = name; ConnectionStatus = "Device Disconnected"; // Create the device object _cueDeviceBoard = new CUEDeviceBoard(); // Get a list of the available cue devices _availableDevices = _cueDeviceBoard.AvailableDevices; // This is a temporary viewmodel that is used before the user has connected to a device _selectedLightingMode = new InformationViewModel(); } protected void OnPropertyChanged(string propertyName) { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); } } } }