mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 19:36:28 +00:00
Added a layer of abstraction between RGB.NET and Artemis
This means Artemis can add extra functionality It also avoid having to reference RGB.NET for basic rendering Implemented rendering scaling
This commit is contained in:
1 parent
4126f5622e
commit
f72f145c7e
41 files changed
+725
-494
No files matched your search
@@ -15,45 +15,45 @@ namespace Artemis.UI.ViewModels.Controls.SurfaceEditor
|
||||
private double _dragOffsetY;
|
||||
private readonly List<SurfaceLedViewModel> _leds;
|
||||
|
||||
public SurfaceDeviceViewModel(SurfaceDeviceConfiguration deviceConfiguration)
|
||||
public SurfaceDeviceViewModel(Device device)
|
||||
{
|
||||
DeviceConfiguration = deviceConfiguration;
|
||||
Device = device;
|
||||
_leds = new List<SurfaceLedViewModel>();
|
||||
|
||||
if (DeviceConfiguration.Device != null)
|
||||
if (Device.RgbDevice != null)
|
||||
{
|
||||
foreach (var led in DeviceConfiguration.Device)
|
||||
foreach (var led in Device.RgbDevice)
|
||||
_leds.Add(new SurfaceLedViewModel(led));
|
||||
}
|
||||
}
|
||||
|
||||
public SurfaceDeviceConfiguration DeviceConfiguration { get; set; }
|
||||
public Device Device { get; set; }
|
||||
public SelectionStatus SelectionStatus { get; set; }
|
||||
public Cursor Cursor { get; set; }
|
||||
|
||||
public double X
|
||||
{
|
||||
get => DeviceConfiguration.X;
|
||||
set => DeviceConfiguration.X = value;
|
||||
get => Device.X;
|
||||
set => Device.X = value;
|
||||
}
|
||||
|
||||
public double Y
|
||||
{
|
||||
get => DeviceConfiguration.Y;
|
||||
set => DeviceConfiguration.Y = value;
|
||||
get => Device.Y;
|
||||
set => Device.Y = value;
|
||||
}
|
||||
|
||||
public int ZIndex
|
||||
{
|
||||
get => DeviceConfiguration.ZIndex;
|
||||
set => DeviceConfiguration.ZIndex = value;
|
||||
get => Device.ZIndex;
|
||||
set => Device.ZIndex = value;
|
||||
}
|
||||
|
||||
public IReadOnlyCollection<SurfaceLedViewModel> Leds => _leds.AsReadOnly();
|
||||
|
||||
public Rect DeviceRectangle => DeviceConfiguration.Device == null
|
||||
public Rect DeviceRectangle => Device.RgbDevice == null
|
||||
? new Rect()
|
||||
: new Rect(X, Y, DeviceConfiguration.Device.Size.Width, DeviceConfiguration.Device.Size.Height);
|
||||
: new Rect(X, Y, Device.RgbDevice.Size.Width, Device.RgbDevice.Size.Height);
|
||||
|
||||
public void StartMouseDrag(Point mouseStartPosition)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Artemis.Core.Events;
|
||||
using Artemis.Core.Services;
|
||||
using Artemis.Core.Services.Interfaces;
|
||||
using Artemis.UI.ViewModels.Controls.Settings;
|
||||
using Artemis.UI.ViewModels.Interfaces;
|
||||
@@ -12,7 +13,7 @@ namespace Artemis.UI.ViewModels.Screens
|
||||
private readonly IKernel _kernel;
|
||||
private readonly IWindowManager _windowManager;
|
||||
|
||||
public SettingsViewModel(IKernel kernel, IRgbService rgbService, IWindowManager windowManager)
|
||||
public SettingsViewModel(IKernel kernel, IRgbService rgbService, IWindowManager windowManager, ISettingsService settingsService)
|
||||
{
|
||||
_kernel = kernel;
|
||||
_windowManager = windowManager;
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace Artemis.UI.ViewModels.Screens
|
||||
public SurfaceEditorViewModel(ISurfaceService surfaceService, IDialogService dialogService)
|
||||
{
|
||||
Devices = new ObservableCollection<SurfaceDeviceViewModel>();
|
||||
SurfaceConfigurations = new ObservableCollection<SurfaceConfiguration>();
|
||||
SurfaceConfigurations = new ObservableCollection<Surface>();
|
||||
SelectionRectangle = new RectangleGeometry();
|
||||
PanZoomViewModel = new PanZoomViewModel();
|
||||
|
||||
@@ -35,14 +35,14 @@ namespace Artemis.UI.ViewModels.Screens
|
||||
|
||||
public RectangleGeometry SelectionRectangle { get; set; }
|
||||
public ObservableCollection<SurfaceDeviceViewModel> Devices { get; set; }
|
||||
public ObservableCollection<SurfaceConfiguration> SurfaceConfigurations { get; set; }
|
||||
public ObservableCollection<Surface> SurfaceConfigurations { get; set; }
|
||||
|
||||
public SurfaceConfiguration SelectedSurfaceConfiguration
|
||||
public Surface SelectedSurface
|
||||
{
|
||||
get => _selectedSurfaceConfiguration;
|
||||
get => _selectedSurface;
|
||||
set
|
||||
{
|
||||
_selectedSurfaceConfiguration = value;
|
||||
_selectedSurface = value;
|
||||
ApplySelectedSurfaceConfiguration();
|
||||
}
|
||||
}
|
||||
@@ -50,7 +50,7 @@ namespace Artemis.UI.ViewModels.Screens
|
||||
public PanZoomViewModel PanZoomViewModel { get; set; }
|
||||
public string Title => "Surface Editor";
|
||||
|
||||
public SurfaceConfiguration CreateSurfaceConfiguration(string name)
|
||||
public Surface CreateSurfaceConfiguration(string name)
|
||||
{
|
||||
var config = _surfaceService.CreateSurfaceConfiguration(name);
|
||||
Execute.OnUIThread(() => SurfaceConfigurations.Add(config));
|
||||
@@ -63,7 +63,7 @@ namespace Artemis.UI.ViewModels.Screens
|
||||
var configs = _surfaceService.SurfaceConfigurations;
|
||||
|
||||
// Get the active config, if empty, create a default config
|
||||
var activeConfig = _surfaceService.ActiveSurfaceConfiguration;
|
||||
var activeConfig = _surfaceService.ActiveSurface;
|
||||
if (activeConfig == null)
|
||||
{
|
||||
activeConfig = CreateSurfaceConfiguration("Default");
|
||||
@@ -78,31 +78,31 @@ namespace Artemis.UI.ViewModels.Screens
|
||||
SurfaceConfigurations.Add(surfaceConfiguration);
|
||||
|
||||
// Set the active config
|
||||
SelectedSurfaceConfiguration = activeConfig;
|
||||
SelectedSurface = activeConfig;
|
||||
});
|
||||
}
|
||||
|
||||
private void ApplySelectedSurfaceConfiguration()
|
||||
{
|
||||
if (SelectedSurfaceConfiguration == null)
|
||||
if (SelectedSurface == null)
|
||||
{
|
||||
Execute.OnUIThread(Devices.Clear);
|
||||
return;
|
||||
}
|
||||
|
||||
// Make sure all devices have an up-to-date VM
|
||||
foreach (var surfaceDeviceConfiguration in SelectedSurfaceConfiguration.DeviceConfigurations)
|
||||
foreach (var surfaceDeviceConfiguration in SelectedSurface.Devices)
|
||||
{
|
||||
// Create VMs for missing devices
|
||||
var viewModel = Devices.FirstOrDefault(vm => vm.DeviceConfiguration.Device == surfaceDeviceConfiguration.Device);
|
||||
var viewModel = Devices.FirstOrDefault(vm => vm.Device.RgbDevice == surfaceDeviceConfiguration.RgbDevice);
|
||||
if (viewModel == null)
|
||||
Execute.OnUIThread(() => Devices.Add(new SurfaceDeviceViewModel(surfaceDeviceConfiguration)));
|
||||
// Update existing devices
|
||||
else
|
||||
viewModel.DeviceConfiguration = surfaceDeviceConfiguration;
|
||||
viewModel.Device = surfaceDeviceConfiguration;
|
||||
}
|
||||
|
||||
_surfaceService.SetActiveSurfaceConfiguration(SelectedSurfaceConfiguration);
|
||||
_surfaceService.SetActiveSurfaceConfiguration(SelectedSurface);
|
||||
}
|
||||
|
||||
#region Overrides of Screen
|
||||
@@ -117,7 +117,7 @@ namespace Artemis.UI.ViewModels.Screens
|
||||
|
||||
#region Configuration management
|
||||
|
||||
public async Task DeleteSurfaceConfiguration(SurfaceConfiguration surfaceConfiguration)
|
||||
public async Task DeleteSurfaceConfiguration(Surface surface)
|
||||
{
|
||||
var result = await _dialogService.ShowConfirmDialogAt(
|
||||
"SurfaceListDialogHost",
|
||||
@@ -126,8 +126,8 @@ namespace Artemis.UI.ViewModels.Screens
|
||||
);
|
||||
if (result)
|
||||
{
|
||||
SurfaceConfigurations.Remove(surfaceConfiguration);
|
||||
_surfaceService.DeleteSurfaceConfiguration(surfaceConfiguration);
|
||||
SurfaceConfigurations.Remove(surface);
|
||||
_surfaceService.DeleteSurfaceConfiguration(surface);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -189,11 +189,11 @@ namespace Artemis.UI.ViewModels.Screens
|
||||
|
||||
#endregion
|
||||
|
||||
#region Device selection
|
||||
#region RgbDevice selection
|
||||
|
||||
private MouseDragStatus _mouseDragStatus;
|
||||
private Point _mouseDragStartPoint;
|
||||
private SurfaceConfiguration _selectedSurfaceConfiguration;
|
||||
private Surface _selectedSurface;
|
||||
|
||||
// ReSharper disable once UnusedMember.Global - Called from view
|
||||
public void EditorGridMouseClick(object sender, MouseEventArgs e)
|
||||
@@ -280,7 +280,7 @@ namespace Artemis.UI.ViewModels.Screens
|
||||
}
|
||||
}
|
||||
else
|
||||
_surfaceService.UpdateSurfaceConfiguration(SelectedSurfaceConfiguration, true);
|
||||
_surfaceService.UpdateSurfaceConfiguration(SelectedSurface, true);
|
||||
|
||||
Mouse.OverrideCursor = null;
|
||||
_mouseDragStatus = MouseDragStatus.None;
|
||||
|
||||
@@ -13,20 +13,20 @@
|
||||
Cursor="{Binding Cursor}"
|
||||
MouseEnter="{s:Action MouseEnter}"
|
||||
MouseLeave="{s:Action MouseLeave}"
|
||||
ToolTip="{Binding DeviceConfiguration.Device.DeviceInfo.DeviceName}">
|
||||
ToolTip="{Binding Device.RgbDevice.DeviceInfo.DeviceName}">
|
||||
<UserControl.Resources>
|
||||
<converters:NullToImageConverter x:Key="NullToImageConverter"/>
|
||||
<converters:NullToVisibilityConverter x:Key="NullToVisibilityConverter" />
|
||||
</UserControl.Resources>
|
||||
<Grid>
|
||||
<Image Source="{Binding DeviceConfiguration.Device.DeviceInfo.Image, Converter={StaticResource NullToImageConverter}}" />
|
||||
<Image Source="{Binding Device.RgbDevice.DeviceInfo.Image, Converter={StaticResource NullToImageConverter}}" />
|
||||
|
||||
<Rectangle Fill="{DynamicResource ControlBackgroundBrush}"
|
||||
Stroke="{DynamicResource ControlBorderBrush}"
|
||||
StrokeThickness="1"
|
||||
Visibility="{Binding DeviceConfiguration.Device.DeviceInfo.Image, ConverterParameter=Inverted, Converter={StaticResource NullToVisibilityConverter}}" />
|
||||
<TextBlock Text="{Binding DeviceConfiguration.Device.DeviceInfo.DeviceName}"
|
||||
Visibility="{Binding DeviceConfiguration.Device.DeviceInfo.Image, ConverterParameter=Inverted, Converter={StaticResource NullToVisibilityConverter}}"
|
||||
Visibility="{Binding Device.RgbDevice.DeviceInfo.Image, ConverterParameter=Inverted, Converter={StaticResource NullToVisibilityConverter}}" />
|
||||
<TextBlock Text="{Binding Device.RgbDevice.DeviceInfo.DeviceName}"
|
||||
Visibility="{Binding Device.RgbDevice.DeviceInfo.Image, ConverterParameter=Inverted, Converter={StaticResource NullToVisibilityConverter}}"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
TextWrapping="Wrap"
|
||||
|
||||
@@ -17,37 +17,40 @@
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
</UserControl.Resources>
|
||||
<StackPanel Margin="16">
|
||||
<TextBlock Style="{StaticResource MaterialDesignHeadlineTextBlock}">General</TextBlock>
|
||||
<StackPanel>
|
||||
<TextBlock>General settings like start up with Windows etc.</TextBlock>
|
||||
<ScrollViewer>
|
||||
<StackPanel Margin="16">
|
||||
<TextBlock Style="{StaticResource MaterialDesignHeadlineTextBlock}">General</TextBlock>
|
||||
<StackPanel>
|
||||
<TextBlock>General settings like start up with Windows etc.</TextBlock>
|
||||
|
||||
<Button Command="{s:Action ShowDebugger}" Style="{StaticResource MaterialDesignRaisedButton}" HorizontalAlignment="Left" Margin="0, 10, 0, 0">
|
||||
Show debugger
|
||||
</Button>
|
||||
<Button Command="{s:Action ShowDebugger}" Style="{StaticResource MaterialDesignRaisedButton}" HorizontalAlignment="Left" Margin="0, 10, 0, 0">
|
||||
Show debugger
|
||||
</Button>
|
||||
</StackPanel>
|
||||
|
||||
<TextBlock Style="{StaticResource MaterialDesignHeadlineTextBlock}">Devices</TextBlock>
|
||||
|
||||
<TextBlock>A list of devices and options to disable them</TextBlock>
|
||||
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled" Margin="0 12 0 0">
|
||||
<ItemsControl ItemsSource="{Binding DeviceSettingsViewModels}">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<WrapPanel/>
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<ContentControl xaml:View.Model="{Binding}" Margin="5" HorizontalAlignment="Left" VerticalAlignment="Top" />
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</ScrollViewer>
|
||||
|
||||
<TextBlock Style="{StaticResource MaterialDesignHeadlineTextBlock}">Plugins</TextBlock>
|
||||
<Grid>
|
||||
<TextBlock>A list of plugins and options to disable them</TextBlock>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
|
||||
<TextBlock Style="{StaticResource MaterialDesignHeadlineTextBlock}">Devices</TextBlock>
|
||||
|
||||
<TextBlock>A list of devices and options to disable them</TextBlock>
|
||||
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled" Margin="0 12 0 0">
|
||||
<ItemsControl ItemsSource="{Binding DeviceSettingsViewModels}">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<WrapPanel/>
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<ContentControl xaml:View.Model="{Binding}" Margin="5" HorizontalAlignment="Left" VerticalAlignment="Top" />
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</ScrollViewer>
|
||||
|
||||
<TextBlock Style="{StaticResource MaterialDesignHeadlineTextBlock}">Plugins</TextBlock>
|
||||
<Grid>
|
||||
<TextBlock>A list of plugins and options to disable them</TextBlock>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
|
||||
</UserControl>
|
||||
@@ -108,8 +108,8 @@
|
||||
</ItemsControl.ItemContainerStyle>
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<ContentControl Width="{Binding DeviceConfiguration.Device.Size.Width}"
|
||||
Height="{Binding DeviceConfiguration.Device.Size.Height}"
|
||||
<ContentControl Width="{Binding Device.RgbDevice.Size.Width}"
|
||||
Height="{Binding Device.RgbDevice.Size.Height}"
|
||||
s:View.Model="{Binding}">
|
||||
<ContentControl.ContextMenu>
|
||||
<ContextMenu>
|
||||
@@ -183,9 +183,9 @@
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<ListBox Grid.Row="0" ItemsSource="{Binding SurfaceConfigurations}" SelectedItem="{Binding SelectedSurfaceConfiguration}">
|
||||
<ListBox Grid.Row="0" ItemsSource="{Binding SurfaceConfigurations}" SelectedItem="{Binding SelectedSurface}">
|
||||
<ListBox.Resources>
|
||||
<DataTemplate DataType="{x:Type models:SurfaceConfiguration}">
|
||||
<DataTemplate DataType="{x:Type models:Surface}">
|
||||
<Grid HorizontalAlignment="Stretch">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="230"/>
|
||||
|
||||
Reference in new issue
Block a user