mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Added some of the architecture for the profile editor
This commit is contained in:
parent
b22fcb3c2a
commit
c846d63acf
@ -1,4 +1,5 @@
|
|||||||
using System.Drawing;
|
using System.Collections.Generic;
|
||||||
|
using System.Drawing;
|
||||||
using Artemis.Core.Models.Surface;
|
using Artemis.Core.Models.Surface;
|
||||||
using Artemis.Core.Plugins.Models;
|
using Artemis.Core.Plugins.Models;
|
||||||
using RGB.NET.Core;
|
using RGB.NET.Core;
|
||||||
@ -42,9 +43,9 @@ namespace Artemis.Core.Plugins.Abstract
|
|||||||
public abstract void Render(double deltaTime, Surface surface, Graphics graphics);
|
public abstract void Render(double deltaTime, Surface surface, Graphics graphics);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called when the module's main view is being shown
|
/// Called when the module's view model is being show, return view models here to create tabs for them
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public abstract IScreen GetMainViewModel();
|
public abstract IEnumerable<ModuleViewModel> GetViewModels();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4,11 +4,13 @@ namespace Artemis.Core.Plugins.Abstract
|
|||||||
{
|
{
|
||||||
public abstract class ModuleViewModel : Screen
|
public abstract class ModuleViewModel : Screen
|
||||||
{
|
{
|
||||||
protected ModuleViewModel(Module module)
|
protected ModuleViewModel(Module module, string name)
|
||||||
{
|
{
|
||||||
Module = module;
|
Module = module;
|
||||||
|
Name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public string Name { get; }
|
||||||
public Module Module { get; }
|
public Module Module { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -15,6 +15,7 @@ using Ninject;
|
|||||||
using Ninject.Extensions.ChildKernel;
|
using Ninject.Extensions.ChildKernel;
|
||||||
using Ninject.Parameters;
|
using Ninject.Parameters;
|
||||||
using RGB.NET.Core;
|
using RGB.NET.Core;
|
||||||
|
using Serilog;
|
||||||
|
|
||||||
namespace Artemis.Core.Services
|
namespace Artemis.Core.Services
|
||||||
{
|
{
|
||||||
@ -24,12 +25,14 @@ namespace Artemis.Core.Services
|
|||||||
public class PluginService : IPluginService
|
public class PluginService : IPluginService
|
||||||
{
|
{
|
||||||
private readonly IKernel _kernel;
|
private readonly IKernel _kernel;
|
||||||
|
private readonly ILogger _logger;
|
||||||
private readonly List<PluginInfo> _plugins;
|
private readonly List<PluginInfo> _plugins;
|
||||||
private IKernel _childKernel;
|
private IKernel _childKernel;
|
||||||
|
|
||||||
internal PluginService(IKernel kernel)
|
internal PluginService(IKernel kernel, ILogger logger)
|
||||||
{
|
{
|
||||||
_kernel = kernel;
|
_kernel = kernel;
|
||||||
|
_logger = logger;
|
||||||
_plugins = new List<PluginInfo>();
|
_plugins = new List<PluginInfo>();
|
||||||
|
|
||||||
// Ensure the plugins directory exists
|
// Ensure the plugins directory exists
|
||||||
@ -114,7 +117,9 @@ namespace Artemis.Core.Services
|
|||||||
// Load the metadata
|
// Load the metadata
|
||||||
var metadataFile = Path.Combine(subDirectory.FullName, "plugin.json");
|
var metadataFile = Path.Combine(subDirectory.FullName, "plugin.json");
|
||||||
if (!File.Exists(metadataFile))
|
if (!File.Exists(metadataFile))
|
||||||
throw new ArtemisPluginException("Couldn't find the plugins metadata file at " + metadataFile);
|
{
|
||||||
|
_logger.Warning(new ArtemisPluginException("Couldn't find the plugins metadata file at " + metadataFile), "Plugin exception");
|
||||||
|
}
|
||||||
|
|
||||||
// Locate the main entry
|
// Locate the main entry
|
||||||
var pluginInfo = JsonConvert.DeserializeObject<PluginInfo>(File.ReadAllText(metadataFile));
|
var pluginInfo = JsonConvert.DeserializeObject<PluginInfo>(File.ReadAllText(metadataFile));
|
||||||
@ -124,14 +129,21 @@ namespace Artemis.Core.Services
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
throw new ArtemisPluginException("Failed to load plugin", e);
|
_logger.Warning(new ArtemisPluginException("Failed to load plugin", e), "Plugin exception");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Activate plugins after they are all loaded
|
// Activate plugins after they are all loaded
|
||||||
foreach (var pluginInfo in _plugins.Where(p => p.Enabled))
|
foreach (var pluginInfo in _plugins.Where(p => p.Enabled))
|
||||||
{
|
{
|
||||||
pluginInfo.Instance.EnablePlugin();
|
try
|
||||||
|
{
|
||||||
|
pluginInfo.Instance.EnablePlugin();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
_logger.Warning(new ArtemisPluginException(pluginInfo, "Failed to load enable plugin", e), "Plugin exception");
|
||||||
|
}
|
||||||
OnPluginEnabled(new PluginEventArgs(pluginInfo));
|
OnPluginEnabled(new PluginEventArgs(pluginInfo));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Drawing.Drawing2D;
|
using System.Drawing.Drawing2D;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -6,15 +7,14 @@ using Artemis.Core.Models.Surface;
|
|||||||
using Artemis.Core.Plugins.Abstract;
|
using Artemis.Core.Plugins.Abstract;
|
||||||
using Artemis.Core.Plugins.Models;
|
using Artemis.Core.Plugins.Models;
|
||||||
using Artemis.Plugins.Modules.General.ViewModels;
|
using Artemis.Plugins.Modules.General.ViewModels;
|
||||||
using Stylet;
|
|
||||||
using Device = Artemis.Core.Models.Surface.Device;
|
using Device = Artemis.Core.Models.Surface.Device;
|
||||||
|
|
||||||
namespace Artemis.Plugins.Modules.General
|
namespace Artemis.Plugins.Modules.General
|
||||||
{
|
{
|
||||||
public class GeneralModule : Module
|
public class GeneralModule : Module
|
||||||
{
|
{
|
||||||
private readonly PluginSettings _settings;
|
|
||||||
private readonly ColorBlend _rainbowColorBlend;
|
private readonly ColorBlend _rainbowColorBlend;
|
||||||
|
private readonly PluginSettings _settings;
|
||||||
|
|
||||||
public GeneralModule(PluginInfo pluginInfo, PluginSettings settings) : base(pluginInfo)
|
public GeneralModule(PluginInfo pluginInfo, PluginSettings settings) : base(pluginInfo)
|
||||||
{
|
{
|
||||||
@ -118,9 +118,9 @@ namespace Artemis.Plugins.Modules.General
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override IScreen GetMainViewModel()
|
public override IEnumerable<ModuleViewModel> GetViewModels()
|
||||||
{
|
{
|
||||||
return new GeneralViewModel(this);
|
return new List<ModuleViewModel> {new GeneralViewModel(this)};
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Dispose()
|
public override void Dispose()
|
||||||
|
|||||||
@ -5,7 +5,7 @@ namespace Artemis.Plugins.Modules.General.ViewModels
|
|||||||
{
|
{
|
||||||
public class GeneralViewModel : ModuleViewModel
|
public class GeneralViewModel : ModuleViewModel
|
||||||
{
|
{
|
||||||
public GeneralViewModel(Module module) : base(module)
|
public GeneralViewModel(Module module) : base(module, "General")
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,8 @@
|
|||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:s="https://github.com/canton7/Stylet"
|
xmlns:s="https://github.com/canton7/Stylet"
|
||||||
xmlns:local="clr-namespace:Artemis.UI">
|
xmlns:local="clr-namespace:Artemis.UI"
|
||||||
|
xmlns:dragablz="http://dragablz.net/winfx/xaml/dragablz">
|
||||||
|
|
||||||
<Application.Resources>
|
<Application.Resources>
|
||||||
<ResourceDictionary>
|
<ResourceDictionary>
|
||||||
@ -28,6 +29,9 @@
|
|||||||
Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Primary/MaterialDesignColor.Teal.xaml" />
|
Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Primary/MaterialDesignColor.Teal.xaml" />
|
||||||
<ResourceDictionary
|
<ResourceDictionary
|
||||||
Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Accent/MaterialDesignColor.Teal.xaml" />
|
Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Accent/MaterialDesignColor.Teal.xaml" />
|
||||||
|
|
||||||
|
<!-- Include the Dragablz Material Design style -->
|
||||||
|
<ResourceDictionary Source="pack://application:,,,/Dragablz;component/Themes/materialdesign.xaml"/>
|
||||||
</ResourceDictionary.MergedDictionaries>
|
</ResourceDictionary.MergedDictionaries>
|
||||||
|
|
||||||
<!-- MahApps Brushes -->
|
<!-- MahApps Brushes -->
|
||||||
@ -54,6 +58,9 @@
|
|||||||
<SolidColorBrush x:Key="MahApps.Metro.Brushes.ToggleSwitchButton.ThumbIndicatorCheckedBrush.Win10"
|
<SolidColorBrush x:Key="MahApps.Metro.Brushes.ToggleSwitchButton.ThumbIndicatorCheckedBrush.Win10"
|
||||||
Color="{DynamicResource Primary500Foreground}" />
|
Color="{DynamicResource Primary500Foreground}" />
|
||||||
|
|
||||||
|
<!-- tell Dragablz tab control to use the Material Design theme -->
|
||||||
|
<Style TargetType="{x:Type dragablz:TabablzControl}" BasedOn="{StaticResource MaterialDesignTabablzControlStyle}" />
|
||||||
|
|
||||||
<!-- Some general convertes etc. -->
|
<!-- Some general convertes etc. -->
|
||||||
<BooleanToVisibilityConverter x:Key="BoolToVisibilityConverter" />
|
<BooleanToVisibilityConverter x:Key="BoolToVisibilityConverter" />
|
||||||
|
|
||||||
|
|||||||
@ -69,6 +69,9 @@
|
|||||||
<Reference Include="ControlzEx, Version=3.0.2.4, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="ControlzEx, Version=3.0.2.4, Culture=neutral, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\ControlzEx.3.0.2.4\lib\net462\ControlzEx.dll</HintPath>
|
<HintPath>..\packages\ControlzEx.3.0.2.4\lib\net462\ControlzEx.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="Dragablz, Version=0.0.3.203, Culture=neutral, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\Dragablz.0.0.3.203\lib\net45\Dragablz.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="FluentValidation, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7de548da2fbae0f0, processorArchitecture=MSIL">
|
<Reference Include="FluentValidation, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7de548da2fbae0f0, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\FluentValidation.8.5.0\lib\net45\FluentValidation.dll</HintPath>
|
<HintPath>..\packages\FluentValidation.8.5.0\lib\net45\FluentValidation.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
@ -163,6 +166,7 @@
|
|||||||
<Compile Include="Converters\NullToVisibilityConverter.cs" />
|
<Compile Include="Converters\NullToVisibilityConverter.cs" />
|
||||||
<Compile Include="Extensions\RgbColorExtensions.cs" />
|
<Compile Include="Extensions\RgbColorExtensions.cs" />
|
||||||
<Compile Include="Extensions\RgbRectangleExtensions.cs" />
|
<Compile Include="Extensions\RgbRectangleExtensions.cs" />
|
||||||
|
<Compile Include="Ninject\Factories\ModuleViewModelFactory.cs" />
|
||||||
<Compile Include="Ninject\UIModule.cs" />
|
<Compile Include="Ninject\UIModule.cs" />
|
||||||
<Compile Include="Properties\Resources.Designer.cs">
|
<Compile Include="Properties\Resources.Designer.cs">
|
||||||
<AutoGen>True</AutoGen>
|
<AutoGen>True</AutoGen>
|
||||||
@ -176,30 +180,33 @@
|
|||||||
<Compile Include="Stylet\FluentValidationAdapter.cs" />
|
<Compile Include="Stylet\FluentValidationAdapter.cs" />
|
||||||
<Compile Include="Stylet\NinjectBootstrapper.cs" />
|
<Compile Include="Stylet\NinjectBootstrapper.cs" />
|
||||||
<Compile Include="ViewModels\Controls\ProfileEditor\ProfileDeviceViewModel.cs" />
|
<Compile Include="ViewModels\Controls\ProfileEditor\ProfileDeviceViewModel.cs" />
|
||||||
|
<Compile Include="ViewModels\Controls\ProfileEditor\ProfileEditorViewModel.cs" />
|
||||||
<Compile Include="ViewModels\Controls\ProfileEditor\ProfileLedViewModel.cs" />
|
<Compile Include="ViewModels\Controls\ProfileEditor\ProfileLedViewModel.cs" />
|
||||||
<Compile Include="ViewModels\Controls\SurfaceEditor\SurfaceLedViewModel.cs" />
|
<Compile Include="ViewModels\Controls\SurfaceEditor\SurfaceLedViewModel.cs" />
|
||||||
<Compile Include="ViewModels\Controls\SurfaceEditor\SurfaceDeviceViewModel.cs" />
|
<Compile Include="ViewModels\Controls\SurfaceEditor\SurfaceDeviceViewModel.cs" />
|
||||||
<Compile Include="ViewModels\Dialogs\ConfirmDialogViewModel.cs" />
|
<Compile Include="ViewModels\Dialogs\ConfirmDialogViewModel.cs" />
|
||||||
<Compile Include="ViewModels\Dialogs\SurfaceCreateViewModelValidator.cs" />
|
<Compile Include="ViewModels\Dialogs\SurfaceCreateViewModelValidator.cs" />
|
||||||
<Compile Include="ViewModels\Dialogs\SurfaceCreateViewModel.cs" />
|
<Compile Include="ViewModels\Dialogs\SurfaceCreateViewModel.cs" />
|
||||||
|
<Compile Include="ViewModels\Screens\ModuleRootViewModel.cs" />
|
||||||
<Compile Include="ViewModels\Screens\SplashViewModel.cs" />
|
<Compile Include="ViewModels\Screens\SplashViewModel.cs" />
|
||||||
<Compile Include="ViewModels\Utilities\DialogViewModelHost.cs" />
|
<Compile Include="ViewModels\Utilities\DialogViewModelHost.cs" />
|
||||||
<Compile Include="ViewModels\Dialogs\DialogViewModelBase.cs" />
|
<Compile Include="ViewModels\Dialogs\DialogViewModelBase.cs" />
|
||||||
<Compile Include="ViewModels\Utilities\PanZoomViewModel.cs" />
|
<Compile Include="ViewModels\Utilities\PanZoomViewModel.cs" />
|
||||||
<Compile Include="ViewModels\Screens\DebugViewModel.cs" />
|
<Compile Include="ViewModels\Screens\DebugViewModel.cs" />
|
||||||
<Compile Include="ViewModels\Screens\SurfaceEditorViewModel.cs" />
|
<Compile Include="ViewModels\Screens\SurfaceEditorViewModel.cs" />
|
||||||
<Compile Include="ViewModels\Interfaces\IEditorViewModel.cs" />
|
|
||||||
<Compile Include="ViewModels\Controls\Settings\DeviceSettingsViewModel.cs" />
|
<Compile Include="ViewModels\Controls\Settings\DeviceSettingsViewModel.cs" />
|
||||||
<Compile Include="ViewModels\Interfaces\IHomeViewModel.cs" />
|
|
||||||
<Compile Include="ViewModels\Interfaces\IScreenViewModel.cs" />
|
<Compile Include="ViewModels\Interfaces\IScreenViewModel.cs" />
|
||||||
<Compile Include="ViewModels\Screens\HomeViewModel.cs" />
|
<Compile Include="ViewModels\Screens\HomeViewModel.cs" />
|
||||||
<Compile Include="ViewModels\Interfaces\ISettingsViewModel.cs" />
|
|
||||||
<Compile Include="ViewModels\Screens\RootViewModel.cs" />
|
<Compile Include="ViewModels\Screens\RootViewModel.cs" />
|
||||||
<Compile Include="App.xaml.cs">
|
<Compile Include="App.xaml.cs">
|
||||||
<DependentUpon>App.xaml</DependentUpon>
|
<DependentUpon>App.xaml</DependentUpon>
|
||||||
<SubType>Code</SubType>
|
<SubType>Code</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="ViewModels\Screens\SettingsViewModel.cs" />
|
<Compile Include="ViewModels\Screens\SettingsViewModel.cs" />
|
||||||
|
<Page Include="Views\Controls\ProfileEditor\ProfileEditorView.xaml">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
</Page>
|
||||||
<Page Include="Views\Controls\SurfaceEditor\SurfaceLedView.xaml">
|
<Page Include="Views\Controls\SurfaceEditor\SurfaceLedView.xaml">
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
@ -232,6 +239,10 @@
|
|||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
</Page>
|
</Page>
|
||||||
|
<Page Include="Views\Screens\ModuleRootView.xaml">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
</Page>
|
||||||
<Page Include="Views\Screens\RootView.xaml">
|
<Page Include="Views\Screens\RootView.xaml">
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
|||||||
10
src/Artemis.UI/Ninject/Factories/ModuleViewModelFactory.cs
Normal file
10
src/Artemis.UI/Ninject/Factories/ModuleViewModelFactory.cs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
using Artemis.Core.Plugins.Abstract;
|
||||||
|
using Artemis.UI.ViewModels.Screens;
|
||||||
|
|
||||||
|
namespace Artemis.UI.Ninject.Factories
|
||||||
|
{
|
||||||
|
public interface IModuleViewModelFactory
|
||||||
|
{
|
||||||
|
ModuleRootViewModel CreateModuleViewModel(Module module);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,9 +1,11 @@
|
|||||||
using Artemis.UI.Services.Interfaces;
|
using Artemis.UI.Ninject.Factories;
|
||||||
|
using Artemis.UI.Services.Interfaces;
|
||||||
using Artemis.UI.Stylet;
|
using Artemis.UI.Stylet;
|
||||||
using Artemis.UI.ViewModels.Dialogs;
|
using Artemis.UI.ViewModels.Dialogs;
|
||||||
using Artemis.UI.ViewModels.Interfaces;
|
using Artemis.UI.ViewModels.Interfaces;
|
||||||
using FluentValidation;
|
using FluentValidation;
|
||||||
using Ninject.Extensions.Conventions;
|
using Ninject.Extensions.Conventions;
|
||||||
|
using Ninject.Extensions.Factory;
|
||||||
using Ninject.Modules;
|
using Ninject.Modules;
|
||||||
using Stylet;
|
using Stylet;
|
||||||
|
|
||||||
@ -32,6 +34,9 @@ namespace Artemis.UI.Ninject
|
|||||||
.BindAllBaseClasses();
|
.BindAllBaseClasses();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Bind the module VM
|
||||||
|
Bind<IModuleViewModelFactory>().ToFactory();
|
||||||
|
|
||||||
// Bind all UI services as singletons
|
// Bind all UI services as singletons
|
||||||
Kernel.Bind(x =>
|
Kernel.Bind(x =>
|
||||||
{
|
{
|
||||||
|
|||||||
@ -0,0 +1,16 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Artemis.Core.Plugins.Abstract;
|
||||||
|
|
||||||
|
namespace Artemis.UI.ViewModels.Controls.ProfileEditor
|
||||||
|
{
|
||||||
|
public class ProfileEditorViewModel : ModuleViewModel
|
||||||
|
{
|
||||||
|
public ProfileEditorViewModel(Module module) : base(module, "Profile Editor")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,7 +0,0 @@
|
|||||||
namespace Artemis.UI.ViewModels.Interfaces
|
|
||||||
{
|
|
||||||
public interface ISurfaceEditorViewModel : IScreenViewModel
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,7 +0,0 @@
|
|||||||
namespace Artemis.UI.ViewModels.Interfaces
|
|
||||||
{
|
|
||||||
public interface IHomeViewModel : IScreenViewModel
|
|
||||||
{
|
|
||||||
void OpenUrl(string url);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,6 +0,0 @@
|
|||||||
namespace Artemis.UI.ViewModels.Interfaces
|
|
||||||
{
|
|
||||||
public interface ISettingsViewModel : IScreenViewModel
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -7,11 +7,12 @@ using System.Windows.Media;
|
|||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
using Artemis.Core.Events;
|
using Artemis.Core.Events;
|
||||||
using Artemis.Core.Services.Interfaces;
|
using Artemis.Core.Services.Interfaces;
|
||||||
|
using Artemis.UI.ViewModels.Interfaces;
|
||||||
using Stylet;
|
using Stylet;
|
||||||
|
|
||||||
namespace Artemis.UI.ViewModels.Screens
|
namespace Artemis.UI.ViewModels.Screens
|
||||||
{
|
{
|
||||||
public class DebugViewModel : Screen
|
public class DebugViewModel : Screen, IScreenViewModel
|
||||||
{
|
{
|
||||||
private readonly ICoreService _coreService;
|
private readonly ICoreService _coreService;
|
||||||
private readonly IRgbService _rgbService;
|
private readonly IRgbService _rgbService;
|
||||||
@ -76,5 +77,7 @@ namespace Artemis.UI.ViewModels.Screens
|
|||||||
[DllImport("gdi32.dll", EntryPoint = "DeleteObject")]
|
[DllImport("gdi32.dll", EntryPoint = "DeleteObject")]
|
||||||
[return: MarshalAs(UnmanagedType.Bool)]
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
public static extern bool DeleteObject([In] IntPtr hObject);
|
public static extern bool DeleteObject([In] IntPtr hObject);
|
||||||
|
|
||||||
|
public string Title => "Debugger";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5,7 +5,7 @@ using Stylet;
|
|||||||
|
|
||||||
namespace Artemis.UI.ViewModels.Screens
|
namespace Artemis.UI.ViewModels.Screens
|
||||||
{
|
{
|
||||||
public class HomeViewModel : Screen, IHomeViewModel
|
public class HomeViewModel : Screen, IScreenViewModel
|
||||||
{
|
{
|
||||||
public string Title => "Home";
|
public string Title => "Home";
|
||||||
|
|
||||||
|
|||||||
21
src/Artemis.UI/ViewModels/Screens/ModuleRootViewModel.cs
Normal file
21
src/Artemis.UI/ViewModels/Screens/ModuleRootViewModel.cs
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
using Artemis.Core.Plugins.Abstract;
|
||||||
|
using Artemis.UI.ViewModels.Controls.ProfileEditor;
|
||||||
|
using Stylet;
|
||||||
|
|
||||||
|
namespace Artemis.UI.ViewModels.Screens
|
||||||
|
{
|
||||||
|
public class ModuleRootViewModel : Screen
|
||||||
|
{
|
||||||
|
public ModuleRootViewModel(Module module)
|
||||||
|
{
|
||||||
|
Module = module;
|
||||||
|
ModuleViewModels = new BindableCollection<ModuleViewModel> {new ProfileEditorViewModel(Module)};
|
||||||
|
ModuleViewModels.AddRange(Module.GetViewModels());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Module Module { get; }
|
||||||
|
public BindableCollection<ModuleViewModel> ModuleViewModels { get; set; }
|
||||||
|
|
||||||
|
public int FixedHeaderCount => ModuleViewModels.Count;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,11 +1,13 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using Artemis.Core.Events;
|
using Artemis.Core.Events;
|
||||||
using Artemis.Core.Plugins.Abstract;
|
using Artemis.Core.Plugins.Abstract;
|
||||||
using Artemis.Core.Services.Interfaces;
|
using Artemis.Core.Services.Interfaces;
|
||||||
|
using Artemis.UI.Ninject.Factories;
|
||||||
using Artemis.UI.ViewModels.Interfaces;
|
using Artemis.UI.ViewModels.Interfaces;
|
||||||
using Stylet;
|
using Stylet;
|
||||||
|
|
||||||
@ -15,11 +17,13 @@ namespace Artemis.UI.ViewModels.Screens
|
|||||||
{
|
{
|
||||||
private readonly ICollection<IScreenViewModel> _artemisViewModels;
|
private readonly ICollection<IScreenViewModel> _artemisViewModels;
|
||||||
private readonly IPluginService _pluginService;
|
private readonly IPluginService _pluginService;
|
||||||
|
private readonly IModuleViewModelFactory _moduleViewModelFactory;
|
||||||
|
|
||||||
public RootViewModel(ICollection<IScreenViewModel> artemisViewModels, IPluginService pluginService)
|
public RootViewModel(ICollection<IScreenViewModel> artemisViewModels, IPluginService pluginService, IModuleViewModelFactory moduleViewModelFactory)
|
||||||
{
|
{
|
||||||
_artemisViewModels = artemisViewModels;
|
_artemisViewModels = artemisViewModels;
|
||||||
_pluginService = pluginService;
|
_pluginService = pluginService;
|
||||||
|
_moduleViewModelFactory = moduleViewModelFactory;
|
||||||
|
|
||||||
// Add the built-in items
|
// Add the built-in items
|
||||||
Items.AddRange(artemisViewModels);
|
Items.AddRange(artemisViewModels);
|
||||||
@ -28,7 +32,7 @@ namespace Artemis.UI.ViewModels.Screens
|
|||||||
|
|
||||||
// Sync up with the plugin service
|
// Sync up with the plugin service
|
||||||
Modules = new BindableCollection<Module>();
|
Modules = new BindableCollection<Module>();
|
||||||
// Modules.AddRange(_pluginService.GetPluginsOfType<Module>());
|
Modules.AddRange(_pluginService.GetPluginsOfType<Module>());
|
||||||
|
|
||||||
_pluginService.PluginEnabled += PluginServiceOnPluginEnabled;
|
_pluginService.PluginEnabled += PluginServiceOnPluginEnabled;
|
||||||
_pluginService.PluginDisabled += PluginServiceOnPluginDisabled;
|
_pluginService.PluginDisabled += PluginServiceOnPluginDisabled;
|
||||||
@ -47,8 +51,7 @@ namespace Artemis.UI.ViewModels.Screens
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// Create a view model for the given plugin info (which will be a module)
|
// Create a view model for the given plugin info (which will be a module)
|
||||||
var viewModel = await Task.Run(() => SelectedModule.GetMainViewModel());
|
var viewModel = await Task.Run(() => _moduleViewModelFactory.CreateModuleViewModel(SelectedModule));
|
||||||
// Tell Stylet to active the view model, the view manager will compile and show the XAML
|
|
||||||
ActivateItem(viewModel);
|
ActivateItem(viewModel);
|
||||||
|
|
||||||
SelectedPage = null;
|
SelectedPage = null;
|
||||||
|
|||||||
@ -8,7 +8,7 @@ using Stylet;
|
|||||||
|
|
||||||
namespace Artemis.UI.ViewModels.Screens
|
namespace Artemis.UI.ViewModels.Screens
|
||||||
{
|
{
|
||||||
public class SettingsViewModel : Screen, ISettingsViewModel
|
public class SettingsViewModel : Screen, IScreenViewModel
|
||||||
{
|
{
|
||||||
private readonly ICoreService _coreService;
|
private readonly ICoreService _coreService;
|
||||||
private readonly IKernel _kernel;
|
private readonly IKernel _kernel;
|
||||||
|
|||||||
@ -1,9 +1,4 @@
|
|||||||
using System;
|
using Artemis.Core.Services.Interfaces;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Artemis.Core.Services.Interfaces;
|
|
||||||
using Ninject;
|
using Ninject;
|
||||||
using Stylet;
|
using Stylet;
|
||||||
|
|
||||||
@ -26,6 +21,7 @@ namespace Artemis.UI.ViewModels.Screens
|
|||||||
var pluginService = _kernel.Get<IPluginService>();
|
var pluginService = _kernel.Get<IPluginService>();
|
||||||
pluginService.CopyingBuildInPlugins += (sender, args) => Status = "Updating built-in plugins";
|
pluginService.CopyingBuildInPlugins += (sender, args) => Status = "Updating built-in plugins";
|
||||||
pluginService.PluginLoading += (sender, args) => Status = "Loading plugin: " + args.PluginInfo.Name;
|
pluginService.PluginLoading += (sender, args) => Status = "Loading plugin: " + args.PluginInfo.Name;
|
||||||
|
pluginService.PluginLoaded += (sender, args) => Status = "Initializing UI";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -17,7 +17,7 @@ using Stylet;
|
|||||||
|
|
||||||
namespace Artemis.UI.ViewModels.Screens
|
namespace Artemis.UI.ViewModels.Screens
|
||||||
{
|
{
|
||||||
public class SurfaceEditorViewModel : Screen, ISurfaceEditorViewModel
|
public class SurfaceEditorViewModel : Screen, IScreenViewModel
|
||||||
{
|
{
|
||||||
private readonly IDialogService _dialogService;
|
private readonly IDialogService _dialogService;
|
||||||
private readonly ISurfaceService _surfaceService;
|
private readonly ISurfaceService _surfaceService;
|
||||||
|
|||||||
@ -0,0 +1,14 @@
|
|||||||
|
<UserControl x:Class="Artemis.UI.Views.Controls.ProfileEditor.ProfileEditorView"
|
||||||
|
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.Views.Controls.ProfileEditor"
|
||||||
|
xmlns:profileEditor="clr-namespace:Artemis.UI.ViewModels.Controls.ProfileEditor"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
d:DesignHeight="450" d:DesignWidth="800"
|
||||||
|
d:DataContext="{d:DesignInstance {x:Type profileEditor:ProfileEditorViewModel}}">
|
||||||
|
<Grid>
|
||||||
|
|
||||||
|
</Grid>
|
||||||
|
</UserControl>
|
||||||
@ -4,7 +4,6 @@
|
|||||||
xmlns:s="https://github.com/canton7/Stylet"
|
xmlns:s="https://github.com/canton7/Stylet"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:vms="clr-namespace:Artemis.UI.ViewModels"
|
|
||||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||||
xmlns:screens="clr-namespace:Artemis.UI.ViewModels.Screens"
|
xmlns:screens="clr-namespace:Artemis.UI.ViewModels.Screens"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
|
|||||||
25
src/Artemis.UI/Views/Screens/ModuleRootView.xaml
Normal file
25
src/Artemis.UI/Views/Screens/ModuleRootView.xaml
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<UserControl x:Class="Artemis.UI.Views.Screens.ModuleRootView"
|
||||||
|
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.Views.Screens"
|
||||||
|
xmlns:screens="clr-namespace:Artemis.UI.ViewModels.Screens"
|
||||||
|
xmlns:dragablz="http://dragablz.net/winfx/xaml/dragablz"
|
||||||
|
xmlns:s="https://github.com/canton7/Stylet"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
d:DesignHeight="450" d:DesignWidth="800"
|
||||||
|
d:DataContext="{d:DesignInstance screens:ModuleRootViewModel}">
|
||||||
|
<dragablz:TabablzControl Margin="0 -1 0 0" FixedHeaderCount="{Binding FixedHeaderCount}" ItemsSource="{Binding ModuleViewModels}">
|
||||||
|
<dragablz:TabablzControl.HeaderItemTemplate>
|
||||||
|
<DataTemplate>
|
||||||
|
<TextBlock Text="{Binding Name}" />
|
||||||
|
</DataTemplate>
|
||||||
|
</dragablz:TabablzControl.HeaderItemTemplate>
|
||||||
|
<dragablz:TabablzControl.ContentTemplate>
|
||||||
|
<DataTemplate>
|
||||||
|
<ContentControl s:View.Model="{Binding}" />
|
||||||
|
</DataTemplate>
|
||||||
|
</dragablz:TabablzControl.ContentTemplate>
|
||||||
|
</dragablz:TabablzControl>
|
||||||
|
</UserControl>
|
||||||
@ -114,7 +114,7 @@
|
|||||||
</DockPanel>
|
</DockPanel>
|
||||||
</materialDesign:DrawerHost.LeftDrawerContent>
|
</materialDesign:DrawerHost.LeftDrawerContent>
|
||||||
<DockPanel>
|
<DockPanel>
|
||||||
<materialDesign:ColorZone Padding="16"
|
<materialDesign:ColorZone Padding="10"
|
||||||
materialDesign:ShadowAssist.ShadowDepth="Depth2"
|
materialDesign:ShadowAssist.ShadowDepth="Depth2"
|
||||||
Mode="PrimaryMid"
|
Mode="PrimaryMid"
|
||||||
DockPanel.Dock="Top">
|
DockPanel.Dock="Top">
|
||||||
@ -134,6 +134,7 @@
|
|||||||
<Button Content="Goodbye" />
|
<Button Content="Goodbye" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</materialDesign:PopupBox>
|
</materialDesign:PopupBox>
|
||||||
|
|
||||||
<TextBlock HorizontalAlignment="Center"
|
<TextBlock HorizontalAlignment="Center"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
FontSize="22"
|
FontSize="22"
|
||||||
|
|||||||
@ -1,24 +1,22 @@
|
|||||||
<mah:MetroWindow x:Class="Artemis.UI.Views.Screens.SplashView"
|
<mah:MetroWindow x:Class="Artemis.UI.Views.Screens.SplashView"
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:local="clr-namespace:Artemis.UI.Views.Screens"
|
xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
|
||||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
xmlns:screens="clr-namespace:Artemis.UI.ViewModels.Screens"
|
||||||
xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
|
mc:Ignorable="d"
|
||||||
xmlns:screens="clr-namespace:Artemis.UI.ViewModels.Screens"
|
Title="Artemis"
|
||||||
mc:Ignorable="d"
|
Height="450"
|
||||||
Title="Artemis"
|
Width="450"
|
||||||
Height="450"
|
ShowTitleBar="False"
|
||||||
Width="450"
|
ShowMaxRestoreButton="False"
|
||||||
ShowTitleBar="False"
|
ShowCloseButton="False"
|
||||||
ShowMaxRestoreButton="False"
|
ShowMinButton="False"
|
||||||
ShowCloseButton="False"
|
WindowStartupLocation="CenterScreen"
|
||||||
ShowMinButton="False"
|
GlowBrush="{DynamicResource AccentColorBrush}"
|
||||||
WindowStartupLocation="CenterScreen"
|
FontFamily="{StaticResource DefaultFont}"
|
||||||
GlowBrush="{DynamicResource AccentColorBrush}"
|
d:DataContext="{d:DesignInstance screens:SplashViewModel}">
|
||||||
FontFamily="{StaticResource DefaultFont}"
|
|
||||||
d:DataContext="{d:DesignInstance screens:SplashViewModel}">
|
|
||||||
<Grid Background="{DynamicResource PrimaryHueMidBrush}">
|
<Grid Background="{DynamicResource PrimaryHueMidBrush}">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="250" />
|
<RowDefinition Height="250" />
|
||||||
@ -28,7 +26,7 @@
|
|||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
<Image Source="{StaticResource BowIcon}" Stretch="Uniform" Margin="6,50,6,6" />
|
<Image Source="{StaticResource BowIcon}" Stretch="Uniform" Margin="6,50,6,6" />
|
||||||
<TextBlock Grid.Row="1" HorizontalAlignment="Center" VerticalAlignment="Bottom" Foreground="White" FontSize="16">Artemis is initializing...</TextBlock>
|
<TextBlock Grid.Row="1" HorizontalAlignment="Center" VerticalAlignment="Bottom" Foreground="White" FontSize="16">Artemis is initializing...</TextBlock>
|
||||||
<TextBlock Grid.Row="2" HorizontalAlignment="Center" Foreground="#FFDDDDDD" Text="{Binding Status}"/>
|
<TextBlock Grid.Row="2" HorizontalAlignment="Center" Foreground="#FFDDDDDD" Text="{Binding Status}" />
|
||||||
<ProgressBar Grid.Row="3" IsIndeterminate="True" Maximum="1" Minimum="1" Margin="16 0"/>
|
<ProgressBar Grid.Row="3" IsIndeterminate="True" Maximum="1" Minimum="1" Margin="16 0" />
|
||||||
</Grid>
|
</Grid>
|
||||||
</mah:MetroWindow>
|
</mah:MetroWindow>
|
||||||
@ -2,6 +2,7 @@
|
|||||||
<packages>
|
<packages>
|
||||||
<package id="Castle.Core" version="4.4.0" targetFramework="net461" />
|
<package id="Castle.Core" version="4.4.0" targetFramework="net461" />
|
||||||
<package id="ControlzEx" version="3.0.2.4" targetFramework="net472" />
|
<package id="ControlzEx" version="3.0.2.4" targetFramework="net472" />
|
||||||
|
<package id="Dragablz" version="0.0.3.203" targetFramework="net472" />
|
||||||
<package id="FluentValidation" version="8.5.0" targetFramework="net472" />
|
<package id="FluentValidation" version="8.5.0" targetFramework="net472" />
|
||||||
<package id="Fody" version="5.0.6" targetFramework="net472" developmentDependency="true" />
|
<package id="Fody" version="5.0.6" targetFramework="net472" developmentDependency="true" />
|
||||||
<package id="Humanizer.Core" version="2.6.2" targetFramework="net461" />
|
<package id="Humanizer.Core" version="2.6.2" targetFramework="net461" />
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user