1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-13 05:48:35 +00:00

Marked all service implementations as internal

Core - Enabled XML docs
Modules - Added DI to module VMs
This commit is contained in:
Robert 2020-08-19 19:45:22 +02:00
parent ae9bdecef1
commit a06ad8f011
29 changed files with 134 additions and 46 deletions

View File

@ -16,6 +16,7 @@
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<PlatformTarget>x64</PlatformTarget> <PlatformTarget>x64</PlatformTarget>
<DocumentationFile>bin\AnyCPU\Debug\Artemis.Core.xml</DocumentationFile>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<NrtRevisionFormat>2.0-{chash:6}</NrtRevisionFormat> <NrtRevisionFormat>2.0-{chash:6}</NrtRevisionFormat>
@ -27,6 +28,9 @@
<NrtRequiredVcs>git</NrtRequiredVcs> <NrtRequiredVcs>git</NrtRequiredVcs>
<NrtShowRevision>true</NrtShowRevision> <NrtShowRevision>true</NrtShowRevision>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DocumentationFile>bin\AnyCPU\Release\Artemis.Core.xml</DocumentationFile>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Artemis.Storage\Artemis.Storage.csproj"> <ProjectReference Include="..\Artemis.Storage\Artemis.Storage.csproj">
<Private>false</Private> <Private>false</Private>
@ -46,7 +50,7 @@
<PackageReference Include="Serilog.Sinks.Debug" Version="1.0.1" /> <PackageReference Include="Serilog.Sinks.Debug" Version="1.0.1" />
<PackageReference Include="Serilog.Sinks.File" Version="4.1.0" /> <PackageReference Include="Serilog.Sinks.File" Version="4.1.0" />
<PackageReference Include="SkiaSharp" Version="1.68.3" /> <PackageReference Include="SkiaSharp" Version="1.68.3" />
<PackageReference Include="Stylet" Version="1.3.2" /> <PackageReference Include="Stylet" Version="1.3.4" />
<PackageReference Include="System.Buffers" Version="4.5.0" /> <PackageReference Include="System.Buffers" Version="4.5.0" />
<PackageReference Include="System.Numerics.Vectors" Version="4.5.0" /> <PackageReference Include="System.Numerics.Vectors" Version="4.5.0" />
<PackageReference Include="System.Reflection.Metadata" Version="1.8.0" /> <PackageReference Include="System.Reflection.Metadata" Version="1.8.0" />

View File

@ -1,11 +1,13 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Windows.Interop;
using Artemis.Core.Plugins.Models; using Artemis.Core.Plugins.Models;
namespace Artemis.Core namespace Artemis.Core
{ {
/// <summary>
/// A few useful constant values
/// </summary>
public static class Constants public static class Constants
{ {
/// <summary> /// <summary>
@ -68,7 +70,7 @@ namespace Artemis.Core
{ {
typeof(float), typeof(float),
typeof(double), typeof(double),
typeof(decimal) typeof(decimal)
}; };
} }
} }

View File

