From: <an...@us...> - 2008-01-19 09:11:19
|
Revision: 1272 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=1272&view=rev Author: and-81 Date: 2008-01-19 01:11:17 -0800 (Sat, 19 Jan 2008) Log Message: ----------- Modified Paths: -------------- trunk/plugins/IR Server Suite/Commands/TestApp/TestApp.csproj trunk/plugins/IR Server Suite/IR Server Suite.sln Added Paths: ----------- trunk/plugins/IR Server Suite/Commands/CommandProcessor/ trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandBlastIR.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandCallMacro.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandProcessor.csproj trunk/plugins/IR Server Suite/Commands/CommandProcessor/EditBlastIR.Designer.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/EditBlastIR.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/EditBlastIR.resx trunk/plugins/IR Server Suite/Commands/CommandProcessor/EditMacro.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/Macro.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/Processor.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/Properties/AssemblyInfo.cs Removed Paths: ------------- trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandBlastIR.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandCallMacro.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/EditMacro.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/Macro.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/Macro.csproj trunk/plugins/IR Server Suite/Commands/CommandProcessor/Properties/AssemblyInfo.cs trunk/plugins/IR Server Suite/Commands/Macro/ Copied: trunk/plugins/IR Server Suite/Commands/CommandProcessor (from rev 1270, trunk/plugins/IR Server Suite/Commands/Macro) Deleted: trunk/plugins/IR Server Suite/Commands/CommandProcessor/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/CommandProcessor/CommandBlastIR.cs 2008-01-19 09:11:17 UTC (rev 1272) @@ -1,79 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Windows.Forms; - -using IrssUtils; - -namespace Commands -{ - - /// <summary> - /// Blast IR macro command. - /// </summary> - public class CommandBlastIR : Command - { - - #region Constructors - - /// <summary> - /// Initializes a new instance of the <see cref="CommandBlastIR"/> class. - /// </summary> - public CommandBlastIR() { InitParameters(2); } - - /// <summary> - /// Initializes a new instance of the <see cref="CommandBlastIR"/> class. - /// </summary> - /// <param name="parameters">The parameters.</param> - public CommandBlastIR(string[] parameters) : base(parameters) { } - - #endregion Constructors - - #region Implementation - - /// <summary> - /// Gets the category of this command. - /// </summary> - /// <returns>The category of this command.</returns> - public override string GetCategory() { return Macro.Category; } - - /// <summary> - /// Gets the user interface text. - /// </summary> - /// <returns>User interface text.</returns> - public override string GetUserInterfaceText() { return "Blast IR"; } - - /// <summary> - /// Gets the user display text. - /// </summary> - /// <returns>The user display text.</returns> - public override string GetUserDisplayText() - { - return String.Format("{0} ({1})", GetUserInterfaceText(), String.Join(", ", Parameters)); - } - /* - public bool Edit(IWin32Window parent, BlastIrDelegate blastIrDelegate, string[] blastPorts) - { - EditBlastIR edit = new EditBlastIR(_parameters, blastIrDelegate, blastPorts); - if (edit.ShowDialog(parent) == DialogResult.OK) - { - _parameters = edit.Parameters; - return true; - } - - return false; - } - - public void Execute(BlastIrDelegate blastIrDelegate) - { - string irFile = Common.FolderIRCommands + _parameters[0] + Common.FileExtensionIR; - string port = _parameters[1]; - - blastIrDelegate(irFile, port); - } - */ - #endregion Implementation - - } - -} Copied: trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandBlastIR.cs (from rev 1271, trunk/plugins/IR Server Suite/Commands/Macro/CommandBlastIR.cs) =================================================================== --- trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandBlastIR.cs (rev 0) +++ trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandBlastIR.cs 2008-01-19 09:11:17 UTC (rev 1272) @@ -0,0 +1,97 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; +using System.Windows.Forms; + +using IrssUtils; + +namespace Commands +{ + + /// <summary> + /// Blast IR macro command. + /// </summary> + public class CommandBlastIR : Command + { + + #region Constructors + + /// <summary> + /// Initializes a new instance of the <see cref="CommandBlastIR"/> class. + /// </summary> + public CommandBlastIR() { InitParameters(2); } + + /// <summary> + /// Initializes a new instance of the <see cref="CommandBlastIR"/> class. + /// </summary> + /// <param name="parameters">The parameters.</param> + public CommandBlastIR(string[] parameters) : base(parameters) { } + + #endregion Constructors + + #region Implementation + + /// <summary> + /// Gets the category of this command. + /// </summary> + /// <returns>The category of this command.</returns> + public override string GetCategory() { return Processor.CategoryHidden; } + + /// <summary> + /// Gets the user interface text. + /// </summary> + /// <returns>User interface text.</returns> + public override string GetUserInterfaceText() { return "Blast IR"; } + + /// <summary> + /// Gets the user display text. + /// </summary> + /// <returns>The user display text.</returns> + public override string GetUserDisplayText() + { + 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(blastIrDelegate, blastPorts, _parameters); + if (edit.ShowDialog(parent) == DialogResult.OK) + { + _parameters = edit.Parameters; + return true; + } + + return false; + } + + /// <summary> + /// Execute this command. + /// </summary> + /// <param name="blastIrDelegate">The blast ir delegate.</param> + public void Execute(BlastIrDelegate blastIrDelegate) + { + string irFile = _parameters[0] + Common.FileExtensionIR; + string port = _parameters[1]; + + blastIrDelegate(irFile, port); + } + + #endregion Implementation + + + } + +} Deleted: trunk/plugins/IR Server Suite/Commands/CommandProcessor/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/CommandProcessor/CommandCallMacro.cs 2008-01-19 09:11:17 UTC (rev 1272) @@ -1,67 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.Windows.Forms; - -namespace Commands -{ - - /// <summary> - /// Call Macro macro command. - /// </summary> - public class CommandCallMacro : Command - { - - #region Constructors - - /// <summary> - /// Initializes a new instance of the <see cref="CommandCallMacro"/> class. - /// </summary> - public CommandCallMacro() { InitParameters(1); } - - /// <summary> - /// Initializes a new instance of the <see cref="CommandCallMacro"/> class. - /// </summary> - /// <param name="parameters">The parameters.</param> - public CommandCallMacro(string [] parameters): base(parameters) { } - - #endregion Constructors - - #region Implementation - - /// <summary> - /// Gets the category of this command. - /// </summary> - /// <returns>The category of this command.</returns> - public override string GetCategory() { return Macro.HiddenCategory; } - - /// <summary> - /// Gets the user interface text. - /// </summary> - /// <returns>User interface text.</returns> - public override string GetUserInterfaceText() { return "Macro"; } - - /// <summary> - /// Gets the user display text. - /// </summary> - /// <returns>The user display text.</returns> - public override string GetUserDisplayText() - { - return String.Format("{0} ({1})", GetUserInterfaceText(), String.Join(", ", Parameters)); - } - - /// <summary> - /// Execute this command. - /// </summary> - /// <param name="variables">The variable list of the calling code.</param> - public override void Execute(VariableList variables) - { - Macro macro = new Macro(_parameters[0]); - macro.Execute(variables); - } - - #endregion Implementation - - } - -} Copied: trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandCallMacro.cs (from rev 1271, trunk/plugins/IR Server Suite/Commands/Macro/CommandCallMacro.cs) =================================================================== --- trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandCallMacro.cs (rev 0) +++ trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandCallMacro.cs 2008-01-19 09:11:17 UTC (rev 1272) @@ -0,0 +1,70 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Windows.Forms; + +using IrssUtils; + +namespace Commands +{ + + /// <summary> + /// Call Macro macro command. + /// </summary> + public class CommandCallMacro : Command + { + + #region Constructors + + /// <summary> + /// Initializes a new instance of the <see cref="CommandCallMacro"/> class. + /// </summary> + public CommandCallMacro() { InitParameters(1); } + + /// <summary> + /// Initializes a new instance of the <see cref="CommandCallMacro"/> class. + /// </summary> + /// <param name="parameters">The parameters.</param> + public CommandCallMacro(string [] parameters): base(parameters) { } + + #endregion Constructors + + #region Implementation + + /// <summary> + /// Gets the category of this command. + /// </summary> + /// <returns>The category of this command.</returns> + public override string GetCategory() { return Processor.CategoryHidden; } + + /// <summary> + /// Gets the user interface text. + /// </summary> + /// <returns>User interface text.</returns> + public override string GetUserInterfaceText() { return "Macro"; } + + /// <summary> + /// Gets the user display text. + /// </summary> + /// <returns>The user display text.</returns> + public override string GetUserDisplayText() + { + return String.Format("{0} ({1})", GetUserInterfaceText(), String.Join(", ", Parameters)); + } + + /// <summary> + /// Execute this command. + /// </summary> + /// <param name="variables">The variable list of the calling code.</param> + /// <param name="blastIrDelegate">The blast ir delegate.</param> + public void Execute(VariableList variables, BlastIrDelegate blastIrDelegate) + { + Macro macro = new Macro(_parameters[0]); + macro.Execute(variables, blastIrDelegate); + } + + #endregion Implementation + + } + +} Copied: trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandProcessor.csproj (from rev 1271, trunk/plugins/IR Server Suite/Commands/Macro/CommandProcessor.csproj) =================================================================== --- trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandProcessor.csproj (rev 0) +++ trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandProcessor.csproj 2008-01-19 09:11:17 UTC (rev 1272) @@ -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 Copied: trunk/plugins/IR Server Suite/Commands/CommandProcessor/EditBlastIR.Designer.cs (from rev 1271, trunk/plugins/IR Server Suite/Commands/Macro/EditBlastIR.Designer.cs) =================================================================== --- trunk/plugins/IR Server Suite/Commands/CommandProcessor/EditBlastIR.Designer.cs (rev 0) +++ trunk/plugins/IR Server Suite/Commands/CommandProcessor/EditBlastIR.Designer.cs 2008-01-19 09:11:17 UTC (rev 1272) @@ -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; + } + +} Copied: trunk/plugins/IR Server Suite/Commands/CommandProcessor/EditBlastIR.cs (from rev 1271, trunk/plugins/IR Server Suite/Commands/Macro/EditBlastIR.cs) =================================================================== --- trunk/plugins/IR Server Suite/Commands/CommandProcessor/EditBlastIR.cs (rev 0) +++ trunk/plugins/IR Server Suite/Commands/CommandProcessor/EditBlastIR.cs 2008-01-19 09:11:17 UTC (rev 1272) @@ -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 + + } + +} Copied: trunk/plugins/IR Server Suite/Commands/CommandProcessor/EditBlastIR.resx (from rev 1271, trunk/plugins/IR Server Suite/Commands/Macro/EditBlastIR.resx) =================================================================== --- trunk/plugins/IR Server Suite/Commands/CommandProcessor/EditBlastIR.resx (rev 0) +++ trunk/plugins/IR Server Suite/Commands/CommandProcessor/EditBlastIR.resx 2008-01-19 09:11:17 UTC (rev 1272) @@ -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 Deleted: trunk/plugins/IR Server Suite/Commands/CommandProcessor/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/CommandProcessor/EditMacro.cs 2008-01-19 09:11:17 UTC (rev 1272) @@ -1,406 +0,0 @@ -using System; -using System.Collections.Generic; -using System.ComponentModel; -#if TRACE -using System.Diagnostics; -#endif -using System.Drawing; -using System.IO; -using System.Text; -using System.Windows.Forms; -using System.Xml; - -using IrssUtils; -//using IrssUtils.Forms; - -namespace Commands -{ - - /// <summary> - /// Edit Macro form. - /// </summary> - public partial class EditMacro : Form - { - - #region Variables - - string _macroFolder; - VariableList _variableList; - IrssUtils.BlastIrDelegate _blastIrDelegate; - string[] _blastIrPorts; - - Dictionary<string, Type> _commands; - - #endregion Variables - - #region Constructor - - /// <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="categories">The command categories to include.</param> - public EditMacro(string macroFolder, VariableList variables, IrssUtils.BlastIrDelegate blastIrDelegate, string[] blastIrPorts, string[] categories) - { - 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; - - PopulateCommandList(categories); - - textBoxName.Text = "New"; - textBoxName.Enabled = true; - } - - /// <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="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) - { - 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"); - - if (String.IsNullOrEmpty(name)) - throw new ArgumentNullException("name"); - - InitializeComponent(); - - _macroFolder = macroFolder; - _variableList = variables; - _blastIrDelegate = blastIrDelegate; - _blastIrPorts = blastIrPorts; - - PopulateCommandList(categories); - - textBoxName.Text = name; - textBoxName.Enabled = false; - - string fileName = macroFolder + name + Macro.FileExtension; - Macro macro = new Macro(fileName); - foreach (Command command in macro.Commands) - { - ListViewItem item = new ListViewItem(command.GetUserDisplayText()); - item.Tag = command.ToString(); - listViewMacro.Items.Add(item); - } - } - - #endregion Constructor - - #region Implementation - - 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(); - - 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()); - _commands.Add(command.GetUserInterfaceText(), type); - } - - treeNodes.Add(Macro.Category, macroCommands); - - foreach (string category in categories) - treeNodes.Add(category, new TreeNode(category)); - - Type[] allCommands = Common.GetLibraryCommands(); - if (allCommands != null) - { - foreach (Type type in allCommands) - { - Command command = (Command)Activator.CreateInstance(type); - - string commandCategory = command.GetCategory(); - - if (treeNodes.ContainsKey(commandCategory)) - { - string uiText = command.GetUserInterfaceText(); - treeNodes[commandCategory].Nodes.Add(uiText); - _commands.Add(uiText, type); - } - } - } - - string[] macros = Macro.GetList(_macroFolder); - if (macros != null) - { - TreeNode otherMacros = new TreeNode("Macros"); - - foreach (string macro in macros) - otherMacros.Nodes.Add(macro); - - treeNodes.Add(otherMacros.Text, otherMacros); - } - - foreach (TreeNode treeNode in treeNodes.Values) - if (treeNode.Nodes.Count > 0) - treeViewCommandList.Nodes.Add(treeNode); - - treeViewCommandList.ExpandAll(); - } - - private void treeViewCommandList_DoubleClick(object sender, EventArgs e) - { - if (treeViewCommandList.SelectedNode == null || treeViewCommandList.SelectedNode.Level == 0) - return; - - try - { - string selected = treeViewCommandList.SelectedNode.Text as string; - - ListViewItem newCommand = new ListViewItem(); - Command command; - - if (treeViewCommandList.SelectedNode.Parent.Text.Equals("Macros", StringComparison.OrdinalIgnoreCase)) - { - command = new CommandCallMacro(new string[] { selected }); - - newCommand.Text = command.GetUserDisplayText(); - newCommand.Tag = command.ToString(); - listViewMacro.Items.Add(newCommand); - } - else if (_commands.ContainsKey(selected)) - { - - command = (Command)Activator.CreateInstance(_commands[selected]); - - /*if (command is CommandBlast) - { - if (command.Edit(this, _blastIrDelegate, _blastIrPorts)) - { - newCommand.Text = command.GetUserDisplayText(); - newCommand.Tag = command.ToXml(); - listViewMacro.Items.Add(newCommand); - } - - } - else*/ - { - if (command.Edit(this)) - { - newCommand.Text = command.GetUserDisplayText(); - newCommand.Tag = command.ToString(); - listViewMacro.Items.Add(newCommand); - } - } - } - else - { - throw new ApplicationException(String.Format("Unknown macro command ({0})", selected)); - } - } - catch (Exception ex) - { - IrssLog.Error(ex); - MessageBox.Show(this, ex.Message, "Failed to add macro command", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } - - private void buttonMoveUp_Click(object sender, EventArgs e) - { - if (listViewMacro.SelectedItems.Count != 1) - return; - - int selected = listViewMacro.SelectedIndices[0]; - if (selected > 0) - { - ListViewItem item = listViewMacro.Items[selected]; - listViewMacro.Items.RemoveAt(selected); - listViewMacro.Items.Insert(selected - 1, item); - item.Selected = true; - } - } - private void buttonMoveDown_Click(object sender, EventArgs e) - { - if (listViewMacro.SelectedItems.Count != 1) - return; - - int selected = listViewMacro.SelectedIndices[0]; - if (selected < listViewMacro.Items.Count - 1) - { - ListViewItem item = listViewMacro.Items[selected]; - listViewMacro.Items.RemoveAt(selected); - listViewMacro.Items.Insert(selected + 1, item); - item.Selected = true; - } - } - - private void buttonRemove_Click(object sender, EventArgs e) - { - if (listViewMacro.SelectedItems.Count == 1) - listViewMacro.Items.RemoveAt(listViewMacro.SelectedIndices[0]); - } - - private void buttonTest_Click(object sender, EventArgs e) - { - string name = textBoxName.Text.Trim(); - - if (name.Length == 0) - { - MessageBox.Show(this, "You must supply a name for this Macro", "Name missing", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); - textBoxName.Focus(); - return; - } - - if (!Common.IsValidFileName(name)) - { - MessageBox.Show(this, "You must supply a valid name for this Macro", "Invalid name", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); - textBoxName.Focus(); - return; - } - - try - { - string[] commands = new string[listViewMacro.Items.Count]; - - Macro newMacro = new Macro(); - foreach (ListViewItem item in listViewMacro.Items) - { - string itemTag = item.Tag as string; - Command command = Macro.CreateCommand(itemTag); - newMacro.Commands.Add(command); - } - - newMacro.Execute(_variableList); - } - catch (Exception ex) - { - IrssLog.Error(ex); - MessageBox.Show(this, ex.Message, "Test failed", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } - - private void buttonCancel_Click(object sender, EventArgs e) - { - this.DialogResult = DialogResult.Cancel; - this.Close(); - } - - private void buttonOK_Click(object sender, EventArgs e) - { - string name = textBoxName.Text.Trim(); - - if (name.Length == 0) - { - MessageBox.Show(this, "You must supply a name for this Macro", "Name missing", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); - textBoxName.Focus(); - return; - } - - if (!Common.IsValidFileName(name)) - { - MessageBox.Show(this, "You must supply a valid name for this Macro", "Invalid name", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); - textBoxName.Focus(); - return; - } - - try - { - string[] commands = new string[listViewMacro.Items.Count]; - - Macro newMacro = new Macro(); - foreach (ListViewItem item in listViewMacro.Items) - { - string itemTag = item.Tag as string; - Command command = Macro.CreateCommand(itemTag); - newMacro.Commands.Add(command); - } - - newMacro.Save(_macroFolder + name + Macro.FileExtension); - } - catch (Exception ex) - { - IrssLog.Error(ex); - MessageBox.Show(this, ex.Message, "Failed writing macro to file", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - - this.DialogResult = DialogResult.OK; - this.Close(); - } - - #endregion Implementation - - private void listViewMacro_DoubleClick(object sender, EventArgs e) - { - try - { - ListViewItem selected = listViewMacro.SelectedItems[0]; - - string selectedTag = selected.Tag as string; - Command command = Macro.CreateCommand(selectedTag); - - //if (command is CommandBlast) - //{ - //} - //else - { - if (command.Edit(this)) - { - selected.Text = command.GetUserDisplayText(); - selected.Tag = command.ToString(); - } - } - } - catch (Exception ex) - { - IrssLog.Error(ex); - MessageBox.Show(this, ex.Message, "Failed to edit macro command", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } - - } - -} Copied: trunk/plugins/IR Server Suite/Commands/CommandProcessor/EditMacro.cs (from rev 1271, trunk/plugins/IR Server Suite/Commands/Macro/EditMacro.cs) =================================================================== --- trunk/plugins/IR Server Suite/Commands/CommandProcessor/EditMacro.cs (rev 0) +++ trunk/plugins/IR Server Suite/Commands/CommandProcessor/EditMacro.cs 2008-01-19 09:11:17 UTC (rev 1272) @@ -0,0 +1,389 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +#if TRACE +using System.Diagnostics; +#endif +using System.Drawing; +using System.IO; +using System.Text; +using System.Windows.Forms; +using System.Xml; + +using IrssUtils; + +namespace Commands +{ + + /// <summary> + /// Edit Macro form. + /// </summary> + public partial class EditMacro : Form + { + + #region Variables + + Processor _commandProcessor; + + string _macroFolder; + string _fileName; + + Dictionary<string, Type> _commands; + + #endregion Variables + + #region Constructor + + /// <summary> + /// Creates a Macro Editor windows form. + /// </summary> + /// <param name="commandProcessor">The command processor.</param> + /// <param name="macroFolder">The macro folder.</param> + /// <param name="categories">The command categories to include.</param> + public EditMacro(Processor commandProcessor, string macroFolder, string[] categories) + { + if (commandProcessor == null) + throw new ArgumentNullException("commandProcessor"); + + if (String.IsNullOrEmpty(macroFolder)) + throw new ArgumentNullException("macroFolder"); + + if (categories == null) + throw new ArgumentNullException("categories"); + + InitializeComponent(); + + _commandProcessor = commandProcessor; + _macroFolder = macroFolder; + + PopulateCommandList(categories); + + textBoxName.Text = "New"; + textBoxName.Enabled = true; + } + + /// <summary> + /// Creates a Macro Editor windows form. + /// </summary> + /// <param name="commandProcessor">The command processor.</param> + /// <param name="categories">The command categories to include.</param> + /// <param name="fileName">Name of the macro file.</param> + public EditMacro(Processor commandProcessor, string[] categories, string fileName) + { + if (commandProcessor == null) + throw new ArgumentNullException("commandProcessor"); + + if (categories == null) + throw new ArgumentNullException("categories"); + + if (String.IsNullOrEmpty(fileName)) + throw new ArgumentNullException("fileName"); + + InitializeComponent(); + + _commandProcessor = commandProcessor; + _fileName = fileName; + + PopulateCommandList(categories); + + string macroName = fileName; + + if (macroName.StartsWith(Common.FolderAppData, StringComparison.OrdinalIgnoreCase)) + macroName = fileName.Substring(Common.FolderAppData.Length); + + textBoxName.Text = macroName; + textBoxName.Enabled = false; + + Macro macro = new Macro(fileName + Processor.FileExtensionMacro); + foreach (Command command in macro.Commands) + { + ListViewItem item = new ListViewItem(command.GetUserDisplayText()); + item.Tag = command.ToString(); + listViewMacro.Items.Add(item); + } + } + + #endregion Constructor + + #region Implementation + + 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 = Processor.GetSpecialCommands(); + foreach (Type type in specialCommands) + { + Command command = (Command)Activator.CreateInstance(type); + + if (!command.GetCategory().Equals(Processor.CategoryHidden, StringComparison.OrdinalIgnoreCase)) + macroCommands.Nodes.Add(command.GetUserInterfaceText()); + + _commands.Add(command.GetUserInterfaceText(), type); + } + + treeNodes.Add(Macro.Category, macroCommands); + + foreach (string category in categories) + treeNodes.Add(category, new TreeNode(category)); + + Type[] allCommands = Common.GetLibraryCommands(); + if (allCommands != null) + { + foreach (Type type in allCommands) + { + Command command = (Command)Activator.CreateInstance(type); + + string commandCategory = command.GetCategory(); + + if (treeNodes.ContainsKey(commandCategory)) + { + string uiText = command.GetUserInterfaceText(); + treeNodes[commandCategory].Nodes.Add(uiText); + _commands.Add(uiText, type); + } + } + } + + 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"); + + foreach (string macro in macros) + otherMacros.Nodes.Add(macro); + + treeNodes.Add(otherMacros.Text, otherMacros); + } + + foreach (TreeNode treeNode in treeNodes.Values) + if (treeNode.Nodes.Count > 0) + treeViewCommandList.Nodes.Add(treeNode); + + treeViewCommandList.ExpandAll(); + } + + private void treeViewCommandList_DoubleClick(object sender, EventArgs e) + { + if (treeViewCommandList.SelectedNode == null || treeViewCommandList.SelectedNode.Level == 0) + return; + + try + { + string selected = treeViewCommandList.SelectedNode.Text as string; + + ListViewItem newCommand = new ListViewItem(); + Command command; + + 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(); + newCommand.Tag = command.ToString(); + listViewMacro.Items.Add(newCommand); + } + else if (_commands.ContainsKey(selected)) + { + command = (Command)Activator.CreateInstance(_commands[selected]); + + if (_commandProcessor.Edit(command, this)) + { + newCommand.Text = command.GetUserDisplayText(); + newCommand.Tag = command.ToString(); + listViewMacro.Items.Add(newCommand); + } + } + else + { + throw new ApplicationException(String.Format("Unknown macro command ({0})", selected)); + } + } + catch (Exception ex) + { + IrssLog.Error(ex); + MessageBox.Show(this, ex.Message, "Failed to add macro command", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void buttonMoveUp_Click(object sender, EventArgs e) + { + if (listViewMacro.SelectedItems.Count != 1) + return; + + int selected = listViewMacro.SelectedIndices[0]; + if (selected > 0) + { + ListViewItem item = listViewMacro.Items[selected]; + listViewMacro.Items.RemoveAt(selected); + listViewMacro.Items.Insert(selected - 1, item); + item.Selected = true; + } + } + private void buttonMoveDown_Click(object sender, EventArgs e) + { + if (listViewMacro.SelectedItems.Count != 1) + return; + + int selected = listViewMacro.SelectedIndices[0]; + if (selected < listViewMacro.Items.Count - 1) + { + ListViewItem item = listViewMacro.Items[selected]; + listViewMacro.Items.RemoveAt(selected); + listViewMacro.Items.Insert(selected + 1, item); + item.Selected = true; + } + } + + private void buttonRemove_Click(object sender, EventArgs e) + { + if (listViewMacro.SelectedItems.Count == 1) + listViewMacro.Items.RemoveAt(listViewMacro.SelectedIndices[0]); + } + + private void buttonTest_Click(object sende... [truncated message content] |