RGBController/RGBController2/ViewModels/Tabs/Tab.cs

131 lines
4.0 KiB
C#
Raw Normal View History

2020-10-25 19:52:14 +00:00
using System;
using System.Windows.Input;
using RGBController2.Commands;
2020-11-08 13:08:52 +00:00
using RGBController2.Boards;
using RGBController2.ViewModels.LightingModes;
2020-10-25 19:52:14 +00:00
namespace RGBController2.ViewModels.Tabs
{
2020-11-08 13:08:52 +00:00
/// <summary>
/// An abstract class of a tab.
/// </summary>
public abstract class Tab : BaseViewModel, ITab
2020-10-25 19:52:14 +00:00
{
2020-11-08 13:08:52 +00:00
/// <summary>
/// An enum of the different types of tabs there can be.
/// Currently this is used for getting the typ0e of the tab for saving the config file.
/// </summary>
2020-10-27 20:07:26 +00:00
public enum tabType
{
Unknown,
Arduino,
2020-11-08 13:08:52 +00:00
CUE,
Chroma
2020-10-27 20:07:26 +00:00
}
2020-11-08 13:08:52 +00:00
/// <summary>
/// The type of this tab.
/// </summary>
2020-10-27 20:07:26 +00:00
public tabType TabType = tabType.Unknown;
2020-11-08 13:08:52 +00:00
/// <summary>
/// The currently selected lighting mode view model of the tab.
/// </summary>
2020-10-27 20:07:26 +00:00
private BaseViewModel _selectedLightingMode;
public BaseViewModel SelectedLightingMode
{
get { return _selectedLightingMode; }
set { _selectedLightingMode = value; }
}
2020-11-08 13:08:52 +00:00
/// <summary>
/// The name used for the tab header.
/// </summary>
2020-10-25 19:52:14 +00:00
public string Name { get; set; }
2020-11-08 13:08:52 +00:00
/// <summary>
/// The command used to close the tab.
/// </summary>
2020-10-25 19:52:14 +00:00
public ICommand CloseCommand { get; }
2020-11-08 13:08:52 +00:00
/// <summary>
/// The event handler to handel closing the tab.
/// </summary>
2020-10-25 19:52:14 +00:00
public event EventHandler CloseRequested;
2020-11-08 13:08:52 +00:00
/// <summary>
/// The connection status string used by the UI.
/// </summary>
private string _conntectionStatus;
public string ConnectionStatus
{
get { return _conntectionStatus; }
set { _conntectionStatus = value; }
}
/// <summary>
/// THE RGB device that the tab will communicated with.
/// </summary>
public IBoard _device;
/// <summary>
/// An enum of the different types of tabs there can be.
/// Currently this is used for getting the typ0e of the tab for saving the config file.
/// </summary>
protected enum LightingModes
{
StaticMode = 0,
AnimationMode,
QuakeMode
}
/// <summary>
/// The selected lighting mode.
/// This corresponds the the selected item from the drop down box.
/// </summary>
private LightingModes _lightingMode;
public int LightingMode
{
get { return (int)_lightingMode; }
set
{
if (_lightingMode != (LightingModes)value)
{
_lightingMode = (LightingModes)value;
switch (_lightingMode)
{
case LightingModes.AnimationMode:
SelectedLightingMode = new AnimationViewModel();
break;
case LightingModes.StaticMode:
SelectedLightingMode = new StaticViewModel(_device);
break;
//case LightingModes.QuakeMode:
// SelectedLightingMode = new Q();
// break;
}
OnPropertyChanged(nameof(SelectedLightingMode));
}
}
}
/// <summary>
/// Binded to the enabled value of the SlectLightingMode combo box
/// </summary>
private bool _enableSelectLightingMode = false;
public bool EnableSelectLightingMode
{
get { return _enableSelectLightingMode; }
set { _enableSelectLightingMode = value; }
}
/// <summary>
/// Creates a tab and sets up the close command.
/// </summary>
public Tab()
{
CloseCommand = new ActionCommand(p => CloseRequested?.Invoke(this, EventArgs.Empty));
}
2020-10-25 19:52:14 +00:00
}
}