Settings UI - Seperated tabs into different VMs

This commit is contained in:
Robert committed 2020-08-19 19:39:34 +02:00
1 parent 8b8fe3a3ec
commit ae9bdecef1
21 files changed
+819 -727

No files matched your search

@@ -0,0 +1,28 @@
<UserControl x:Class="Artemis.UI.Screens.Settings.Tabs.Plugins.PluginSettingsTabView"
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:local="clr-namespace:Artemis.UI.Screens.Settings.Tabs.Plugins"
xmlns:s="https://github.com/canton7/Stylet"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"
d:DataContext="{d:DesignInstance local:PluginSettingsTabViewModel}">
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled" Margin="0 12 0 0">
<DockPanel Margin="15" MaxWidth="1230" HorizontalAlignment="Center">
<TextBlock DockPanel.Dock="Top">The list below shows all loaded plugins. If you're missing something, view your logs folder.</TextBlock>
<ItemsControl ItemsSource="{Binding Plugins}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<ContentControl s:View.Model="{Binding}" Margin="5" HorizontalAlignment="Left" VerticalAlignment="Top" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</DockPanel>
</ScrollViewer>
</UserControl>
@@ -0,0 +1,43 @@
using System.Linq;
using System.Threading.Tasks;
using Artemis.Core.Services.Interfaces;
using Artemis.UI.Ninject.Factories;
using Stylet;
namespace Artemis.UI.Screens.Settings.Tabs.Plugins
{
public class PluginSettingsTabViewModel : Screen
{
private readonly IPluginService _pluginService;
private readonly ISettingsVmFactory _settingsVmFactory;
private BindableCollection<PluginSettingsViewModel> _plugins;
public PluginSettingsTabViewModel(IPluginService pluginService, ISettingsVmFactory settingsVmFactory)
{
DisplayName = "PLUGINS";
_pluginService = pluginService;
_settingsVmFactory = settingsVmFactory;
Plugins = new BindableCollection<PluginSettingsViewModel>();
}
public BindableCollection<PluginSettingsViewModel> Plugins
{
get => _plugins;
set => SetAndNotify(ref _plugins, value);
}
protected override void OnActivate()
{
// Take it off the UI thread to avoid freezing on tab change
Task.Run(() =>
{
Plugins.Clear();
var instances = _pluginService.GetAllPluginInfo().Select(p => _settingsVmFactory.CreatePluginSettingsViewModel(p.Instance)).ToList();
foreach (var pluginSettingsViewModel in instances)
Plugins.Add(pluginSettingsViewModel);
});
}
}
}
@@ -9,18 +9,6 @@
d:DataContext="{d:DesignInstance devices:PluginSettingsViewModel}"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary
Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Button.xaml" />
<ResourceDictionary
Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.PopupBox.xaml" />
<ResourceDictionary
Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.TextBlock.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
<materialDesign:Card Width="400">
<Grid Margin="8">
<Grid.ColumnDefinitions>