mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 19:36:28 +00:00
Fixed plugin binding and reworked some interfaces to abstract classes
This commit is contained in:
1 parent
90cd27b0c6
commit
155073f14d
17 files changed
+88
-82
No files matched your search
@@ -1,8 +1,4 @@
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
using System.Windows.Markup;
|
||||
using Artemis.Core.Plugins.Interfaces;
|
||||
using Stylet;
|
||||
using Stylet;
|
||||
|
||||
namespace Artemis.UI.Stylet
|
||||
{
|
||||
@@ -10,30 +6,7 @@ namespace Artemis.UI.Stylet
|
||||
{
|
||||
public ArtemisViewManager(ViewManagerConfig config) : base(config)
|
||||
{
|
||||
}
|
||||
|
||||
public override UIElement CreateViewForModel(object model)
|
||||
{
|
||||
if (model is IModuleViewModel)
|
||||
return CreateViewForPlugin(model);
|
||||
|
||||
return base.CreateViewForModel(model);
|
||||
}
|
||||
|
||||
private UIElement CreateViewForPlugin(object model)
|
||||
{
|
||||
var viewName = model.GetType().Name.Replace("Model", "");
|
||||
var pluginInfo = ((IModuleViewModel) model).PluginInfo;
|
||||
var viewPath = $"{pluginInfo.Folder}{viewName}.xaml";
|
||||
// There doesn't have to be a view so make sure one exists
|
||||
if (!File.Exists(viewPath))
|
||||
return null;
|
||||
|
||||
// Compile the view if found, must be done on UI thread sadly
|
||||
object view = null;
|
||||
Execute.OnUIThread(() => view = XamlReader.Parse(File.ReadAllText(viewPath)));
|
||||
|
||||
return (UIElement) view;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -31,11 +31,10 @@ namespace Artemis.UI.Stylet
|
||||
ViewFactory = GetInstance,
|
||||
ViewAssemblies = new List<Assembly> {GetType().Assembly}
|
||||
};
|
||||
kernel.Bind<IViewManager>().ToConstant(new ArtemisViewManager(viewManagerConfig));
|
||||
kernel.Bind<IViewManager>().ToConstant(new ViewManager(viewManagerConfig));
|
||||
|
||||
kernel.Bind<IWindowManagerConfig>().ToConstant(this).InTransientScope();
|
||||
kernel.Bind<IWindowManager>().ToMethod(c => new WindowManager(c.Kernel.Get<IViewManager>(),
|
||||
() => c.Kernel.Get<IMessageBoxViewModel>(), c.Kernel.Get<IWindowManagerConfig>())).InSingletonScope();
|
||||
kernel.Bind<IWindowManager>().ToMethod(c => new WindowManager(c.Kernel.Get<IViewManager>(),() => c.Kernel.Get<IMessageBoxViewModel>(), c.Kernel.Get<IWindowManagerConfig>())).InSingletonScope();
|
||||
kernel.Bind<IEventAggregator>().To<EventAggregator>().InSingletonScope();
|
||||
kernel.Bind<IMessageBoxViewModel>().To<MessageBoxViewModel>(); // Not singleton!
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@
|
||||
</Grid.ColumnDefinitions>
|
||||
<materialDesign:PackIcon Kind="Discord" Width="140" Height="140"
|
||||
HorizontalAlignment="Center" VerticalAlignment="Center" />
|
||||
<StackPanel Grid.Column="1">
|
||||
<StackPanel Grid.Row="0" Grid.Column="1">
|
||||
<TextBlock Style="{StaticResource MaterialDesignHeadlineTextBlock}" Margin="16 16 16 8">Have a chat</TextBlock>
|
||||
<TextBlock TextWrapping="Wrap" Margin="16 0 16 8"
|
||||
Foreground="{DynamicResource MaterialDesignBodyLight}"
|
||||
@@ -75,7 +75,7 @@
|
||||
<Run Text=". " />
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
<Border Grid.Row="1" Grid.ColumnSpan="2" BorderThickness="0 1 0 0"
|
||||
<Border Grid.Row="1" Grid.ColumnSpan="2" Grid.Column="0" BorderThickness="0 1 0 0"
|
||||
BorderBrush="{DynamicResource MaterialDesignDivider}" Padding="8">
|
||||
<DockPanel>
|
||||
<Grid Margin="8">
|
||||
@@ -92,7 +92,7 @@
|
||||
<TextBlock Margin="8 0 0 0" VerticalAlignment="Center">GitHub</TextBlock>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
<Button Style="{DynamicResource MaterialDesignFlatButton}"
|
||||
<Button Grid.Row="0" Style="{DynamicResource MaterialDesignFlatButton}"
|
||||
HorizontalAlignment="Right"
|
||||
x:Name="TwitterButton" Command="{s:Action OpenUrl}"
|
||||
CommandParameter="https://twitter.com/spoinkynl">
|
||||
@@ -136,7 +136,7 @@
|
||||
</Grid.ColumnDefinitions>
|
||||
<materialDesign:PackIcon Kind="GithubCircle" Width="160" Height="160"
|
||||
HorizontalAlignment="Center" VerticalAlignment="Center" />
|
||||
<StackPanel Grid.Column="1">
|
||||
<StackPanel Grid.Row="0" Grid.Column="1">
|
||||
<TextBlock Style="{StaticResource MaterialDesignHeadlineTextBlock}" Margin="16 16 16 8">Open Source</TextBlock>
|
||||
<TextBlock TextWrapping="Wrap" Margin="16 0 16 8"
|
||||
Foreground="{DynamicResource MaterialDesignBodyLight}"
|
||||
@@ -146,7 +146,7 @@
|
||||
<Run Text=". You can also make your own modules!" />
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
<Border Grid.Row="1" Grid.ColumnSpan="2" BorderThickness="0 1 0 0"
|
||||
<Border Grid.Row="1" Grid.ColumnSpan="2" Grid.Column="0" BorderThickness="0 1 0 0"
|
||||
BorderBrush="{DynamicResource MaterialDesignDivider}" Padding="8">
|
||||
<DockPanel>
|
||||
<Button Style="{DynamicResource MaterialDesignFlatButton}"
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
xmlns:s="https://github.com/canton7/Stylet"
|
||||
xmlns:vms="clr-namespace:Artemis.UI.ViewModels"
|
||||
xmlns:models="clr-namespace:Artemis.Core.Plugins.Models;assembly=Artemis.Core"
|
||||
xmlns:interfaces="clr-namespace:Artemis.Core.Plugins.Interfaces;assembly=Artemis.Core"
|
||||
mc:Ignorable="d"
|
||||
GlowBrush="{DynamicResource AccentColorBrush}"
|
||||
FontFamily="{StaticResource DefaultFont}"
|
||||
@@ -126,13 +127,13 @@
|
||||
SelectedItem="{Binding SelectedModule}"
|
||||
DockPanel.Dock="Top">
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate DataType="models:PluginInfo">
|
||||
<DataTemplate DataType="interfaces:IModule">
|
||||
<DockPanel HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch"
|
||||
Margin="0">
|
||||
<materialDesign:PackIcon Kind="Home"
|
||||
Margin="0,0,8,0" />
|
||||
<TextBlock Text="{Binding Name}" />
|
||||
<TextBlock Text="{Binding DisplayName}" />
|
||||
</DockPanel>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
|
||||
Reference in new issue
Block a user