Add project files.
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
<Application x:Class="Tasklight.Controller.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:Tasklight.Controller"
|
||||
StartupUri="MainWindow.xaml">
|
||||
<Application.Resources>
|
||||
|
||||
</Application.Resources>
|
||||
</Application>
|
||||
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
|
||||
namespace Tasklight.Controller
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for App.xaml
|
||||
/// </summary>
|
||||
public partial class App : Application
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
using System.Windows;
|
||||
|
||||
[assembly: ThemeInfo(
|
||||
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
|
||||
//(used if a resource is not found in the page,
|
||||
// or application resource dictionaries)
|
||||
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
|
||||
//(used if a resource is not found in the page,
|
||||
// app, or any theme specific resource dictionaries)
|
||||
)]
|
||||
@@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace Tasklight.Controller
|
||||
{
|
||||
public abstract class ModelBase : PropertyChangedBase
|
||||
{
|
||||
public void SetProperty<T>(ref T storage, T value, string name)
|
||||
{
|
||||
//if (storage == null)
|
||||
//throw new InvalidCastException("osrs_toolbox.ModelBase.UpdateProperty\nStorage cannot be null.");
|
||||
if (value == null)
|
||||
throw new InvalidCastException("ModelBase.UpdateProperty\nValue cannot be null.");
|
||||
//if (storage.GetType() != value.GetType())
|
||||
//throw new InvalidCastException("osrs_toolbox.ModelBase.UpdateProperty\nVariable type mismatch between storage and value.");
|
||||
storage = value;
|
||||
OnPropertyChanged(name);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class PropertyChangedBase : INotifyPropertyChanged
|
||||
{
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
public void OnPropertyChanged(string name) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
|
||||
}
|
||||
|
||||
public class RelayCommand : ICommand
|
||||
{
|
||||
private Action<object> execute;
|
||||
private Func<object, bool>? canExecute;
|
||||
|
||||
|
||||
public event EventHandler? CanExecuteChanged
|
||||
{
|
||||
add { CommandManager.RequerySuggested += value; }
|
||||
remove { CommandManager.RequerySuggested -= value; }
|
||||
}
|
||||
|
||||
public RelayCommand(Action<object> execute, Func<object, bool>? canExecute = null)
|
||||
{
|
||||
this.execute = execute;
|
||||
this.canExecute = canExecute;
|
||||
}
|
||||
|
||||
public bool CanExecute(object? parameter)
|
||||
{
|
||||
return this.canExecute == null || this.canExecute(parameter);
|
||||
}
|
||||
|
||||
public void Execute(object? parameter)
|
||||
{
|
||||
this.execute(parameter);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
<Window x:Class="Tasklight.Controller.MainWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:Tasklight.Controller"
|
||||
mc:Ignorable="d"
|
||||
Title="Blynclight Controller" Height="450" Width="800" SizeToContent="Height">
|
||||
<Window.DataContext>
|
||||
<local:MainWindowViewModel/>
|
||||
</Window.DataContext>
|
||||
<Window.TaskbarItemInfo>
|
||||
<TaskbarItemInfo Description="Quick Light Controls">
|
||||
<TaskbarItemInfo.ThumbButtonInfos>
|
||||
<ThumbButtonInfo Description="Red" Command="{Binding RedSet, UpdateSourceTrigger=PropertyChanged}"/>
|
||||
<ThumbButtonInfo Description="Yellow" Command="{Binding YellowSet, UpdateSourceTrigger=PropertyChanged}"/>
|
||||
<ThumbButtonInfo Description="Green" Command="{Binding GreenSet, UpdateSourceTrigger=PropertyChanged}"/>
|
||||
</TaskbarItemInfo.ThumbButtonInfos>
|
||||
</TaskbarItemInfo>
|
||||
</Window.TaskbarItemInfo>
|
||||
<Grid>
|
||||
<Grid Visibility="{Binding ConnectVisible, UpdateSourceTrigger=PropertyChanged}">
|
||||
<Button Content="Connect to Light" Command="{Binding LightConnect, UpdateSourceTrigger=PropertyChanged}"/>
|
||||
</Grid>
|
||||
<Grid Visibility="{Binding CommandsVisible, UpdateSourceTrigger=PropertyChanged}">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Text="Quick Actions:" Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="4"/>
|
||||
<Button Content="Red" Command="{Binding RedSet, UpdateSourceTrigger=PropertyChanged}" Grid.Row="1" Grid.Column="0"/>
|
||||
<Button Content="Green" Command="{Binding GreenSet, UpdateSourceTrigger=PropertyChanged}" Grid.Row="1" Grid.Column="1"/>
|
||||
<Button Content="Blue" Command="{Binding BlueSet, UpdateSourceTrigger=PropertyChanged}" Grid.Row="1" Grid.Column="2"/>
|
||||
<Button Content="White" Command="{Binding WhiteSet, UpdateSourceTrigger=PropertyChanged}" Grid.Row="1" Grid.Column="3"/>
|
||||
<Button Content="Cyan" Command="{Binding CyanSet, UpdateSourceTrigger=PropertyChanged}" Grid.Row="2" Grid.Column="0"/>
|
||||
<Button Content="Magenta" Command="{Binding MagentaSet, UpdateSourceTrigger=PropertyChanged}" Grid.Row="2" Grid.Column="1"/>
|
||||
<Button Content="Yellow" Command="{Binding YellowSet, UpdateSourceTrigger=PropertyChanged}" Grid.Row="2" Grid.Column="2"/>
|
||||
<Button Content="Orange" Command="{Binding OrangeSet, UpdateSourceTrigger=PropertyChanged}" Grid.Row="2" Grid.Column="3"/>
|
||||
<TextBlock Text="Color Settings:" Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="2"/>
|
||||
<TextBlock Text="Other Settings:" Grid.Row="3" Grid.Column="2" Grid.ColumnSpan="2"/>
|
||||
<StackPanel Orientation="Horizontal" Grid.Row="4" Grid.Column="0">
|
||||
<TextBlock Text="Red:" Width="50"/>
|
||||
<TextBox Text="{Binding Red, UpdateSourceTrigger=PropertyChanged}" Width="150"/>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal" Grid.Row="5" Grid.Column="0">
|
||||
<TextBlock Text="Green:" Width="50"/>
|
||||
<TextBox Text="{Binding Green, UpdateSourceTrigger=PropertyChanged}" Width="150"/>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal" Grid.Row="6" Grid.Column="0">
|
||||
<TextBlock Text="Blue:" Width="50"/>
|
||||
<TextBox Text="{Binding Blue, UpdateSourceTrigger=PropertyChanged}" Width="150"/>
|
||||
</StackPanel>
|
||||
<Slider Value="{Binding Red, UpdateSourceTrigger=PropertyChanged}" Minimum="0" Maximum="255" Grid.Row="4" Grid.Column="1"/>
|
||||
<Slider Value="{Binding Green, UpdateSourceTrigger=PropertyChanged}" Minimum="0" Maximum="255" Grid.Row="5" Grid.Column="1"/>
|
||||
<Slider Value="{Binding Blue, UpdateSourceTrigger=PropertyChanged}" Minimum="0" Maximum="255" Grid.Row="6" Grid.Column="1"/>
|
||||
<TextBlock Text="Dim Light:" Grid.Row="4" Grid.Column="2"/>
|
||||
<TextBlock Text="Flash Light:" Grid.Row="5" Grid.Column="2"/>
|
||||
<TextBlock Text="Flashing Type:" Grid.Row="6" Grid.Column="2"/>
|
||||
<CheckBox IsChecked="{Binding Dimmed, UpdateSourceTrigger=PropertyChanged}" Grid.Row="4" Grid.Column="3"/>
|
||||
<CheckBox IsChecked="{Binding FlashEnabled, UpdateSourceTrigger=PropertyChanged}" Grid.Row="5" Grid.Column="3"/>
|
||||
<ComboBox SelectedIndex="{Binding SelectedFlashIndex, UpdateSourceTrigger=PropertyChanged}" ItemsSource="{Binding FlashNames, UpdateSourceTrigger=PropertyChanged}" Grid.Row="6" Grid.Column="3"/>
|
||||
<Button Content="Color Picker" Command="{Binding ColorPick, UpdateSourceTrigger=PropertyChanged}" Grid.Row="7" Grid.Column="0"/>
|
||||
<Button Content="Update Light" Command="{Binding LightUpdate, UpdateSourceTrigger=PropertyChanged}" Grid.Row="7" Grid.Column="1"/>
|
||||
<Button Content="Reset Light" Command="{Binding LightReset, UpdateSourceTrigger=PropertyChanged}" Grid.Row="7" Grid.Column="2"/>
|
||||
<Button Content="Disconnect" Command="{Binding LightDisconnect, UpdateSourceTrigger=PropertyChanged}" Grid.Row="7" Grid.Column="3"/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace Tasklight.Controller
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for MainWindow.xaml
|
||||
/// </summary>
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,164 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using Blynclight;
|
||||
|
||||
namespace Tasklight.Controller
|
||||
{
|
||||
public abstract class MainWindowModel : ModelBase
|
||||
{
|
||||
private BlynclightController _lightController;
|
||||
private bool _lightConnected;
|
||||
private Visibility _connectVisible;
|
||||
private Visibility _commandsVisible;
|
||||
|
||||
private int _red;
|
||||
private int _green;
|
||||
private int _blue;
|
||||
|
||||
private ICommand _lightConnect;
|
||||
private ICommand _lightUpdate;
|
||||
private ICommand _lightReset;
|
||||
private ICommand _lightDisconnect;
|
||||
|
||||
private ICommand _redSet;
|
||||
private ICommand _greenSet;
|
||||
private ICommand _blueSet;
|
||||
private ICommand _yellowSet;
|
||||
private ICommand _magentaSet;
|
||||
private ICommand _cyanSet;
|
||||
private ICommand _whiteSet;
|
||||
private ICommand _orangeSet;
|
||||
|
||||
private ICommand _colorPick;
|
||||
|
||||
private bool _flashEnabled;
|
||||
private string _flashType;
|
||||
private bool _dimmed;
|
||||
|
||||
public BlynclightController LightController
|
||||
{
|
||||
get { return _lightController; }
|
||||
set { SetProperty(ref _lightController, value, nameof(LightController)); }
|
||||
}
|
||||
public bool LightConnected
|
||||
{
|
||||
get { return _lightConnected; }
|
||||
set { SetProperty(ref _lightConnected, value, nameof(LightConnected)); }
|
||||
}
|
||||
public Visibility ConnectVisible
|
||||
{
|
||||
get { return _connectVisible; }
|
||||
set { SetProperty(ref _connectVisible, value, nameof(ConnectVisible)); }
|
||||
}
|
||||
public Visibility CommandsVisible
|
||||
{
|
||||
get { return _commandsVisible; }
|
||||
set { SetProperty(ref _commandsVisible, value, nameof(CommandsVisible)); }
|
||||
}
|
||||
|
||||
public int Red
|
||||
{
|
||||
get { return _red; }
|
||||
set { SetProperty(ref _red, value, nameof(Red)); }
|
||||
}
|
||||
public int Green
|
||||
{
|
||||
get { return _green; }
|
||||
set { SetProperty(ref _green, value, nameof(Green)); }
|
||||
}
|
||||
public int Blue
|
||||
{
|
||||
get { return _blue; }
|
||||
set { SetProperty(ref _blue, value, nameof(Blue)); }
|
||||
}
|
||||
|
||||
public ICommand LightConnect
|
||||
{
|
||||
get { return _lightConnect; }
|
||||
set { SetProperty(ref _lightConnect, value, nameof(LightConnect)); }
|
||||
}
|
||||
public ICommand LightUpdate
|
||||
{
|
||||
get { return _lightUpdate; }
|
||||
set { SetProperty(ref _lightUpdate, _lightUpdate, nameof(LightUpdate)); }
|
||||
}
|
||||
public ICommand LightReset
|
||||
{
|
||||
get { return _lightReset; }
|
||||
set { SetProperty(ref _lightReset, value, nameof(LightReset)); }
|
||||
}
|
||||
public ICommand LightDisconnect
|
||||
{
|
||||
get { return _lightDisconnect; }
|
||||
set { SetProperty(ref _lightDisconnect, value, nameof(LightDisconnect)); }
|
||||
}
|
||||
|
||||
public ICommand RedSet
|
||||
{
|
||||
get { return _redSet; }
|
||||
set { SetProperty(ref _redSet, value, nameof(RedSet)); }
|
||||
}
|
||||
public ICommand GreenSet
|
||||
{
|
||||
get { return _greenSet; }
|
||||
set { SetProperty(ref _greenSet, value, nameof(GreenSet)); }
|
||||
}
|
||||
public ICommand BlueSet
|
||||
{
|
||||
get { return _blueSet; }
|
||||
set { SetProperty(ref _blueSet, value, nameof(BlueSet)); }
|
||||
}
|
||||
public ICommand YellowSet
|
||||
{
|
||||
get { return _yellowSet; }
|
||||
set { SetProperty(ref _yellowSet, value, nameof(YellowSet)); }
|
||||
}
|
||||
public ICommand MagentaSet
|
||||
{
|
||||
get { return _magentaSet; }
|
||||
set { SetProperty(ref _magentaSet, value, nameof(MagentaSet)); }
|
||||
}
|
||||
public ICommand CyanSet
|
||||
{
|
||||
get { return _cyanSet; }
|
||||
set { SetProperty(ref _cyanSet, value, nameof(CyanSet)); }
|
||||
}
|
||||
public ICommand WhiteSet
|
||||
{
|
||||
get { return _whiteSet; }
|
||||
set { SetProperty(ref _whiteSet, value, nameof(WhiteSet)); }
|
||||
}
|
||||
public ICommand OrangeSet
|
||||
{
|
||||
get { return _orangeSet; }
|
||||
set { SetProperty(ref _orangeSet, value, nameof(OrangeSet)); }
|
||||
}
|
||||
|
||||
public ICommand ColorPick
|
||||
{
|
||||
get { return _colorPick; }
|
||||
set { SetProperty(ref _colorPick, value, nameof(ColorPick)); }
|
||||
}
|
||||
|
||||
public bool FlashEnabled
|
||||
{
|
||||
get { return _flashEnabled; }
|
||||
set { SetProperty(ref _flashEnabled, value, nameof(FlashEnabled)); }
|
||||
}
|
||||
public string FlashType
|
||||
{
|
||||
get { return _flashType; }
|
||||
set { SetProperty(ref _flashType, value, nameof(FlashType)); }
|
||||
}
|
||||
public bool Dimmed
|
||||
{
|
||||
get { return _dimmed; }
|
||||
set { SetProperty(ref _dimmed, value, nameof(Dimmed)); }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,377 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Drawing;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using Blynclight;
|
||||
using Cyotek.Windows.Forms;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace Tasklight.Controller
|
||||
{
|
||||
public class MainWindowViewModel : ModelBase
|
||||
{
|
||||
#region Model Declaration
|
||||
private void CommandPlaceholder(object obj)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
private BlynclightController _lightController;
|
||||
private bool _lightConnected;
|
||||
private Visibility _connectVisible;
|
||||
private Visibility _commandsVisible;
|
||||
|
||||
private int _red;
|
||||
private int _green;
|
||||
private int _blue;
|
||||
|
||||
private ICommand _lightConnect;
|
||||
private ICommand _lightUpdate;
|
||||
private ICommand _lightReset;
|
||||
private ICommand _lightDisconnect;
|
||||
|
||||
private ICommand _redSet;
|
||||
private ICommand _greenSet;
|
||||
private ICommand _blueSet;
|
||||
private ICommand _yellowSet;
|
||||
private ICommand _magentaSet;
|
||||
private ICommand _cyanSet;
|
||||
private ICommand _whiteSet;
|
||||
private ICommand _orangeSet;
|
||||
|
||||
private ICommand _colorPick;
|
||||
|
||||
private bool _flashEnabled;
|
||||
private bool _dimmed;
|
||||
private int _selectedFlashIndex;
|
||||
private List<string> _flashNames;
|
||||
|
||||
public BlynclightController LightController
|
||||
{
|
||||
get { return _lightController; }
|
||||
set { SetProperty(ref _lightController, value, nameof(LightController)); }
|
||||
}
|
||||
public bool LightConnected
|
||||
{
|
||||
get { return _lightConnected; }
|
||||
set { SetProperty(ref _lightConnected, value, nameof(LightConnected)); }
|
||||
}
|
||||
public Visibility ConnectVisible
|
||||
{
|
||||
get { return _connectVisible; }
|
||||
set { SetProperty(ref _connectVisible, value, nameof(ConnectVisible)); }
|
||||
}
|
||||
public Visibility CommandsVisible
|
||||
{
|
||||
get { return _commandsVisible; }
|
||||
set { SetProperty(ref _commandsVisible, value, nameof(CommandsVisible)); }
|
||||
}
|
||||
|
||||
public int Red
|
||||
{
|
||||
get { return _red; }
|
||||
set { SetProperty(ref _red, value, nameof(Red)); }
|
||||
}
|
||||
public int Green
|
||||
{
|
||||
get { return _green; }
|
||||
set { SetProperty(ref _green, value, nameof(Green)); }
|
||||
}
|
||||
public int Blue
|
||||
{
|
||||
get { return _blue; }
|
||||
set { SetProperty(ref _blue, value, nameof(Blue)); }
|
||||
}
|
||||
|
||||
public ICommand LightConnect
|
||||
{
|
||||
get { return _lightConnect; }
|
||||
set { SetProperty(ref _lightConnect, value, nameof(LightConnect)); }
|
||||
}
|
||||
public ICommand LightUpdate
|
||||
{
|
||||
get { return _lightUpdate; }
|
||||
set { SetProperty(ref _lightUpdate, _lightUpdate, nameof(LightUpdate)); }
|
||||
}
|
||||
public ICommand LightReset
|
||||
{
|
||||
get { return _lightReset; }
|
||||
set { SetProperty(ref _lightReset, value, nameof(LightReset)); }
|
||||
}
|
||||
public ICommand LightDisconnect
|
||||
{
|
||||
get { return _lightDisconnect; }
|
||||
set { SetProperty(ref _lightDisconnect, value, nameof(LightDisconnect)); }
|
||||
}
|
||||
|
||||
public ICommand RedSet
|
||||
{
|
||||
get { return _redSet; }
|
||||
set { SetProperty(ref _redSet, value, nameof(RedSet)); }
|
||||
}
|
||||
public ICommand GreenSet
|
||||
{
|
||||
get { return _greenSet; }
|
||||
set { SetProperty(ref _greenSet, value, nameof(GreenSet)); }
|
||||
}
|
||||
public ICommand BlueSet
|
||||
{
|
||||
get { return _blueSet; }
|
||||
set { SetProperty(ref _blueSet, value, nameof(BlueSet)); }
|
||||
}
|
||||
public ICommand YellowSet
|
||||
{
|
||||
get { return _yellowSet; }
|
||||
set { SetProperty(ref _yellowSet, value, nameof(YellowSet)); }
|
||||
}
|
||||
public ICommand MagentaSet
|
||||
{
|
||||
get { return _magentaSet; }
|
||||
set { SetProperty(ref _magentaSet, value, nameof(MagentaSet)); }
|
||||
}
|
||||
public ICommand CyanSet
|
||||
{
|
||||
get { return _cyanSet; }
|
||||
set { SetProperty(ref _cyanSet, value, nameof(CyanSet)); }
|
||||
}
|
||||
public ICommand WhiteSet
|
||||
{
|
||||
get { return _whiteSet; }
|
||||
set { SetProperty(ref _whiteSet, value, nameof(WhiteSet)); }
|
||||
}
|
||||
public ICommand OrangeSet
|
||||
{
|
||||
get { return _orangeSet; }
|
||||
set { SetProperty(ref _orangeSet, value, nameof(OrangeSet)); }
|
||||
}
|
||||
|
||||
public ICommand ColorPick
|
||||
{
|
||||
get { return _colorPick; }
|
||||
set { SetProperty(ref _colorPick, value, nameof(ColorPick)); }
|
||||
}
|
||||
|
||||
public bool FlashEnabled
|
||||
{
|
||||
get { return _flashEnabled; }
|
||||
set { SetProperty(ref _flashEnabled, value, nameof(FlashEnabled)); }
|
||||
}
|
||||
public bool Dimmed
|
||||
{
|
||||
get { return _dimmed; }
|
||||
set { SetProperty(ref _dimmed, value, nameof(Dimmed)); }
|
||||
}
|
||||
public int SelectedFlashIndex
|
||||
{
|
||||
get { return _selectedFlashIndex; }
|
||||
set { SetProperty(ref _selectedFlashIndex, value, nameof(SelectedFlashIndex)); }
|
||||
}
|
||||
public List<string> FlashNames
|
||||
{
|
||||
get { return _flashNames; }
|
||||
set { SetProperty(ref _flashNames, value, nameof(FlashNames)); }
|
||||
}
|
||||
#endregion
|
||||
|
||||
public MainWindowViewModel()
|
||||
{
|
||||
PreInitializeCommands();
|
||||
InitializeVariables();
|
||||
InitializeCommands();
|
||||
}
|
||||
|
||||
private void InitializeVariables()
|
||||
{
|
||||
LightController = new BlynclightController();
|
||||
LightConnected = false;
|
||||
ConnectVisible = Visibility.Visible;
|
||||
CommandsVisible = Visibility.Collapsed;
|
||||
Red = 0;
|
||||
Green = 0;
|
||||
Blue = 0;
|
||||
FlashEnabled = false;
|
||||
Dimmed = false;
|
||||
SelectedFlashIndex = -1;
|
||||
FlashNames = new List<string>();
|
||||
FlashNames.AddRange(new string[] { "Low", "Medium", "High", "Pulse" });
|
||||
}
|
||||
|
||||
private void PreInitializeCommands()
|
||||
{
|
||||
_lightConnect = new RelayCommand(CommandPlaceholder);
|
||||
_lightUpdate = new RelayCommand(DoLightUpdate);
|
||||
_lightReset = new RelayCommand(DoResetLight);
|
||||
_lightDisconnect = new RelayCommand(DoDisconnectLight);
|
||||
|
||||
_redSet = new RelayCommand(DoSetRed);
|
||||
_greenSet = new RelayCommand(DoSetGreen);
|
||||
_blueSet = new RelayCommand(DoSetBlue);
|
||||
_yellowSet = new RelayCommand(DoSetYellow);
|
||||
_magentaSet = new RelayCommand(DoSetMagenta);
|
||||
_cyanSet = new RelayCommand(DoSetCyan);
|
||||
_whiteSet = new RelayCommand(DoSetWhite);
|
||||
_orangeSet = new RelayCommand(DoSetOrange);
|
||||
_colorPick = new RelayCommand(DoPickColor);
|
||||
}
|
||||
|
||||
private void InitializeCommands()
|
||||
{
|
||||
LightConnect = new RelayCommand(DoLightConnect);
|
||||
LightUpdate = new RelayCommand(DoLightUpdate);
|
||||
LightReset = new RelayCommand(DoResetLight);
|
||||
LightDisconnect = new RelayCommand(DoDisconnectLight);
|
||||
|
||||
RedSet = new RelayCommand(DoSetRed);
|
||||
GreenSet = new RelayCommand(DoSetGreen);
|
||||
BlueSet = new RelayCommand(DoSetBlue);
|
||||
YellowSet = new RelayCommand(DoSetYellow);
|
||||
MagentaSet = new RelayCommand(DoSetMagenta);
|
||||
CyanSet = new RelayCommand(DoSetCyan);
|
||||
WhiteSet = new RelayCommand(DoSetWhite);
|
||||
OrangeSet = new RelayCommand(DoSetOrange);
|
||||
ColorPick = new RelayCommand(DoPickColor);
|
||||
}
|
||||
|
||||
private void DoLightConnect(object obj)
|
||||
{
|
||||
int LightsConnected = LightController.InitBlyncDevices();
|
||||
if (LightsConnected > 0)
|
||||
{
|
||||
LightConnected = true;
|
||||
ConnectVisible = Visibility.Collapsed;
|
||||
CommandsVisible = Visibility.Visible;
|
||||
}
|
||||
else InitializeVariables();
|
||||
}
|
||||
|
||||
private void DoLightUpdate(object obj)
|
||||
{
|
||||
LightController.TurnOnRGBLights(0, Convert.ToByte(Red), Convert.ToByte(Green), Convert.ToByte(Blue));
|
||||
|
||||
if (Dimmed) LightController.SetLightDim(0);
|
||||
else LightController.ClearLightDim(0);
|
||||
|
||||
if (FlashEnabled)
|
||||
{
|
||||
switch (FlashNames.ElementAt(SelectedFlashIndex))
|
||||
{
|
||||
case "Low":
|
||||
LightController.SelectLightFlashSpeed(0, 0x01);
|
||||
break;
|
||||
case "Medium":
|
||||
LightController.SelectLightFlashSpeed(0, 0x02);
|
||||
break;
|
||||
case "High":
|
||||
LightController.SelectLightFlashSpeed(0, 0x03);
|
||||
break;
|
||||
case "Pulse":
|
||||
LightController.SelectLightFlashSpeed(0, 0x04);
|
||||
break;
|
||||
}
|
||||
LightController.StartLightFlash(0);
|
||||
}
|
||||
else LightController.StopLightFlash(0);
|
||||
}
|
||||
|
||||
private void DoResetLight(object obj)
|
||||
{
|
||||
LightController.ResetLight(0);
|
||||
Red = 0;
|
||||
Green = 0;
|
||||
Blue = 0;
|
||||
FlashEnabled = false;
|
||||
Dimmed = false;
|
||||
SelectedFlashIndex = -1;
|
||||
}
|
||||
|
||||
private void DoDisconnectLight(object obj)
|
||||
{
|
||||
LightController.ResetLight(0);
|
||||
InitializeVariables();
|
||||
}
|
||||
|
||||
private void DoSetRed(object obj)
|
||||
{
|
||||
Red = 255;
|
||||
Green = 0;
|
||||
Blue = 0;
|
||||
LightController.TurnOnRedLight(0);
|
||||
}
|
||||
|
||||
private void DoSetGreen(object obj)
|
||||
{
|
||||
Red = 0;
|
||||
Green = 255;
|
||||
Blue = 0;
|
||||
LightController.TurnOnGreenLight(0);
|
||||
}
|
||||
|
||||
private void DoSetBlue(object obj)
|
||||
{
|
||||
Red = 0;
|
||||
Green = 0;
|
||||
Blue = 255;
|
||||
LightController.TurnOnBlueLight(0);
|
||||
}
|
||||
|
||||
private void DoSetYellow(object obj)
|
||||
{
|
||||
Red = 255;
|
||||
Green = 255;
|
||||
Blue = 0;
|
||||
LightController.TurnOnYellowLight(0);
|
||||
}
|
||||
|
||||
private void DoSetMagenta(object obj)
|
||||
{
|
||||
Red = 255;
|
||||
Green = 0;
|
||||
Blue = 255;
|
||||
LightController.TurnOnMagentaLight(0);
|
||||
}
|
||||
|
||||
private void DoSetCyan(object obj)
|
||||
{
|
||||
Red = 0;
|
||||
Green = 255;
|
||||
Blue = 255;
|
||||
LightController.TurnOnCyanLight(0);
|
||||
}
|
||||
|
||||
private void DoSetWhite(object obj)
|
||||
{
|
||||
Red = 255;
|
||||
Green = 255;
|
||||
Blue = 255;
|
||||
LightController.TurnOnWhiteLight(0);
|
||||
}
|
||||
|
||||
private void DoSetOrange(object obj)
|
||||
{
|
||||
Red = 255;
|
||||
Green = 165;
|
||||
Blue = 0;
|
||||
LightController.TurnOnOrangeLight(0);
|
||||
}
|
||||
|
||||
private void DoPickColor(object obj)
|
||||
{
|
||||
ColorPickerDialog cpd = new ColorPickerDialog();
|
||||
cpd.Color = Color.FromArgb(Red, Green, Blue);
|
||||
cpd.ShowDialog();
|
||||
if (cpd.DialogResult == DialogResult.OK)
|
||||
{
|
||||
Red = cpd.Color.R;
|
||||
Green = cpd.Color.G;
|
||||
Blue = cpd.Color.B;
|
||||
}
|
||||
cpd.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net5.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWPF>true</UseWPF>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Cyotek.Windows.Forms.ColorPicker" Version="2.0.0-beta.7" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="Blynclight">
|
||||
<HintPath>..\..\..\..\Downloads\Embrava_SDK_For_Windows_v3.0.4\Binaries\AnyCpu\Blynclight.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user