mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Removed my 'optimisations' from LED samples and made it a lot faster 😓
Expanded settings
This commit is contained in:
parent
b1870e9e64
commit
62a9c19ae1
@ -46,6 +46,7 @@ namespace Artemis.Core.RGB.NET
|
|||||||
public Dictionary<BrushRenderTarget, Color> RenderedTargets { get; } = new Dictionary<BrushRenderTarget, Color>();
|
public Dictionary<BrushRenderTarget, Color> RenderedTargets { get; } = new Dictionary<BrushRenderTarget, Color>();
|
||||||
|
|
||||||
public Scale Scale { get; set; }
|
public Scale Scale { get; set; }
|
||||||
|
public Scale RenderedScale { get; private set; }
|
||||||
public SKBitmap Bitmap { get; private set; }
|
public SKBitmap Bitmap { get; private set; }
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@ -85,7 +86,6 @@ namespace Artemis.Core.RGB.NET
|
|||||||
{
|
{
|
||||||
var sampleSize = _sampleSizeSetting.Value;
|
var sampleSize = _sampleSizeSetting.Value;
|
||||||
var sampleDepth = Math.Sqrt(sampleSize).RoundToInt();
|
var sampleDepth = Math.Sqrt(sampleSize).RoundToInt();
|
||||||
var pixelSpan = Bitmap.GetPixelSpan();
|
|
||||||
|
|
||||||
foreach (var renderTarget in renderTargets)
|
foreach (var renderTarget in renderTargets)
|
||||||
{
|
{
|
||||||
@ -94,7 +94,8 @@ namespace Artemis.Core.RGB.NET
|
|||||||
(float) ((renderTarget.Rectangle.Location.X + 4) * Scale.Horizontal),
|
(float) ((renderTarget.Rectangle.Location.X + 4) * Scale.Horizontal),
|
||||||
(float) ((renderTarget.Rectangle.Location.Y + 4) * Scale.Vertical),
|
(float) ((renderTarget.Rectangle.Location.Y + 4) * Scale.Vertical),
|
||||||
(float) ((renderTarget.Rectangle.Size.Width - 8) * Scale.Horizontal),
|
(float) ((renderTarget.Rectangle.Size.Width - 8) * Scale.Horizontal),
|
||||||
(float) ((renderTarget.Rectangle.Size.Height - 8) * Scale.Vertical));
|
(float) ((renderTarget.Rectangle.Size.Height - 8) * Scale.Vertical)
|
||||||
|
);
|
||||||
|
|
||||||
var verticalSteps = rect.Height / (sampleDepth - 1);
|
var verticalSteps = rect.Height / (sampleDepth - 1);
|
||||||
var horizontalSteps = rect.Width / (sampleDepth - 1);
|
var horizontalSteps = rect.Width / (sampleDepth - 1);
|
||||||
@ -103,6 +104,8 @@ namespace Artemis.Core.RGB.NET
|
|||||||
var r = 0;
|
var r = 0;
|
||||||
var g = 0;
|
var g = 0;
|
||||||
var b = 0;
|
var b = 0;
|
||||||
|
|
||||||
|
// TODO: Compare this with LINQ, might be quicker and cleaner
|
||||||
for (var horizontalStep = 0; horizontalStep < sampleDepth; horizontalStep++)
|
for (var horizontalStep = 0; horizontalStep < sampleDepth; horizontalStep++)
|
||||||
{
|
{
|
||||||
for (var verticalStep = 0; verticalStep < sampleDepth; verticalStep++)
|
for (var verticalStep = 0; verticalStep < sampleDepth; verticalStep++)
|
||||||
@ -112,11 +115,11 @@ namespace Artemis.Core.RGB.NET
|
|||||||
if (x < 0 || x > Bitmap.Width || y < 0 || y > Bitmap.Height)
|
if (x < 0 || x > Bitmap.Width || y < 0 || y > Bitmap.Height)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var (pixelA, pixelR, pixelG, pixelB) = GetRgbColor(pixelSpan, x, y);
|
var color = Bitmap.GetPixel(x, y);
|
||||||
a += pixelA;
|
a += color.Alpha;
|
||||||
r += pixelR;
|
r += color.Red;
|
||||||
g += pixelG;
|
g += color.Green;
|
||||||
b += pixelB;
|
b += color.Blue;
|
||||||
|
|
||||||
// Uncomment to view the sample pixels in the debugger, need a checkbox in the actual debugger but this was a quickie
|
// Uncomment to view the sample pixels in the debugger, need a checkbox in the actual debugger but this was a quickie
|
||||||
// Bitmap.SetPixel(x, y, new SKColor(0, 255, 0));
|
// Bitmap.SetPixel(x, y, new SKColor(0, 255, 0));
|
||||||
@ -127,8 +130,6 @@ namespace Artemis.Core.RGB.NET
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Scale RenderedScale { get; private set; }
|
|
||||||
|
|
||||||
private void CreateBitmap(Rectangle rectangle)
|
private void CreateBitmap(Rectangle rectangle)
|
||||||
{
|
{
|
||||||
var width = Math.Min((rectangle.Location.X + rectangle.Size.Width) * Scale.Horizontal, 4096);
|
var width = Math.Min((rectangle.Location.X + rectangle.Size.Width) * Scale.Horizontal, 4096);
|
||||||
@ -136,21 +137,6 @@ namespace Artemis.Core.RGB.NET
|
|||||||
Bitmap = new SKBitmap(new SKImageInfo(width.RoundToInt(), height.RoundToInt()));
|
Bitmap = new SKBitmap(new SKImageInfo(width.RoundToInt(), height.RoundToInt()));
|
||||||
}
|
}
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
||||||
private Tuple<int, int, int, int> GetRgbColor(in ReadOnlySpan<byte> pixelSpan, float x, float y)
|
|
||||||
{
|
|
||||||
var index = ((int) y * Bitmap.Width + (int) x) * 4;
|
|
||||||
if (index + 3 > pixelSpan.Length)
|
|
||||||
return new Tuple<int, int, int, int>(0, 0, 0, 0);
|
|
||||||
|
|
||||||
var b = pixelSpan[index];
|
|
||||||
var g = pixelSpan[index + 1];
|
|
||||||
var r = pixelSpan[index + 2];
|
|
||||||
var a = pixelSpan[index + 3];
|
|
||||||
|
|
||||||
return new Tuple<int, int, int, int>(a, r, g, b);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public virtual void PerformFinalize()
|
public virtual void PerformFinalize()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -201,6 +201,7 @@
|
|||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Screens\Module\ProfileEditor\Visualization\Tools\ViewpointMoveToolViewModel.cs" />
|
<Compile Include="Screens\Module\ProfileEditor\Visualization\Tools\ViewpointMoveToolViewModel.cs" />
|
||||||
<Compile Include="Screens\Module\ProfileEditor\Visualization\Tools\VisualizationToolViewModel.cs" />
|
<Compile Include="Screens\Module\ProfileEditor\Visualization\Tools\VisualizationToolViewModel.cs" />
|
||||||
|
<Compile Include="Screens\Settings\Tabs\Plugins\PluginSettingsViewModel.cs" />
|
||||||
<Compile Include="Screens\Sidebar\SidebarView.xaml.cs">
|
<Compile Include="Screens\Sidebar\SidebarView.xaml.cs">
|
||||||
<DependentUpon>SidebarView.xaml</DependentUpon>
|
<DependentUpon>SidebarView.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
@ -533,5 +534,5 @@
|
|||||||
</Target>
|
</Target>
|
||||||
<Target Name="RemoveTranslationsAfterBuild" AfterTargets="AfterBuild">
|
<Target Name="RemoveTranslationsAfterBuild" AfterTargets="AfterBuild">
|
||||||
<RemoveDir Directories="@(FluentValidationExcludedCultures->'$(OutputPath)%(Filename)')" />
|
<RemoveDir Directories="@(FluentValidationExcludedCultures->'$(OutputPath)%(Filename)')" />
|
||||||
</Target>
|
</Target>
|
||||||
</Project>
|
</Project>
|
||||||
@ -78,11 +78,58 @@
|
|||||||
</TextBlock>
|
</TextBlock>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<StackPanel Grid.Row="0" Grid.Column="1" VerticalAlignment="Center">
|
<StackPanel Grid.Row="0" Grid.Column="1" VerticalAlignment="Center">
|
||||||
<Button Style="{StaticResource MaterialDesignOutlinedButton}" Command="{s:Action ShowDebugger}">
|
<Button Style="{StaticResource MaterialDesignOutlinedButton}" Command="{s:Action ShowDebugger}" Width="150">
|
||||||
SHOW DEBUGGER
|
SHOW DEBUGGER
|
||||||
</Button>
|
</Button>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
<Separator Style="{StaticResource MaterialDesignSeparator}" Margin="-15 5" />
|
||||||
|
|
||||||
|
<Grid>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition />
|
||||||
|
<RowDefinition />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
|
<ColumnDefinition Width="Auto" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<StackPanel Grid.Column="0" VerticalAlignment="Center">
|
||||||
|
<TextBlock Style="{StaticResource MaterialDesignBody1TextBlock}">Logs</TextBlock>
|
||||||
|
<TextBlock Style="{StaticResource MaterialDesignBody1TextBlock}" Foreground="{DynamicResource MaterialDesignNavigationItemSubheader}">
|
||||||
|
Opens the directory where logs are stored.
|
||||||
|
</TextBlock>
|
||||||
|
</StackPanel>
|
||||||
|
<StackPanel Grid.Row="0" Grid.Column="1" VerticalAlignment="Center">
|
||||||
|
<Button Style="{StaticResource MaterialDesignOutlinedButton}" Command="{s:Action ShowLogsFolder}" Width="150">
|
||||||
|
SHOW LOGS
|
||||||
|
</Button>
|
||||||
|
</StackPanel>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<Separator Style="{StaticResource MaterialDesignSeparator}" Margin="-15 5" />
|
||||||
|
|
||||||
|
<Grid>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition />
|
||||||
|
<RowDefinition />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
|
<ColumnDefinition Width="Auto" />
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<StackPanel Grid.Column="0" VerticalAlignment="Center">
|
||||||
|
<TextBlock Style="{StaticResource MaterialDesignBody1TextBlock}">Application files</TextBlock>
|
||||||
|
<TextBlock Style="{StaticResource MaterialDesignBody1TextBlock}" Foreground="{DynamicResource MaterialDesignNavigationItemSubheader}">
|
||||||
|
Opens the directory where application files like plugins and settings are stored.
|
||||||
|
</TextBlock>
|
||||||
|
</StackPanel>
|
||||||
|
<StackPanel Grid.Row="0" Grid.Column="1" VerticalAlignment="Center">
|
||||||
|
<Button Style="{StaticResource MaterialDesignOutlinedButton}" Command="{s:Action ShowDataFolder}" Width="150">
|
||||||
|
SHOW APP FILES
|
||||||
|
</Button>
|
||||||
|
</StackPanel>
|
||||||
|
</Grid>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</materialDesign:Card>
|
</materialDesign:Card>
|
||||||
|
|
||||||
@ -106,7 +153,7 @@
|
|||||||
</TextBlock>
|
</TextBlock>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<StackPanel Grid.Row="0" Grid.Column="1" VerticalAlignment="Center">
|
<StackPanel Grid.Row="0" Grid.Column="1" VerticalAlignment="Center">
|
||||||
<ComboBox Width="80" SelectedItem="{Binding SelectedRenderScale}" ItemsSource="{Binding RenderScales}" DisplayMemberPath="Item1"/>
|
<ComboBox Width="80" SelectedItem="{Binding SelectedRenderScale}" ItemsSource="{Binding RenderScales}" DisplayMemberPath="Item1" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Separator Style="{StaticResource MaterialDesignSeparator}" Margin="-15 5" />
|
<Separator Style="{StaticResource MaterialDesignSeparator}" Margin="-15 5" />
|
||||||
@ -127,7 +174,7 @@
|
|||||||
</TextBlock>
|
</TextBlock>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<StackPanel Grid.Row="0" Grid.Column="1" VerticalAlignment="Center">
|
<StackPanel Grid.Row="0" Grid.Column="1" VerticalAlignment="Center">
|
||||||
<ComboBox Width="80" SelectedItem="{Binding SelectedTargetFrameRate}" ItemsSource="{Binding TargetFrameRates}" DisplayMemberPath="Item1"/>
|
<ComboBox Width="80" SelectedItem="{Binding SelectedTargetFrameRate}" ItemsSource="{Binding TargetFrameRates}" DisplayMemberPath="Item1" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Separator Style="{StaticResource MaterialDesignSeparator}" Margin="-15 5" />
|
<Separator Style="{StaticResource MaterialDesignSeparator}" Margin="-15 5" />
|
||||||
@ -144,12 +191,11 @@
|
|||||||
<StackPanel Grid.Column="0">
|
<StackPanel Grid.Column="0">
|
||||||
<TextBlock Style="{StaticResource MaterialDesignBody1TextBlock}">LED sample size</TextBlock>
|
<TextBlock Style="{StaticResource MaterialDesignBody1TextBlock}">LED sample size</TextBlock>
|
||||||
<TextBlock Style="{StaticResource MaterialDesignBody1TextBlock}" Foreground="{DynamicResource MaterialDesignNavigationItemSubheader}" TextWrapping="Wrap">
|
<TextBlock Style="{StaticResource MaterialDesignBody1TextBlock}" Foreground="{DynamicResource MaterialDesignNavigationItemSubheader}" TextWrapping="Wrap">
|
||||||
Sets the amount of samples that is taken to determine each LEDs color.
|
Sets the amount of samples that is taken to determine each LEDs color. This means a LED can be semi off if it is not completely covered by a color.
|
||||||
Best you leave it on 1 but included for completeness, a higher value increases CPU-usage quite rapidly.
|
|
||||||
</TextBlock>
|
</TextBlock>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<StackPanel Grid.Row="0" Grid.Column="1" VerticalAlignment="Center">
|
<StackPanel Grid.Row="0" Grid.Column="1" VerticalAlignment="Center">
|
||||||
<ComboBox Width="80" SelectedItem="{Binding SampleSize}" ItemsSource="{Binding SampleSizes}"/>
|
<ComboBox Width="80" SelectedItem="{Binding SampleSize}" ItemsSource="{Binding SampleSizes}" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
@ -159,64 +205,37 @@
|
|||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem Header="PLUGINS" TextElement.Foreground="{DynamicResource MaterialDesignBody}">
|
<TabItem Header="PLUGINS" TextElement.Foreground="{DynamicResource MaterialDesignBody}">
|
||||||
<DockPanel Margin="15">
|
<DockPanel Margin="15">
|
||||||
<TextBlock DockPanel.Dock="Top">Below you view and manage your plugins. To find and install new plugins use the workshop (TODO).</TextBlock>
|
<TextBlock DockPanel.Dock="Top">The list below shows all loaded plugins. You can't really edit it right now. If you're missing something, view your logs folder.</TextBlock>
|
||||||
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled">
|
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled">
|
||||||
<DataGrid Margin="0 8 0 0"
|
<DataGrid Margin="0 8 0 0"
|
||||||
ItemsSource="{Binding Items3}"
|
ItemsSource="{Binding Plugins}"
|
||||||
CanUserSortColumns="True"
|
CanUserSortColumns="True"
|
||||||
CanUserAddRows="False"
|
CanUserAddRows="False"
|
||||||
AutoGenerateColumns="False"
|
AutoGenerateColumns="False"
|
||||||
materialDesign:DataGridAssist.CellPadding="13 8 8 8"
|
materialDesign:DataGridAssist.CellPadding="13 8 8 8"
|
||||||
materialDesign:DataGridAssist.ColumnHeaderPadding="8">
|
materialDesign:DataGridAssist.ColumnHeaderPadding="8">
|
||||||
<DataGrid.Columns>
|
<DataGrid.Columns>
|
||||||
<DataGridCheckBoxColumn Binding="{Binding IsSelected}"
|
<DataGridTextColumn Binding="{Binding Type}" Header="Type" IsReadOnly="True"/>
|
||||||
|
<DataGridTextColumn Binding="{Binding Name}" Header="Name" IsReadOnly="True" Width="*"/>
|
||||||
|
<DataGridTextColumn Binding="{Binding Description}" Header="Description" IsReadOnly="True" Width="*"/>
|
||||||
|
<DataGridTextColumn Binding="{Binding Version}" Header="Version" IsReadOnly="True"/>
|
||||||
|
<DataGridCheckBoxColumn Header="Enabled"
|
||||||
|
Binding="{Binding IsEnabled}"
|
||||||
ElementStyle="{StaticResource MaterialDesignDataGridCheckBoxColumnStyle}"
|
ElementStyle="{StaticResource MaterialDesignDataGridCheckBoxColumnStyle}"
|
||||||
EditingElementStyle="{StaticResource MaterialDesignDataGridCheckBoxColumnEditingStyle}">
|
EditingElementStyle="{StaticResource MaterialDesignDataGridCheckBoxColumnEditingStyle}">
|
||||||
<DataGridCheckBoxColumn.Header>
|
<DataGridCheckBoxColumn.HeaderStyle>
|
||||||
<!--padding to allow hit test to pass thru for sorting -->
|
|
||||||
<Border Background="Transparent" Padding="6 0 6 0" HorizontalAlignment="Center">
|
|
||||||
<CheckBox HorizontalAlignment="Center"
|
|
||||||
DataContext="{Binding RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}, Path=DataContext}"
|
|
||||||
IsChecked="{Binding IsAllItems3Selected}" />
|
|
||||||
</Border>
|
|
||||||
</DataGridCheckBoxColumn.Header>
|
|
||||||
</DataGridCheckBoxColumn>
|
|
||||||
<DataGridTextColumn Binding="{Binding Code}" Header="Code" EditingElementStyle="{StaticResource MaterialDesignDataGridTextColumnEditingStyle}" />
|
|
||||||
<!-- if you want to use the pop up style (MaterialDesignDataGridTextColumnPopupEditingStyle), you must use MaterialDataGridTextColumn -->
|
|
||||||
<materialDesign:MaterialDataGridTextColumn Binding="{Binding Name}"
|
|
||||||
Header="Name"
|
|
||||||
EditingElementStyle="{StaticResource MaterialDesignDataGridTextColumnPopupEditingStyle}" />
|
|
||||||
<!-- set a max length to get an indicator in the editor -->
|
|
||||||
<materialDesign:MaterialDataGridTextColumn Binding="{Binding Description}"
|
|
||||||
Header="Description"
|
|
||||||
MaxLength="255"
|
|
||||||
EditingElementStyle="{StaticResource MaterialDesignDataGridTextColumnPopupEditingStyle}" />
|
|
||||||
<materialDesign:MaterialDataGridTextColumn Binding="{Binding Numeric}"
|
|
||||||
Header="Number with long header"
|
|
||||||
Width="120"
|
|
||||||
EditingElementStyle="{StaticResource MaterialDesignDataGridTextColumnPopupEditingStyle}">
|
|
||||||
<DataGridTextColumn.HeaderStyle>
|
|
||||||
<Style TargetType="{x:Type DataGridColumnHeader}" BasedOn="{StaticResource MaterialDesignDataGridColumnHeader}">
|
<Style TargetType="{x:Type DataGridColumnHeader}" BasedOn="{StaticResource MaterialDesignDataGridColumnHeader}">
|
||||||
<Setter Property="HorizontalAlignment" Value="Right" />
|
<Setter Property="HorizontalAlignment" Value="Right" />
|
||||||
<Setter Property="ContentTemplate">
|
<Setter Property="ContentTemplate">
|
||||||
<Setter.Value>
|
<Setter.Value>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<TextBlock TextWrapping="Wrap" Text="{Binding}" TextAlignment="Right" />
|
<TextBlock Text="{Binding}" TextAlignment="Right" />
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</Setter.Value>
|
</Setter.Value>
|
||||||
</Setter>
|
</Setter>
|
||||||
</Style>
|
</Style>
|
||||||
</DataGridTextColumn.HeaderStyle>
|
</DataGridCheckBoxColumn.HeaderStyle>
|
||||||
<DataGridTextColumn.ElementStyle>
|
</DataGridCheckBoxColumn>
|
||||||
<Style TargetType="{x:Type TextBlock}">
|
|
||||||
<Setter Property="HorizontalAlignment" Value="Right" />
|
|
||||||
</Style>
|
|
||||||
</DataGridTextColumn.ElementStyle>
|
|
||||||
</materialDesign:MaterialDataGridTextColumn>
|
|
||||||
<!-- use custom combo box column to get better combos. Use ItemsSourceBinding as your binding template to be applied to each combo -->
|
|
||||||
<materialDesign:MaterialDataGridComboBoxColumn Header="Food"
|
|
||||||
SelectedValueBinding="{Binding Food}"
|
|
||||||
ItemsSourceBinding="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type DataGrid}}, Path=DataContext.Foods}" />
|
|
||||||
</DataGrid.Columns>
|
</DataGrid.Columns>
|
||||||
</DataGrid>
|
</DataGrid>
|
||||||
</ScrollViewer>
|
</ScrollViewer>
|
||||||
|
|||||||
@ -1,11 +1,17 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Artemis.Core;
|
||||||
|
using Artemis.Core.Plugins.Abstract;
|
||||||
using Artemis.Core.Services;
|
using Artemis.Core.Services;
|
||||||
|
using Artemis.Core.Services.Interfaces;
|
||||||
using Artemis.Core.Services.Storage.Interfaces;
|
using Artemis.Core.Services.Storage.Interfaces;
|
||||||
using Artemis.UI.Ninject.Factories;
|
using Artemis.UI.Ninject.Factories;
|
||||||
using Artemis.UI.Screens.Settings.Debug;
|
using Artemis.UI.Screens.Settings.Debug;
|
||||||
using Artemis.UI.Screens.Settings.Tabs.Devices;
|
using Artemis.UI.Screens.Settings.Tabs.Devices;
|
||||||
|
using Artemis.UI.Screens.Settings.Tabs.Plugins;
|
||||||
using MaterialDesignThemes.Wpf;
|
using MaterialDesignThemes.Wpf;
|
||||||
using Ninject;
|
using Ninject;
|
||||||
using Stylet;
|
using Stylet;
|
||||||
@ -18,10 +24,12 @@ namespace Artemis.UI.Screens.Settings
|
|||||||
private readonly IKernel _kernel;
|
private readonly IKernel _kernel;
|
||||||
private readonly ISettingsService _settingsService;
|
private readonly ISettingsService _settingsService;
|
||||||
private readonly ISurfaceService _surfaceService;
|
private readonly ISurfaceService _surfaceService;
|
||||||
|
private readonly IPluginService _pluginService;
|
||||||
private readonly IWindowManager _windowManager;
|
private readonly IWindowManager _windowManager;
|
||||||
|
|
||||||
public SettingsViewModel(IKernel kernel,
|
public SettingsViewModel(IKernel kernel,
|
||||||
ISurfaceService surfaceService,
|
ISurfaceService surfaceService,
|
||||||
|
IPluginService pluginService,
|
||||||
IWindowManager windowManager,
|
IWindowManager windowManager,
|
||||||
ISettingsService settingsService,
|
ISettingsService settingsService,
|
||||||
IDeviceSettingsViewModelFactory deviceSettingsViewModelFactory)
|
IDeviceSettingsViewModelFactory deviceSettingsViewModelFactory)
|
||||||
@ -32,12 +40,13 @@ namespace Artemis.UI.Screens.Settings
|
|||||||
|
|
||||||
_kernel = kernel;
|
_kernel = kernel;
|
||||||
_surfaceService = surfaceService;
|
_surfaceService = surfaceService;
|
||||||
|
_pluginService = pluginService;
|
||||||
_windowManager = windowManager;
|
_windowManager = windowManager;
|
||||||
_settingsService = settingsService;
|
_settingsService = settingsService;
|
||||||
_deviceSettingsViewModelFactory = deviceSettingsViewModelFactory;
|
_deviceSettingsViewModelFactory = deviceSettingsViewModelFactory;
|
||||||
|
|
||||||
DeviceSettingsViewModels = new BindableCollection<DeviceSettingsViewModel>();
|
DeviceSettingsViewModels = new BindableCollection<DeviceSettingsViewModel>();
|
||||||
|
Plugins = new BindableCollection<PluginSettingsViewModel>();
|
||||||
RenderScales = new List<Tuple<string, double>> {new Tuple<string, double>("10%", 0.1)};
|
RenderScales = new List<Tuple<string, double>> {new Tuple<string, double>("10%", 0.1)};
|
||||||
for (var i = 25; i <= 100; i += 25)
|
for (var i = 25; i <= 100; i += 25)
|
||||||
RenderScales.Add(new Tuple<string, double>(i + "%", i / 100.0));
|
RenderScales.Add(new Tuple<string, double>(i + "%", i / 100.0));
|
||||||
@ -50,11 +59,11 @@ namespace Artemis.UI.Screens.Settings
|
|||||||
SampleSizes = new List<int> {1, 9};
|
SampleSizes = new List<int> {1, 9};
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<int> SampleSizes { get; set; }
|
public List<Tuple<string, int>> TargetFrameRates { get; set; }
|
||||||
|
|
||||||
public BindableCollection<DeviceSettingsViewModel> DeviceSettingsViewModels { get; set; }
|
|
||||||
|
|
||||||
public List<Tuple<string, double>> RenderScales { get; set; }
|
public List<Tuple<string, double>> RenderScales { get; set; }
|
||||||
|
public List<int> SampleSizes { get; set; }
|
||||||
|
public BindableCollection<DeviceSettingsViewModel> DeviceSettingsViewModels { get; set; }
|
||||||
|
public BindableCollection<PluginSettingsViewModel> Plugins { get; set; }
|
||||||
|
|
||||||
public Tuple<string, double> SelectedRenderScale
|
public Tuple<string, double> SelectedRenderScale
|
||||||
{
|
{
|
||||||
@ -66,7 +75,7 @@ namespace Artemis.UI.Screens.Settings
|
|||||||
{
|
{
|
||||||
get => TargetFrameRates.FirstOrDefault(t => Math.Abs(t.Item2 - TargetFrameRate) < 0.01);
|
get => TargetFrameRates.FirstOrDefault(t => Math.Abs(t.Item2 - TargetFrameRate) < 0.01);
|
||||||
set => TargetFrameRate = value.Item2;
|
set => TargetFrameRate = value.Item2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double RenderScale
|
public double RenderScale
|
||||||
{
|
{
|
||||||
@ -78,7 +87,6 @@ namespace Artemis.UI.Screens.Settings
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Tuple<string, int>> TargetFrameRates { get; set; }
|
|
||||||
|
|
||||||
public int TargetFrameRate
|
public int TargetFrameRate
|
||||||
{
|
{
|
||||||
@ -100,14 +108,17 @@ namespace Artemis.UI.Screens.Settings
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Title => "Settings";
|
|
||||||
|
|
||||||
protected override void OnActivate()
|
protected override void OnActivate()
|
||||||
{
|
{
|
||||||
DeviceSettingsViewModels.Clear();
|
DeviceSettingsViewModels.Clear();
|
||||||
foreach (var device in _surfaceService.ActiveSurface.Devices)
|
foreach (var device in _surfaceService.ActiveSurface.Devices)
|
||||||
DeviceSettingsViewModels.Add(_deviceSettingsViewModelFactory.Create(device));
|
DeviceSettingsViewModels.Add(_deviceSettingsViewModelFactory.Create(device));
|
||||||
|
|
||||||
|
// TODO: GetPluginsOfType isn't ideal here as it doesn't include disabled plugins
|
||||||
|
Plugins.Clear();
|
||||||
|
foreach (var plugin in _pluginService.GetPluginsOfType<Plugin>())
|
||||||
|
Plugins.Add(new PluginSettingsViewModel(plugin));
|
||||||
|
|
||||||
base.OnActivate();
|
base.OnActivate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,5 +126,15 @@ namespace Artemis.UI.Screens.Settings
|
|||||||
{
|
{
|
||||||
_windowManager.ShowWindow(_kernel.Get<DebugViewModel>());
|
_windowManager.ShowWindow(_kernel.Get<DebugViewModel>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ShowLogsFolder()
|
||||||
|
{
|
||||||
|
Process.Start(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Logs"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ShowDataFolder()
|
||||||
|
{
|
||||||
|
Process.Start(Constants.DataFolder);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -0,0 +1,23 @@
|
|||||||
|
using System;
|
||||||
|
using Artemis.Core.Plugins.Abstract;
|
||||||
|
using Stylet;
|
||||||
|
|
||||||
|
namespace Artemis.UI.Screens.Settings.Tabs.Plugins
|
||||||
|
{
|
||||||
|
public class PluginSettingsViewModel : PropertyChangedBase
|
||||||
|
{
|
||||||
|
private readonly Plugin _plugin;
|
||||||
|
|
||||||
|
public PluginSettingsViewModel(Plugin plugin)
|
||||||
|
{
|
||||||
|
_plugin = plugin;
|
||||||
|
IsEnabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Type => _plugin.GetType().BaseType?.Name ?? _plugin.GetType().Name;
|
||||||
|
public string Name => _plugin.PluginInfo.Name;
|
||||||
|
public string Description => "N.Y.I.";
|
||||||
|
public Version Version => _plugin.PluginInfo.Version;
|
||||||
|
public bool IsEnabled { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user