@ -24,6 +24,7 @@ namespace Artemis.Core.Ninject
Kernel.Bind(x => Kernel.Bind(x =>
{ {
x.FromThisAssembly() x.FromThisAssembly()
.IncludingNonPublicTypes()
.SelectAllClasses() .SelectAllClasses()
.InheritedFrom<IArtemisService>() .InheritedFrom<IArtemisService>()
.BindAllInterfaces() .BindAllInterfaces()
@ -34,6 +35,7 @@ namespace Artemis.Core.Ninject
Kernel.Bind(x => Kernel.Bind(x =>
{ {
x.FromThisAssembly() x.FromThisAssembly()
.IncludingNonPublicTypes()
.SelectAllClasses() .SelectAllClasses()
.InheritedFrom<IProtectedArtemisService>() .InheritedFrom<IProtectedArtemisService>()
.BindAllInterfaces() .BindAllInterfaces()
@ -68,6 +70,7 @@ namespace Artemis.Core.Ninject
Kernel.Bind(x => Kernel.Bind(x =>
{ {
x.FromAssemblyContaining<IStorageMigration>() x.FromAssemblyContaining<IStorageMigration>()
.IncludingNonPublicTypes()
.SelectAllClasses() .SelectAllClasses()
.InheritedFrom<IStorageMigration>() .InheritedFrom<IStorageMigration>()
.BindAllInterfaces() .BindAllInterfaces()
@ -78,6 +81,7 @@ namespace Artemis.Core.Ninject
Kernel.Bind(x => Kernel.Bind(x =>
{ {
x.FromAssemblyContaining<IRepository>() x.FromAssemblyContaining<IRepository>()
.IncludingNonPublicTypes()
.SelectAllClasses() .SelectAllClasses()
.InheritedFrom<IRepository>() .InheritedFrom<IRepository>()
.BindAllInterfaces() .BindAllInterfaces()

View File

@ -5,7 +5,7 @@ using Artemis.Core.Models.Surface;
using Artemis.Core.Plugins.Abstract.DataModels; using Artemis.Core.Plugins.Abstract.DataModels;
using Artemis.Core.Plugins.Abstract.DataModels.Attributes; using Artemis.Core.Plugins.Abstract.DataModels.Attributes;
using Artemis.Core.Plugins.Abstract.ViewModels; using Artemis.Core.Plugins.Abstract.ViewModels;
using Artemis.Core.Plugins.ModuleActivationRequirements; using Artemis.Core.Plugins.Modules;
using Artemis.Storage.Entities.Module; using Artemis.Storage.Entities.Module;
using SkiaSharp; using SkiaSharp;
@ -134,10 +134,10 @@ namespace Artemis.Core.Plugins.Abstract
public abstract void Render(double deltaTime, ArtemisSurface surface, SKCanvas canvas, SKImageInfo canvasInfo); public abstract void Render(double deltaTime, ArtemisSurface surface, SKCanvas canvas, SKImageInfo canvasInfo);
/// <summary> /// <summary>
/// Called when the module's view model is being show, return view models here to create tabs for them /// Called when the module's view model is being show, return a list of module tabs here if you want them to show up in the UI
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public abstract IEnumerable<ModuleViewModel> GetViewModels(); public abstract IEnumerable<ModuleTab> GetModuleTabs();
/// <summary> /// <summary>
/// Called when the <see cref="ActivationRequirements" /> are met /// Called when the <see cref="ActivationRequirements" /> are met

View File

@ -0,0 +1,43 @@
using System;
using Artemis.Core.Plugins.Abstract;
using Artemis.Core.Plugins.Abstract.ViewModels;
namespace Artemis.Core.Plugins.Modules
{
/// <inheritdoc />
public class ModuleTab<T> : ModuleTab where T : ModuleViewModel
{
/// <summary>
/// Initializes a new instance of the <see cref="ModuleTab{T}" /> class
/// </summary>
/// <param name="title">The title of the tab</param>
public ModuleTab(string title)
{
Title = title;
}
/// <inheritdoc />
public override Type Type => typeof(T);
}
/// <summary>
/// Describes a UI tab for a specific module
/// </summary>
public abstract class ModuleTab
{
/// <summary>
/// The module this tab belongs to
/// </summary>
internal Module Module { get; set; }
/// <summary>
/// The title of the tab
/// </summary>
public string Title { get; protected set; }
/// <summary>
/// The type of view model the tab contains
/// </summary>
public abstract Type Type { get; }
}
}

View File

@ -1,12 +1,9 @@
using System; using System.Diagnostics;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Text;
using Artemis.Core.Extensions; using Artemis.Core.Extensions;
namespace Artemis.Core.Plugins.ModuleActivationRequirements namespace Artemis.Core.Plugins.Modules
{ {
public class ProcessActivationRequirement : IModuleActivationRequirement public class ProcessActivationRequirement : IModuleActivationRequirement
{ {

View File

@ -27,7 +27,7 @@ namespace Artemis.Core.Services
/// <summary> /// <summary>
/// Provides Artemis's core update loop /// Provides Artemis's core update loop
/// </summary> /// </summary>
public class CoreService : ICoreService internal class CoreService : ICoreService
{ {
private readonly Stopwatch _frameStopWatch; private readonly Stopwatch _frameStopWatch;
private readonly ILogger _logger; private readonly ILogger _logger;
@ -41,7 +41,7 @@ namespace Artemis.Core.Services
private IntroAnimation _introAnimation; private IntroAnimation _introAnimation;
// ReSharper disable once UnusedParameter.Local - Storage migration service is injected early to ensure it runs before anything else // ReSharper disable once UnusedParameter.Local - Storage migration service is injected early to ensure it runs before anything else
internal CoreService(ILogger logger, StorageMigrationService _, ISettingsService settingsService, IPluginService pluginService, public CoreService(ILogger logger, StorageMigrationService _, ISettingsService settingsService, IPluginService pluginService,
IRgbService rgbService, ISurfaceService surfaceService, IProfileService profileService, IModuleService moduleService) IRgbService rgbService, ISurfaceService surfaceService, IProfileService profileService, IModuleService moduleService)
{ {
_logger = logger; _logger = logger;
@ -173,7 +173,10 @@ namespace Artemis.Core.Services
List<Module> modules; List<Module> modules;
lock (_modules) lock (_modules)
{ {
modules = _modules.Where(m => m.IsActivated).OrderByDescending(m => m.PriorityCategory).ThenByDescending(m => m.Priority).ToList(); modules = _modules.Where(m => m.IsActivated || m.InternalExpandsMainDataModel)
.OrderByDescending(m => m.PriorityCategory)
.ThenByDescending(m => m.Priority)
.ToList();
} }
// Update all active modules // Update all active modules
@ -194,7 +197,8 @@ namespace Artemis.Core.Services
canvas.Clear(new SKColor(0, 0, 0)); canvas.Clear(new SKColor(0, 0, 0));
if (!ModuleRenderingDisabled) if (!ModuleRenderingDisabled)
{ {
foreach (var module in modules) // While non-activated modules may be updated above if they expand the main data model, they may never render
foreach (var module in modules.Where(m => m.IsActivated))
module.Render(args.DeltaTime, _surfaceService.ActiveSurface, canvas, _rgbService.BitmapBrush.Bitmap.Info); module.Render(args.DeltaTime, _surfaceService.ActiveSurface, canvas, _rgbService.BitmapBrush.Bitmap.Info);
} }

View File

@ -20,14 +20,14 @@ namespace Artemis.Core.Services
/// <summary> /// <summary>
/// Provides access to the main data model /// Provides access to the main data model
/// </summary> /// </summary>
public class DataModelService : IDataModelService internal class DataModelService : IDataModelService
{ {
private readonly List<DataModel> _dataModelExpansions; private readonly List<DataModel> _dataModelExpansions;
private readonly IPluginService _pluginService; private readonly IPluginService _pluginService;
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly List<DisplayConditionOperator> _registeredConditionOperators; private readonly List<DisplayConditionOperator> _registeredConditionOperators;
internal DataModelService(IPluginService pluginService, ILogger logger) public DataModelService(IPluginService pluginService, ILogger logger)
{ {
_pluginService = pluginService; _pluginService = pluginService;
_logger = logger; _logger = logger;

View File

@ -6,7 +6,7 @@ using SkiaSharp;
namespace Artemis.Core.Services namespace Artemis.Core.Services
{ {
public class DeviceService : IDeviceService internal class DeviceService : IDeviceService
{ {
private readonly ICoreService _coreService; private readonly ICoreService _coreService;

View File

@ -10,7 +10,7 @@ using Serilog;
namespace Artemis.Core.Services namespace Artemis.Core.Services
{ {
public class ModuleService : IModuleService internal class ModuleService : IModuleService
{ {
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly IModuleRepository _moduleRepository; private readonly IModuleRepository _moduleRepository;

View File

@ -26,7 +26,7 @@ namespace Artemis.Core.Services
/// <summary> /// <summary>
/// Provides access to plugin loading and unloading /// Provides access to plugin loading and unloading
/// </summary> /// </summary>
public class PluginService : IPluginService internal class PluginService : IPluginService
{ {
private readonly IKernel _kernel; private readonly IKernel _kernel;
private readonly ILogger _logger; private readonly ILogger _logger;
@ -34,7 +34,7 @@ namespace Artemis.Core.Services
private readonly List<PluginInfo> _plugins; private readonly List<PluginInfo> _plugins;
private IKernel _childKernel; private IKernel _childKernel;
internal PluginService(IKernel kernel, ILogger logger, IPluginRepository pluginRepository) public PluginService(IKernel kernel, ILogger logger, IPluginRepository pluginRepository)
{ {
_kernel = kernel; _kernel = kernel;
_logger = logger; _logger = logger;

View File

@ -15,7 +15,7 @@ using Serilog;
namespace Artemis.Core.Services namespace Artemis.Core.Services
{ {
public class RenderElementService : IRenderElementService internal class RenderElementService : IRenderElementService
{ {
private readonly IKernel _kernel; private readonly IKernel _kernel;
private readonly ILogger _logger; private readonly ILogger _logger;

View File

@ -14,7 +14,7 @@ namespace Artemis.Core.Services
/// <summary> /// <summary>
/// Provides wrapped access the RGB.NET /// Provides wrapped access the RGB.NET
/// </summary> /// </summary>
public class RgbService : IRgbService, IDisposable internal class RgbService : IRgbService, IDisposable
{ {
private readonly List<IRGBDevice> _loadedDevices; private readonly List<IRGBDevice> _loadedDevices;
private readonly ILogger _logger; private readonly ILogger _logger;
@ -23,7 +23,7 @@ namespace Artemis.Core.Services
private readonly PluginSetting<int> _targetFrameRateSetting; private readonly PluginSetting<int> _targetFrameRateSetting;
private ListLedGroup _surfaceLedGroup; private ListLedGroup _surfaceLedGroup;
internal RgbService(ILogger logger, ISettingsService settingsService) public RgbService(ILogger logger, ISettingsService settingsService)
{ {
_logger = logger; _logger = logger;
_renderScaleSetting = settingsService.GetSetting("Core.RenderScale", 0.5); _renderScaleSetting = settingsService.GetSetting("Core.RenderScale", 0.5);

View File

@ -5,7 +5,7 @@ using Artemis.Storage.Repositories.Interfaces;
namespace Artemis.Core.Services namespace Artemis.Core.Services
{ {
/// <inheritdoc /> /// <inheritdoc />
public class SettingsService : ISettingsService internal class SettingsService : ISettingsService
{ {
private readonly PluginSettings _pluginSettings; private readonly PluginSettings _pluginSettings;
@ -26,6 +26,13 @@ namespace Artemis.Core.Services
/// </summary> /// </summary>
public interface ISettingsService : IProtectedArtemisService public interface ISettingsService : IProtectedArtemisService
{ {
/// <summary>
/// Gets the setting with the provided name. If the setting does not exist yet, it is created.
/// </summary>
/// <typeparam name="T">The type of the setting, can be any serializable type</typeparam>
/// <param name="name">The name of the setting</param>
/// <param name="defaultValue">The default value to use if the setting does not exist yet</param>
/// <returns></returns>
PluginSetting<T> GetSetting<T>(string name, T defaultValue = default); PluginSetting<T> GetSetting<T>(string name, T defaultValue = default);
} }
} }

View File

@ -17,7 +17,7 @@ using Serilog;
namespace Artemis.Core.Services.Storage namespace Artemis.Core.Services.Storage
{ {
public class ProfileService : IProfileService internal class ProfileService : IProfileService
{ {
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly IPluginService _pluginService; private readonly IPluginService _pluginService;
@ -59,7 +59,8 @@ namespace Artemis.Core.Services.Storage
public void ActivateLastProfile(ProfileModule profileModule) public void ActivateLastProfile(ProfileModule profileModule)
{ {
var activeProfile = GetLastActiveProfile(profileModule); var activeProfile = GetLastActiveProfile(profileModule);
ActivateProfile(activeProfile); if (activeProfile != null)
ActivateProfile(activeProfile);
} }
public Profile ActivateProfile(ProfileDescriptor profileDescriptor) public Profile ActivateProfile(ProfileDescriptor profileDescriptor)

View File

@ -6,6 +6,7 @@ using Artemis.Core.Extensions;
using Artemis.Core.Models.Profile; using Artemis.Core.Models.Profile;
using Artemis.Core.Plugins.Abstract; using Artemis.Core.Plugins.Abstract;
using Artemis.Core.Plugins.Abstract.ViewModels; using Artemis.Core.Plugins.Abstract.ViewModels;
using Artemis.Core.Plugins.Modules;
using Artemis.Core.Services.Storage.Interfaces; using Artemis.Core.Services.Storage.Interfaces;
using Artemis.Storage.Entities.Profile; using Artemis.Storage.Entities.Profile;
using Newtonsoft.Json; using Newtonsoft.Json;
@ -91,7 +92,7 @@ namespace Artemis.Core.Utilities
throw new NotImplementedException(); throw new NotImplementedException();
} }
public override IEnumerable<ModuleViewModel> GetViewModels() public override IEnumerable<ModuleTab> GetModuleTabs()
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }

View File

@ -29,6 +29,12 @@
<NrtShowRevision>true</NrtShowRevision> <NrtShowRevision>true</NrtShowRevision>
<Version>2.0.0</Version> <Version>2.0.0</Version>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DocumentationFile>bin\AnyCPU\Debug\Artemis.UI.Shared.xml</DocumentationFile>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DocumentationFile>bin\AnyCPU\Release\Artemis.UI.Shared.xml</DocumentationFile>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="AvalonEdit" Version="6.0.1" /> <PackageReference Include="AvalonEdit" Version="6.0.1" />
<PackageReference Include="Humanizer.Core" Version="2.8.26" /> <PackageReference Include="Humanizer.Core" Version="2.8.26" />
@ -39,7 +45,7 @@
<PackageReference Include="Ninject.Extensions.Conventions" Version="3.3.0" /> <PackageReference Include="Ninject.Extensions.Conventions" Version="3.3.0" />
<PackageReference Include="SkiaSharp" Version="1.68.3" /> <PackageReference Include="SkiaSharp" Version="1.68.3" />
<PackageReference Include="SkiaSharp.Views.WPF" Version="1.68.3" /> <PackageReference Include="SkiaSharp.Views.WPF" Version="1.68.3" />
<PackageReference Include="Stylet" Version="1.3.2" /> <PackageReference Include="Stylet" Version="1.3.4" />
<PackageReference Include="System.Buffers" Version="4.5.0" /> <PackageReference Include="System.Buffers" Version="4.5.0" />
<PackageReference Include="System.Numerics.Vectors" Version="4.5.0" /> <PackageReference Include="System.Numerics.Vectors" Version="4.5.0" />
<PackageReference Include="Unclassified.NetRevisionTask" Version="0.3.0"> <PackageReference Include="Unclassified.NetRevisionTask" Version="0.3.0">

View File

@ -19,6 +19,7 @@ namespace Artemis.UI.Shared.Ninject
Kernel.Bind(x => Kernel.Bind(x =>
{ {
x.FromAssemblyContaining<IVmFactory>() x.FromAssemblyContaining<IVmFactory>()
.IncludingNonPublicTypes()
.SelectAllInterfaces() .SelectAllInterfaces()
.InheritedFrom<IVmFactory>() .InheritedFrom<IVmFactory>()
.BindToFactory(); .BindToFactory();
@ -28,6 +29,7 @@ namespace Artemis.UI.Shared.Ninject
Kernel.Bind(x => Kernel.Bind(x =>
{ {
x.FromAssemblyContaining<IArtemisSharedUIService>() x.FromAssemblyContaining<IArtemisSharedUIService>()
.IncludingNonPublicTypes()
.SelectAllClasses() .SelectAllClasses()
.InheritedFrom<IArtemisSharedUIService>() .InheritedFrom<IArtemisSharedUIService>()
.BindAllInterfaces() .BindAllInterfaces()

View File

@ -18,7 +18,7 @@ using Stylet;
namespace Artemis.UI.Shared.Services namespace Artemis.UI.Shared.Services
{ {
public class DataModelVisualizationService : IDataModelVisualizationService internal class DataModelVisualizationService : IDataModelVisualizationService
{ {
private readonly IDataModelService _dataModelService; private readonly IDataModelService _dataModelService;
private readonly IKernel _kernel; private readonly IKernel _kernel;

View File

@ -12,7 +12,7 @@ using Stylet;
namespace Artemis.UI.Shared.Services.Dialog namespace Artemis.UI.Shared.Services.Dialog
{ {
public class DialogService : IDialogService internal class DialogService : IDialogService
{ {
private readonly IKernel _kernel; private readonly IKernel _kernel;
private readonly IViewManager _viewManager; private readonly IViewManager _viewManager;

View File

@ -6,7 +6,7 @@ using Artemis.UI.Shared.Services.Interfaces;
namespace Artemis.UI.Shared.Services namespace Artemis.UI.Shared.Services
{ {
public class GradientPickerService : IGradientPickerService internal class GradientPickerService : IGradientPickerService
{ {
private readonly IDialogService _dialogService; private readonly IDialogService _dialogService;

View File

@ -15,7 +15,7 @@ using Serilog;
namespace Artemis.UI.Shared.Services namespace Artemis.UI.Shared.Services
{ {
public class ProfileEditorService : IProfileEditorService internal class ProfileEditorService : IProfileEditorService
{ {
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly IProfileService _profileService; private readonly IProfileService _profileService;

View File

@ -136,7 +136,7 @@
<PackageReference Include="Ninject.Extensions.Conventions" Version="3.3.0" /> <PackageReference Include="Ninject.Extensions.Conventions" Version="3.3.0" />
<PackageReference Include="Serilog" Version="2.9.0" /> <PackageReference Include="Serilog" Version="2.9.0" />
<PackageReference Include="SkiaSharp.Views.WPF" Version="1.68.3" /> <PackageReference Include="SkiaSharp.Views.WPF" Version="1.68.3" />
<PackageReference Include="Stylet" Version="1.3.2" /> <PackageReference Include="Stylet" Version="1.3.4" />
<PackageReference Include="System.Buffers" Version="4.5.0" /> <PackageReference Include="System.Buffers" Version="4.5.0" />
<PackageReference Include="System.ComponentModel.Annotations" Version="4.7.0" /> <PackageReference Include="System.ComponentModel.Annotations" Version="4.7.0" />
<PackageReference Include="System.Drawing.Common" Version="4.7.0" /> <PackageReference Include="System.Drawing.Common" Version="4.7.0" />

View File

@ -1,7 +1,10 @@
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Artemis.Core.Plugins.Abstract; using Artemis.Core.Plugins.Abstract;
using Artemis.Core.Plugins.Abstract.ViewModels;
using Artemis.UI.Ninject.Factories; using Artemis.UI.Ninject.Factories;
using Ninject;
using Ninject.Parameters;
using Stylet; using Stylet;
namespace Artemis.UI.Screens.Module namespace Artemis.UI.Screens.Module
@ -9,13 +12,15 @@ namespace Artemis.UI.Screens.Module
public class ModuleRootViewModel : Conductor<Screen>.Collection.OneActive public class ModuleRootViewModel : Conductor<Screen>.Collection.OneActive
{ {
private readonly IProfileEditorVmFactory _profileEditorVmFactory; private readonly IProfileEditorVmFactory _profileEditorVmFactory;
private readonly IKernel _kernel;
public ModuleRootViewModel(Core.Plugins.Abstract.Module module, IProfileEditorVmFactory profileEditorVmFactory) public ModuleRootViewModel(Core.Plugins.Abstract.Module module, IProfileEditorVmFactory profileEditorVmFactory, IKernel kernel)
{ {
DisplayName = module?.DisplayName; DisplayName = module?.DisplayName;
Module = module; Module = module;
_profileEditorVmFactory = profileEditorVmFactory; _profileEditorVmFactory = profileEditorVmFactory;
_kernel = kernel;
Task.Run(AddTabsAsync); Task.Run(AddTabsAsync);
} }
@ -34,8 +39,18 @@ namespace Artemis.UI.Screens.Module
Items.Add(profileEditor); Items.Add(profileEditor);
} }
var moduleViewModels = Module.GetViewModels(); var moduleTabs = Module.GetModuleTabs();
Items.AddRange(moduleViewModels); if (moduleTabs != null)
{
foreach (var moduleTab in moduleTabs.Where(m => m != null))
{
var module = new ConstructorArgument("module", Module);
var displayName = new ConstructorArgument("displayName", DisplayName);
var viewModel = (ModuleViewModel) _kernel.Get(moduleTab.Type, module, displayName);
Items.Add(viewModel);
}
}
ActiveItem = Items.FirstOrDefault(); ActiveItem = Items.FirstOrDefault();
} }

View File

@ -233,6 +233,7 @@ namespace Artemis.UI.Screens.ProfileEditor
LoadWorkspaceSettings(); LoadWorkspaceSettings();
Module.IsProfileUpdatingDisabled = true; Module.IsProfileUpdatingDisabled = true;
Module.ActiveProfileChanged += ModuleOnActiveProfileChanged; Module.ActiveProfileChanged += ModuleOnActiveProfileChanged;
Execute.PostToUIThread(LoadProfiles); Execute.PostToUIThread(LoadProfiles);
base.OnInitialActivate(); base.OnInitialActivate();
} }

View File

@ -24,7 +24,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="SkiaSharp" Version="1.68.3" /> <PackageReference Include="SkiaSharp" Version="1.68.3" />
<PackageReference Include="Stylet" Version="1.3.2" /> <PackageReference Include="Stylet" Version="1.3.4" />
<PackageReference Include="System.Buffers" Version="4.5.0" /> <PackageReference Include="System.Buffers" Version="4.5.0" />
<PackageReference Include="System.Numerics.Vectors" Version="4.5.0" /> <PackageReference Include="System.Numerics.Vectors" Version="4.5.0" />
</ItemGroup> </ItemGroup>

View File

@ -24,7 +24,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="SkiaSharp" Version="1.68.3" /> <PackageReference Include="SkiaSharp" Version="1.68.3" />
<PackageReference Include="Stylet" Version="1.3.2" /> <PackageReference Include="Stylet" Version="1.3.4" />
<PackageReference Include="System.Buffers" Version="4.5.0" /> <PackageReference Include="System.Buffers" Version="4.5.0" />
<PackageReference Include="System.Numerics.Vectors" Version="4.5.0" /> <PackageReference Include="System.Numerics.Vectors" Version="4.5.0" />
</ItemGroup> </ItemGroup>

View File

@ -24,7 +24,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="SkiaSharp" Version="1.68.3" /> <PackageReference Include="SkiaSharp" Version="1.68.3" />
<PackageReference Include="Stylet" Version="1.3.2" /> <PackageReference Include="Stylet" Version="1.3.4" />
<PackageReference Include="System.Buffers" Version="4.5.0" /> <PackageReference Include="System.Buffers" Version="4.5.0" />
<PackageReference Include="System.Numerics.Vectors" Version="4.5.0" /> <PackageReference Include="System.Numerics.Vectors" Version="4.5.0" />
</ItemGroup> </ItemGroup>

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using Artemis.Core.Plugins.Abstract; using Artemis.Core.Plugins.Abstract;
using Artemis.Core.Plugins.Abstract.ViewModels; using Artemis.Core.Plugins.Abstract.ViewModels;
using Artemis.Core.Plugins.Modules;
using Artemis.Plugins.Modules.General.DataModel; using Artemis.Plugins.Modules.General.DataModel;
using Artemis.Plugins.Modules.General.DataModel.Windows; using Artemis.Plugins.Modules.General.DataModel.Windows;
using Artemis.Plugins.Modules.General.Utilities; using Artemis.Plugins.Modules.General.Utilities;
@ -18,10 +19,10 @@ namespace Artemis.Plugins.Modules.General
DisplayIcon = "AllInclusive"; DisplayIcon = "AllInclusive";
ExpandsDataModel = true; ExpandsDataModel = true;
DataModel.TestTimeList.Add(new TimeDataModel { CurrentTime = DateTime.Now.AddDays(1), CurrentTimeUTC = DateTime.UtcNow.AddDays(1) }); DataModel.TestTimeList.Add(new TimeDataModel {CurrentTime = DateTime.Now.AddDays(1), CurrentTimeUTC = DateTime.UtcNow.AddDays(1)});
DataModel.TestTimeList.Add(new TimeDataModel { CurrentTime = DateTime.Now.AddDays(2), CurrentTimeUTC = DateTime.UtcNow.AddDays(2) }); DataModel.TestTimeList.Add(new TimeDataModel {CurrentTime = DateTime.Now.AddDays(2), CurrentTimeUTC = DateTime.UtcNow.AddDays(2)});
DataModel.TestTimeList.Add(new TimeDataModel { CurrentTime = DateTime.Now.AddDays(3), CurrentTimeUTC = DateTime.UtcNow.AddDays(3) }); DataModel.TestTimeList.Add(new TimeDataModel {CurrentTime = DateTime.Now.AddDays(3), CurrentTimeUTC = DateTime.UtcNow.AddDays(3)});
DataModel.TestTimeList.Add(new TimeDataModel { CurrentTime = DateTime.Now.AddDays(4), CurrentTimeUTC = DateTime.UtcNow.AddDays(4) }); DataModel.TestTimeList.Add(new TimeDataModel {CurrentTime = DateTime.Now.AddDays(4), CurrentTimeUTC = DateTime.UtcNow.AddDays(4)});
} }
public override void DisablePlugin() public override void DisablePlugin()
@ -45,9 +46,9 @@ namespace Artemis.Plugins.Modules.General
base.Update(deltaTime); base.Update(deltaTime);
} }
public override IEnumerable<ModuleViewModel> GetViewModels() public override IEnumerable<ModuleTab> GetModuleTabs()
{ {
return new List<ModuleViewModel> { new GeneralViewModel(this) }; return new List<ModuleTab> {new ModuleTab<GeneralViewModel>("General")};
} }
#region Open windows #region Open windows