Added some of the architecture for the profile editor

This commit is contained in:
SpoinkyNL committed 2019-11-11 22:12:36 +01:00
1 parent db46df5ce6
commit c3df4dfc44
26 files changed
+181 -76

No files matched your search

@@ -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 Artemis.Core.Events;
using Artemis.Core.Services.Interfaces;
using Artemis.UI.ViewModels.Interfaces;
using Stylet;
namespace Artemis.UI.ViewModels.Screens
{
public class DebugViewModel : Screen
public class DebugViewModel : Screen, IScreenViewModel
{
private readonly ICoreService _coreService;
private readonly IRgbService _rgbService;
@@ -76,5 +77,7 @@ namespace Artemis.UI.ViewModels.Screens
[DllImport("gdi32.dll", EntryPoint = "DeleteObject")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool DeleteObject([In] IntPtr hObject);
public string Title => "Debugger";
}
}
@@ -5,7 +5,7 @@ using Stylet;
namespace Artemis.UI.ViewModels.Screens
{
public class HomeViewModel : Screen, IHomeViewModel
public class HomeViewModel : Screen, IScreenViewModel
{
public string Title => "Home";
@@ -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.ComponentModel;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Controls;
using Artemis.Core.Events;
using Artemis.Core.Plugins.Abstract;
using Artemis.Core.Services.Interfaces;
using Artemis.UI.Ninject.Factories;
using Artemis.UI.ViewModels.Interfaces;
using Stylet;
@@ -15,11 +17,13 @@ namespace Artemis.UI.ViewModels.Screens
{
private readonly ICollection<IScreenViewModel> _artemisViewModels;
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;
_pluginService = pluginService;
_moduleViewModelFactory = moduleViewModelFactory;
// Add the built-in items
Items.AddRange(artemisViewModels);
@@ -28,7 +32,7 @@ namespace Artemis.UI.ViewModels.Screens
// Sync up with the plugin service
Modules = new BindableCollection<Module>();
// Modules.AddRange(_pluginService.GetPluginsOfType<Module>());
Modules.AddRange(_pluginService.GetPluginsOfType<Module>());
_pluginService.PluginEnabled += PluginServiceOnPluginEnabled;
_pluginService.PluginDisabled += PluginServiceOnPluginDisabled;
@@ -47,8 +51,7 @@ namespace Artemis.UI.ViewModels.Screens
return;
// Create a view model for the given plugin info (which will be a module)
var viewModel = await Task.Run(() => SelectedModule.GetMainViewModel());
// Tell Stylet to active the view model, the view manager will compile and show the XAML
var viewModel = await Task.Run(() => _moduleViewModelFactory.CreateModuleViewModel(SelectedModule));
ActivateItem(viewModel);
SelectedPage = null;
@@ -8,7 +8,7 @@ using Stylet;
namespace Artemis.UI.ViewModels.Screens
{
public class SettingsViewModel : Screen, ISettingsViewModel
public class SettingsViewModel : Screen, IScreenViewModel
{
private readonly ICoreService _coreService;
private readonly IKernel _kernel;
@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Artemis.Core.Services.Interfaces;
using Artemis.Core.Services.Interfaces;
using Ninject;
using Stylet;
@@ -26,6 +21,7 @@ namespace Artemis.UI.ViewModels.Screens
var pluginService = _kernel.Get<IPluginService>();
pluginService.CopyingBuildInPlugins += (sender, args) => Status = "Updating built-in plugins";
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
{
public class SurfaceEditorViewModel : Screen, ISurfaceEditorViewModel
public class SurfaceEditorViewModel : Screen, IScreenViewModel
{
private readonly IDialogService _dialogService;
private readonly ISurfaceService _surfaceService;