1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-13 05:48:35 +00:00

Merge branch 'development' into feature/releases

This commit is contained in:
Robert 2024-03-30 20:46:09 +01:00
commit 7030c7af2a
6 changed files with 151 additions and 112 deletions

View File

@ -7,6 +7,7 @@ public class LayoutSelection : CorePropertyChanged
{ {
private string? _type; private string? _type;
private string? _parameter; private string? _parameter;
private string? _errorState;
/// <summary> /// <summary>
/// Gets or sets what kind of layout reference this is. /// Gets or sets what kind of layout reference this is.
@ -25,4 +26,13 @@ public class LayoutSelection : CorePropertyChanged
get => _parameter; get => _parameter;
set => SetAndNotify(ref _parameter, value); set => SetAndNotify(ref _parameter, value);
} }
/// <summary>
/// Gets or sets the error state of the layout reference.
/// </summary>
public string? ErrorState
{
get => _errorState;
set => SetAndNotify(ref _errorState, value);
}
} }

View File

@ -184,13 +184,14 @@ internal class DeviceService : IDeviceService
device.ApplyLayout(null, false, false); device.ApplyLayout(null, false, false);
else else
provider?.ApplyLayout(device, layout); provider?.ApplyLayout(device, layout);
UpdateLeds();
} }
catch (Exception e) catch (Exception e)
{ {
device.LayoutSelection.ErrorState = e.Message;
_logger.Error(e, "Failed to apply device layout"); _logger.Error(e, "Failed to apply device layout");
} }
UpdateLeds();
} }
/// <inheritdoc /> /// <inheritdoc />

View File

@ -9,7 +9,16 @@
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="800" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="800"
x:Class="Artemis.UI.Screens.Device.Layout.DeviceLayoutTabView" x:Class="Artemis.UI.Screens.Device.Layout.DeviceLayoutTabView"
x:DataType="layout:DeviceLayoutTabViewModel"> x:DataType="layout:DeviceLayoutTabViewModel">
<ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto"> <Grid RowDefinitions="Auto,*">
<controls:InfoBar Grid.Row="0"
Title="Failed to apply layout"
IsOpen="{CompiledBinding Device.LayoutSelection.ErrorState, Converter={x:Static StringConverters.IsNotNullOrEmpty}}"
Message="{CompiledBinding Device.LayoutSelection.ErrorState}"
Severity="Error"
IsClosable="False"
Margin="5 0"/>
<ScrollViewer Grid.Row="1" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
<Border Classes="card" Margin="5"> <Border Classes="card" Margin="5">
<Grid RowDefinitions="*,Auto"> <Grid RowDefinitions="*,Auto">
<StackPanel Grid.Row="0"> <StackPanel Grid.Row="0">
@ -105,4 +114,6 @@
</Grid> </Grid>
</Border> </Border>
</ScrollViewer> </ScrollViewer>
</Grid>
</UserControl> </UserControl>

View File

@ -250,15 +250,11 @@ public abstract partial class TreeItemViewModel : ActivatableViewModelBase
private async void UpdateCanPaste(bool isFlyoutOpen) private async void UpdateCanPaste(bool isFlyoutOpen)
{ {
string[] formats = await Shared.UI.Clipboard.GetFormatsAsync(); string[]? formats = await Shared.UI.Clipboard.GetFormatsAsync();
//diogotr7: This can be null on Linux sometimes. I'm not sure why.
if (formats == null!)
{
CanPaste = false;
return;
}
CanPaste = formats.Contains(ProfileElementExtensions.ClipboardDataFormat); // Can be null on some platforms
// ReSharper disable once ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract
CanPaste = formats != null && formats.Contains(ProfileElementExtensions.ClipboardDataFormat);
} }
private bool GetIsFocused(ProfileEditorFocusMode focusMode, RenderProfileElement? currentProfileElement) private bool GetIsFocused(ProfileEditorFocusMode focusMode, RenderProfileElement? currentProfileElement)

View File

@ -174,8 +174,11 @@ public partial class TimelineKeyframeViewModel<T> : ActivatableViewModelBase, IT
private async void UpdateCanPaste(bool isFlyoutOpen) private async void UpdateCanPaste(bool isFlyoutOpen)
{ {
string[] formats = await Shared.UI.Clipboard.GetFormatsAsync(); string[]? formats = await Shared.UI.Clipboard.GetFormatsAsync();
CanPaste = formats.Contains("Artemis.Keyframes");
// Can be null on some platforms
// ReSharper disable once ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract
CanPaste = formats != null && formats.Contains("Artemis.Keyframes");
} }
#endregion #endregion

View File

@ -1,10 +1,11 @@
<Styles xmlns="https://github.com/avaloniaui" <Styles xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:avalonia="clr-namespace:Markdown.Avalonia;assembly=Markdown.Avalonia" xmlns:avalonia="clr-namespace:Markdown.Avalonia;assembly=Markdown.Avalonia"
xmlns:ctxt="clr-namespace:ColorTextBlock.Avalonia;assembly=ColorTextBlock.Avalonia"> xmlns:ctxt="clr-namespace:ColorTextBlock.Avalonia;assembly=ColorTextBlock.Avalonia"
xmlns:controls="clr-namespace:Markdown.Avalonia.Controls;assembly=Markdown.Avalonia">
<Design.PreviewWith> <Design.PreviewWith>
<avalonia:MarkdownScrollViewer> <avalonia:MarkdownScrollViewer MarkdownStyleName="FluentAvalonia">
Test Markdown.Xaml support ```inline code ``` and block code.
</avalonia:MarkdownScrollViewer> </avalonia:MarkdownScrollViewer>
</Design.PreviewWith> </Design.PreviewWith>
<Style Selector="ScrollViewer > StackPanel"> <Style Selector="ScrollViewer > StackPanel">
@ -65,4 +66,21 @@
<Setter Property="Margin" Value="0,10,0,5" /> <Setter Property="Margin" Value="0,10,0,5" />
</Style.Setters> </Style.Setters>
</Style> </Style>
<Style Selector="ctxt|CCode">
<Style.Setters>
<Setter Property="Foreground" Value="#CE9178" />
<Setter Property="Background" Value="#333333" />
<Setter Property="Padding" Value="4 3 4 -1"></Setter>
<Setter Property="Margin" Value="0 2 0 0"></Setter>
<Setter Property="CornerRadius" Value="5" />
<Setter Property="TextVerticalAlignment" Value="Bottom"></Setter>
</Style.Setters>
</Style>
<Style Selector="controls|Rule">
<Style.Setters>
<Setter Property="Foreground" Value="{DynamicResource ButtonBorderBrush}"/>
</Style.Setters>
</Style>
</Styles> </Styles>