JD2022-TU1/main/tools/modules/JD.SceneExplorer/SceneExplorerModule.cs

55 lines
No EOL
1.8 KiB
C#

using System;
using System.Windows.Input;
using System.Windows.Threading;
using JD.Remoting.Services;
using JD.SceneExplorer.Views;
using JetBrains.Annotations;
using Plume.Icons;
using Plume.Interfaces.Modules;
using Plume.Interfaces.WPF.Modules;
using Plume.Interfaces.WPF.Window;
using Plume.WPF.Commands;
namespace JD.SceneExplorer
{
public sealed class SceneExplorerModule : IWpfModule
{
private SceneExplorerModuleSetup _setup;
/// <inheritdoc />
public void Dispose()
{
//Nothing to dispose
}
/// <inheritdoc />
public void Setup([NotNull] IModuleSetup setup)
{
if (setup == null) throw new ArgumentNullException(nameof(setup));
if (!(setup is SceneExplorerModuleSetup))
{
throw new Exception($"The setup must be of type {nameof(SceneExplorerModuleSetup)}");
}
_setup = (SceneExplorerModuleSetup)setup;
}
/// <inheritdoc />
public void Initialize(IWpfModuleContext context)
{
SceneExplorerPlugin plugin = new SceneExplorerPlugin(context.LoggerManager.GetOrCreateLogger($"{nameof(SceneExplorerPlugin)}"), _setup.Dispatcher);
context.ServiceManager.GetPluginService().Register(plugin);
context.WindowManager.AddToolWindow("SceneExplorerTreeToolWindow", "Scene tree", StandardIcon.TreeView,
new SceneExplorerTreeToolWindow(plugin), DockingSide.Left, new DoubleKeyGesture(ModifierKeys.Control, Key.S,Key.E));
}
}
public class SceneExplorerModuleSetup : IModuleSetup
{
public SceneExplorerModuleSetup(Dispatcher dispatcher)
{
Dispatcher = dispatcher;
}
public Dispatcher Dispatcher { get; }
}
}