From: <an...@us...> - 2008-01-19 15:24:47
|
Revision: 1274 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=1274&view=rev Author: and-81 Date: 2008-01-19 07:24:40 -0800 (Sat, 19 Jan 2008) Log Message: ----------- Modified Paths: -------------- trunk/plugins/IR Server Suite/Applications/IR Blast/Program.cs trunk/plugins/IR Server Suite/Applications/IR Blast (No Window)/Program.cs trunk/plugins/IR Server Suite/Applications/MacroScope/MacroScope.csproj trunk/plugins/IR Server Suite/Commands/Command/Command.csproj trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandCallMacro.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandClearVariables.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandGotoLabel.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandIf.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandLabel.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandLoadVariables.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandProcessor.csproj trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandSaveVariables.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandSetVariable.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/EditBlastIR.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/EditMacro.Designer.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/EditMacro.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/EditSetVariable.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/EditVariablesFile.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/MediaPortalCommands/MediaPortalCommands.csproj trunk/plugins/IR Server Suite/Commands/TestApp/Program.cs trunk/plugins/IR Server Suite/Documentation/new.html Added Paths: ----------- trunk/plugins/IR Server Suite/Commands/Command/CommandStructureException.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandMathsOperation.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandStringOperation.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandSwapVariables.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/EditMathsOperation.Designer.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/EditMathsOperation.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/EditMathsOperation.resx trunk/plugins/IR Server Suite/Commands/CommandProcessor/EditStringOperation.Designer.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/EditStringOperation.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/EditStringOperation.resx trunk/plugins/IR Server Suite/Commands/CommandProcessor/EditSwapVariables.Designer.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/EditSwapVariables.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/EditSwapVariables.resx trunk/plugins/IR Server Suite/Commands/MediaPortalCommands/CommandGotoScreen.cs trunk/plugins/IR Server Suite/Commands/MediaPortalCommands/EditGotoScreen.Designer.cs trunk/plugins/IR Server Suite/Commands/MediaPortalCommands/EditGotoScreen.cs trunk/plugins/IR Server Suite/Commands/MediaPortalCommands/EditGotoScreen.resx Modified: trunk/plugins/IR Server Suite/Applications/IR Blast/Program.cs =================================================================== --- trunk/plugins/IR Server Suite/Applications/IR Blast/Program.cs 2008-01-19 09:25:43 UTC (rev 1273) +++ trunk/plugins/IR Server Suite/Applications/IR Blast/Program.cs 2008-01-19 15:24:40 UTC (rev 1274) @@ -25,7 +25,7 @@ static bool _registered; - static string _serverHost; + static string _serverHost = "localhost"; static string _blastPort = "Default"; @@ -82,7 +82,7 @@ } } - if (String.IsNullOrEmpty(_serverHost) || irCommands.Count == 0) + if (irCommands.Count == 0) { Console.WriteLine("Malformed command line parameters ..."); Console.WriteLine(); @@ -191,7 +191,7 @@ { IrssLog.Debug("Show Help"); - Console.WriteLine("IRBlast -host <server> [-port x] [-speed x] [-pad x] [-channel] <commands>"); + Console.WriteLine("IRBlast [-host x] [-port x] [-speed x] [-pad x] [-channel] <commands>"); Console.WriteLine(""); Console.WriteLine("Use -host to specify the computer that is hosting the IR Server."); Console.WriteLine("Use -port to blast to a particular blaster port (Optional)."); @@ -215,10 +215,10 @@ Console.WriteLine("This would blast the \"Turn on surround.IR\" command on the MEDIAPC computer"); Console.WriteLine("to blaster port 2 at the default blaster speed."); Console.WriteLine(""); - Console.WriteLine("IRBlast -host HTPC -pad 4 -channel 302"); + Console.WriteLine("IRBlast -pad 4 -channel 302"); Console.WriteLine(""); Console.WriteLine("This would blast the 0.IR (for padding), 3.IR, 0.IR, and 2.IR commands on"); - Console.WriteLine("the HTPC computer to the default blaster port at the default blaster speed."); + Console.WriteLine("the local computer to the default blaster port at the default blaster speed."); Console.WriteLine(""); Console.WriteLine(""); } Modified: trunk/plugins/IR Server Suite/Applications/IR Blast (No Window)/Program.cs =================================================================== --- trunk/plugins/IR Server Suite/Applications/IR Blast (No Window)/Program.cs 2008-01-19 09:25:43 UTC (rev 1273) +++ trunk/plugins/IR Server Suite/Applications/IR Blast (No Window)/Program.cs 2008-01-19 15:24:40 UTC (rev 1274) @@ -26,7 +26,7 @@ static bool _registered; - static string _serverHost; + static string _serverHost = "localhost"; static string _blastPort = "Default"; @@ -81,7 +81,7 @@ } } - if (String.IsNullOrEmpty(_serverHost) || irCommands.Count == 0) + if (irCommands.Count == 0) { Console.WriteLine("Malformed command line parameters ..."); Console.WriteLine(); Modified: trunk/plugins/IR Server Suite/Applications/MacroScope/MacroScope.csproj =================================================================== --- trunk/plugins/IR Server Suite/Applications/MacroScope/MacroScope.csproj 2008-01-19 09:25:43 UTC (rev 1273) +++ trunk/plugins/IR Server Suite/Applications/MacroScope/MacroScope.csproj 2008-01-19 15:24:40 UTC (rev 1274) @@ -58,7 +58,7 @@ <Project>{21E04B17-D850-43E7-AAD3-876C0E062BDB}</Project> <Name>Command</Name> </ProjectReference> - <ProjectReference Include="..\..\Commands\Macro\Macro.csproj"> + <ProjectReference Include="..\..\Commands\CommandProcessor\CommandProcessor.csproj"> <Project>{49CF376E-811C-4EB4-817F-A39C9529B608}</Project> <Name>Macro</Name> </ProjectReference> Modified: trunk/plugins/IR Server Suite/Commands/Command/Command.csproj =================================================================== --- trunk/plugins/IR Server Suite/Commands/Command/Command.csproj 2008-01-19 09:25:43 UTC (rev 1273) +++ trunk/plugins/IR Server Suite/Commands/Command/Command.csproj 2008-01-19 15:24:40 UTC (rev 1274) @@ -39,6 +39,7 @@ <ItemGroup> <Compile Include="Command.cs" /> <Compile Include="CommandExecutionException.cs" /> + <Compile Include="CommandStructureException.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> </ItemGroup> <ItemGroup> Added: trunk/plugins/IR Server Suite/Commands/Command/CommandStructureException.cs =================================================================== --- trunk/plugins/IR Server Suite/Commands/Command/CommandStructureException.cs (rev 0) +++ trunk/plugins/IR Server Suite/Commands/Command/CommandStructureException.cs 2008-01-19 15:24:40 UTC (rev 1274) @@ -0,0 +1,41 @@ +using System; +using System.Runtime.Serialization; + +namespace Commands +{ + + /// <summary> + /// The exception that is thrown when a structural error in a command is discovered. + /// </summary> + [Serializable] + public class CommandStructureException : ApplicationException + { + + /// <summary> + /// Initializes a new instance of the <see cref="CommandStructureException"/> class. + /// </summary> + public CommandStructureException() : base() { } + + /// <summary> + /// Initializes a new instance of the <see cref="CommandStructureException"/> class. + /// </summary> + /// <param name="message">The message.</param> + public CommandStructureException(string message) : base(message) { } + + /// <summary> + /// Initializes a new instance of the <see cref="CommandStructureException"/> class. + /// </summary> + /// <param name="message">The message.</param> + /// <param name="innerException">The inner exception.</param> + public CommandStructureException(string message, Exception innerException) : base(message, innerException) { } + + /// <summary> + /// Initializes a new instance of the <see cref="CommandStructureException"/> class. + /// </summary> + /// <param name="info">The object that holds the serialized object data.</param> + /// <param name="context">The contextual information about the source or destination.</param> + protected CommandStructureException(SerializationInfo info, StreamingContext context) : base(info, context) { } + + } + +} Modified: trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandCallMacro.cs =================================================================== --- trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandCallMacro.cs 2008-01-19 09:25:43 UTC (rev 1273) +++ trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandCallMacro.cs 2008-01-19 15:24:40 UTC (rev 1274) @@ -49,18 +49,22 @@ /// <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})", GetUserInterfaceText(), fileName); } /// <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) + /// <param name="commandProcessor">The command processor.</param> + public void Execute(Processor commandProcessor) { Macro macro = new Macro(_parameters[0]); - macro.Execute(variables, blastIrDelegate); + macro.Execute(commandProcessor); } #endregion Implementation Modified: trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandClearVariables.cs =================================================================== --- trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandClearVariables.cs 2008-01-19 09:25:43 UTC (rev 1273) +++ trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandClearVariables.cs 2008-01-19 15:24:40 UTC (rev 1274) @@ -33,7 +33,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.CategoryMacro; } /// <summary> /// Gets the user interface text. Modified: trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandGotoLabel.cs =================================================================== --- trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandGotoLabel.cs 2008-01-19 09:25:43 UTC (rev 1273) +++ trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandGotoLabel.cs 2008-01-19 15:24:40 UTC (rev 1274) @@ -18,13 +18,13 @@ /// Initializes a new instance of the <see cref="CommandGotoLabel"/> class. /// </summary> public CommandGotoLabel() { InitParameters(1); } - + /// <summary> /// Initializes a new instance of the <see cref="CommandGotoLabel"/> class. /// </summary> /// <param name="parameters">The parameters.</param> public CommandGotoLabel(string[] parameters) : base(parameters) { } - + #endregion Constructors #region Implementation @@ -33,7 +33,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.CategoryMacro; } /// <summary> /// Gets the user interface text. @@ -42,15 +42,6 @@ public override string GetUserInterfaceText() { return "Goto Label"; } /// <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> /// Edit this command. /// </summary> /// <param name="parent">The parent window.</param> Modified: trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandIf.cs =================================================================== --- trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandIf.cs 2008-01-19 09:25:43 UTC (rev 1273) +++ trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandIf.cs 2008-01-19 15:24:40 UTC (rev 1274) @@ -7,7 +7,7 @@ { /// <summary> - /// If macro command. + /// If Statement macro command. /// </summary> public class CommandIf : Command { @@ -50,24 +50,15 @@ /// 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.CategoryMacro; } /// <summary> /// Gets the user interface text. /// </summary> /// <returns>User interface text.</returns> public override string GetUserInterfaceText() { return "If Statement"; } -/* + /// <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> /// Edit this command. /// </summary> /// <param name="parent">The parent window.</param> @@ -84,27 +75,34 @@ return false; } + #endregion Implementation + + #region Static Methods + /// <summary> - /// This method will determine if this If Command evaluates true. + /// This method will determine if an If Statement evaluates true. /// </summary> - /// <returns><c>true</c> if the command evaluates true, otherwise <c>false</c>.</returns> - public bool Evaluate() + /// <param name="value1">The first value for comparison.</param> + /// <param name="comparison">The comparison type.</param> + /// <param name="value2">The second value for comparison.</param> + /// <returns><c>true</c> if the parameters evaluates true, otherwise <c>false</c>.</returns> + public static bool Evaluate(string value1, string comparison, string value2) { int value1AsInt; - bool value1IsInt = int.TryParse(_parameters[0], out value1AsInt); + bool value1IsInt = int.TryParse(value1, out value1AsInt); int value2AsInt; - bool value2IsInt = int.TryParse(_parameters[2], out value2AsInt); + bool value2IsInt = int.TryParse(value2, out value2AsInt); bool comparisonResult = false; - switch (_parameters[1].ToUpperInvariant()) + switch (comparison.ToUpperInvariant()) { // Use string comparison ... - case IfEquals: comparisonResult = _parameters[0].Equals(_parameters[2], StringComparison.OrdinalIgnoreCase); break; - case IfNotEqual: comparisonResult = !_parameters[0].Equals(_parameters[2], StringComparison.OrdinalIgnoreCase); break; - case IfContains: comparisonResult = _parameters[0].ToUpperInvariant().Contains(_parameters[2].ToUpperInvariant()); break; - case IfStartsWith: comparisonResult = _parameters[0].ToUpperInvariant().StartsWith(_parameters[2].ToUpperInvariant()); break; - case IfEndsWith: comparisonResult = _parameters[0].ToUpperInvariant().EndsWith(_parameters[2].ToUpperInvariant()); break; + case IfEquals: comparisonResult = value1.Equals(value2, StringComparison.OrdinalIgnoreCase); break; + case IfNotEqual: comparisonResult = !value1.Equals(value2, StringComparison.OrdinalIgnoreCase); break; + case IfContains: comparisonResult = value1.ToUpperInvariant().Contains(value2.ToUpperInvariant()); break; + case IfStartsWith: comparisonResult = value1.ToUpperInvariant().StartsWith(value2.ToUpperInvariant()); break; + case IfEndsWith: comparisonResult = value1.ToUpperInvariant().EndsWith(value2.ToUpperInvariant()); break; // Use integer comparison ... case IfGreaterThan: @@ -128,14 +126,14 @@ break; default: - throw new InvalidOperationException(String.Format("Invalid variable comparison method: {0}", _parameters[1])); + throw new CommandStructureException(String.Format("Invalid variable comparison method: {0}", comparison)); } return comparisonResult; } - #endregion Implementation - + #endregion Static Methods + } } Modified: trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandLabel.cs =================================================================== --- trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandLabel.cs 2008-01-19 09:25:43 UTC (rev 1273) +++ trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandLabel.cs 2008-01-19 15:24:40 UTC (rev 1274) @@ -33,7 +33,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.CategoryMacro; } /// <summary> /// Gets the user interface text. @@ -42,15 +42,6 @@ public override string GetUserInterfaceText() { return "Label"; } /// <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> /// Edit this command. /// </summary> /// <param name="parent">The parent window.</param> Modified: trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandLoadVariables.cs =================================================================== --- trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandLoadVariables.cs 2008-01-19 09:25:43 UTC (rev 1273) +++ trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandLoadVariables.cs 2008-01-19 15:24:40 UTC (rev 1274) @@ -33,7 +33,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.CategoryMacro; } /// <summary> /// Gets the user interface text. @@ -42,15 +42,6 @@ public override string GetUserInterfaceText() { return "Load Variables"; } /// <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> /// Edit this command. /// </summary> /// <param name="parent">The parent window.</param> @@ -67,6 +58,15 @@ return false; } + /// <summary> + /// Execute this command. + /// </summary> + /// <param name="variables">The variable list of the calling code.</param> + public override void Execute(VariableList variables) + { + variables.Load(_parameters[0]); + } + #endregion Implementation } Added: trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandMathsOperation.cs =================================================================== --- trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandMathsOperation.cs (rev 0) +++ trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandMathsOperation.cs 2008-01-19 15:24:40 UTC (rev 1274) @@ -0,0 +1,123 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Windows.Forms; + +namespace Commands +{ + + /// <summary> + /// Maths Operation macro command. + /// </summary> + public class CommandMathsOperation : Command + { + + #region Maths Operations + + internal const string MathOpAdd = "Add"; + internal const string MathOpSubtract = "Subtract"; + internal const string MathOpMultiply = "Multiply"; + internal const string MathOpDivide = "Divide"; + internal const string MathOpModulo = "Modulo"; + internal const string MathOpPower = "Power"; + internal const string MathOpAbsolute = "Absolute"; + internal const string MathOpRoot = "Square Root"; + + // TODO: Add more maths operations + + //internal const string MathOpToBinary = "To Binary (Input 1)"; + //internal const string MathOpFromBinary = "From Binary (Input 1)"; + + //internal const string MathOpToHex = "To Hex (Input 1)"; + //internal const string MathOpFromHex = "From Hex (Input 1)"; + + //internal const string MathOpToOctal = "To Octal (Input 1)"; + //internal const string MathOpFromOctal = "From Octal (Input 1)"; + + #endregion Maths Operations + + #region Constructors + + /// <summary> + /// Initializes a new instance of the <see cref="CommandMathsOperation"/> class. + /// </summary> + public CommandMathsOperation() { InitParameters(4); } + + /// <summary> + /// Initializes a new instance of the <see cref="CommandMathsOperation"/> class. + /// </summary> + /// <param name="parameters">The parameters.</param> + public CommandMathsOperation(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.CategoryMacro; } + + /// <summary> + /// Gets the user interface text. + /// </summary> + /// <returns>User interface text.</returns> + public override string GetUserInterfaceText() { return "Maths Operation"; } + + /// <summary> + /// Edit this command. + /// </summary> + /// <param name="parent">The parent window.</param> + /// <returns><c>true</c> if the command was modified; otherwise <c>false</c>.</returns> + public override bool Edit(IWin32Window parent) + { + EditMathsOperation edit = new EditMathsOperation(_parameters); + if (edit.ShowDialog(parent) == DialogResult.OK) + { + _parameters = edit.Parameters; + return true; + } + + return false; + } + + /// <summary> + /// Execute this command. + /// </summary> + /// <param name="variables">The variable list of the calling code.</param> + public override void Execute(VariableList variables) + { + string input1 = Processor.ReplaceSpecial(_parameters[1]); + int input1Int = 0; + int.TryParse(input1, out input1Int); + + string input2 = Processor.ReplaceSpecial(_parameters[2]); + int input2Int = 0; + int.TryParse(input2, out input2Int); + + int output = 0; + + switch (_parameters[0]) + { + case MathOpAdd: output = input1Int + input2Int; break; + case MathOpDivide: output = input1Int / input2Int; break; + case MathOpModulo: output = input1Int % input2Int; break; + case MathOpMultiply: output = input1Int * input2Int; break; + case MathOpPower: output = (int)Math.Pow((double)input1Int, (double)input2Int); break; + case MathOpSubtract: output = input1Int - input2Int; break; + case MathOpAbsolute: output = Math.Abs(input1Int); break; + case MathOpRoot: output = (int)Math.Sqrt((double) input1Int); break; + + default: + throw new CommandStructureException(String.Format("Invalid Maths Operation: {0}", _parameters[0])); + } + + variables.SetVariable(_parameters[3], output.ToString()); + } + + #endregion Implementation + + } + +} Modified: trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandProcessor.csproj =================================================================== --- trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandProcessor.csproj 2008-01-19 09:25:43 UTC (rev 1273) +++ trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandProcessor.csproj 2008-01-19 15:24:40 UTC (rev 1274) @@ -38,6 +38,27 @@ <Reference Include="System.Xml" /> </ItemGroup> <ItemGroup> + <Compile Include="CommandStringOperation.cs" /> + <Compile Include="CommandSwapVariables.cs" /> + <Compile Include="CommandMathsOperation.cs" /> + <Compile Include="EditMathsOperation.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="EditMathsOperation.Designer.cs"> + <DependentUpon>EditMathsOperation.cs</DependentUpon> + </Compile> + <Compile Include="EditSwapVariables.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="EditSwapVariables.Designer.cs"> + <DependentUpon>EditSwapVariables.cs</DependentUpon> + </Compile> + <Compile Include="EditStringOperation.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="EditStringOperation.Designer.cs"> + <DependentUpon>EditStringOperation.cs</DependentUpon> + </Compile> <Compile Include="Processor.cs" /> <Compile Include="EditBlastIR.cs"> <SubType>Form</SubType> @@ -89,6 +110,18 @@ </Compile> </ItemGroup> <ItemGroup> + <EmbeddedResource Include="EditMathsOperation.resx"> + <DependentUpon>EditMathsOperation.cs</DependentUpon> + <SubType>Designer</SubType> + </EmbeddedResource> + <EmbeddedResource Include="EditSwapVariables.resx"> + <DependentUpon>EditSwapVariables.cs</DependentUpon> + <SubType>Designer</SubType> + </EmbeddedResource> + <EmbeddedResource Include="EditStringOperation.resx"> + <DependentUpon>EditStringOperation.cs</DependentUpon> + <SubType>Designer</SubType> + </EmbeddedResource> <EmbeddedResource Include="EditBlastIR.resx"> <DependentUpon>EditBlastIR.cs</DependentUpon> <SubType>Designer</SubType> Modified: trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandSaveVariables.cs =================================================================== --- trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandSaveVariables.cs 2008-01-19 09:25:43 UTC (rev 1273) +++ trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandSaveVariables.cs 2008-01-19 15:24:40 UTC (rev 1274) @@ -33,7 +33,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.CategoryMacro; } /// <summary> /// Gets the user interface text. @@ -42,15 +42,6 @@ public override string GetUserInterfaceText() { return "Save Variables"; } /// <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> /// Edit this command. /// </summary> /// <param name="parent">The parent window.</param> @@ -67,6 +58,15 @@ return false; } + /// <summary> + /// Execute this command. + /// </summary> + /// <param name="variables">The variable list of the calling code.</param> + public override void Execute(VariableList variables) + { + variables.Save(_parameters[0]); + } + #endregion Implementation } Modified: trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandSetVariable.cs =================================================================== --- trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandSetVariable.cs 2008-01-19 09:25:43 UTC (rev 1273) +++ trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandSetVariable.cs 2008-01-19 15:24:40 UTC (rev 1274) @@ -33,7 +33,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.CategoryMacro; } /// <summary> /// Gets the user interface text. @@ -42,15 +42,6 @@ public override string GetUserInterfaceText() { return "Set Variable"; } /// <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> /// Edit this command. /// </summary> /// <param name="parent">The parent window.</param> @@ -67,6 +58,17 @@ return false; } + /// <summary> + /// Execute this command. + /// </summary> + /// <param name="variables">The variable list of the calling code.</param> + public override void Execute(VariableList variables) + { + string value = Processor.ReplaceSpecial(_parameters[1]); + + variables.SetVariable(_parameters[0], value); + } + #endregion Implementation } Added: trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandStringOperation.cs =================================================================== --- trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandStringOperation.cs (rev 0) +++ trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandStringOperation.cs 2008-01-19 15:24:40 UTC (rev 1274) @@ -0,0 +1,106 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Windows.Forms; + +namespace Commands +{ + + /// <summary> + /// String Operation macro command. + /// </summary> + public class CommandStringOperation : Command + { + + #region String Operations + + internal const string StrOpConcatenate = "Join"; + internal const string StrOpTrim = "Trim"; + internal const string StrOpUpper = "Upper Case"; + internal const string StrOpLower = "Lower Case"; + + // TODO: Add more string operations + + //internal const string StrOpTrimStart = "Trim Start (Input 1)"; + //internal const string StrOpTrimEnd = "Trim End (Input 1)"; + //internal const string StrOpLeft = "Left (Input 1 by Input 2)"; + //internal const string StrOpRight = "Right (Input 1 by Input 2)"; + + #endregion String Operations + + #region Constructors + + /// <summary> + /// Initializes a new instance of the <see cref="CommandStringOperation"/> class. + /// </summary> + public CommandStringOperation() { InitParameters(4); } + + /// <summary> + /// Initializes a new instance of the <see cref="CommandStringOperation"/> class. + /// </summary> + /// <param name="parameters">The parameters.</param> + public CommandStringOperation(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.CategoryMacro; } + + /// <summary> + /// Gets the user interface text. + /// </summary> + /// <returns>User interface text.</returns> + public override string GetUserInterfaceText() { return "String Operation"; } + + /// <summary> + /// Edit this command. + /// </summary> + /// <param name="parent">The parent window.</param> + /// <returns><c>true</c> if the command was modified; otherwise <c>false</c>.</returns> + public override bool Edit(IWin32Window parent) + { + EditStringOperation edit = new EditStringOperation(_parameters); + if (edit.ShowDialog(parent) == DialogResult.OK) + { + _parameters = edit.Parameters; + return true; + } + + return false; + } + + /// <summary> + /// Execute this command. + /// </summary> + /// <param name="variables">The variable list of the calling code.</param> + public override void Execute(VariableList variables) + { + string input1 = Processor.ReplaceSpecial(_parameters[1]); + string input2 = Processor.ReplaceSpecial(_parameters[2]); + + string output = String.Empty; + + switch (_parameters[0]) + { + case StrOpConcatenate: output = input1 + input2; break; + case StrOpTrim: output = input1.Trim(); break; + case StrOpUpper: output = input1.ToUpper(); break; + case StrOpLower: output = input1.ToLower(); break; + + default: + throw new CommandStructureException(String.Format("Invalid String Operation: {0}", _parameters[0])); + } + + variables.SetVariable(_parameters[3], output); + } + + #endregion Implementation + + } + +} Added: trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandSwapVariables.cs =================================================================== --- trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandSwapVariables.cs (rev 0) +++ trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandSwapVariables.cs 2008-01-19 15:24:40 UTC (rev 1274) @@ -0,0 +1,78 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Windows.Forms; + +namespace Commands +{ + + /// <summary> + /// Swap Variables macro command. + /// </summary> + public class CommandSwapVariables : Command + { + + #region Constructors + + /// <summary> + /// Initializes a new instance of the <see cref="CommandSwapVariables"/> class. + /// </summary> + public CommandSwapVariables() { InitParameters(2); } + + /// <summary> + /// Initializes a new instance of the <see cref="CommandSwapVariables"/> class. + /// </summary> + /// <param name="parameters">The parameters.</param> + public CommandSwapVariables(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.CategoryMacro; } + + /// <summary> + /// Gets the user interface text. + /// </summary> + /// <returns>User interface text.</returns> + public override string GetUserInterfaceText() { return "Swap Variables"; } + + /// <summary> + /// Edit this command. + /// </summary> + /// <param name="parent">The parent window.</param> + /// <returns><c>true</c> if the command was modified; otherwise <c>false</c>.</returns> + public override bool Edit(IWin32Window parent) + { + EditSwapVariables edit = new EditSwapVariables(_parameters); + if (edit.ShowDialog(parent) == DialogResult.OK) + { + _parameters = edit.Parameters; + return true; + } + + return false; + } + + /// <summary> + /// Execute this command. + /// </summary> + /// <param name="variables">The variable list of the calling code.</param> + public override void Execute(VariableList variables) + { + string value0 = variables.GetVariable(_parameters[0]); + string value1 = variables.GetVariable(_parameters[1]); + + variables.SetVariable(_parameters[0], value1); + variables.SetVariable(_parameters[1], value0); + } + + #endregion Implementation + + } + +} Modified: trunk/plugins/IR Server Suite/Commands/CommandProcessor/EditBlastIR.cs =================================================================== --- trunk/plugins/IR Server Suite/Commands/CommandProcessor/EditBlastIR.cs 2008-01-19 09:25:43 UTC (rev 1273) +++ trunk/plugins/IR Server Suite/Commands/CommandProcessor/EditBlastIR.cs 2008-01-19 15:24:40 UTC (rev 1274) @@ -13,7 +13,7 @@ /// <summary> /// Edit Blast IR Command form. /// </summary> - public partial class EditBlastIR : Form + partial class EditBlastIR : Form { #region Properties Modified: trunk/plugins/IR Server Suite/Commands/CommandProcessor/EditMacro.Designer.cs =================================================================== --- trunk/plugins/IR Server Suite/Commands/CommandProcessor/EditMacro.Designer.cs 2008-01-19 09:25:43 UTC (rev 1273) +++ trunk/plugins/IR Server Suite/Commands/CommandProcessor/EditMacro.Designer.cs 2008-01-19 15:24:40 UTC (rev 1274) @@ -60,7 +60,7 @@ this.textBoxName.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.textBoxName.Location = new System.Drawing.Point(8, 16); this.textBoxName.Name = "textBoxName"; - this.textBoxName.Size = new System.Drawing.Size(294, 22); + this.textBoxName.Size = new System.Drawing.Size(300, 22); this.textBoxName.TabIndex = 0; this.toolTips.SetToolTip(this.textBoxName, "Provide a name for this macro (must be a valid windows file name)"); // @@ -75,7 +75,7 @@ this.groupBoxCommandSequence.Controls.Add(this.buttonMoveUp); this.groupBoxCommandSequence.Location = new System.Drawing.Point(0, 56); this.groupBoxCommandSequence.Name = "groupBoxCommandSequence"; - this.groupBoxCommandSequence.Size = new System.Drawing.Size(310, 232); + this.groupBoxCommandSequence.Size = new System.Drawing.Size(316, 304); this.groupBoxCommandSequence.TabIndex = 1; this.groupBoxCommandSequence.TabStop = false; this.groupBoxCommandSequence.Text = "Macro"; @@ -94,7 +94,7 @@ this.listViewMacro.Location = new System.Drawing.Point(8, 16); this.listViewMacro.Name = "listViewMacro"; this.listViewMacro.ShowGroups = false; - this.listViewMacro.Size = new System.Drawing.Size(294, 176); + this.listViewMacro.Size = new System.Drawing.Size(300, 248); this.listViewMacro.TabIndex = 0; this.listViewMacro.UseCompatibleStateImageBehavior = false; this.listViewMacro.View = System.Windows.Forms.View.Details; @@ -108,7 +108,7 @@ // buttonRemove // this.buttonRemove.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonRemove.Location = new System.Drawing.Point(246, 200); + this.buttonRemove.Location = new System.Drawing.Point(252, 272); this.buttonRemove.Name = "buttonRemove"; this.buttonRemove.Size = new System.Drawing.Size(56, 24); this.buttonRemove.TabIndex = 3; @@ -120,7 +120,7 @@ // buttonMoveDown // this.buttonMoveDown.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.buttonMoveDown.Location = new System.Drawing.Point(64, 200); + this.buttonMoveDown.Location = new System.Drawing.Point(64, 272); this.buttonMoveDown.Name = "buttonMoveDown"; this.buttonMoveDown.Size = new System.Drawing.Size(48, 24); this.buttonMoveDown.TabIndex = 2; @@ -132,7 +132,7 @@ // buttonMoveUp // this.buttonMoveUp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.buttonMoveUp.Location = new System.Drawing.Point(8, 200); + this.buttonMoveUp.Location = new System.Drawing.Point(8, 272); this.buttonMoveUp.Name = "buttonMoveUp"; this.buttonMoveUp.Size = new System.Drawing.Size(48, 24); this.buttonMoveUp.TabIndex = 1; @@ -147,7 +147,7 @@ this.groupBoxCommands.Dock = System.Windows.Forms.DockStyle.Fill; this.groupBoxCommands.Location = new System.Drawing.Point(0, 0); this.groupBoxCommands.Name = "groupBoxCommands"; - this.groupBoxCommands.Size = new System.Drawing.Size(156, 288); + this.groupBoxCommands.Size = new System.Drawing.Size(166, 360); this.groupBoxCommands.TabIndex = 0; this.groupBoxCommands.TabStop = false; this.groupBoxCommands.Text = "Commands"; @@ -159,7 +159,7 @@ | System.Windows.Forms.AnchorStyles.Right))); this.treeViewCommandList.Location = new System.Drawing.Point(8, 16); this.treeViewCommandList.Name = "treeViewCommandList"; - this.treeViewCommandList.Size = new System.Drawing.Size(140, 264); + this.treeViewCommandList.Size = new System.Drawing.Size(150, 336); this.treeViewCommandList.TabIndex = 0; this.treeViewCommandList.DoubleClick += new System.EventHandler(this.treeViewCommandList_DoubleClick); // @@ -167,7 +167,7 @@ // 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(424, 304); + this.buttonCancel.Location = new System.Drawing.Point(440, 376); this.buttonCancel.Name = "buttonCancel"; this.buttonCancel.Size = new System.Drawing.Size(56, 24); this.buttonCancel.TabIndex = 3; @@ -178,7 +178,7 @@ // 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, 304); + this.buttonTest.Location = new System.Drawing.Point(8, 376); this.buttonTest.Name = "buttonTest"; this.buttonTest.Size = new System.Drawing.Size(56, 24); this.buttonTest.TabIndex = 1; @@ -190,7 +190,7 @@ // 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(360, 304); + this.buttonOK.Location = new System.Drawing.Point(376, 376); this.buttonOK.Name = "buttonOK"; this.buttonOK.Size = new System.Drawing.Size(56, 24); this.buttonOK.TabIndex = 2; @@ -204,7 +204,7 @@ this.groupBoxMacroName.Dock = System.Windows.Forms.DockStyle.Top; this.groupBoxMacroName.Location = new System.Drawing.Point(0, 0); this.groupBoxMacroName.Name = "groupBoxMacroName"; - this.groupBoxMacroName.Size = new System.Drawing.Size(310, 48); + this.groupBoxMacroName.Size = new System.Drawing.Size(316, 48); this.groupBoxMacroName.TabIndex = 0; this.groupBoxMacroName.TabStop = false; this.groupBoxMacroName.Text = "Macro Name"; @@ -228,8 +228,8 @@ // this.splitContainer.Panel2.Controls.Add(this.groupBoxCommands); this.splitContainer.Panel2MinSize = 128; - this.splitContainer.Size = new System.Drawing.Size(472, 288); - this.splitContainer.SplitterDistance = 310; + this.splitContainer.Size = new System.Drawing.Size(488, 360); + this.splitContainer.SplitterDistance = 316; this.splitContainer.SplitterWidth = 6; this.splitContainer.TabIndex = 0; // @@ -237,13 +237,13 @@ // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(488, 337); + this.ClientSize = new System.Drawing.Size(504, 409); this.Controls.Add(this.buttonTest); this.Controls.Add(this.splitContainer); this.Controls.Add(this.buttonCancel); this.Controls.Add(this.buttonOK); this.MinimizeBox = false; - this.MinimumSize = new System.Drawing.Size(496, 364); + this.MinimumSize = new System.Drawing.Size(512, 436); this.Name = "EditMacro"; this.ShowIcon = false; this.ShowInTaskbar = false; Modified: trunk/plugins/IR Server Suite/Commands/CommandProcessor/EditMacro.cs =================================================================== --- trunk/plugins/IR Server Suite/Commands/CommandProcessor/EditMacro.cs 2008-01-19 09:25:43 UTC (rev 1273) +++ trunk/plugins/IR Server Suite/Commands/CommandProcessor/EditMacro.cs 2008-01-19 15:24:40 UTC (rev 1274) @@ -83,6 +83,7 @@ _commandProcessor = commandProcessor; _fileName = fileName; + _macroFolder = Path.GetDirectoryName(fileName); PopulateCommandList(categories); @@ -113,7 +114,7 @@ treeViewCommandList.Nodes.Clear(); Dictionary<string, TreeNode> treeNodes = new Dictionary<string,TreeNode>(categories.Length); - TreeNode macroCommands = new TreeNode(Macro.Category); + TreeNode macroCommands = new TreeNode(Processor.CategoryMacro); Type[] specialCommands = Processor.GetSpecialCommands(); foreach (Type type in specialCommands) { @@ -125,7 +126,7 @@ _commands.Add(command.GetUserInterfaceText(), type); } - treeNodes.Add(Macro.Category, macroCommands); + treeNodes.Add(Processor.CategoryMacro, macroCommands); foreach (string category in categories) treeNodes.Add(category, new TreeNode(category)); @@ -303,7 +304,7 @@ newMacro.Commands.Add(command); } - newMacro.Execute(_commandProcessor.Variables, _commandProcessor.BlastIr); + newMacro.Execute(_commandProcessor); } catch (Exception ex) { Added: trunk/plugins/IR Server Suite/Commands/CommandProcessor/EditMathsOperation.Designer.cs =================================================================== --- trunk/plugins/IR Server Suite/Commands/CommandProcessor/EditMathsOperation.Designer.cs (rev 0) +++ trunk/plugins/IR Server Suite/Commands/CommandProcessor/EditMathsOperation.Designer.cs 2008-01-19 15:24:40 UTC (rev 1274) @@ -0,0 +1,204 @@ +namespace Commands +{ + + partial class EditMathsOperation + { + /// <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.buttonOK = new System.Windows.Forms.Button(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.toolTips = new System.Windows.Forms.ToolTip(this.components); + this.textBoxInput1 = new System.Windows.Forms.TextBox(); + this.comboBoxOperation = new System.Windows.Forms.ComboBox(); + this.textBoxInput2 = new System.Windows.Forms.TextBox(); + this.labelOperation = new System.Windows.Forms.Label(); + this.labelInput1 = new System.Windows.Forms.Label(); + this.labelInput2 = new System.Windows.Forms.Label(); + this.labelVarPrefix = new System.Windows.Forms.Label(); + this.labelOutput = new System.Windows.Forms.Label(); + this.textBoxOutputVar = new System.Windows.Forms.TextBox(); + this.SuspendLayout(); + // + // 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(248, 136); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(64, 24); + this.buttonOK.TabIndex = 9; + 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(320, 136); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(64, 24); + this.buttonCancel.TabIndex = 10; + this.buttonCancel.Text = "Cancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); + // + // textBoxInput1 + // + this.textBoxInput1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.textBoxInput1.Location = new System.Drawing.Point(80, 40); + this.textBoxInput1.Name = "textBoxInput1"; + this.textBoxInput1.Size = new System.Drawing.Size(304, 20); + this.textBoxInput1.TabIndex = 3; + this.toolTips.SetToolTip(this.textBoxInput1, "The first operation input"); + // + // comboBoxOperation + // + this.comboBoxOperation.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.comboBoxOperation.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBoxOperation.FormattingEnabled = true; + this.comboBoxOperation.Location = new System.Drawing.Point(80, 8); + this.comboBoxOperation.Name = "comboBoxOperation"; + this.comboBoxOperation.Size = new System.Drawing.Size(304, 21); + this.comboBoxOperation.TabIndex = 1; + this.toolTips.SetToolTip(this.comboBoxOperation, "The string operation to perform"); + // + // textBoxInput2 + // + this.textBoxInput2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.textBoxInput2.Location = new System.Drawing.Point(80, 72); + this.textBoxInput2.Name = "textBoxInput2"; + this.textBoxInput2.Size = new System.Drawing.Size(304, 20); + this.textBoxInput2.TabIndex = 5; + this.toolTips.SetToolTip(this.textBoxInput2, "The second operation input (sometimes optional)"); + // + // labelOperation + // + this.labelOperation.Location = new System.Drawing.Point(8, 8); + this.labelOperation.Name = "labelOperation"; + this.labelOperation.Size = new System.Drawing.Size(72, 21); + this.labelOperation.TabIndex = 0; + this.labelOperation.Text = "Operation:"; + this.labelOperation.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // labelInput1 + // + this.labelInput1.Location = new System.Drawing.Point(8, 40); + this.labelInput1.Name = "labelInput1"; + this.labelInput1.Size = new System.Drawing.Size(72, 21); + this.labelInput1.TabIndex = 2; + this.labelInput1.Text = "Input 1:"; + this.labelInput1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + this.toolTips.SetToolTip(this.labelInput1, "The first input string"); + // + // labelInput2 + // + this.labelInput2.Location = new System.Drawing.Point(8, 72); + this.labelInput2.Name = "labelInput2"; + this.labelInput2.Size = new System.Drawing.Size(72, 21); + this.labelInput2.TabIndex = 4; + this.labelInput2.Text = "Input 2:"; + this.labelInput2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + this.toolTips.SetToolTip(this.labelInput2, "The second input string"); + // + // labelVarPrefix + // + this.labelVarPrefix.Location = new System.Drawing.Point(80, 104); + this.labelVarPrefix.Name = "labelVarPrefix"; + this.labelVarPrefix.Size = new System.Drawing.Size(32, 21); + this.labelVarPrefix.TabIndex = 7; + this.labelVarPrefix.Text = "var_"; + this.labelVarPrefix.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // labelOutput + // + this.labelOutput.Location = new System.Drawing.Point(8, 104); + this.labelOutput.Name = "labelOutput"; + this.labelOutput.Size = new System.Drawing.Size(72, 21); + this.labelOutput.TabIndex = 6; + this.labelOutput.Text = "Output:"; + this.labelOutput.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // textBoxOutputVar + // + this.textBoxOutputVar.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.textBoxOutputVar.Location = new System.Drawing.Point(112, 104); + this.textBoxOutputVar.Name = "textBoxOutputVar"; + this.textBoxOutputVar.Size = new System.Drawing.Size(272, 20); + this.textBoxOutputVar.TabIndex = 8; + this.toolTips.SetToolTip(this.textBoxOutputVar, "The variable to place the output of the operation into"); + // + // EditStringOperation + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(392, 169); + this.Controls.Add(this.labelVarPrefix); + this.Controls.Add(this.labelOutput); + this.Controls.Add(this.textBoxOutputVar); + this.Controls.Add(this.labelInput2); + this.Controls.Add(this.labelInput1); + this.Controls.Add(this.labelOperation); + this.Controls.Add(this.textBoxInput2); + this.Controls.Add(this.comboBoxOperation); + this.Controls.Add(this.textBoxInput1); + this.Controls.Add(this.buttonOK); + this.Controls.Add(this.buttonCancel); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.MinimumSize = new System.Drawing.Size(400, 196); + this.Name = "EditStringOperation"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "String Operation"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button buttonOK; + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.ToolTip toolTips; + private System.Windows.Forms.TextBox textBoxInput1; + private System.Windows.Forms.ComboBox comboBoxOperation; + private System.Windows.Forms.TextBox textBoxInput2; + private System.Windows.Forms.Label labelOperation; + private System.Windows.Forms.Label labelInput1; + private System.Windows.Forms.Label labelInput2; + private System.Windows.Forms.Label labelVarPrefix; + private System.Windows.Forms.Label labelOutput; + private System.Windows.Forms.TextBox textBoxOutputVar; + } + +} Added: trunk/plugins/IR Server Suite/Commands/CommandProcessor/EditMathsOperation.cs =================================================================== --- trunk/plugins/IR Server Suite/Commands/CommandProcessor/EditMathsOperation.cs (rev 0) +++ trunk/plugins/IR Server Suite/Commands/CommandProcessor/EditMathsOperation.cs 2008-01-19 15:24:40 UTC (rev 1274) @@ -0,0 +1,107 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Text; +using System.Windows.Forms; + +namespace Commands +{ + + /// <summary> + /// Edit Maths Operation Command form. + /// </summary> + partial class EditMathsOperation : Form + { + + #region Properties + + /// <summary> + /// Gets the command parameters. + /// </summary> + /// <value>The command parameters.</value> + public string[] Parameters + { + get + { + return new string[] { + comboBoxOperation.SelectedItem as string, + textBoxInput1.Text.Trim(), + textBoxInput2.Text.Trim(), + textBoxOutputVar.Text.Trim() + }; + } + } + + #endregion Properties + + #region Constructors + + /// <summary> + /// Initializes a new instance of the <see cref="EditMathsOperation"/> class. + /// </summary> + public EditMathsOperation() + { + InitializeComponent(); + + labelVarPrefix.Text = VariableList.VariablePrefix; + + comboBoxOperation.Items.Clear(); + comboBoxOperation.Items.Add(CommandMathsOperation.MathOpAbsolute); + comboBoxOperation.Items.Add(CommandMathsOperation.MathOpAdd); + comboBoxOperation.Items.Add(CommandMathsOperation.MathOpDivide); + comboBoxOperation.Items.Add(CommandMathsOperation.MathOpModulo); + comboBoxOperation.Items.Add(CommandMathsOperation.MathOpMultiply); + comboBoxOperation.Items.Add(CommandMathsOperation.MathOpPower); + comboBoxOperation.Items.Add(CommandMathsOperation.MathOpRoot); + comboBoxOperation.Items.Add(CommandMathsOperation.MathOpSubtract); + + comboBoxOperation.SelectedIndex = 0; + } + + /// <summary> + /// Initializes a new instance of the <see cref="EditMathsOperation"/> class. + /// </summary> + /// <param name="parameters">The parameters.</param> + public EditMathsOperation(string[] parameters) + : this() + { + comboBoxOperation.SelectedItem = parameters[0]; + textBoxInput1.Text = parameters[1]; + textBoxInput2.Text = parameters[2]; + textBoxOutputVar.Text = parameters[3]; + } + + #endregion Constructors + + #region Buttons + + private void buttonOK_Click(object sender, EventArgs e) + { + if (String.IsNullOrEmpty(textBoxInput1.Text.Trim())) + { + MessageBox.Show(this, "You must include at least the first input", "Missing first input", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + + if (String.IsNullOrEmpty(textBoxOutputVar.Text.Trim())) + ... [truncated message content] |