Skip to content

Commit

Permalink
project handling changes
Browse files Browse the repository at this point in the history
  • Loading branch information
martin31821 committed May 28, 2015
1 parent 8aaba33 commit bfbe594
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 145 deletions.
1 change: 0 additions & 1 deletion MidiPlugin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@
</Compile>
<Compile Include="MidiPlugin\Utilities\ExecutorWindowHelper.cs" />
<Compile Include="MidiPlugin\Utilities\Extensions.cs" />
<Compile Include="MidiPlugin\Utilities\InputLayerManagementHelper.cs" />
<Compile Include="MidiPlugin\Utilities\LinkChangedHandler.cs" />
<Compile Include="MidiPlugin\ValueChangedEventArgs.cs" />
<Compile Include="MidiPlugin\ValueTypeTypeConverter.cs" />
Expand Down
29 changes: 13 additions & 16 deletions MidiPlugin/MidiPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ namespace MidiPlugin
{
public class MidiPlugin : GuiPluginBase, IMessageListener
{
public org.dmxc.lumos.Kernel.Input.IInputLayerManager interfacedILM;
public Type interfacedILMType;
internal static readonly ILumosLog log = LumosLogger.getInstance(typeof(MidiPlugin));
private static readonly LumosResourceMetadata myMetaData = new LumosResourceMetadata("MidiSettings.xml", ELumosResourceType.MANAGED_TREE);
private static readonly LumosResourceMetadata metadata2 = new LumosResourceMetadata("MidiPlugin.Config.xml", ELumosResourceType.MANAGED_TREE);
Expand All @@ -29,6 +27,7 @@ public class MidiPlugin : GuiPluginBase, IMessageListener
private AssemblyHelper asmh;
private Utilities.ExecutorWindowHelper ewHelper;
private Utilities.LinkChangedHandler lch;
private bool projectLoaded = false;
public MidiPlugin() : base("{2E9C6D8E-431E-4d24-965C-AC4080C25CBA}", "Midi Plugin")
{
}
Expand All @@ -53,6 +52,8 @@ protected override void startupPlugin()
{
try
{
if (ConnectionManager.getInstance().Connected)
Load();
log.Debug("Startup MidiPlugin!");
ConnectionManager.getInstance().registerMessageListener(this, "KernelInputLayerManager", "LinkChanged");
ConnectionManager.getInstance().registerMessageListener(this, "ExecutorManager", "OnExecutorChanged");
Expand All @@ -71,10 +72,6 @@ protected override void startupPlugin()
{
log.Info("No configuration found.");
}
//var pemgr = PEManager.getInstance();
//var settingsBranch = pemgr.GetBranchByID(SettingsManager.getInstance().GetSettignsBranchID()) as SettingsBranch;
//ConfigurableSettingsNode midiPluginNode = new ConfigurableSettingsNode("Settings:MidiPlugin", "MidiPlugin", "preferences");
//settingsBranch.AddRecursive(settingsBranch.ID, midiPluginNode);
SettingsManager.getInstance().SettingChanged += ewHelper.HandleSettingChanged;
}
catch (Exception ex)
Expand Down Expand Up @@ -113,6 +110,7 @@ protected override void shutdownPlugin()
{
try
{
if (projectLoaded) Close();
log.Debug("Shutdown MidiPlugin!");
this.devices.Stop();
ConnectionManager.getInstance().deregisterMessageListener(this, "KernelInputLayerManager", "LinkChanged");
Expand Down Expand Up @@ -147,45 +145,42 @@ public override void loadProject(LumosGUIIOContext context)
log.Debug("LoadProject in MidiPlugin");
base.loadProject(context);
this.Load();
lch.Update(ewHelper);
//lch.Update(ewHelper);
}
public override void closeProject(LumosGUIIOContext context)
{
if (!ConnectionManager.getInstance().Connected) return;
log.Debug("CloseProject in MidiPlugin");
base.closeProject(context);
this.Close();
}
public override void connectionClosing()
{
this.Save();
this.Close();
log.Debug("Connection closing in MidiPlugin...");

ewHelper.Cleanup();
lch.Update(ewHelper);
base.connectionClosing();
}
public override void connectionEstablished()
{
this.Load();

log.Debug("Connection established in MidiPlugin...");

ewHelper.Establish();
lch.Update(ewHelper);
base.connectionEstablished();
}
private void Close()
{
lch.Clear();
List<RuleSet> rules = new List<RuleSet>(this.midi.RuleSets);
foreach (RuleSet item in rules)
{
this.midi.RuleSets.Remove(item);
}

projectLoaded = false;
}
private void Load()

{
this.Close();
if (ResourceManager.getInstance().existsResource(EResourceType.PROJECT, MidiPlugin.myMetaData))
{
LumosResource r = ResourceManager.getInstance().loadResource(EResourceAccess.READ_WRITE, EResourceType.PROJECT, MidiPlugin.myMetaData);
Expand All @@ -198,6 +193,7 @@ private void Load()
this.midi.RuleSets.Add(rs);
}
}
projectLoaded = true;
}
}
private void Save()
Expand Down Expand Up @@ -258,7 +254,8 @@ public void onMessage(org.dmxc.lumos.Kernel.Messaging.Message.IMessage message)
//log.Info("OnMessage {0}", message.GetType().Name);
var msg = message as InputLinkChangedMessage;
if (msg != null)
lch.Update(ewHelper);

lch.Update(ewHelper, msg);
}

#endregion
Expand Down
17 changes: 0 additions & 17 deletions MidiPlugin/Utilities/ExecutorWindowHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -494,23 +494,6 @@ internal void RegisterSettings()

}

//internal void DeregisterSettings()
//{
// var settings = SettingsManager.getInstance();
// for (int i = 0; i < dynExecutors.Length; i++)
// {
// SettingsMetadata mt;
//
// settings.registerGuiSetting(new SettingsMetadata(ESettingsRegisterType.APPLICATION, "Executor", null, "Dynamic Executor " + (i + 1) + ": Tolerance", "MidiPlugin", "MPL.EXECFG" + i, "", null)
// {
// MinDouble = 0,
// MaxDouble = 1,
//
// }, dynExecutors[i].Tolerance);
//
// }
// settings.GUISettingChanged -= HandleSettingChanged;
//}
public void HandleSettingChanged(object sender, SettingChangedEventArgs args)
{
MidiPlugin.log.Info("SettingChanged: {0}, NewValue: {1}, Type:{2}", args.PropertyName, args.NewValue, args.Type);
Expand Down
37 changes: 0 additions & 37 deletions MidiPlugin/Utilities/InputLayerManagementHelper.cs

This file was deleted.

Loading

0 comments on commit bfbe594

Please sign in to comment.