Skip to content

Commit

Permalink
update to 3.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
martin31821 committed Jul 16, 2016
1 parent bfbe594 commit 22752af
Show file tree
Hide file tree
Showing 38 changed files with 231 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
namespace MidiPlugin
{
public class AssemblyHelper : IAssemblyListener
{
public List<Type> DeviceRuleTypes = new List<Type>();
public AssemblyHelper()
{
AssemblyManager.getInstance().registerAssemblyListener(this);
{
AssemblyManager.getInstance().registerAssemblyListener(this);
ContextManager.AssemblyHelper = this;
foreach (var t in GetType().Assembly.GetTypes())
scanNewType(t);
}
public void scanNewType(Type t)
{
ContextManager.log.Debug("Scanning type {0}", t.FullName);
if (t.IsClass && !t.IsAbstract && typeof(DeviceRule).IsAssignableFrom(t))
{
this.DeviceRuleTypes.Add(t);
Expand All @@ -36,14 +40,5 @@ public string GetFriendlyName(Type t)
}
}

public class FriendlyNameAttribute : Attribute
{
public string Name { get; set; }
public FriendlyNameAttribute(string Name)
{
this.Name = Name;
}
}


}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ public override void Init(ManagedTreeItem i)
}
public override void Save(ManagedTreeItem i)
{
MidiPlugin.log.Debug("Saving ButtonRule {0}, {1}, {2}", EnableMessage.Data, DisableMessage.Data, Treshold);
ContextManager.log.Debug("Saving ButtonRule {0}, {1}, {2}", EnableMessage.Data, DisableMessage.Data, Treshold);
base.Save(i);
i.setValue<bool>("State", this.State);
i.setValue<byte>("Treshold", this.Treshold);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
using LumosLIB.Kernel.Log;
using System;
namespace MidiPlugin
{
internal static class ContextManager
internal static class ContextManager
{
private static MidiInformation info;
private static DeviceInformation dev;
Expand Down Expand Up @@ -56,5 +57,21 @@ public static MidiForm MidiForm
get;
set;
}

public static ILumosLog log
{
get;
set;
}

static ContextManager()
{
log = LumosLogger.getInstance(typeof(MidiPluginLog));
}
}

public class MidiPluginLog
{

}
}
File renamed without changes.
File renamed without changes.
10 changes: 7 additions & 3 deletions MidiPlugin/DeviceRule.cs → MidiPlugin.Rules/DeviceRule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,17 @@ protected void OnValueChanged()
public static DeviceRule Load(RuleSet r, ManagedTreeItem item)
{
DeviceRule result;
if (!item.hasValue<Type>("Type"))
if (!item.hasValue<string>("Type") && !item.hasValue<Type>("Type"))
{
result = null;
}
else
{
Type type = item.getValue<Type>("Type");
string type = "";
if (item.hasValue<string>("Type"))
type = item.getValue<string>("Type");
else
type = item.getValue<Type>("Type").FullName; //Backward compat.
DeviceRule o = r.createRule(type);
if (o == null)
{
Expand Down Expand Up @@ -126,7 +130,7 @@ public virtual void Init(ManagedTreeItem i)
public virtual void Save(ManagedTreeItem i)
{
Type type = base.GetType();
i.setValue<Type>("Type", type);
i.setValue<string>("Type", type.FullName);
i.setValue<string>("Name", this.Name);
i.setValue<string>("GUID", this.GUID);
i.setValue<bool>("UseBacktrack", this.UseBacktrack);
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public override void Init(ManagedTreeItem i)
public override void Save(ManagedTreeItem i)
{

MidiPlugin.log.Debug("Saving EncoderRule {0}, {1}, {2}", CWMessage.Data, CCWMessage.Data, Increment);
ContextManager.log.Debug("Saving EncoderRule {0}, {1}, {2}", CWMessage.Data, CCWMessage.Data, Increment);
base.Save(i);
i.setValue<double>("Value", this.Value);
i.setValue<double>("Increment", this.Increment);
Expand Down
16 changes: 16 additions & 0 deletions MidiPlugin.Rules/FriendlyNameAttribute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MidiPlugin
{
public class FriendlyNameAttribute : Attribute
{
public string Name { get; set; }
public FriendlyNameAttribute(string Name)
{
this.Name = Name;
}
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions MidiPlugin/MidiForm.cs → MidiPlugin.Rules/MidiForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ private void HandleKeyDown(object s, KeyEventArgs e)
}
private void HandleRulesDoubleClick(object s, DataGridViewCellEventArgs e)
{
if (e.RowIndex == -1)
return;
RuleSet rs = ContextManager.MidiInformation.RuleSets[e.RowIndex];
rs.OpenEditWindow();
}
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion MidiPlugin/MidiInput.cs → MidiPlugin.Rules/MidiInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ private void HandleMsgReceived(object s, MidiInMessageEventArgs e)
}
catch(Exception ex)
{
MidiPlugin.log.Error("Error processing incoming midi message", ex);
ContextManager.log.Error("Error processing incoming midi message", ex);
}
}
protected void OnMessageReceived(MidiMessage m)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
114 changes: 114 additions & 0 deletions MidiPlugin.Rules/MidiPlugin.Rules.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{8198E18C-2428-4CC1-9453-D14F08FEA217}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>MidiPlugin.Rules</RootNamespace>
<AssemblyName>MidiPlugin.Rules</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="LumosGUI">
<HintPath>..\..\..\..\..\Program Files (x86)\DMXControl3\GUI\LumosGUI.exe</HintPath>
</Reference>
<Reference Include="LumosLIB">
<HintPath>..\..\..\..\..\Program Files (x86)\DMXControl3\GUI\LumosLIB.dll</HintPath>
</Reference>
<Reference Include="NAudio">
<HintPath>..\..\..\..\..\Program Files (x86)\DMXControl3\GUI\NAudio.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="WeifenLuo.WinFormsUI.Docking">
<HintPath>..\..\..\..\..\Program Files (x86)\DMXControl3\GUI\WeifenLuo.WinFormsUI.Docking.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="AssemblyHelper.cs" />
<Compile Include="ButtonInputChannel.cs" />
<Compile Include="ButtonRule.cs" />
<Compile Include="ContextManager.cs" />
<Compile Include="DeviceId.cs" />
<Compile Include="DeviceInformation.cs" />
<Compile Include="DeviceRule.cs" />
<Compile Include="EDeviceType.cs" />
<Compile Include="EncoderRule.cs" />
<Compile Include="FriendlyNameAttribute.cs" />
<Compile Include="IBacktrack.cs" />
<Compile Include="ILearnable.cs" />
<Compile Include="IProcessable.cs" />
<Compile Include="ISave.cs" />
<Compile Include="MidiDev.cs" />
<Compile Include="MidiEventArgs.cs" />
<Compile Include="MidiForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="MidiInformation.cs" />
<Compile Include="MidiInput.cs" />
<Compile Include="MidiInputChannel.cs" />
<Compile Include="MidiInputLayer.cs" />
<Compile Include="MidiMessage.cs" />
<Compile Include="MidiOutput.cs" />
<Compile Include="MidiRangeInputChannel.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RuleSet.cs" />
<Compile Include="RuleSetEditForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="SliderRule.cs" />
<Compile Include="ToolStripDeviceRuleButton.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="ValueChangedEventArgs.cs" />
<Compile Include="ValueTypeTypeConverter.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="MidiForm.resx">
<DependentUpon>MidiForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="RuleSetEditForm.resx">
<DependentUpon>RuleSetEditForm.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>copy /Y "$(TargetDir)$(TargetFileName)" "C:\Program Files (x86)\DMXControl3\GUI"</PostBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
File renamed without changes.
36 changes: 36 additions & 0 deletions MidiPlugin.Rules/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// Allgemeine Informationen über eine Assembly werden über die folgenden
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
// die mit einer Assembly verknüpft sind.
[assembly: AssemblyTitle("MidiPlugin.Rules")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MidiPlugin.Rules")]
[assembly: AssemblyCopyright("Copyright © 2016")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar
// für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von
// COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest.
[assembly: ComVisible(false)]

// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
[assembly: Guid("945e553f-986c-498e-acac-e2e9ee69ff10")]

// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
//
// Hauptversion
// Nebenversion
// Buildnummer
// Revision
//
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
// übernehmen, indem Sie "*" eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
12 changes: 8 additions & 4 deletions MidiPlugin/RuleSet.cs → MidiPlugin.Rules/RuleSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ private void genInputLayer()
}
public void Save(ManagedTreeItem mti)
{
MidiPlugin.log.Debug("Saving RuleSet {0}", Name);
ContextManager.log.Debug("Saving RuleSet {0}", Name);
mti.setValue<string>("Name", this.Name);
mti.setValue<string>("InputDeviceID", this.InputDeviceID);
mti.setValue<string>("OutputDeviceID", this.OutputDeviceID);
Expand All @@ -179,7 +179,7 @@ protected void OnSendMessage(object s, MidiEventArgs m)
}
catch(Exception)
{
MidiPlugin.log.Warn("Error sending Midi Message to device {0}, message: {1}.{2}, {3},{4}", OutputDevice.DeviceID, m.m.channel, m.m.message, m.m.data1, m.m.data2);
ContextManager.log.Warn("Error sending Midi Message to device {0}, message: {1}.{2}, {3},{4}", OutputDevice.DeviceID, m.m.channel, m.m.message, m.m.data1, m.m.data2);
}
this.OutputUsed = false;
}
Expand Down Expand Up @@ -209,9 +209,13 @@ private void HandleMessageReceived(object s, MidiEventArgs e)
item.Process(e.m);
}
}
public DeviceRule createRule(Type t)
public DeviceRule createRule(string t)
{
return Activator.CreateInstance(t) as DeviceRule;
var type = ContextManager.AssemblyHelper.DeviceRuleTypes.FirstOrDefault(j => j.FullName == t);
if (type == null) return null;
var obj = Activator.CreateInstance(type) as DeviceRule;

return obj;
}
public void AddRule(DeviceRule r)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ private void DeleteSelected()
}
private void AddRule(Type t)
{
DeviceRule r = this.rules.createRule(t);
DeviceRule r = this.rules.createRule(t.FullName);
if (r != null)
{
this.rules.AddRule(r);
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public override void Init(org.dmxc.lumos.Kernel.Resource.ManagedTreeItem i)

public override void Save(org.dmxc.lumos.Kernel.Resource.ManagedTreeItem i)
{
MidiPlugin.log.Debug("Saving SliderRule {0}, {1}, {2}", SliderMessage.Data, MaximumBacktrack.Data, MinimumBacktrack.Data);
ContextManager.log.Debug("Saving SliderRule {0}, {1}, {2}", SliderMessage.Data, MaximumBacktrack.Data, MinimumBacktrack.Data);
base.Save(i);
i.setValue<double>("Value", this.Value);
i.setValue<int>("Message", this.SliderMessage.Data);
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 22752af

Please sign in to comment.