Added module (the first major plugin type) view(model) creation

This commit is contained in:
SpoinkyNL committed 2018-01-08 20:41:21 +01:00
1 parent f7fe57676d
commit 3bea4463dc
26 files changed
+172 -1038

No files matched your search

@@ -1,6 +1,5 @@
using System;
using System.Diagnostics;
using Artemis.Core.Services.Interfaces;
using Artemis.UI.ViewModels.Interfaces;
using Stylet;
@@ -8,15 +7,6 @@ namespace Artemis.UI.ViewModels
{
public class HomeViewModel : Screen, IHomeViewModel
{
private readonly IPluginService _pluginService;
public HomeViewModel(IPluginService pluginService)
{
_pluginService = pluginService;
_pluginService.FinishedLoadedPlugins += PluginServiceOnFinishedLoadedPlugins;
}
public string Title => "Home";
public void OpenUrl(string url)
@@ -25,15 +15,5 @@ namespace Artemis.UI.ViewModels
if (Uri.IsWellFormedUriString(url, UriKind.RelativeOrAbsolute))
Process.Start(url);
}
/// <summary>
/// Populates the sidebar with plugins when they are finished loading
/// </summary>
/// <param name="sender"></param>
/// <param name="eventArgs"></param>
private void PluginServiceOnFinishedLoadedPlugins(object sender, EventArgs eventArgs)
{
throw new NotImplementedException();
}
}
}
@@ -1,6 +1,8 @@
namespace Artemis.UI.ViewModels.Interfaces
using Stylet;
namespace Artemis.UI.ViewModels.Interfaces
{
public interface IArtemisViewModel
public interface IArtemisViewModel : IScreen
{
string Title { get; }
}
+44 -3
View File
@@ -1,24 +1,57 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Linq;
using Artemis.Core.Services.Interfaces;
using Artemis.Plugins.Interfaces;
using Artemis.Plugins.Models;
using Artemis.UI.Services.Interfaces;
using Artemis.UI.ViewModels.Interfaces;
using Stylet;
namespace Artemis.UI.ViewModels
{
public class RootViewModel : Conductor<IArtemisViewModel>.Collection.OneActive
public class RootViewModel : Conductor<IScreen>.Collection.OneActive
{
private readonly ICollection<IArtemisViewModel> _artemisViewModels;
private readonly IPluginService _pluginService;
public RootViewModel(ICollection<IArtemisViewModel> artemisViewModels)
public RootViewModel(ICollection<IArtemisViewModel> artemisViewModels, IPluginService pluginService)
{
_artemisViewModels = artemisViewModels;
_pluginService = pluginService;
// Add the built-in items
Items.AddRange(artemisViewModels);
// Activate the home item
ActiveItem = _artemisViewModels.First(v => v.GetType() == typeof(HomeViewModel));
// Sync up with the plugin service
Modules = new BindableCollection<PluginInfo>();
LoadingPlugins = _pluginService.LoadingPlugins;
_pluginService.StartedLoadingPlugins += PluginServiceOnStartedLoadingPlugins;
_pluginService.FinishedLoadedPlugins += PluginServiceOnFinishedLoadedPlugins;
if (!LoadingPlugins)
Modules.AddRange(_pluginService.Plugins.Where(p => p.Plugin is IModule));
}
public IObservableCollection<PluginInfo> Modules { get; set; }
public bool MenuOpen { get; set; }
public bool LoadingPlugins { get; set; }
private void PluginServiceOnStartedLoadingPlugins(object sender, EventArgs eventArgs)
{
LoadingPlugins = true;
Modules.Clear();
}
private void PluginServiceOnFinishedLoadedPlugins(object sender, EventArgs eventArgs)
{
LoadingPlugins = false;
Modules.AddRange(_pluginService.Plugins.Where(p => p.Plugin is IModule));
NavigateToModule(Modules.First());
}
public void NavigateToHome()
{
@@ -39,5 +72,13 @@ namespace Artemis.UI.ViewModels
ActivateItem(_artemisViewModels.First(v => v.GetType() == typeof(SettingsViewModel)));
MenuOpen = false;
}
public async void NavigateToModule(PluginInfo pluginInfo)
{
// Create a view model for the given plugin info (which will be a module)
var viewModel = await _pluginService.GetPluginViewModel(pluginInfo);
// Tell Stylet to active the view model, the view manager will compile and show the XAML
ActivateItem(viewModel);
}
}
}