mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Snackbar - Tweaked parameters
Plugins - Show exception message in snackbar
This commit is contained in:
parent
a47eedf1c2
commit
7bb246ea0b
@ -34,7 +34,7 @@ namespace Artemis.UI.Shared.Ninject
|
||||
.Configure(c => c.InSingletonScope());
|
||||
});
|
||||
|
||||
Kernel.Bind<ISnackbarMessageQueue>().ToConstant(new SnackbarMessageQueue()).InSingletonScope();
|
||||
Kernel.Bind<ISnackbarMessageQueue>().ToConstant(new SnackbarMessageQueue(TimeSpan.FromSeconds(5))).InSingletonScope();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -70,7 +70,7 @@
|
||||
<ContentControl s:View.Model="{Binding ActiveItem}" Style="{StaticResource InitializingFade}" />
|
||||
</DockPanel>
|
||||
</materialDesign:DrawerHost>
|
||||
<materialDesign:Snackbar x:Name="MainSnackbar" MessageQueue="{Binding MainMessageQueue}" />
|
||||
<materialDesign:Snackbar x:Name="MainSnackbar" MessageQueue="{Binding MainMessageQueue}" materialDesign:SnackbarMessage.InlineActionButtonMaxHeight="80" materialDesign:SnackbarMessage.ContentMaxHeight="200" />
|
||||
</Grid>
|
||||
</materialDesign:DialogHost>
|
||||
</mde:MaterialWindow>
|
||||
@ -36,7 +36,7 @@
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="80" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
@ -45,9 +45,14 @@
|
||||
|
||||
<materialDesign:PackIcon Kind="{Binding Icon}" Width="48" Height="48" Grid.Row="0" Grid.RowSpan="2" HorizontalAlignment="Center" />
|
||||
|
||||
<TextBlock Grid.Column="1" Grid.Row="0" Style="{StaticResource MaterialDesignTextBlock}" Text="{Binding PluginInfo.Name}" />
|
||||
<materialDesign:Card Grid.Column="2" Grid.Row="0" Background="#FF4343" Height="22" Padding="4" Margin="0 -18 0 0"
|
||||
Visibility="{Binding PluginInfo.LastEnableSuccessful, Converter={x:Static s:BoolToVisibilityConverter.InverseInstance}, Mode=OneWay}">
|
||||
<TextBlock Grid.Column="1" Grid.Row="0" Style="{StaticResource MaterialDesignTextBlock}" Text="{Binding PluginInfo.Name}" />
|
||||
<materialDesign:Card Grid.Column="2" Grid.Row="0"
|
||||
Background="#FF4343"
|
||||
Foreground="White"
|
||||
Height="22"
|
||||
Padding="4"
|
||||
Margin="0 -18 0 0"
|
||||
Visibility="{Binding DisplayLoadFailed, Converter={x:Static s:BoolToVisibilityConverter.Instance}, Mode=OneWay}">
|
||||
LOAD FAILED
|
||||
</materialDesign:Card>
|
||||
|
||||
|
||||
@ -47,6 +47,8 @@ namespace Artemis.UI.Screens.Settings.Tabs.Plugins
|
||||
|
||||
public bool Enabling { get; set; }
|
||||
|
||||
public bool DisplayLoadFailed => !Enabling && !PluginInfo.LastEnableSuccessful;
|
||||
|
||||
public async Task OpenSettings()
|
||||
{
|
||||
try
|
||||
@ -106,7 +108,7 @@ namespace Artemis.UI.Screens.Settings.Tabs.Plugins
|
||||
{
|
||||
if (PluginInfo.Enabled == enable)
|
||||
{
|
||||
NotifyOfPropertyChange(() => IsEnabled);
|
||||
NotifyOfPropertyChange(nameof(IsEnabled));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -118,7 +120,7 @@ namespace Artemis.UI.Screens.Settings.Tabs.Plugins
|
||||
);
|
||||
if (!confirm)
|
||||
{
|
||||
NotifyOfPropertyChange(() => IsEnabled);
|
||||
NotifyOfPropertyChange(nameof(IsEnabled));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -126,25 +128,28 @@ namespace Artemis.UI.Screens.Settings.Tabs.Plugins
|
||||
if (enable)
|
||||
{
|
||||
Enabling = true;
|
||||
NotifyOfPropertyChange(nameof(DisplayLoadFailed));
|
||||
|
||||
try
|
||||
{
|
||||
_pluginService.EnablePlugin(Plugin);
|
||||
_snackbarMessageQueue.Enqueue($"Enabled plugin {PluginInfo.Name}");
|
||||
}
|
||||
catch (Exception)
|
||||
catch (Exception e)
|
||||
{
|
||||
_snackbarMessageQueue.Enqueue($"Failed to enable plugin {PluginInfo.Name}", "VIEW LOGS", async () => await ShowLogsFolder());
|
||||
_snackbarMessageQueue.Enqueue($"Failed to enable plugin {PluginInfo.Name}\r\n{e.Message}", "VIEW LOGS", async () => await ShowLogsFolder());
|
||||
}
|
||||
finally
|
||||
{
|
||||
Enabling = false;
|
||||
NotifyOfPropertyChange(() => IsEnabled);
|
||||
NotifyOfPropertyChange(nameof(IsEnabled));
|
||||
NotifyOfPropertyChange(nameof(DisplayLoadFailed));
|
||||
}
|
||||
}
|
||||
else
|
||||
_pluginService.DisablePlugin(Plugin);
|
||||
|
||||
NotifyOfPropertyChange(() => IsEnabled);
|
||||
NotifyOfPropertyChange(nameof(IsEnabled));
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user