From: <an...@us...> - 2008-01-19 08:44:55
|
Revision: 1271 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=1271&view=rev Author: and-81 Date: 2008-01-19 00:44:47 -0800 (Sat, 19 Jan 2008) Log Message: ----------- Modified Paths: -------------- trunk/plugins/IR Server Suite/Commands/Macro/CommandBlastIR.cs trunk/plugins/IR Server Suite/Commands/Macro/CommandCallMacro.cs trunk/plugins/IR Server Suite/Commands/Macro/EditMacro.cs trunk/plugins/IR Server Suite/Commands/Macro/Macro.cs trunk/plugins/IR Server Suite/Commands/Macro/Properties/AssemblyInfo.cs trunk/plugins/IR Server Suite/Commands/TestApp/Program.cs trunk/plugins/IR Server Suite/Commands/TestApp/TestApp.csproj trunk/plugins/IR Server Suite/IR Server Suite.sln trunk/plugins/IR Server Suite/MediaPortal Plugins/MP Blast Zone Plugin/MP Blast Zone Plugin.csproj Added Paths: ----------- trunk/plugins/IR Server Suite/Commands/Macro/CommandProcessor.csproj trunk/plugins/IR Server Suite/Commands/Macro/EditBlastIR.Designer.cs trunk/plugins/IR Server Suite/Commands/Macro/EditBlastIR.cs trunk/plugins/IR Server Suite/Commands/Macro/EditBlastIR.resx trunk/plugins/IR Server Suite/Commands/Macro/Processor.cs Removed Paths: ------------- trunk/plugins/IR Server Suite/Commands/Macro/Macro.csproj trunk/plugins/IR Server Suite/Commands/TestApp/Form1.Designer.cs trunk/plugins/IR Server Suite/Commands/TestApp/Form1.cs Modified: trunk/plugins/IR Server Suite/Commands/Macro/CommandBlastIR.cs =================================================================== --- trunk/plugins/IR Server Suite/Commands/Macro/CommandBlastIR.cs 2008-01-19 08:02:20 UTC (rev 1270) +++ trunk/plugins/IR Server Suite/Commands/Macro/CommandBlastIR.cs 2008-01-19 08:44:47 UTC (rev 1271) @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.IO; using System.Text; using System.Windows.Forms; @@ -35,7 +36,7 @@ /// Gets the category of this command. /// </summary> /// <returns>The category of this command.</returns> - public override string GetCategory() { return Macro.Category; } + public override string GetCategory() { return Processor.CategoryHidden; } /// <summary> /// Gets the user interface text. @@ -49,12 +50,24 @@ /// <returns>The user display text.</returns> public override string GetUserDisplayText() { - return String.Format("{0} ({1})", GetUserInterfaceText(), String.Join(", ", Parameters)); + string fileName = _parameters[0]; + + if (_parameters[0].StartsWith(Common.FolderAppData, StringComparison.OrdinalIgnoreCase)) + fileName = _parameters[0].Substring(Common.FolderAppData.Length); + + return String.Format("{0} ({1}, {2})", GetUserInterfaceText(), fileName, _parameters[1]); } - /* + + /// <summary> + /// Edit this command. + /// </summary> + /// <param name="parent">The parent window.</param> + /// <param name="blastIrDelegate">The blast ir delegate.</param> + /// <param name="blastPorts">The blast ports.</param> + /// <returns><c>true</c> if the command was modified; otherwise <c>false</c>.</returns> public bool Edit(IWin32Window parent, BlastIrDelegate blastIrDelegate, string[] blastPorts) { - EditBlastIR edit = new EditBlastIR(_parameters, blastIrDelegate, blastPorts); + EditBlastIR edit = new EditBlastIR(blastIrDelegate, blastPorts, _parameters); if (edit.ShowDialog(parent) == DialogResult.OK) { _parameters = edit.Parameters; @@ -64,16 +77,21 @@ return false; } + /// <summary> + /// Execute this command. + /// </summary> + /// <param name="blastIrDelegate">The blast ir delegate.</param> public void Execute(BlastIrDelegate blastIrDelegate) { - string irFile = Common.FolderIRCommands + _parameters[0] + Common.FileExtensionIR; + string irFile = _parameters[0] + Common.FileExtensionIR; string port = _parameters[1]; blastIrDelegate(irFile, port); } - */ + #endregion Implementation + } } Modified: trunk/plugins/IR Server Suite/Commands/Macro/CommandCallMacro.cs =================================================================== --- trunk/plugins/IR Server Suite/Commands/Macro/CommandCallMacro.cs 2008-01-19 08:02:20 UTC (rev 1270) +++ trunk/plugins/IR Server Suite/Commands/Macro/CommandCallMacro.cs 2008-01-19 08:44:47 UTC (rev 1271) @@ -3,6 +3,8 @@ using System.Text; using System.Windows.Forms; +using IrssUtils; + namespace Commands { @@ -33,7 +35,7 @@ /// Gets the category of this command. /// </summary> /// <returns>The category of this command.</returns> - public override string GetCategory() { return Macro.HiddenCategory; } + public override string GetCategory() { return Processor.CategoryHidden; } /// <summary> /// Gets the user interface text. @@ -54,10 +56,11 @@ /// Execute this command. /// </summary> /// <param name="variables">The variable list of the calling code.</param> - public override void Execute(VariableList variables) + /// <param name="blastIrDelegate">The blast ir delegate.</param> + public void Execute(VariableList variables, BlastIrDelegate blastIrDelegate) { Macro macro = new Macro(_parameters[0]); - macro.Execute(variables); + macro.Execute(variables, blastIrDelegate); } #endregion Implementation Added: trunk/plugins/IR Server Suite/Commands/Macro/CommandProcessor.csproj =================================================================== --- trunk/plugins/IR Server Suite/Commands/Macro/CommandProcessor.csproj (rev 0) +++ trunk/plugins/IR Server Suite/Commands/Macro/CommandProcessor.csproj 2008-01-19 08:44:47 UTC (rev 1271) @@ -0,0 +1,142 @@ +<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProductVersion>8.0.50727</ProductVersion> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{49CF376E-811C-4EB4-817F-A39C9529B608}</ProjectGuid> + <OutputType>Library</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>Commands</RootNamespace> + <AssemblyName>CommandProcessor</AssemblyName> + <RunPostBuildEvent>OnOutputUpdated</RunPostBuildEvent> + </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> + <UseVSHostingProcess>false</UseVSHostingProcess> + <TreatWarningsAsErrors>true</TreatWarningsAsErrors> + <DocumentationFile>bin\Debug\CommandProcessor.xml</DocumentationFile> + </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="System" /> + <Reference Include="System.Drawing" /> + <Reference Include="System.Windows.Forms" /> + <Reference Include="System.Xml" /> + </ItemGroup> + <ItemGroup> + <Compile Include="Processor.cs" /> + <Compile Include="EditBlastIR.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="EditBlastIR.Designer.cs"> + <DependentUpon>EditBlastIR.cs</DependentUpon> + </Compile> + <Compile Include="CommandClearVariables.cs" /> + <Compile Include="CommandIf.cs" /> + <Compile Include="CommandLabel.cs" /> + <Compile Include="CommandGotoLabel.cs" /> + <Compile Include="CommandSetVariable.cs" /> + <Compile Include="CommandSaveVariables.cs" /> + <Compile Include="CommandLoadVariables.cs" /> + <Compile Include="CommandCallMacro.cs" /> + <Compile Include="CommandBlastIR.cs" /> + <Compile Include="EditIf.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="EditIf.Designer.cs"> + <DependentUpon>EditIf.cs</DependentUpon> + </Compile> + <Compile Include="EditLabel.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="EditLabel.Designer.cs"> + <DependentUpon>EditLabel.cs</DependentUpon> + </Compile> + <Compile Include="Macro.cs" /> + <Compile Include="EditMacro.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="EditMacro.Designer.cs"> + <DependentUpon>EditMacro.cs</DependentUpon> + </Compile> + <Compile Include="MacroStructureException.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + <Compile Include="EditSetVariable.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="EditSetVariable.Designer.cs"> + <DependentUpon>EditSetVariable.cs</DependentUpon> + </Compile> + <Compile Include="EditVariablesFile.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="EditVariablesFile.Designer.cs"> + <DependentUpon>EditVariablesFile.cs</DependentUpon> + </Compile> + </ItemGroup> + <ItemGroup> + <EmbeddedResource Include="EditBlastIR.resx"> + <DependentUpon>EditBlastIR.cs</DependentUpon> + <SubType>Designer</SubType> + </EmbeddedResource> + <EmbeddedResource Include="EditIf.resx"> + <DependentUpon>EditIf.cs</DependentUpon> + <SubType>Designer</SubType> + </EmbeddedResource> + <EmbeddedResource Include="EditMacro.resx"> + <DependentUpon>EditMacro.cs</DependentUpon> + <SubType>Designer</SubType> + </EmbeddedResource> + <EmbeddedResource Include="EditLabel.resx"> + <DependentUpon>EditLabel.cs</DependentUpon> + <SubType>Designer</SubType> + </EmbeddedResource> + <EmbeddedResource Include="EditSetVariable.resx"> + <DependentUpon>EditSetVariable.cs</DependentUpon> + <SubType>Designer</SubType> + </EmbeddedResource> + <EmbeddedResource Include="EditVariablesFile.resx"> + <DependentUpon>EditVariablesFile.cs</DependentUpon> + <SubType>Designer</SubType> + </EmbeddedResource> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\..\Common\IrssUtils\IrssUtils.csproj"> + <Project>{CA15769C-232E-4CA7-94FD-206A06CA3ABB}</Project> + <Name>IrssUtils</Name> + <Private>False</Private> + </ProjectReference> + <ProjectReference Include="..\Command\Command.csproj"> + <Project>{21E04B17-D850-43E7-AAD3-876C0E062BDB}</Project> + <Name>Command</Name> + <Private>False</Private> + </ProjectReference> + <ProjectReference Include="..\VariableList\VariableList.csproj"> + <Project>{106A69D2-670C-4DE5-A81C-A3CD5D3F21EB}</Project> + <Name>VariableList</Name> + <Private>False</Private> + </ProjectReference> + </ItemGroup> + <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> + <!-- 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> \ No newline at end of file Added: trunk/plugins/IR Server Suite/Commands/Macro/EditBlastIR.Designer.cs =================================================================== --- trunk/plugins/IR Server Suite/Commands/Macro/EditBlastIR.Designer.cs (rev 0) +++ trunk/plugins/IR Server Suite/Commands/Macro/EditBlastIR.Designer.cs 2008-01-19 08:44:47 UTC (rev 1271) @@ -0,0 +1,174 @@ +namespace Commands +{ + + partial class EditBlastIR + { + /// <summary> + /// Required designer variable. + /// </summary> + private System.ComponentModel.IContainer components = null; + + /// <summary> + /// Clean up any resources being used. + /// </summary> + /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// <summary> + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// </summary> + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.labelIRFile = new System.Windows.Forms.Label(); + this.labelBlasterPort = new System.Windows.Forms.Label(); + this.comboBoxPort = new System.Windows.Forms.ComboBox(); + this.labelIRCommandFile = new System.Windows.Forms.Label(); + this.buttonTest = new System.Windows.Forms.Button(); + this.buttonOK = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.checkBoxUseForAll = new System.Windows.Forms.CheckBox(); + this.toolTips = new System.Windows.Forms.ToolTip(this.components); + this.SuspendLayout(); + // + // labelIRFile + // + this.labelIRFile.Location = new System.Drawing.Point(8, 8); + this.labelIRFile.Name = "labelIRFile"; + this.labelIRFile.Size = new System.Drawing.Size(88, 20); + this.labelIRFile.TabIndex = 0; + this.labelIRFile.Text = "IR Command:"; + this.labelIRFile.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // labelBlasterPort + // + this.labelBlasterPort.Location = new System.Drawing.Point(8, 40); + this.labelBlasterPort.Name = "labelBlasterPort"; + this.labelBlasterPort.Size = new System.Drawing.Size(88, 21); + this.labelBlasterPort.TabIndex = 2; + this.labelBlasterPort.Text = "Blaster port:"; + this.labelBlasterPort.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // comboBoxPort + // + this.comboBoxPort.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.comboBoxPort.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxPort.FormattingEnabled = true; + this.comboBoxPort.Location = new System.Drawing.Point(96, 40); + this.comboBoxPort.Name = "comboBoxPort"; + this.comboBoxPort.Size = new System.Drawing.Size(160, 21); + this.comboBoxPort.TabIndex = 3; + this.toolTips.SetToolTip(this.comboBoxPort, "Choose the blaster port to transmit this command to"); + // + // labelIRCommandFile + // + this.labelIRCommandFile.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.labelIRCommandFile.AutoEllipsis = true; + this.labelIRCommandFile.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; + this.labelIRCommandFile.Location = new System.Drawing.Point(96, 8); + this.labelIRCommandFile.Name = "labelIRCommandFile"; + this.labelIRCommandFile.Size = new System.Drawing.Size(248, 20); + this.labelIRCommandFile.TabIndex = 1; + this.labelIRCommandFile.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // buttonTest + // + this.buttonTest.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.buttonTest.Location = new System.Drawing.Point(8, 72); + this.buttonTest.Name = "buttonTest"; + this.buttonTest.Size = new System.Drawing.Size(56, 24); + this.buttonTest.TabIndex = 4; + this.buttonTest.Text = "Test"; + this.toolTips.SetToolTip(this.buttonTest, "Test this blast command"); + this.buttonTest.UseVisualStyleBackColor = true; + this.buttonTest.Click += new System.EventHandler(this.buttonTest_Click); + // + // buttonOK + // + this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonOK.Location = new System.Drawing.Point(224, 72); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(56, 24); + this.buttonOK.TabIndex = 6; + this.buttonOK.Text = "OK"; + this.buttonOK.UseVisualStyleBackColor = true; + this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.Location = new System.Drawing.Point(288, 72); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(56, 24); + this.buttonCancel.TabIndex = 7; + this.buttonCancel.Text = "Cancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); + // + // checkBoxUseForAll + // + this.checkBoxUseForAll.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.checkBoxUseForAll.Location = new System.Drawing.Point(72, 72); + this.checkBoxUseForAll.Name = "checkBoxUseForAll"; + this.checkBoxUseForAll.Size = new System.Drawing.Size(144, 24); + this.checkBoxUseForAll.TabIndex = 5; + this.checkBoxUseForAll.Text = "Use this port for all"; + this.toolTips.SetToolTip(this.checkBoxUseForAll, "Use the selected blaster port for all blast commands in this group"); + this.checkBoxUseForAll.UseVisualStyleBackColor = true; + this.checkBoxUseForAll.Visible = false; + // + // BlastCommand + // + this.AcceptButton = this.buttonOK; + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.CancelButton = this.buttonCancel; + this.ClientSize = new System.Drawing.Size(352, 105); + this.Controls.Add(this.checkBoxUseForAll); + this.Controls.Add(this.buttonOK); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonTest); + this.Controls.Add(this.labelIRCommandFile); + this.Controls.Add(this.labelBlasterPort); + this.Controls.Add(this.comboBoxPort); + this.Controls.Add(this.labelIRFile); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.MinimumSize = new System.Drawing.Size(360, 132); + this.Name = "BlastCommand"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Blast Command"; + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Label labelIRFile; + private System.Windows.Forms.Label labelBlasterPort; + private System.Windows.Forms.ComboBox comboBoxPort; + private System.Windows.Forms.Label labelIRCommandFile; + private System.Windows.Forms.Button buttonTest; + private System.Windows.Forms.Button buttonOK; + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.CheckBox checkBoxUseForAll; + private System.Windows.Forms.ToolTip toolTips; + } + +} Added: trunk/plugins/IR Server Suite/Commands/Macro/EditBlastIR.cs =================================================================== --- trunk/plugins/IR Server Suite/Commands/Macro/EditBlastIR.cs (rev 0) +++ trunk/plugins/IR Server Suite/Commands/Macro/EditBlastIR.cs 2008-01-19 08:44:47 UTC (rev 1271) @@ -0,0 +1,162 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Text; +using System.Windows.Forms; + +using IrssUtils; + +namespace Commands +{ + + /// <summary> + /// Edit Blast IR Command form. + /// </summary> + public partial class EditBlastIR : Form + { + + #region Properties + + /// <summary> + /// Gets the command parameters. + /// </summary> + /// <value>The command parameters.</value> + public string[] Parameters + { + get + { + return new string[] { + _fileName, + comboBoxPort.SelectedItem as string }; + } + } + + /// <summary> + /// Gets or sets the blaster port. + /// </summary> + /// <value>The blaster port.</value> + public string BlasterPort + { + get { return comboBoxPort.SelectedItem as string; } + set { comboBoxPort.SelectedItem = value; } + } + + /// <summary> + /// Gets a value indicating whether to use this commands details for all in the batch. + /// </summary> + /// <value><c>true</c> if use for all; otherwise, <c>false</c>.</value> + public bool UseForAll + { + get { return checkBoxUseForAll.Checked; } + } + + #endregion Properties + + #region Variables + + BlastIrDelegate _blastIrDelegate; + string _fileName; + + #endregion Variables + + #region Constructors + + /// <summary> + /// Initializes a new instance of the <see cref="EditBlastIR"/> class. + /// </summary> + /// <param name="blastIrDelegate">The blast IR delegate.</param> + /// <param name="ports">The available ports.</param> + EditBlastIR(BlastIrDelegate blastIrDelegate, string[] ports) + { + if (blastIrDelegate == null) + throw new ArgumentNullException("blastIrDelegate"); + + if (ports == null) + throw new ArgumentNullException("ports"); + + InitializeComponent(); + + _blastIrDelegate = blastIrDelegate; + + comboBoxPort.Items.AddRange(ports); + comboBoxPort.SelectedIndex = 0; + } + + /// <summary> + /// Initializes a new instance of the <see cref="EditBlastIR"/> class. + /// </summary> + /// <param name="blastIrDelegate">The blast IR delegate.</param> + /// <param name="ports">The available ports.</param> + /// <param name="parameters">The command parameters.</param> + public EditBlastIR(BlastIrDelegate blastIrDelegate, string[] ports, string[] parameters) + : this(blastIrDelegate, ports) + { + if (parameters == null) + throw new ArgumentNullException("parameters"); + + _fileName = parameters[0]; + + string displayName = _fileName; + if (_fileName.StartsWith(Common.FolderAppData, StringComparison.OrdinalIgnoreCase)) + displayName = _fileName.Substring(Common.FolderAppData.Length); + + labelIRCommandFile.Text = displayName; + + if (comboBoxPort.Items.Contains(parameters[1])) + comboBoxPort.SelectedItem = parameters[1]; + } + + /// <summary> + /// Initializes a new instance of the <see cref="EditBlastIR"/> class. + /// </summary> + /// <param name="blastIrDelegate">The blast IR delegate.</param> + /// <param name="ports">The available ports.</param> + /// <param name="parameters">The command parameters.</param> + /// <param name="commandCount">The command count for this batch of commands.</param> + public EditBlastIR(BlastIrDelegate blastIrDelegate, string[] ports, string[] parameters, int commandCount) + : this(blastIrDelegate, ports, parameters) + { + if (commandCount > 1) + { + checkBoxUseForAll.Text = String.Format("Use this port for all ({0})", commandCount); + checkBoxUseForAll.Visible = true; + } + } + + #endregion Constructors + + #region Buttons + + private void buttonOK_Click(object sender, EventArgs e) + { + this.DialogResult = DialogResult.OK; + this.Close(); + } + + private void buttonCancel_Click(object sender, EventArgs e) + { + this.DialogResult = DialogResult.Cancel; + this.Close(); + } + + private void buttonTest_Click(object sender, EventArgs e) + { + try + { + string fileName = _fileName + Common.FileExtensionIR; + string port = comboBoxPort.SelectedItem as string; + + _blastIrDelegate(fileName, port); + } + catch (Exception ex) + { + MessageBox.Show(this, ex.Message, "Test failed", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + #endregion Buttons + + } + +} Added: trunk/plugins/IR Server Suite/Commands/Macro/EditBlastIR.resx =================================================================== --- trunk/plugins/IR Server Suite/Commands/Macro/EditBlastIR.resx (rev 0) +++ trunk/plugins/IR Server Suite/Commands/Macro/EditBlastIR.resx 2008-01-19 08:44:47 UTC (rev 1271) @@ -0,0 +1,123 @@ +<?xml version="1.0" encoding="utf-8"?> +<root> + <!-- + Microsoft ResX Schema + + Version 2.0 + + The primary goals of this format is to allow a simple XML format + that is mostly human readable. The generation and parsing of the + various data types are done through the TypeConverter classes + associated with the data types. + + Example: + + ... ado.net/XML headers & schema ... + <resheader name="resmimetype">text/microsoft-resx</resheader> + <resheader name="version">2.0</resheader> + <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> + <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> + <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> + <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> + <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> + <value>[base64 mime encoded serialized .NET Framework object]</value> + </data> + <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> + <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> + <comment>This is a comment</comment> + </data> + + There are any number of "resheader" rows that contain simple + name/value pairs. + + Each data row contains a name, and value. The row also contains a + type or mimetype. Type corresponds to a .NET class that support + text/value conversion through the TypeConverter architecture. + Classes that don't support this are serialized and stored with the + mimetype set. + + The mimetype is used for serialized objects, and tells the + ResXResourceReader how to depersist the object. This is currently not + extensible. For a given mimetype the value must be set accordingly: + + Note - application/x-microsoft.net.object.binary.base64 is the format + that the ResXResourceWriter will generate, however the reader can + read any of the formats listed below. + + mimetype: application/x-microsoft.net.object.binary.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.soap.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Soap.SoapFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.bytearray.base64 + value : The object must be serialized into a byte array + : using a System.ComponentModel.TypeConverter + : and then encoded with base64 encoding. + --> + <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> + <xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> + <xsd:element name="root" msdata:IsDataSet="true"> + <xsd:complexType> + <xsd:choice maxOccurs="unbounded"> + <xsd:element name="metadata"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" /> + </xsd:sequence> + <xsd:attribute name="name" use="required" type="xsd:string" /> + <xsd:attribute name="type" type="xsd:string" /> + <xsd:attribute name="mimetype" type="xsd:string" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="assembly"> + <xsd:complexType> + <xsd:attribute name="alias" type="xsd:string" /> + <xsd:attribute name="name" type="xsd:string" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="data"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> + <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> + <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="resheader"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" /> + </xsd:complexType> + </xsd:element> + </xsd:choice> + </xsd:complexType> + </xsd:element> + </xsd:schema> + <resheader name="resmimetype"> + <value>text/microsoft-resx</value> + </resheader> + <resheader name="version"> + <value>2.0</value> + </resheader> + <resheader name="reader"> + <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <resheader name="writer"> + <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <metadata name="toolTips.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> + <value>17, 17</value> + </metadata> +</root> \ No newline at end of file Modified: trunk/plugins/IR Server Suite/Commands/Macro/EditMacro.cs =================================================================== --- trunk/plugins/IR Server Suite/Commands/Macro/EditMacro.cs 2008-01-19 08:02:20 UTC (rev 1270) +++ trunk/plugins/IR Server Suite/Commands/Macro/EditMacro.cs 2008-01-19 08:44:47 UTC (rev 1271) @@ -11,7 +11,6 @@ using System.Xml; using IrssUtils; -//using IrssUtils.Forms; namespace Commands { @@ -24,10 +23,10 @@ #region Variables + Processor _commandProcessor; + string _macroFolder; - VariableList _variableList; - IrssUtils.BlastIrDelegate _blastIrDelegate; - string[] _blastIrPorts; + string _fileName; Dictionary<string, Type> _commands; @@ -38,34 +37,24 @@ /// <summary> /// Creates a Macro Editor windows form. /// </summary> + /// <param name="commandProcessor">The command processor.</param> /// <param name="macroFolder">The macro folder.</param> - /// <param name="variables">The variable list.</param> - /// <param name="blastIrDelegate">The blast ir delegate.</param> - /// <param name="blastIrPorts">The blast ir ports.</param> /// <param name="categories">The command categories to include.</param> - public EditMacro(string macroFolder, VariableList variables, IrssUtils.BlastIrDelegate blastIrDelegate, string[] blastIrPorts, string[] categories) + public EditMacro(Processor commandProcessor, string macroFolder, string[] categories) { + if (commandProcessor == null) + throw new ArgumentNullException("commandProcessor"); + if (String.IsNullOrEmpty(macroFolder)) throw new ArgumentNullException("macroFolder"); - if (variables == null) - throw new ArgumentNullException("variables"); - - if (blastIrDelegate == null) - throw new ArgumentNullException("blastIrDelegate"); - - if (blastIrPorts == null) - throw new ArgumentNullException("blastIrPorts"); - if (categories == null) throw new ArgumentNullException("categories"); InitializeComponent(); - _macroFolder = macroFolder; - _variableList = variables; - _blastIrDelegate = blastIrDelegate; - _blastIrPorts = blastIrPorts; + _commandProcessor = commandProcessor; + _macroFolder = macroFolder; PopulateCommandList(categories); @@ -76,46 +65,36 @@ /// <summary> /// Creates a Macro Editor windows form. /// </summary> - /// <param name="macroFolder">The macro folder.</param> - /// <param name="variables">The variable list.</param> - /// <param name="blastIrDelegate">The blast ir delegate.</param> - /// <param name="blastIrPorts">The blast ir ports.</param> + /// <param name="commandProcessor">The command processor.</param> /// <param name="categories">The command categories to include.</param> - /// <param name="name">The existing macro name.</param> - public EditMacro(string macroFolder, VariableList variables, IrssUtils.BlastIrDelegate blastIrDelegate, string[] blastIrPorts, string[] categories, string name) + /// <param name="fileName">Name of the macro file.</param> + public EditMacro(Processor commandProcessor, string[] categories, string fileName) { - if (String.IsNullOrEmpty(macroFolder)) - throw new ArgumentNullException("macroFolder"); + if (commandProcessor == null) + throw new ArgumentNullException("commandProcessor"); - if (variables == null) - throw new ArgumentNullException("variables"); - - if (blastIrDelegate == null) - throw new ArgumentNullException("blastIrDelegate"); - - if (blastIrPorts == null) - throw new ArgumentNullException("blastIrPorts"); - if (categories == null) throw new ArgumentNullException("categories"); - if (String.IsNullOrEmpty(name)) - throw new ArgumentNullException("name"); + if (String.IsNullOrEmpty(fileName)) + throw new ArgumentNullException("fileName"); InitializeComponent(); - _macroFolder = macroFolder; - _variableList = variables; - _blastIrDelegate = blastIrDelegate; - _blastIrPorts = blastIrPorts; + _commandProcessor = commandProcessor; + _fileName = fileName; PopulateCommandList(categories); - textBoxName.Text = name; + string macroName = fileName; + + if (macroName.StartsWith(Common.FolderAppData, StringComparison.OrdinalIgnoreCase)) + macroName = fileName.Substring(Common.FolderAppData.Length); + + textBoxName.Text = macroName; textBoxName.Enabled = false; - string fileName = macroFolder + name + Macro.FileExtension; - Macro macro = new Macro(fileName); + Macro macro = new Macro(fileName + Processor.FileExtensionMacro); foreach (Command command in macro.Commands) { ListViewItem item = new ListViewItem(command.GetUserDisplayText()); @@ -131,23 +110,18 @@ void PopulateCommandList(string[] categories) { _commands = new Dictionary<string, Type>(); - treeViewCommandList.Nodes.Clear(); - Dictionary<string, TreeNode> treeNodes = new Dictionary<string,TreeNode>(categories.Length); TreeNode macroCommands = new TreeNode(Macro.Category); - - Type[] specialCommands = Macro.GetSpecialCommands(); - + Type[] specialCommands = Processor.GetSpecialCommands(); foreach (Type type in specialCommands) { Command command = (Command)Activator.CreateInstance(type); - if (command.GetCategory().Equals(Macro.HiddenCategory, StringComparison.OrdinalIgnoreCase)) - continue; - - macroCommands.Nodes.Add(command.GetUserInterfaceText()); + if (!command.GetCategory().Equals(Processor.CategoryHidden, StringComparison.OrdinalIgnoreCase)) + macroCommands.Nodes.Add(command.GetUserInterfaceText()); + _commands.Add(command.GetUserInterfaceText(), type); } @@ -174,7 +148,23 @@ } } - string[] macros = Macro.GetList(_macroFolder); + string[] irFiles = Processor.GetListIR(); + if (irFiles != null) + { + TreeNode irCommands = new TreeNode("IR Commands"); + + foreach (string irFile in irFiles) + { + TreeNode newNode = new TreeNode(irFile); + newNode.Tag = Common.FolderIRCommands + irFile; + irCommands.Nodes.Add(newNode); + } + + treeNodes.Add(irCommands.Text, irCommands); + } + + + string[] macros = Processor.GetListMacro(_macroFolder); if (macros != null) { TreeNode otherMacros = new TreeNode("Macros"); @@ -204,8 +194,21 @@ ListViewItem newCommand = new ListViewItem(); Command command; - if (treeViewCommandList.SelectedNode.Parent.Text.Equals("Macros", StringComparison.OrdinalIgnoreCase)) + if (treeViewCommandList.SelectedNode.Parent.Text.Equals("IR Commands", StringComparison.OrdinalIgnoreCase)) { + string selectedTag = treeViewCommandList.SelectedNode.Tag as string; + + command = new CommandBlastIR(new string[] { selectedTag, _commandProcessor.BlastIrPorts[0] }); + + if (_commandProcessor.Edit(command, this)) + { + newCommand.Text = command.GetUserDisplayText(); + newCommand.Tag = command.ToString(); + listViewMacro.Items.Add(newCommand); + } + } + else if (treeViewCommandList.SelectedNode.Parent.Text.Equals("Macros", StringComparison.OrdinalIgnoreCase)) + { command = new CommandCallMacro(new string[] { selected }); newCommand.Text = command.GetUserDisplayText(); @@ -214,28 +217,14 @@ } else if (_commands.ContainsKey(selected)) { - command = (Command)Activator.CreateInstance(_commands[selected]); - /*if (command is CommandBlast) + if (_commandProcessor.Edit(command, this)) { - if (command.Edit(this, _blastIrDelegate, _blastIrPorts)) - { - newCommand.Text = command.GetUserDisplayText(); - newCommand.Tag = command.ToXml(); - listViewMacro.Items.Add(newCommand); - } - + newCommand.Text = command.GetUserDisplayText(); + newCommand.Tag = command.ToString(); + listViewMacro.Items.Add(newCommand); } - else*/ - { - if (command.Edit(this)) - { - newCommand.Text = command.GetUserDisplayText(); - newCommand.Tag = command.ToString(); - listViewMacro.Items.Add(newCommand); - } - } } else { @@ -310,11 +299,11 @@ foreach (ListViewItem item in listViewMacro.Items) { string itemTag = item.Tag as string; - Command command = Macro.CreateCommand(itemTag); + Command command = Processor.CreateCommand(itemTag); newMacro.Commands.Add(command); } - newMacro.Execute(_variableList); + newMacro.Execute(_commandProcessor.Variables, _commandProcessor.BlastIr); } catch (Exception ex) { @@ -355,11 +344,11 @@ foreach (ListViewItem item in listViewMacro.Items) { string itemTag = item.Tag as string; - Command command = Macro.CreateCommand(itemTag); + Command command = Processor.CreateCommand(itemTag); newMacro.Commands.Add(command); } - newMacro.Save(_macroFolder + name + Macro.FileExtension); + newMacro.Save(_macroFolder + name + Processor.FileExtensionMacro); } catch (Exception ex) { @@ -380,18 +369,12 @@ ListViewItem selected = listViewMacro.SelectedItems[0]; string selectedTag = selected.Tag as string; - Command command = Macro.CreateCommand(selectedTag); + Command command = Processor.CreateCommand(selectedTag); - //if (command is CommandBlast) - //{ - //} - //else + if (_commandProcessor.Edit(command, this)) { - if (command.Edit(this)) - { - selected.Text = command.GetUserDisplayText(); - selected.Tag = command.ToString(); - } + selected.Text = command.GetUserDisplayText(); + selected.Tag = command.ToString(); } } catch (Exception ex) Modified: trunk/plugins/IR Server Suite/Commands/Macro/Macro.cs =================================================================== --- trunk/plugins/IR Server Suite/Commands/Macro/Macro.cs 2008-01-19 08:02:20 UTC (rev 1270) +++ trunk/plugins/IR Server Suite/Commands/Macro/Macro.cs 2008-01-19 08:44:47 UTC (rev 1271) @@ -20,21 +20,11 @@ #region Constants /// <summary> - /// Macro file extension. - /// </summary> - public const string FileExtension = ".Macro"; - - /// <summary> /// Category for Macro Commands. /// </summary> public const string Category = "Macro Commands"; /// <summary> - /// Category for commands that should not be visible in command lists. - /// </summary> - public const string HiddenCategory = "Hidden"; - - /// <summary> /// User Interface Text. /// </summary> public const string UserInterfaceText = "Macro"; @@ -84,7 +74,7 @@ foreach (XmlNode item in commandSequence) { string xml = item.Attributes["xml"].Value; - Command command = Macro.CreateCommand(xml); + Command command = Processor.CreateCommand(xml); _commands.Add(command); } } @@ -121,7 +111,8 @@ /// Exceutes this macro the specified variables and process command method. /// </summary> /// <param name="variables">The variables to use.</param> - public void Execute(VariableList variables) + /// <param name="blastIrDelegate">The blast ir delegate.</param> + public void Execute(VariableList variables, BlastIrDelegate blastIrDelegate) { for (int position = 0; position < _commands.Count; position++) { @@ -137,7 +128,7 @@ command.Parameters[2] = variables.GetVariable(command.Parameters[2].Substring(VariableList.VariablePrefix.Length)); command.Parameters[2] = Common.ReplaceSpecial(command.Parameters[2]); - if (((CommandIf)command).Evaluate()) + if ((command as CommandIf).Evaluate()) position = FindLabel(command.Parameters[3]); else if (!String.IsNullOrEmpty(command.Parameters[4])) position = FindLabel(command.Parameters[4]); @@ -148,8 +139,12 @@ } else if (command is CommandBlastIR) { - //((CommandBlastIR)command).Execute(_blastIrDelegate); + (command as CommandBlastIR).Execute(blastIrDelegate); } + else if (command is CommandCallMacro) + { + (command as CommandCallMacro).Execute(variables, blastIrDelegate); + } else { command.Execute(variables); @@ -182,23 +177,8 @@ #endregion Implementation #region Static Methods - + /* /// <summary> - /// Returns a list of Macros in the specified folder. - /// </summary> - /// <returns>List of Macros.</returns> - public static string[] GetList(string folder) - { - string[] files = Directory.GetFiles(folder, '*' + FileExtension); - - for (int index = 0; index < files.Length; index++) - files[index] = Path.GetFileNameWithoutExtension(files[index]); - - return files; - } - - - /// <summary> /// Creates a new <c>Command</c> from the supplied information. /// </summary> /// <param name="commandString">The command string representation.</param> @@ -277,8 +257,6 @@ { List<Type> specialCommands = new List<Type>(); - specialCommands.Add(typeof(CommandBlastIR)); - specialCommands.Add(typeof(CommandIf)); specialCommands.Add(typeof(CommandLabel)); specialCommands.Add(typeof(CommandGotoLabel)); @@ -287,13 +265,13 @@ specialCommands.Add(typeof(CommandSaveVariables)); specialCommands.Add(typeof(CommandLoadVariables)); - // Hidden commands ... + specialCommands.Add(typeof(CommandBlastIR)); specialCommands.Add(typeof(CommandCallMacro)); return specialCommands.ToArray(); } - + */ #endregion Static Methods } Deleted: trunk/plugins/IR Server Suite/Commands/Macro/Macro.csproj =================================================================== --- trunk/plugins/IR Server Suite/Commands/Macro/Macro.csproj 2008-01-19 08:02:20 UTC (rev 1270) +++ trunk/plugins/IR Server Suite/Commands/Macro/Macro.csproj 2008-01-19 08:44:47 UTC (rev 1271) @@ -1,131 +0,0 @@ -<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <PropertyGroup> - <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> - <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> - <ProductVersion>8.0.50727</ProductVersion> - <SchemaVersion>2.0</SchemaVersion> - <ProjectGuid>{49CF376E-811C-4EB4-817F-A39C9529B608}</ProjectGuid> - <OutputType>Library</OutputType> - <AppDesignerFolder>Properties</AppDesignerFolder> - <RootNamespace>Commands</RootNamespace> - <AssemblyName>Macro</AssemblyName> - <RunPostBuildEvent>OnOutputUpdated</RunPostBuildEvent> - </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> - <UseVSHostingProcess>false</UseVSHostingProcess> - <TreatWarningsAsErrors>true</TreatWarningsAsErrors> - <DocumentationFile>bin\Debug\Macro.XML</DocumentationFile> - </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="System" /> - <Reference Include="System.Drawing" /> - <Reference Include="System.Windows.Forms" /> - <Reference Include="System.Xml" /> - </ItemGroup> - <ItemGroup> - <Compile Include="CommandClearVariables.cs" /> - <Compile Include="CommandIf.cs" /> - <Compile Include="CommandLabel.cs" /> - <Compile Include="CommandGotoLabel.cs" /> - <Compile Include="CommandSetVariable.cs" /> - <Compile Include="CommandSaveVariables.cs" /> - <Compile Include="CommandLoadVariables.cs" /> - <Compile Include="CommandCallMacro.cs" /> - <Compile Include="CommandBlastIR.cs" /> - <Compile Include="EditIf.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="EditIf.Designer.cs"> - <DependentUpon>EditIf.cs</DependentUpon> - </Compile> - <Compile Include="EditLabel.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="EditLabel.Designer.cs"> - <DependentUpon>EditLabel.cs</DependentUpon> - </Compile> - <Compile Include="Macro.cs" /> - <Compile Include="EditMacro.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="EditMacro.Designer.cs"> - <DependentUpon>EditMacro.cs</DependentUpon> - </Compile> - <Compile Include="MacroStructureException.cs" /> - <Compile Include="Properties\AssemblyInfo.cs" /> - <Compile Include="EditSetVariable.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="EditSetVariable.Designer.cs"> - <DependentUpon>EditSetVariable.cs</DependentUpon> - </Compile> - <Compile Include="EditVariablesFile.cs"> - <SubType>Form</SubType> - </Compile> - <Compile Include="EditVariablesFile.Designer.cs"> - <DependentUpon>EditVariablesFile.cs</DependentUpon> - </Compile> - </ItemGroup> - <ItemGroup> - <EmbeddedResource Include="EditIf.resx"> - <DependentUpon>EditIf.cs</DependentUpon> - <SubType>Designer</SubType> - </EmbeddedResource> - <EmbeddedResource Include="EditMacro.resx"> - <DependentUpon>EditMacro.cs</DependentUpon> - <SubType>Designer</SubType> - </EmbeddedResource> - <EmbeddedResource Include="EditLabel.resx"> - <DependentUpon>EditLabel.cs</DependentUpon> - <SubType>Designer</SubType> - </EmbeddedResource> - <EmbeddedResource Include="EditSetVariable.resx"> - <DependentUpon>EditSetVariable.cs</DependentUpon> - <SubType>Designer</SubType> - </EmbeddedResource> - <EmbeddedResource Include="EditVariablesFile.resx"> - <DependentUpon>EditVariablesFile.cs</DependentUpon> - <SubType>Designer</SubType> - </EmbeddedResource> - </ItemGroup> - <ItemGroup> - <ProjectReference Include="..\..\Common\IrssUtils\IrssUtils.csproj"> - <Project>{CA15769C-232E-4CA7-94FD-206A06CA3ABB}</Project> - <Name>IrssUtils</Name> - <Private>False</Private> - </ProjectReference> - <ProjectReference Include="..\Command\Command.csproj"> - <Project>{21E04B17-D850-43E7-AAD3-876C0E062BDB}</Project> - <Name>Command</Name> - <Private>False</Private> - </ProjectReference> - <ProjectReference Include="..\VariableList\VariableList.csproj"> - <Project>{106A69D2-670C-4DE5-A81C-A3CD5D3F21EB}</Project> - <Name>VariableList</Name> - <Private>False</Private> - </ProjectReference> - </ItemGroup> - <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> - <!-- 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> \ No newline at end of file Added: trunk/plugins/IR Server Suite/Commands/Macro/Processor.cs =================================================================== --- trunk/plugins/IR Server Suite/Commands/Macro/Processor.cs (rev 0) +++ trunk/plugins/IR Server Suite/Commands/Macro/Processor.cs 2008-01-19 08:44:47 UTC (rev 1271) @@ -0,0 +1,282 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.IO; +using System.Text; +using System.Windows.Forms; +using System.Xml; +using System.Xml.Serialization; + +namespace Commands +{ + + /// <summary> + /// Provides a delegate to call to execute an IR Command. + /// </summary> + /// <param name="fileName">Full file path to the IR Command file.</param> + /// <param name="port">IR Blaster port to transmit on.</param> + public delegate void BlastIrDelegate(string fileName, string port); + + /// <summary> + /// Encapsulates all Command Processing. + /// </summary> + public class Processor + { + + #region Constants + + /// <summary> + /// Macro file extension. + /// </summary> + public const string FileExtensionMacro = ".Macro"; + + /// <summary> + /// IR Command file extension. + /// </summary> + public const string FileExtensionIR = ".IR"; + + + /// <summary> + /// Standard text for the Macro Category. + /// </summary> + public const string CategoryMacro = "Macro Commands"; + /// <summary> + /// Standard text for the Macro Category. + /// </summary> + public const string CategoryGeneral = "General Commands"; + /// <summary> + /// Standard text for the Macro Category. + /// </summary> + public const string CategoryMediaPortal = "MediaPortal Commands"; + /// <summary> + /// Standard text for the Macro Category. + /// </summary> + public const string CategoryHidden = "Hidden"; + + #endregion Constants + + #region Variables + + VariableList _variables; + + BlastIrDelegate _blastIrDelegate; + string[] _blastIrPorts; + + #endregion Variables + + #region Properties + + /// <summary> + /// Gets the variable list. + /// </summary> + /// <value>The variable list.</value> + public VariableList Variables + { + get { return _variables; } + } + + /// <summary> + /// Gets the blast ir delegate. + /// </summary> + /// <value>The blast ir delegate.</value> + public BlastIrDelegate BlastIr + { + get { return _blastIrDelegate; } + } + + /// <summary> + /// Gets the blast ir ports. + /// </summary> + /// <value>The blast ir ports.</value> + public string[] BlastIrPorts + { + get { return _blastIrPorts; } + } + + #endregion Properties + + #region Constructor + + /// <summary> + /// Initializes a new instance of the <see cref="Processor"/> class. + /// </summary> + /// <param name="blastIrDelegate">The blast ir delegate.</param> + /// <param name="blastIrPorts">The blast ir ports.</param> + public Processor(BlastIrDelegate blastIrDelegate, string[] blastIrPorts) + { + _variables = new VariableList(); + + _blastIrDelegate = blastIrDelegate; + _blastIrPorts = blastIrPorts; + } + + #endregion Constructor + + #region Implementation + + /// <summary> + /// Executes the specified command. + /// </summary> + /// <param name="command">The command.</param> + public void Execute(Command command) + { + if (command is CommandBlastIR) + (command as CommandBlastIR).Execute(_blastIrDelegate); + else if (command is CommandCallMacro) + (command as CommandCallMacro).Execute(_variables, _blastIrDelegate); + else + command.Execute(_variables); + } + + /// <summary> + /// Edits the specified command. + /// </summary> + /// <param name="command">The command.</param> + /// <param name="parent">The parent window.</param> + /// <returns><c>true</c> if the edit </returns> + public bool Edit(Command command, IWin32Window parent) + { + if (command is CommandBlastIR) + return (command as CommandBlastIR).Edit(parent, _blastIrDelegate, _blastIrPorts); + else + return command.Edit(parent); + } + + #endregion Implementation + + #region Static Methods + + /// <summary> + /// Returns a list of IR Command files. + /// </summary> + /// <returns>List of IR Command files.</returns> + public static string[] GetListIR() + { + string[] files = Directory.GetFiles(IrssUtils.Common.FolderIRCommands, '*' + FileExtensionIR); + + for (int index = 0; index < files.Length; index++) + files[index] = Path.GetFileNameWithoutExtension(files[index]); + + return files; + } + + /// <summary> + /// Returns a list of Macros in the specified folder. + /// </summary> + /// <param name="folder">The folder.</param> + /// <returns>List of Macros.</returns> + public static string[] GetListMacro(string folder) + { + string[] files = Directory.GetFiles(folder, '*' + FileExtensionMacro); + + for (int index = 0; index < files.Length; index++) + files[index] = Path.GetFileNameWithoutExtension(files[index]); + + return files; + } + + + /// <summary> + /// Creates a new <c>Command</c> from the supplied information. + /// </summary> + /// <param name="commandString">The command string representation.</param> + /// <returns>A new <c>Command</c>.</returns> + public static Command CreateCommand(string commandString) + { + if (String.IsNullOrEmpty(commandString)) + throw new ArgumentNullException("commandString"); + + string splitAt = ", "; + + int splitPoint = commandString.IndexOf(splitAt); + if (splitPoint == -1) + throw new ArgumentException("Invalid command string", "commandString"); + + string commandType = commandString.Substring(0, splitPoint); + string parametersXml = commandString.Substring(splitPoint + splitAt.Length); + + return CreateCommand(commandType, parametersXml); + } + + /// <summary> + /// Creates a new <c>Command</c> from the supplied information. + /// </summary> + /// <param name="commandType">Type of command to create (FullName).</param> + /// <param name="parametersXml">The parameters of this command in XML.</param> + /// <returns>A new <c>Command</c>.</returns> + public static Command CreateCommand(string commandType, string parametersXml) + { + if (String.IsNullOrEmpty(commandType)) + throw new ArgumentNullException("commandType"); + + if (String.IsNullOrEmpty(parametersXml)) + throw new ArgumentNullException("parametersXml"); + + string[] parameters; + using (StringReader stringReader = new StringReader(parametersXml)) + { + XmlSerializer xmlSerializer = new XmlSerializer(typeof(string[])); + parameters = (string[])xmlSerializer.Deserialize(stringReader); + } + + return CreateCommand(commandType, parameters); + } + + /// <summary> + /// Creates a new <c>Command</c> from the supplied information. + /// </summary> + /// <param name="commandType">Type of command to create (FullName).</param> + /// <param name="parameters">The command parameters.</param> + /// <returns>A new <c>Command</c>.</returns> + public static Command CreateCommand(string commandType, string[] parameters) + { + List<Type> allCommands = new List<Type>(); + + Type[] specialCommands = GetSpecialCommands(); + if (specialCommands != null) + allCommands.AddRange(specialCommands); + + Type[] libraryCommands = IrssUtils.Common.GetLibraryCommands(); + if (libraryCommands != null) + allCommands.AddRange(libraryCommands); + + foreach (Type type in allCommands) + if (type.FullName.Equals(commandType)) + return (Command)Activator.CreateInstance(type, new object[] { parameters }); + + throw new InvalidOperationException(String.Format("Could not find command type: {0}", commandType)); + } + + /// <summary> + /// Gets the special commands. + /// </summary> + /// <returns>List of special command types.</returns> + public static Type[] GetSpecialCommands() + { + List<Type> specialCommands = new List<Type>(); + + specialCommands.Add(typeof(CommandIf)); + specialCommands.Add(typeof(CommandLabel)); + specialCommands.Add(typeof(CommandGotoLabel)); + specialCommands.Add(typeof(CommandSetVariable)); + specialCommands.Add(typeof(CommandClearVariables)); + specialCommands.Add(typeof(CommandSaveVariables)); + specialCommands.Add(typeof(CommandLoadVariables)); + + // Hidden commands ... + specialCommands.Add(typeof(CommandBlastIR)); + specialCommands.Add(typeof(CommandCallMacro)); + + return specialCommands.ToArray(); + } + + #endregion Static Methods + + + + + + } + + +} Modified: trunk/plugins/IR Server Suite/Commands/Macro/Properties/AssemblyInfo.cs =... [truncated message content] |