/
CustomPropEditorModule.cs
73 lines (64 loc) · 1.9 KB
/
CustomPropEditorModule.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
using System.Windows.Forms.Integration;
using Vixen.Module.App;
using Vixen.Sys;
using VixenModules.App.CustomPropEditor.Model;
using VixenModules.App.CustomPropEditor.Views;
using ConfigurationService = VixenModules.App.CustomPropEditor.Services.ConfigurationService;
namespace VixenModules.App.CustomPropEditor
{
public class CustomPropEditorModule : AppModuleInstanceBase
{
private IApplication _application;
private const string MenuIdRoot = "CustomPropRoot";
public override void Loading()
{
AddApplicationMenu();
Configuration config = new Configuration((CustomPropEditorData)StaticModuleData);
ConfigurationService service = ConfigurationService.Instance();
service.Config = config;
}
public override void Unloading()
{
if (AppSupportsCommands)
{
AppCommand toolsMenu = GetToolsMenu();
toolsMenu.Remove(MenuIdRoot);
}
}
public override IApplication Application
{
set { _application = value; }
}
private bool AppSupportsCommands
{
get { return _application != null && _application.AppCommands != null; }
}
private void AddApplicationMenu()
{
if (AppSupportsCommands)
{
var toolsMenu = GetToolsMenu();
var rootCommand = new AppCommand(MenuIdRoot, "Custom Prop Editor");
rootCommand.Click += RootCommand_Click;
toolsMenu.Add(rootCommand);
}
}
private void RootCommand_Click(object sender, System.EventArgs e)
{
CustomPropEditorWindow mw = new CustomPropEditorWindow();
//PropEditorWindow mw = new PropEditorWindow();
ElementHost.EnableModelessKeyboardInterop(mw);
mw.Show();
}
private AppCommand GetToolsMenu()
{
AppCommand toolsMenu = _application.AppCommands.Find("Tools");
if (toolsMenu == null)
{
toolsMenu = new AppCommand("Tools", "Tools");
_application.AppCommands.Add(toolsMenu);
}
return toolsMenu;
}
}
}