mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Merge branch 'development'
This commit is contained in:
commit
4865254ab6
@ -119,11 +119,24 @@ namespace Artemis.Core.Services
|
||||
try
|
||||
{
|
||||
_frameStopWatch.Restart();
|
||||
|
||||
// Render all active modules
|
||||
SKTexture texture = _rgbService.OpenRender();
|
||||
|
||||
lock (_dataModelExpansions)
|
||||
{
|
||||
// Update all active modules, check Enabled status because it may go false before before the _dataModelExpansions list is updated
|
||||
foreach (BaseDataModelExpansion dataModelExpansion in _dataModelExpansions.Where(e => e.IsEnabled))
|
||||
dataModelExpansion.InternalUpdate(args.DeltaTime);
|
||||
{
|
||||
try
|
||||
{
|
||||
dataModelExpansion.InternalUpdate(args.DeltaTime);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_updateExceptions.Add(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<Module> modules;
|
||||
@ -137,10 +150,16 @@ namespace Artemis.Core.Services
|
||||
|
||||
// Update all active modules
|
||||
foreach (Module module in modules)
|
||||
module.InternalUpdate(args.DeltaTime);
|
||||
|
||||
// Render all active modules
|
||||
SKTexture texture = _rgbService.OpenRender();
|
||||
{
|
||||
try
|
||||
{
|
||||
module.InternalUpdate(args.DeltaTime);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_updateExceptions.Add(e);
|
||||
}
|
||||
}
|
||||
|
||||
SKCanvas canvas = texture.Surface.Canvas;
|
||||
canvas.Save();
|
||||
@ -152,7 +171,16 @@ namespace Artemis.Core.Services
|
||||
if (!ModuleRenderingDisabled)
|
||||
{
|
||||
foreach (Module module in modules.Where(m => m.IsActivated))
|
||||
module.InternalRender(args.DeltaTime, canvas, texture.ImageInfo);
|
||||
{
|
||||
try
|
||||
{
|
||||
module.InternalRender(args.DeltaTime, canvas, texture.ImageInfo);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_updateExceptions.Add(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
OnFrameRendering(new FrameRenderingEventArgs(canvas, args.DeltaTime, _rgbService.Surface));
|
||||
|
||||
@ -100,15 +100,11 @@ namespace Artemis.UI.Shared
|
||||
|
||||
// Determine the scale required to fit the desired size of the control
|
||||
Size measureSize = MeasureDevice();
|
||||
double scale = Math.Min(DesiredSize.Width / measureSize.Width, DesiredSize.Height / measureSize.Height);
|
||||
Rect scaledRect = new(0, 0, measureSize.Width * scale, measureSize.Height * scale);
|
||||
double scale = Math.Min(RenderSize.Width / measureSize.Width, RenderSize.Height / measureSize.Height);
|
||||
|
||||
// Center and scale the visualization in the desired bounding box
|
||||
if (DesiredSize.Width > 0 && DesiredSize.Height > 0)
|
||||
{
|
||||
drawingContext.PushTransform(new TranslateTransform(DesiredSize.Width / 2 - scaledRect.Width / 2, DesiredSize.Height / 2 - scaledRect.Height / 2));
|
||||
// Scale the visualization in the desired bounding box
|
||||
if (RenderSize.Width > 0 && RenderSize.Height > 0)
|
||||
drawingContext.PushTransform(new ScaleTransform(scale, scale));
|
||||
}
|
||||
|
||||
// Determine the offset required to rotate within bounds
|
||||
Rect rotationRect = new(0, 0, Device.RgbDevice.ActualSize.Width, Device.RgbDevice.ActualSize.Height);
|
||||
|
||||
@ -7,17 +7,20 @@
|
||||
xmlns:s="https://github.com/canton7/Stylet"
|
||||
xmlns:shared="clr-namespace:Artemis.UI.Shared;assembly=Artemis.UI.Shared"
|
||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
xmlns:converters="clr-namespace:Artemis.UI.Converters"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800"
|
||||
d:DataContext="{d:DesignInstance local:PluginPrerequisitesInstallDialogViewModel}">
|
||||
<UserControl.Resources>
|
||||
<shared:NullToVisibilityConverter x:Key="NullToVisibilityConverter"/>
|
||||
<converters:InverseBooleanConverter x:Key="InverseBooleanConverter"/>
|
||||
<converters:NullToBooleanConverter x:Key="NullToBooleanConverter" />
|
||||
<shared:NullToVisibilityConverter x:Key="NullToVisibilityConverter" />
|
||||
</UserControl.Resources>
|
||||
<Grid Margin="16">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition MinHeight="150"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition MinHeight="150" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="300" />
|
||||
@ -32,7 +35,6 @@
|
||||
ItemsSource="{Binding Prerequisites}"
|
||||
SelectedItem="{Binding ActivePrerequisite, Mode=OneWay}"
|
||||
HorizontalContentAlignment="Stretch">
|
||||
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate DataType="{x:Type local:PluginPrerequisiteViewModel}">
|
||||
<Border Padding="8" BorderThickness="0 0 0 1" BorderBrush="{DynamicResource MaterialDesignDivider}" VerticalAlignment="Stretch">
|
||||
@ -75,26 +77,36 @@
|
||||
HorizontalContentAlignment="Stretch"
|
||||
Margin="10 0"
|
||||
IsTabStop="False"
|
||||
Visibility="{Binding ActivePrerequisite, Converter={StaticResource NullToVisibilityConverter}}"/>
|
||||
Visibility="{Binding ShowProgress, Converter={x:Static s:BoolToVisibilityConverter.Instance}, Mode=OneWay}" />
|
||||
|
||||
<TextBlock Grid.Row="1"
|
||||
Grid.Column="1"
|
||||
Style="{StaticResource MaterialDesignBody1TextBlock}"
|
||||
<TextBlock Grid.Row="1"
|
||||
Grid.Column="1"
|
||||
Style="{StaticResource MaterialDesignBody1TextBlock}"
|
||||
TextWrapping="Wrap"
|
||||
Margin="10 0"
|
||||
Visibility="{Binding ActivePrerequisite, Converter={StaticResource NullToVisibilityConverter}, ConverterParameter=Inverted}">
|
||||
Visibility="{Binding ShowIntro, Converter={x:Static s:BoolToVisibilityConverter.Instance}, Mode=OneWay}">
|
||||
In order for this plugin/feature to function certain prerequisites must be met. <LineBreak /><LineBreak />
|
||||
On the left side you can see all prerequisites and whether they are currently met or not.
|
||||
Clicking install prerequisites will automatically set everything up for you.
|
||||
</TextBlock>
|
||||
|
||||
<TextBlock Grid.Row="1"
|
||||
Grid.Column="1"
|
||||
Style="{StaticResource MaterialDesignBody1TextBlock}"
|
||||
TextWrapping="Wrap"
|
||||
Margin="10 0"
|
||||
Visibility="{Binding ShowFailed, Converter={x:Static s:BoolToVisibilityConverter.Instance}, Mode=OneWay}">
|
||||
Installing <Run Text="{Binding ActivePrerequisite.PluginPrerequisite.Name, Mode=OneWay}" FontWeight="SemiBold" /> failed. <LineBreak /><LineBreak />
|
||||
You may try again to see if that helps, otherwise install the prerequisite manually or contact the plugin developer.
|
||||
</TextBlock>
|
||||
|
||||
<StackPanel Grid.Row="2"
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="2"
|
||||
Orientation="Horizontal"
|
||||
HorizontalAlignment="Right"
|
||||
Margin="0 8 0 0"
|
||||
Visibility="{Binding IsFinished, Converter={x:Static s:BoolToVisibilityConverter.InverseInstance}, Mode=OneWay}">
|
||||
Visibility="{Binding ShowInstall, Converter={x:Static s:BoolToVisibilityConverter.Instance}, Mode=OneWay}">
|
||||
<Button Style="{StaticResource MaterialDesignFlatButton}"
|
||||
Focusable="False"
|
||||
IsCancel="True"
|
||||
@ -104,6 +116,7 @@
|
||||
Style="{StaticResource MaterialDesignFlatButton}"
|
||||
IsDefault="True"
|
||||
Focusable="True"
|
||||
IsEnabled="{Binding ShowProgress, Converter={StaticResource InverseBooleanConverter}, Mode=OneWay}"
|
||||
Command="{s:Action Install}"
|
||||
Content="INSTALL PREREQUISITES" />
|
||||
</StackPanel>
|
||||
@ -114,7 +127,7 @@
|
||||
Orientation="Horizontal"
|
||||
HorizontalAlignment="Right"
|
||||
Margin="0 8 0 0"
|
||||
Visibility="{Binding IsFinished, Converter={x:Static s:BoolToVisibilityConverter.Instance}, Mode=OneWay}">
|
||||
Visibility="{Binding ShowInstall, Converter={x:Static s:BoolToVisibilityConverter.InverseInstance}, Mode=OneWay}">
|
||||
<Button Style="{StaticResource MaterialDesignFlatButton}"
|
||||
Focusable="False"
|
||||
IsCancel="True"
|
||||
|
||||
@ -13,18 +13,16 @@ namespace Artemis.UI.Screens.Plugins
|
||||
{
|
||||
public class PluginPrerequisitesInstallDialogViewModel : DialogViewModelBase
|
||||
{
|
||||
private readonly IDialogService _dialogService;
|
||||
private readonly List<IPrerequisitesSubject> _subjects;
|
||||
private PluginPrerequisiteViewModel _activePrerequisite;
|
||||
private bool _canInstall;
|
||||
private bool _isFinished;
|
||||
private CancellationTokenSource _tokenSource;
|
||||
private bool _showProgress;
|
||||
private bool _showIntro = true;
|
||||
private bool _showFailed;
|
||||
private bool _showInstall = true;
|
||||
private bool _canInstall;
|
||||
|
||||
public PluginPrerequisitesInstallDialogViewModel(List<IPrerequisitesSubject> subjects, IPrerequisitesVmFactory prerequisitesVmFactory, IDialogService dialogService)
|
||||
{
|
||||
_subjects = subjects;
|
||||
_dialogService = dialogService;
|
||||
|
||||
Prerequisites = new BindableCollection<PluginPrerequisiteViewModel>();
|
||||
foreach (IPrerequisitesSubject prerequisitesSubject in subjects)
|
||||
Prerequisites.AddRange(prerequisitesSubject.Prerequisites.Select(p => prerequisitesVmFactory.PluginPrerequisiteViewModel(p, false)));
|
||||
@ -41,18 +39,36 @@ namespace Artemis.UI.Screens.Plugins
|
||||
set => SetAndNotify(ref _activePrerequisite, value);
|
||||
}
|
||||
|
||||
public bool ShowProgress
|
||||
{
|
||||
get => _showProgress;
|
||||
set => SetAndNotify(ref _showProgress, value);
|
||||
}
|
||||
|
||||
public bool ShowIntro
|
||||
{
|
||||
get => _showIntro;
|
||||
set => SetAndNotify(ref _showIntro, value);
|
||||
}
|
||||
|
||||
public bool ShowFailed
|
||||
{
|
||||
get => _showFailed;
|
||||
set => SetAndNotify(ref _showFailed, value);
|
||||
}
|
||||
|
||||
public bool ShowInstall
|
||||
{
|
||||
get => _showInstall;
|
||||
set => SetAndNotify(ref _showInstall, value);
|
||||
}
|
||||
|
||||
public bool CanInstall
|
||||
{
|
||||
get => _canInstall;
|
||||
set => SetAndNotify(ref _canInstall, value);
|
||||
}
|
||||
|
||||
public bool IsFinished
|
||||
{
|
||||
get => _isFinished;
|
||||
set => SetAndNotify(ref _isFinished, value);
|
||||
}
|
||||
|
||||
#region Overrides of DialogViewModelBase
|
||||
|
||||
/// <inheritdoc />
|
||||
@ -67,6 +83,10 @@ namespace Artemis.UI.Screens.Plugins
|
||||
public async void Install()
|
||||
{
|
||||
CanInstall = false;
|
||||
ShowFailed = false;
|
||||
ShowIntro = false;
|
||||
ShowProgress = true;
|
||||
|
||||
_tokenSource = new CancellationTokenSource();
|
||||
|
||||
try
|
||||
@ -80,27 +100,20 @@ namespace Artemis.UI.Screens.Plugins
|
||||
ActivePrerequisite = pluginPrerequisiteViewModel;
|
||||
await ActivePrerequisite.Install(_tokenSource.Token);
|
||||
|
||||
if (!ActivePrerequisite.IsMet)
|
||||
{
|
||||
CanInstall = true;
|
||||
ShowFailed = true;
|
||||
ShowProgress = false;
|
||||
return;
|
||||
}
|
||||
|
||||
// Wait after the task finished for the user to process what happened
|
||||
if (pluginPrerequisiteViewModel != Prerequisites.Last())
|
||||
await Task.Delay(1000);
|
||||
}
|
||||
|
||||
if (Prerequisites.All(p => p.IsMet))
|
||||
{
|
||||
IsFinished = true;
|
||||
return;
|
||||
}
|
||||
|
||||
// This shouldn't be happening and the experience isn't very nice for the user (too lazy to make a nice UI for such an edge case)
|
||||
// but at least give some feedback
|
||||
Session?.Close(false);
|
||||
await _dialogService.ShowConfirmDialog(
|
||||
"Plugin prerequisites",
|
||||
"All prerequisites are installed but some still aren't met. \r\nPlease try again or contact the plugin creator.",
|
||||
"Confirm",
|
||||
""
|
||||
);
|
||||
await Show(_dialogService, _subjects);
|
||||
ShowInstall = false;
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
@ -108,7 +121,6 @@ namespace Artemis.UI.Screens.Plugins
|
||||
}
|
||||
finally
|
||||
{
|
||||
CanInstall = true;
|
||||
_tokenSource.Dispose();
|
||||
_tokenSource = null;
|
||||
}
|
||||
|
||||
@ -114,7 +114,8 @@
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
ShowColors="True"
|
||||
LedClicked="{s:Action OnLedClicked}"/>
|
||||
LedClicked="{s:Action OnLedClicked}"
|
||||
Margin="20"/>
|
||||
|
||||
<TextBlock Style="{StaticResource MaterialDesignSubtitle1TextBlock}"
|
||||
Visibility="{Binding Device.Layout.RgbLayout.Author, Converter={StaticResource NullToVisibilityConverter}}"
|
||||
|
||||
@ -1,17 +1,17 @@
|
||||
<UserControl
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
xmlns:tabs="clr-namespace:Artemis.UI.Screens.Settings.Device.Tabs"
|
||||
xmlns:converters="clr-namespace:Artemis.UI.Converters"
|
||||
x:Class="Artemis.UI.Screens.Settings.Device.Tabs.DeviceLedsTabView"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800"
|
||||
d:DataContext="{d:DesignInstance {x:Type tabs:DeviceLedsTabViewModel}}">
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||
xmlns:tabs="clr-namespace:Artemis.UI.Screens.Settings.Device.Tabs"
|
||||
xmlns:converters="clr-namespace:Artemis.UI.Converters"
|
||||
x:Class="Artemis.UI.Screens.Settings.Device.Tabs.DeviceLedsTabView"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800"
|
||||
d:DataContext="{d:DesignInstance {x:Type tabs:DeviceLedsTabViewModel}}">
|
||||
<UserControl.Resources>
|
||||
<converters:UriToFileNameConverter x:Key="UriToFileNameConverter"/>
|
||||
<converters:UriToFileNameConverter x:Key="UriToFileNameConverter" />
|
||||
</UserControl.Resources>
|
||||
<Grid>
|
||||
<DataGrid ItemsSource="{Binding LedViewModels}"
|
||||
@ -20,8 +20,8 @@
|
||||
IsReadOnly="True"
|
||||
CanUserAddRows="False"
|
||||
AutoGenerateColumns="False"
|
||||
materialDesign:DataGridAssist.CellPadding="5"
|
||||
materialDesign:DataGridAssist.ColumnHeaderPadding="5"
|
||||
materialDesign:DataGridAssist.CellPadding="16 5 5 5"
|
||||
materialDesign:DataGridAssist.ColumnHeaderPadding="16 5 5 5"
|
||||
CanUserResizeRows="False"
|
||||
VirtualizingStackPanel.VirtualizationMode="Standard"
|
||||
Margin="10">
|
||||
@ -32,10 +32,10 @@
|
||||
</DataGrid.Resources>
|
||||
<DataGrid.Columns>
|
||||
<materialDesign:DataGridTextColumn Binding="{Binding ArtemisLed.RgbLed.Id}" Header="LED ID" Width="Auto" />
|
||||
<materialDesign:DataGridTextColumn Binding="{Binding ArtemisLed.RgbLed.Color}" Header="Color (ARGB)" Width="Auto" />
|
||||
<materialDesign:DataGridTextColumn Binding="{Binding ArtemisLed.Layout.Image, Converter={StaticResource UriToFileNameConverter}, Mode=OneWay}" Header="Image file" />
|
||||
<materialDesign:DataGridTextColumn Binding="{Binding ArtemisLed.RgbLed.Color}" Header="Color (ARGB)" Width="Auto" CanUserSort="False" />
|
||||
<materialDesign:DataGridTextColumn Binding="{Binding ArtemisLed.Layout.Image, Converter={StaticResource UriToFileNameConverter}, Mode=OneWay}" Header="Image file" CanUserSort="False" />
|
||||
<materialDesign:DataGridTextColumn Binding="{Binding ArtemisLed.RgbLed.Shape}" Header="Shape" />
|
||||
<materialDesign:DataGridTextColumn Binding="{Binding ArtemisLed.RgbLed.Size}" Header="Size" Width="Auto" />
|
||||
<materialDesign:DataGridTextColumn Binding="{Binding ArtemisLed.RgbLed.Size}" Header="Size" Width="Auto" CanUserSort="False" />
|
||||
<materialDesign:DataGridTextColumn Binding="{Binding ArtemisLed.RgbLed.CustomData}" Header="LED data" Width="Auto" />
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
|
||||
@ -7,6 +7,7 @@ using Artemis.Core;
|
||||
using Artemis.Core.Services;
|
||||
using Artemis.UI.Shared.Services;
|
||||
using Ookii.Dialogs.Wpf;
|
||||
using RGB.NET.Core;
|
||||
using SkiaSharp;
|
||||
using Stylet;
|
||||
|
||||
@ -105,6 +106,8 @@ namespace Artemis.UI.Screens.Settings.Device.Tabs
|
||||
Device.RedScale = RedScale / 100f;
|
||||
Device.GreenScale = GreenScale / 100f;
|
||||
Device.BlueScale = BlueScale / 100f;
|
||||
|
||||
_rgbService.Surface.Update(true);
|
||||
}
|
||||
|
||||
public void BrowseCustomLayout(object sender, MouseEventArgs e)
|
||||
|
||||
@ -55,8 +55,8 @@
|
||||
CanUserAddRows="False"
|
||||
AutoGenerateColumns="False"
|
||||
CanUserResizeRows="False"
|
||||
materialDesign:DataGridAssist.CellPadding="8"
|
||||
materialDesign:DataGridAssist.ColumnHeaderPadding="8"
|
||||
materialDesign:DataGridAssist.CellPadding="16 5 5 5"
|
||||
materialDesign:DataGridAssist.ColumnHeaderPadding="16 5 5 5"
|
||||
VirtualizingPanel.VirtualizationMode="Standard"
|
||||
Margin="10">
|
||||
<DataGrid.Columns>
|
||||
|
||||
@ -30,7 +30,12 @@
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Rectangle Grid.Row="0" Fill="{DynamicResource MaterialDesignPaper}" />
|
||||
<shared:DeviceVisualizer Device="{Binding Device}" RenderOptions.BitmapScalingMode="HighQuality" Grid.Row="0" Height="130" Width="190" />
|
||||
<shared:DeviceVisualizer VerticalAlignment="Center"
|
||||
HorizontalAlignment="Center"
|
||||
Margin="10"
|
||||
Device="{Binding Device}"
|
||||
RenderOptions.BitmapScalingMode="HighQuality"
|
||||
Grid.Row="0" />
|
||||
<Button Grid.Row="0"
|
||||
Style="{StaticResource MaterialDesignFloatingActionMiniButton}"
|
||||
HorizontalAlignment="Right"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user