1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2026-01-01 02:03:32 +00:00

Compare commits

...

2 Commits

Author SHA1 Message Date
Robert
ff2e57aeaa Device properties - We can do a bit better with UX than that :P 2024-03-30 20:40:24 +01:00
Robert
f152812064 Device properties - Show layout error state 2024-03-30 20:28:01 +01:00
3 changed files with 115 additions and 93 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,100 +9,111 @@
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,*">
<Border Classes="card" Margin="5"> <controls:InfoBar Grid.Row="0"
<Grid RowDefinitions="*,Auto"> Title="Failed to apply layout"
<StackPanel Grid.Row="0"> IsOpen="{CompiledBinding Device.LayoutSelection.ErrorState, Converter={x:Static StringConverters.IsNotNullOrEmpty}}"
<Grid RowDefinitions="*,*" ColumnDefinitions="*,Auto"> Message="{CompiledBinding Device.LayoutSelection.ErrorState}"
<StackPanel Grid.Row="0" Grid.Column="0"> Severity="Error"
<TextBlock Text="Default layout file path" /> IsClosable="False"
<TextBlock Classes="subtitle" FontSize="12" TextWrapping="Wrap" Text="{CompiledBinding DefaultLayoutPath}" /> Margin="5 0"/>
</StackPanel>
<StackPanel Grid.Row="0" Grid.Column="1" VerticalAlignment="Center">
<Button
Classes="icon-button"
HorizontalAlignment="Right"
IsEnabled="{CompiledBinding !!DefaultLayoutPath}"
ToolTip.Tip="Copy layout file path to clipboard"
Click="LayoutPathButton_OnClick">
<avalonia:MaterialIcon Kind="ContentCopy" Width="18" Height="18" />
</Button>
</StackPanel>
</Grid>
<Border Classes="card-separator" /> <ScrollViewer Grid.Row="1" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
<Grid RowDefinitions="*,*" ColumnDefinitions="*,Auto"> <Border Classes="card" Margin="5">
<StackPanel Grid.Row="1" Grid.Column="0"> <Grid RowDefinitions="*,Auto">
<TextBlock Text="Image file path" /> <StackPanel Grid.Row="0">
<TextBlock Classes="subtitle" FontSize="12" TextWrapping="Wrap" Text="{CompiledBinding ImagePath, TargetNullValue=None}" /> <Grid RowDefinitions="*,*" ColumnDefinitions="*,Auto">
</StackPanel> <StackPanel Grid.Row="0" Grid.Column="0">
<StackPanel Grid.Row="1" Grid.Column="1" VerticalAlignment="Center"> <TextBlock Text="Default layout file path" />
<Button <TextBlock Classes="subtitle" FontSize="12" TextWrapping="Wrap" Text="{CompiledBinding DefaultLayoutPath}" />
Classes="icon-button" </StackPanel>
HorizontalAlignment="Right" <StackPanel Grid.Row="0" Grid.Column="1" VerticalAlignment="Center">
IsEnabled="{CompiledBinding !!ImagePath}" <Button
ToolTip.Tip="Copy image file path to clipboard" Classes="icon-button"
Click="ImagePathButton_OnClick"> HorizontalAlignment="Right"
<avalonia:MaterialIcon Kind="ContentCopy" Width="18" Height="18" /> IsEnabled="{CompiledBinding !!DefaultLayoutPath}"
</Button> ToolTip.Tip="Copy layout file path to clipboard"
</StackPanel> Click="LayoutPathButton_OnClick">
</Grid> <avalonia:MaterialIcon Kind="ContentCopy" Width="18" Height="18" />
</Button>
</StackPanel>
</Grid>
<Border Classes="card-separator" /> <Border Classes="card-separator" />
<Grid RowDefinitions="*,*,*" ColumnDefinitions="*,Auto"> <Grid RowDefinitions="*,*" ColumnDefinitions="*,Auto">
<StackPanel Grid.Row="1" Grid.Column="0"> <StackPanel Grid.Row="1" Grid.Column="0">
<TextBlock Text="Layout provider" /> <TextBlock Text="Image file path" />
<TextBlock Classes="subtitle" FontSize="12" Text="Choose between different ways to load a layout for this device." /> <TextBlock Classes="subtitle" FontSize="12" TextWrapping="Wrap" Text="{CompiledBinding ImagePath, TargetNullValue=None}" />
</StackPanel> </StackPanel>
<StackPanel Grid.Row="1" Grid.Column="1" VerticalAlignment="Center"> <StackPanel Grid.Row="1" Grid.Column="1" VerticalAlignment="Center">
<StackPanel.Styles> <Button
<Style Selector="ComboBox.layoutProvider /template/ ContentControl#ContentPresenter"> Classes="icon-button"
<Setter Property="ContentTemplate"> HorizontalAlignment="Right"
<Setter.Value> IsEnabled="{CompiledBinding !!ImagePath}"
<DataTemplate x:DataType="layoutProviders:ILayoutProviderViewModel"> ToolTip.Tip="Copy image file path to clipboard"
Click="ImagePathButton_OnClick">
<avalonia:MaterialIcon Kind="ContentCopy" Width="18" Height="18" />
</Button>
</StackPanel>
</Grid>
<Border Classes="card-separator" />
<Grid RowDefinitions="*,*,*" ColumnDefinitions="*,Auto">
<StackPanel Grid.Row="1" Grid.Column="0">
<TextBlock Text="Layout provider" />
<TextBlock Classes="subtitle" FontSize="12" Text="Choose between different ways to load a layout for this device." />
</StackPanel>
<StackPanel Grid.Row="1" Grid.Column="1" VerticalAlignment="Center">
<StackPanel.Styles>
<Style Selector="ComboBox.layoutProvider /template/ ContentControl#ContentPresenter">
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate x:DataType="layoutProviders:ILayoutProviderViewModel">
<TextBlock Text="{CompiledBinding Name}" TextWrapping="Wrap" MaxWidth="350" />
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
</StackPanel.Styles>
<ComboBox Classes="layoutProvider"
Width="150"
SelectedItem="{CompiledBinding SelectedLayoutProvider}"
ItemsSource="{CompiledBinding LayoutProviders}">
<ComboBox.ItemTemplate>
<DataTemplate x:DataType="layoutProviders:ILayoutProviderViewModel">
<StackPanel>
<TextBlock Text="{CompiledBinding Name}" TextWrapping="Wrap" MaxWidth="350" /> <TextBlock Text="{CompiledBinding Name}" TextWrapping="Wrap" MaxWidth="350" />
</DataTemplate> <TextBlock Classes="subtitle" Text="{CompiledBinding Description}" TextWrapping="Wrap" MaxWidth="350" />
</Setter.Value> </StackPanel>
</Setter> </DataTemplate>
</Style> </ComboBox.ItemTemplate>
</StackPanel.Styles> </ComboBox>
<ComboBox Classes="layoutProvider" </StackPanel>
Width="150" </Grid>
SelectedItem="{CompiledBinding SelectedLayoutProvider}"
ItemsSource="{CompiledBinding LayoutProviders}">
<ComboBox.ItemTemplate>
<DataTemplate x:DataType="layoutProviders:ILayoutProviderViewModel">
<StackPanel>
<TextBlock Text="{CompiledBinding Name}" TextWrapping="Wrap" MaxWidth="350" />
<TextBlock Classes="subtitle" Text="{CompiledBinding Description}" TextWrapping="Wrap" MaxWidth="350" />
</StackPanel>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
</StackPanel>
</Grid>
<ContentControl Content="{CompiledBinding SelectedLayoutProvider}" ClipToBounds="False" /> <ContentControl Content="{CompiledBinding SelectedLayoutProvider}" ClipToBounds="False" />
<Border Classes="card-separator" />
<Grid RowDefinitions="*,*" ColumnDefinitions="*,Auto">
<StackPanel Grid.Row="1" Grid.Column="0">
<TextBlock Text="Export current layout" />
<TextBlock Classes="subtitle" FontSize="12" Text="If there is a layout used, export that. Otherwise, export the LEDs present." />
</StackPanel>
<StackPanel Grid.Row="1" Grid.Column="1" VerticalAlignment="Center" Orientation="Horizontal">
<Button HorizontalAlignment="Right" Content="Export" Command="{CompiledBinding ExportLayout}" />
</StackPanel>
</Grid>
</StackPanel>
<controls:HyperlinkButton
Grid.Row="1"
Content="Learn more about layouts on the wiki"
NavigateUri="https://wiki.artemis-rgb.com/en/guides/developer/layouts?mtm_campaign=artemis&amp;mtm_kwd=device-properties"
Margin="0 20"
HorizontalAlignment="Right"
VerticalAlignment="Bottom" />
</Grid>
</Border>
</ScrollViewer>
</Grid>
<Border Classes="card-separator" />
<Grid RowDefinitions="*,*" ColumnDefinitions="*,Auto">
<StackPanel Grid.Row="1" Grid.Column="0">
<TextBlock Text="Export current layout" />
<TextBlock Classes="subtitle" FontSize="12" Text="If there is a layout used, export that. Otherwise, export the LEDs present." />
</StackPanel>
<StackPanel Grid.Row="1" Grid.Column="1" VerticalAlignment="Center" Orientation="Horizontal">
<Button HorizontalAlignment="Right" Content="Export" Command="{CompiledBinding ExportLayout}" />
</StackPanel>
</Grid>
</StackPanel>
<controls:HyperlinkButton
Grid.Row="1"
Content="Learn more about layouts on the wiki"
NavigateUri="https://wiki.artemis-rgb.com/en/guides/developer/layouts?mtm_campaign=artemis&amp;mtm_kwd=device-properties"
Margin="0 20"
HorizontalAlignment="Right"
VerticalAlignment="Bottom" />
</Grid>
</Border>
</ScrollViewer>
</UserControl> </UserControl>