From: <an...@us...> - 2008-01-21 14:07:39
|
Revision: 1291 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=1291&view=rev Author: and-81 Date: 2008-01-21 06:07:12 -0800 (Mon, 21 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/Commands/CommandProcessor/CommandProcessor.csproj trunk/plugins/IR Server Suite/Commands/CommandProcessor/Forms/EditBlastIR.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/Forms/EditMacro.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/Forms/EditMathsOperation.Designer.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/Forms/EditMathsOperation.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/Forms/EditStringOperation.Designer.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/Forms/EditStringOperation.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/GeneralCommands/CommandKeystrokes.cs trunk/plugins/IR Server Suite/Commands/MediaPortalCommands/MediaPortalCommands.csproj trunk/plugins/IR Server Suite/Commands/TestApp/Program.cs trunk/plugins/IR Server Suite/Commands/TestApp/TestApp.csproj trunk/plugins/IR Server Suite/Commands/VariableList/VariableList.cs trunk/plugins/IR Server Suite/Documentation/new.html Added Paths: ----------- trunk/plugins/IR Server Suite/Commands/CommandProcessor/Control Statements/ trunk/plugins/IR Server Suite/Commands/CommandProcessor/Control Statements/CommandGotoLabel.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/Control Statements/CommandIf.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/Control Statements/CommandLabel.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/Control Statements/CommandSwitch.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/Forms/EditStackFile.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/Forms/EditStackFile.designer.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/Forms/EditStackFile.resx trunk/plugins/IR Server Suite/Commands/CommandProcessor/MacroExecutionException.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/Maths Operations/ trunk/plugins/IR Server Suite/Commands/CommandProcessor/Maths Operations/CommandMathsAbsolute.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/Maths Operations/CommandMathsAdd.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/Maths Operations/CommandMathsDivide.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/Maths Operations/CommandMathsModulo.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/Maths Operations/CommandMathsMultiply.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/Maths Operations/CommandMathsPower.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/Maths Operations/CommandMathsSquareRoot.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/Maths Operations/CommandMathsSubtract.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/Special Commands/ trunk/plugins/IR Server Suite/Commands/CommandProcessor/Special Commands/CommandBlastIR.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/Special Commands/CommandCallMacro.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/Stack Commands/ trunk/plugins/IR Server Suite/Commands/CommandProcessor/Stack Commands/CommandClearStack.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/Stack Commands/CommandLoadStack.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/Stack Commands/CommandPeekStack.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/Stack Commands/CommandPopStack.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/Stack Commands/CommandPushStack.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/Stack Commands/CommandSaveStack.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/String Operations/ trunk/plugins/IR Server Suite/Commands/CommandProcessor/String Operations/CommandStringJoin.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/String Operations/CommandStringToLower.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/String Operations/CommandStringToUpper.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/String Operations/CommandStringTrim.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/Variable Commands/ trunk/plugins/IR Server Suite/Commands/CommandProcessor/Variable Commands/CommandClearVariables.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/Variable Commands/CommandLoadVariables.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/Variable Commands/CommandSaveVariables.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/Variable Commands/CommandSetVariable.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/Variable Commands/CommandSwapVariables.cs Removed Paths: ------------- trunk/plugins/IR Server Suite/Commands/CommandProcessor/Commands/ Modified: trunk/plugins/IR Server Suite/Applications/IR Blast/Program.cs =================================================================== --- trunk/plugins/IR Server Suite/Applications/IR Blast/Program.cs 2008-01-21 07:03:10 UTC (rev 1290) +++ trunk/plugins/IR Server Suite/Applications/IR Blast/Program.cs 2008-01-21 14:07:12 UTC (rev 1291) @@ -29,6 +29,8 @@ static string _blastPort = "Default"; + static int _delay = 50; + static bool _treatAsChannelNumber; static int _padChannelNumber; @@ -68,6 +70,10 @@ _blastPort = args[++index]; continue; + case "-DELAY": + _delay = int.Parse(args[++index]); + continue; + case "-CHANNEL": _treatAsChannelNumber = true; continue; @@ -139,6 +145,9 @@ fileName = Common.FolderIRCommands + digit + Common.FileExtensionIR; BlastIR(fileName, _blastPort); } + + if (_delay > 0) + Thread.Sleep(_delay); } } else if (command.StartsWith("~", StringComparison.OrdinalIgnoreCase)) @@ -150,6 +159,9 @@ fileName = Common.FolderIRCommands + command; BlastIR(fileName, _blastPort); } + + if (_delay > 0) + Thread.Sleep(_delay); } Thread.Sleep(500); 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-21 07:03:10 UTC (rev 1290) +++ trunk/plugins/IR Server Suite/Applications/IR Blast (No Window)/Program.cs 2008-01-21 14:07:12 UTC (rev 1291) @@ -30,6 +30,8 @@ static string _blastPort = "Default"; + static int _delay = 50; + static bool _treatAsChannelNumber; static int _padChannelNumber; @@ -67,6 +69,10 @@ _blastPort = args[++index]; continue; + case "-DELAY": + _delay = int.Parse(args[++index]); + continue; + case "-CHANNEL": _treatAsChannelNumber = true; continue; @@ -138,6 +144,9 @@ fileName = Common.FolderIRCommands + digit + Common.FileExtensionIR; BlastIR(fileName, _blastPort); } + + if (_delay > 0) + Thread.Sleep(_delay); } } else if (command.StartsWith("~", StringComparison.OrdinalIgnoreCase)) @@ -149,6 +158,9 @@ fileName = Common.FolderIRCommands + command; BlastIR(fileName, _blastPort); } + + if (_delay > 0) + Thread.Sleep(_delay); } Thread.Sleep(500); @@ -157,9 +169,7 @@ { IrssLog.Warn("Failed to register with server host \"{0}\", blasting not sent", _serverHost); } - } - } } else // Give help ... Modified: trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandProcessor.csproj =================================================================== --- trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandProcessor.csproj 2008-01-21 07:03:10 UTC (rev 1290) +++ trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandProcessor.csproj 2008-01-21 14:07:12 UTC (rev 1291) @@ -38,10 +38,33 @@ <Reference Include="System.Xml" /> </ItemGroup> <ItemGroup> - <Compile Include="Commands\CommandStringOperation.cs" /> - <Compile Include="Commands\CommandSwapVariables.cs" /> - <Compile Include="Commands\CommandMathsOperation.cs" /> - <Compile Include="Commands\CommandSwitch.cs" /> + <Compile Include="MacroExecutionException.cs" /> + <Compile Include="Maths Operations\CommandMathsSubtract.cs" /> + <Compile Include="Maths Operations\CommandMathsMultiply.cs" /> + <Compile Include="Maths Operations\CommandMathsDivide.cs" /> + <Compile Include="Maths Operations\CommandMathsModulo.cs" /> + <Compile Include="Maths Operations\CommandMathsPower.cs" /> + <Compile Include="Maths Operations\CommandMathsAbsolute.cs" /> + <Compile Include="Maths Operations\CommandMathsSquareRoot.cs" /> + <Compile Include="String Operations\CommandStringJoin.cs" /> + <Compile Include="Forms\EditStackFile.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="Forms\EditStackFile.designer.cs"> + <DependentUpon>EditStackFile.cs</DependentUpon> + </Compile> + <Compile Include="Stack Commands\CommandClearStack.cs" /> + <Compile Include="Stack Commands\CommandLoadStack.cs" /> + <Compile Include="Stack Commands\CommandSaveStack.cs" /> + <Compile Include="Stack Commands\CommandPushStack.cs" /> + <Compile Include="Stack Commands\CommandPopStack.cs" /> + <Compile Include="Stack Commands\CommandPeekStack.cs" /> + <Compile Include="String Operations\CommandStringTrim.cs" /> + <Compile Include="String Operations\CommandStringToUpper.cs" /> + <Compile Include="String Operations\CommandStringToLower.cs" /> + <Compile Include="Variable Commands\CommandSwapVariables.cs" /> + <Compile Include="Maths Operations\CommandMathsAdd.cs" /> + <Compile Include="Control Statements\CommandSwitch.cs" /> <Compile Include="Forms\EditBlastIR.cs"> <SubType>Form</SubType> </Compile> @@ -103,15 +126,15 @@ <DependentUpon>EditVariablesFile.cs</DependentUpon> </Compile> <Compile Include="Processor.cs" /> - <Compile Include="Commands\CommandClearVariables.cs" /> - <Compile Include="Commands\CommandIf.cs" /> - <Compile Include="Commands\CommandLabel.cs" /> - <Compile Include="Commands\CommandGotoLabel.cs" /> - <Compile Include="Commands\CommandSetVariable.cs" /> - <Compile Include="Commands\CommandSaveVariables.cs" /> - <Compile Include="Commands\CommandLoadVariables.cs" /> - <Compile Include="Commands\CommandCallMacro.cs" /> - <Compile Include="Commands\CommandBlastIR.cs" /> + <Compile Include="Variable Commands\CommandClearVariables.cs" /> + <Compile Include="Control Statements\CommandIf.cs" /> + <Compile Include="Control Statements\CommandLabel.cs" /> + <Compile Include="Control Statements\CommandGotoLabel.cs" /> + <Compile Include="Variable Commands\CommandSetVariable.cs" /> + <Compile Include="Variable Commands\CommandSaveVariables.cs" /> + <Compile Include="Variable Commands\CommandLoadVariables.cs" /> + <Compile Include="Special Commands\CommandCallMacro.cs" /> + <Compile Include="Special Commands\CommandBlastIR.cs" /> <Compile Include="Macro.cs" /> <Compile Include="MacroStructureException.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> @@ -122,6 +145,10 @@ </Compile> </ItemGroup> <ItemGroup> + <EmbeddedResource Include="Forms\EditStackFile.resx"> + <DependentUpon>EditStackFile.cs</DependentUpon> + <SubType>Designer</SubType> + </EmbeddedResource> <EmbeddedResource Include="Forms\EditBlastIR.resx"> <DependentUpon>EditBlastIR.cs</DependentUpon> <SubType>Designer</SubType> @@ -169,11 +196,6 @@ </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> Added: trunk/plugins/IR Server Suite/Commands/CommandProcessor/Control Statements/CommandGotoLabel.cs =================================================================== --- trunk/plugins/IR Server Suite/Commands/CommandProcessor/Control Statements/CommandGotoLabel.cs (rev 0) +++ trunk/plugins/IR Server Suite/Commands/CommandProcessor/Control Statements/CommandGotoLabel.cs 2008-01-21 14:07:12 UTC (rev 1291) @@ -0,0 +1,74 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Windows.Forms; + +namespace Commands +{ + + /// <summary> + /// Goto Label macro command. + /// </summary> + public class CommandGotoLabel : Command + { + + #region Constructors + + /// <summary> + /// 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 + + /// <summary> + /// Gets the category of this command. + /// </summary> + /// <returns>The category of this command.</returns> + public override string GetCategory() { return Processor.CategoryControl; } + + /// <summary> + /// Gets the user interface text. + /// </summary> + /// <returns>User interface text.</returns> + 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(), Parameters[0]); + } + + /// <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) + { + EditLabel edit = new EditLabel(Parameters[0]); + if (edit.ShowDialog(parent) == DialogResult.OK) + { + Parameters[0] = edit.LabelName; + return true; + } + + return false; + } + + #endregion Implementation + + } + +} Added: trunk/plugins/IR Server Suite/Commands/CommandProcessor/Control Statements/CommandIf.cs =================================================================== --- trunk/plugins/IR Server Suite/Commands/CommandProcessor/Control Statements/CommandIf.cs (rev 0) +++ trunk/plugins/IR Server Suite/Commands/CommandProcessor/Control Statements/CommandIf.cs 2008-01-21 14:07:12 UTC (rev 1291) @@ -0,0 +1,151 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Windows.Forms; + +namespace Commands +{ + + /// <summary> + /// If Statement macro command. + /// </summary> + public class CommandIf : Command + { + + #region Comparisons + + // String comparisons ... + internal const string IfEquals = "=="; + internal const string IfNotEqual = "!="; + internal const string IfContains = "CONTAINS"; + internal const string IfStartsWith = "STARTS WITH"; + internal const string IfEndsWith = "ENDS WITH"; + + // Integer comparisons ... + internal const string IfGreaterThan = ">"; + internal const string IfLessThan = "<"; + internal const string IfGreaterThanOrEqual = ">="; + internal const string IfLessThanOrEqual = "<="; + + #endregion Comparisons + + #region Constructors + + /// <summary> + /// Initializes a new instance of the <see cref="CommandIf"/> class. + /// </summary> + public CommandIf() { InitParameters(5); } + + /// <summary> + /// Initializes a new instance of the <see cref="CommandIf"/> class. + /// </summary> + /// <param name="parameters">The parameters.</param> + public CommandIf(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.CategoryControl; } + + /// <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() + { + if (String.IsNullOrEmpty(Parameters[4])) + return String.Format("If ({0} {1} {2}) then goto \"{3}\"", Parameters[0], Parameters[1], Parameters[2], Parameters[3]); + else + return String.Format("If ({0} {1} {2}) then goto \"{3}\" else goto \"{4}\"", Parameters[0], Parameters[1], Parameters[2], Parameters[3], Parameters[4]); + } + + /// <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) + { + EditIf edit = new EditIf(Parameters); + if (edit.ShowDialog(parent) == DialogResult.OK) + { + Parameters = edit.Parameters; + return true; + } + + return false; + } + + #endregion Implementation + + #region Static Methods + + /// <summary> + /// This method will determine if an If Statement evaluates true. + /// </summary> + /// <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(value1, out value1AsInt); + + int value2AsInt; + bool value2IsInt = int.TryParse(value2, out value2AsInt); + + bool comparisonResult = false; + switch (comparison.ToUpperInvariant()) + { + // Use string comparison ... + 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.StartsWith(value2, StringComparison.OrdinalIgnoreCase); break; + case IfEndsWith: comparisonResult = value1.EndsWith(value2, StringComparison.OrdinalIgnoreCase); break; + + // Use integer comparison ... + case IfGreaterThan: + if (value1IsInt && value2IsInt) + comparisonResult = (value1AsInt > value2AsInt); + break; + + case IfLessThan: + if (value1IsInt && value2IsInt) + comparisonResult = (value1AsInt < value2AsInt); + break; + + case IfGreaterThanOrEqual: + if (value1IsInt && value2IsInt) + comparisonResult = (value1AsInt >= value2AsInt); + break; + + case IfLessThanOrEqual: + if (value1IsInt && value2IsInt) + comparisonResult = (value1AsInt <= value2AsInt); + break; + + default: + throw new CommandStructureException(String.Format("Invalid variable comparison method: {0}", comparison)); + } + + return comparisonResult; + } + + #endregion Static Methods + + } + +} Added: trunk/plugins/IR Server Suite/Commands/CommandProcessor/Control Statements/CommandLabel.cs =================================================================== --- trunk/plugins/IR Server Suite/Commands/CommandProcessor/Control Statements/CommandLabel.cs (rev 0) +++ trunk/plugins/IR Server Suite/Commands/CommandProcessor/Control Statements/CommandLabel.cs 2008-01-21 14:07:12 UTC (rev 1291) @@ -0,0 +1,74 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Windows.Forms; + +namespace Commands +{ + + /// <summary> + /// Label macro command. + /// </summary> + public class CommandLabel : Command + { + + #region Constructors + + /// <summary> + /// Initializes a new instance of the <see cref="CommandLabel"/> class. + /// </summary> + public CommandLabel() { InitParameters(1); } + + /// <summary> + /// Initializes a new instance of the <see cref="CommandLabel"/> class. + /// </summary> + /// <param name="parameters">The parameters.</param> + public CommandLabel(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.CategoryControl; } + + /// <summary> + /// Gets the user interface text. + /// </summary> + /// <returns>User interface text.</returns> + 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(), Parameters[0]); + } + + /// <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) + { + EditLabel edit = new EditLabel(Parameters[0]); + if (edit.ShowDialog(parent) == DialogResult.OK) + { + Parameters[0] = edit.LabelName; + return true; + } + + return false; + } + + #endregion Implementation + + } + +} Added: trunk/plugins/IR Server Suite/Commands/CommandProcessor/Control Statements/CommandSwitch.cs =================================================================== --- trunk/plugins/IR Server Suite/Commands/CommandProcessor/Control Statements/CommandSwitch.cs (rev 0) +++ trunk/plugins/IR Server Suite/Commands/CommandProcessor/Control Statements/CommandSwitch.cs 2008-01-21 14:07:12 UTC (rev 1291) @@ -0,0 +1,103 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; +using System.Windows.Forms; +using System.Xml; +using System.Xml.Serialization; + +namespace Commands +{ + + /// <summary> + /// Switch Statement macro command. + /// </summary> + public class CommandSwitch : Command + { + + #region Constructors + + /// <summary> + /// Initializes a new instance of the <see cref="CommandSwitch"/> class. + /// </summary> + public CommandSwitch() { InitParameters(3); } + + /// <summary> + /// Initializes a new instance of the <see cref="CommandSwitch"/> class. + /// </summary> + /// <param name="parameters">The parameters.</param> + public CommandSwitch(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.CategoryControl; } + + /// <summary> + /// Gets the user interface text. + /// </summary> + /// <returns>User interface text.</returns> + public override string GetUserInterfaceText() { return "Switch Statement"; } + + /// <summary> + /// Gets the user display text. + /// </summary> + /// <returns>The user display text.</returns> + public override string GetUserDisplayText() + { + return String.Format("Switch ({0}) ...", Parameters[0]); + } + + /// <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) + { + EditSwitch edit = new EditSwitch(Parameters); + if (edit.ShowDialog(parent) == DialogResult.OK) + { + Parameters = edit.Parameters; + return true; + } + + return false; + } + + #endregion Implementation + + #region Static Methods + + /// <summary> + /// This method will determine which (if any) case in a Switch Statement evaluates true. + /// </summary> + /// <param name="value">The value.</param> + /// <param name="casesXml">The cases XML.</param> + /// <returns>Label to goto (null for default).</returns> + public static string Evaluate(string value, string casesXml) + { + string[] cases; + using (StringReader stringReader = new StringReader(casesXml)) + { + XmlSerializer xmlSerializer = new XmlSerializer(typeof(string[])); + cases = (string[])xmlSerializer.Deserialize(stringReader); + } + + for (int index = 0; index < cases.Length; index += 2) + if (value.Equals(cases[index], StringComparison.OrdinalIgnoreCase)) + return cases[index + 1]; + + return null; + } + + #endregion Static Methods + + } + +} Modified: trunk/plugins/IR Server Suite/Commands/CommandProcessor/Forms/EditBlastIR.cs =================================================================== --- trunk/plugins/IR Server Suite/Commands/CommandProcessor/Forms/EditBlastIR.cs 2008-01-21 07:03:10 UTC (rev 1290) +++ trunk/plugins/IR Server Suite/Commands/CommandProcessor/Forms/EditBlastIR.cs 2008-01-21 14:07:12 UTC (rev 1291) @@ -6,7 +6,7 @@ using System.Text; using System.Windows.Forms; -using IrssUtils; +//using IrssUtils; namespace Commands { Modified: trunk/plugins/IR Server Suite/Commands/CommandProcessor/Forms/EditMacro.cs =================================================================== --- trunk/plugins/IR Server Suite/Commands/CommandProcessor/Forms/EditMacro.cs 2008-01-21 07:03:10 UTC (rev 1290) +++ trunk/plugins/IR Server Suite/Commands/CommandProcessor/Forms/EditMacro.cs 2008-01-21 14:07:12 UTC (rev 1291) @@ -10,7 +10,7 @@ using System.Windows.Forms; using System.Xml; -using IrssUtils; +//using IrssUtils; namespace Commands { @@ -21,13 +21,6 @@ public partial class EditMacro : Form { - #region Special Categories - - const string CategoryIRCommands = "IR Commands"; - const string CategoryMacros = "Macros"; - - #endregion Special Categories - #region Variables Processor _commandProcessor; @@ -133,82 +126,64 @@ //categoryNode.NodeFont = new Font(treeViewCommandList.Font, FontStyle.Underline); categoryNodes.Add(category, categoryNode); } - - Type[] libCommands = Common.GetLibraryCommands(); - if (libCommands != null) - { - foreach (Type type in libCommands) - { - Command command = (Command)Activator.CreateInstance(type); - string commandCategory = command.GetCategory(); + List<Type> allCommands = new List<Type>(); - if (categoryNodes.ContainsKey(commandCategory)) - { - TreeNode newNode = new TreeNode(command.GetUserInterfaceText()); - newNode.Tag = type; + Type[] specialCommands = Processor.GetBuiltInCommands(); + allCommands.AddRange(specialCommands); - categoryNodes[commandCategory].Nodes.Add(newNode); - } - } - } + Type[] libCommands = Common.GetLibraryCommands(); + if (libCommands != null) + allCommands.AddRange(libCommands); - // Add built-in macro commands ... - TreeNode macroCommands = new TreeNode(Processor.CategoryMacro); - //macroCommands.NodeFont = new Font(treeViewCommandList.Font, FontStyle.Underline); - - Type[] specialCommands = Processor.GetSpecialCommands(); - foreach (Type type in specialCommands) + foreach (Type type in allCommands) { Command command = (Command)Activator.CreateInstance(type); - //if (!command.GetCategory().Equals(Processor.CategoryHidden, StringComparison.OrdinalIgnoreCase)) + string commandCategory = command.GetCategory(); + + if (categoryNodes.ContainsKey(commandCategory)) { TreeNode newNode = new TreeNode(command.GetUserInterfaceText()); newNode.Tag = type; - macroCommands.Nodes.Add(newNode); + categoryNodes[commandCategory].Nodes.Add(newNode); } } - categoryNodes.Add(Processor.CategoryMacro, macroCommands); // Add list of existing IR Commands ... - string[] irFiles = Processor.GetListIR(); - if (irFiles != null) + if (categoryNodes.ContainsKey(Processor.CategoryIRCommands)) { - TreeNode irCommands = new TreeNode(CategoryIRCommands); - //irCommands.NodeFont = new Font(treeViewCommandList.Font, FontStyle.Underline); - - foreach (string irFile in irFiles) + string[] irFiles = Processor.GetListIR(); + if (irFiles != null) { - TreeNode newNode = new TreeNode(Path.GetFileNameWithoutExtension(irFile)); - newNode.Tag = irFile; + foreach (string irFile in irFiles) + { + TreeNode newNode = new TreeNode(Path.GetFileNameWithoutExtension(irFile)); + newNode.Tag = irFile; - irCommands.Nodes.Add(newNode); + categoryNodes[Processor.CategoryIRCommands].Nodes.Add(newNode); + } } - - categoryNodes.Add(irCommands.Text, irCommands); } // Add list of existing Macros ... - string macroFolder = _macroFolder; - if (String.IsNullOrEmpty(_macroFolder)) - macroFolder = Path.GetDirectoryName(_fileName); - string[] macros = Processor.GetListMacro(macroFolder); - if (macros != null) + if (categoryNodes.ContainsKey(Processor.CategoryMacros)) { - TreeNode otherMacros = new TreeNode(CategoryMacros); - //otherMacros.NodeFont = new Font(treeViewCommandList.Font, FontStyle.Underline); - - foreach (string macro in macros) + string macroFolder = _macroFolder; + if (String.IsNullOrEmpty(_macroFolder)) + macroFolder = Path.GetDirectoryName(_fileName); + string[] macros = Processor.GetListMacro(macroFolder); + if (macros != null) { - TreeNode newNode = new TreeNode(Path.GetFileNameWithoutExtension(macro)); - newNode.Tag = macro; + foreach (string macro in macros) + { + TreeNode newNode = new TreeNode(Path.GetFileNameWithoutExtension(macro)); + newNode.Tag = macro; - otherMacros.Nodes.Add(newNode); + categoryNodes[Processor.CategoryMacros].Nodes.Add(newNode); + } } - - categoryNodes.Add(otherMacros.Text, otherMacros); } // Put all commands into tree view ... @@ -225,23 +200,15 @@ if (listViewMacro.SelectedItems.Count != 1) return; - try - { - ListViewItem selected = listViewMacro.SelectedItems[0]; + ListViewItem selected = listViewMacro.SelectedItems[0]; - string selectedTag = selected.Tag as string; - Command command = Processor.CreateCommand(selectedTag); + string selectedTag = selected.Tag as string; + Command command = Processor.CreateCommand(selectedTag); - if (_commandProcessor.Edit(command, this)) - { - selected.Text = command.GetUserDisplayText(); - selected.Tag = command.ToString(); - } - } - catch (Exception ex) + if (_commandProcessor.Edit(command, this)) { - IrssLog.Error(ex); - MessageBox.Show(this, ex.Message, "Failed to edit macro command", MessageBoxButtons.OK, MessageBoxIcon.Error); + selected.Text = command.GetUserDisplayText(); + selected.Tag = command.ToString(); } } @@ -318,49 +285,41 @@ if (treeViewCommandList.SelectedNode == null || treeViewCommandList.SelectedNode.Level == 0) return; - try - { - string selected = treeViewCommandList.SelectedNode.Text as string; + string selected = treeViewCommandList.SelectedNode.Text as string; - ListViewItem newCommand = new ListViewItem(); - Command command; + ListViewItem newCommand = new ListViewItem(); + Command command; - if (treeViewCommandList.SelectedNode.Parent.Text.Equals(CategoryIRCommands, StringComparison.OrdinalIgnoreCase)) - { - command = new CommandBlastIR(new string[] { treeViewCommandList.SelectedNode.Tag as string, _commandProcessor.BlastIrPorts[0] }); + if (treeViewCommandList.SelectedNode.Parent.Text.Equals(Processor.CategoryIRCommands, StringComparison.OrdinalIgnoreCase)) + { + command = new CommandBlastIR(new string[] { treeViewCommandList.SelectedNode.Tag as string, _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(CategoryMacros, StringComparison.OrdinalIgnoreCase)) + if (_commandProcessor.Edit(command, this)) { - command = new CommandCallMacro(new string[] { treeViewCommandList.SelectedNode.Tag as string }); - newCommand.Text = command.GetUserDisplayText(); newCommand.Tag = command.ToString(); listViewMacro.Items.Add(newCommand); } - else - { - Type commandType = treeViewCommandList.SelectedNode.Tag as Type; - command = (Command)Activator.CreateInstance(commandType); + } + else if (treeViewCommandList.SelectedNode.Parent.Text.Equals(Processor.CategoryMacros, StringComparison.OrdinalIgnoreCase)) + { + command = new CommandCallMacro(new string[] { treeViewCommandList.SelectedNode.Tag as string }); - if (_commandProcessor.Edit(command, this)) - { - newCommand.Text = command.GetUserDisplayText(); - newCommand.Tag = command.ToString(); - listViewMacro.Items.Add(newCommand); - } - } + newCommand.Text = command.GetUserDisplayText(); + newCommand.Tag = command.ToString(); + listViewMacro.Items.Add(newCommand); } - catch (Exception ex) + else { - IrssLog.Error(ex); - MessageBox.Show(this, ex.Message, "Failed to add macro command", MessageBoxButtons.OK, MessageBoxIcon.Error); + Type commandType = treeViewCommandList.SelectedNode.Tag as Type; + command = (Command)Activator.CreateInstance(commandType); + + if (_commandProcessor.Edit(command, this)) + { + newCommand.Text = command.GetUserDisplayText(); + newCommand.Tag = command.ToString(); + listViewMacro.Items.Add(newCommand); + } } } @@ -432,7 +391,6 @@ } catch (Exception ex) { - IrssLog.Error(ex); MessageBox.Show(this, ex.Message, "Test failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } } @@ -478,7 +436,6 @@ } catch (Exception ex) { - IrssLog.Error(ex); MessageBox.Show(this, ex.Message, "Failed writing macro to file", MessageBoxButtons.OK, MessageBoxIcon.Error); } Modified: trunk/plugins/IR Server Suite/Commands/CommandProcessor/Forms/EditMathsOperation.Designer.cs =================================================================== --- trunk/plugins/IR Server Suite/Commands/CommandProcessor/Forms/EditMathsOperation.Designer.cs 2008-01-21 07:03:10 UTC (rev 1290) +++ trunk/plugins/IR Server Suite/Commands/CommandProcessor/Forms/EditMathsOperation.Designer.cs 2008-01-21 14:07:12 UTC (rev 1291) @@ -34,23 +34,21 @@ 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.textBoxOutputVar = new System.Windows.Forms.TextBox(); 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.Location = new System.Drawing.Point(248, 104); this.buttonOK.Name = "buttonOK"; this.buttonOK.Size = new System.Drawing.Size(64, 24); - this.buttonOK.TabIndex = 9; + this.buttonOK.TabIndex = 7; this.buttonOK.Text = "OK"; this.buttonOK.UseVisualStyleBackColor = true; this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); @@ -59,10 +57,10 @@ // 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.Location = new System.Drawing.Point(320, 104); this.buttonCancel.Name = "buttonCancel"; this.buttonCancel.Size = new System.Drawing.Size(64, 24); - this.buttonCancel.TabIndex = 10; + this.buttonCancel.TabIndex = 8; this.buttonCancel.Text = "Cancel"; this.buttonCancel.UseVisualStyleBackColor = true; this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); @@ -71,115 +69,92 @@ // 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.Location = new System.Drawing.Point(80, 8); this.textBoxInput1.Name = "textBoxInput1"; this.textBoxInput1.Size = new System.Drawing.Size(304, 20); - this.textBoxInput1.TabIndex = 3; + this.textBoxInput1.TabIndex = 1; 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.Location = new System.Drawing.Point(80, 40); this.textBoxInput2.Name = "textBoxInput2"; this.textBoxInput2.Size = new System.Drawing.Size(304, 20); - this.textBoxInput2.TabIndex = 5; + this.textBoxInput2.TabIndex = 3; 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.Location = new System.Drawing.Point(8, 8); this.labelInput1.Name = "labelInput1"; this.labelInput1.Size = new System.Drawing.Size(72, 21); - this.labelInput1.TabIndex = 2; + this.labelInput1.TabIndex = 0; 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.Location = new System.Drawing.Point(8, 40); this.labelInput2.Name = "labelInput2"; this.labelInput2.Size = new System.Drawing.Size(72, 21); - this.labelInput2.TabIndex = 4; + this.labelInput2.TabIndex = 2; this.labelInput2.Text = "Input 2:"; this.labelInput2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; this.toolTips.SetToolTip(this.labelInput2, "The second input string"); // + // 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, 72); + this.textBoxOutputVar.Name = "textBoxOutputVar"; + this.textBoxOutputVar.Size = new System.Drawing.Size(272, 20); + this.textBoxOutputVar.TabIndex = 6; + this.toolTips.SetToolTip(this.textBoxOutputVar, "The variable to place the output of the operation into"); + // // labelVarPrefix // - this.labelVarPrefix.Location = new System.Drawing.Point(80, 104); + this.labelVarPrefix.Location = new System.Drawing.Point(80, 72); this.labelVarPrefix.Name = "labelVarPrefix"; this.labelVarPrefix.Size = new System.Drawing.Size(32, 21); - this.labelVarPrefix.TabIndex = 7; + this.labelVarPrefix.TabIndex = 5; this.labelVarPrefix.Text = "var_"; this.labelVarPrefix.TextAlign = System.Drawing.ContentAlignment.MiddleRight; // // labelOutput // - this.labelOutput.Location = new System.Drawing.Point(8, 104); + this.labelOutput.Location = new System.Drawing.Point(8, 72); this.labelOutput.Name = "labelOutput"; this.labelOutput.Size = new System.Drawing.Size(72, 21); - this.labelOutput.TabIndex = 6; + this.labelOutput.TabIndex = 4; this.labelOutput.Text = "Output:"; this.labelOutput.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // - // textBoxOutputVar + // EditMathsOperation // - 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.ClientSize = new System.Drawing.Size(392, 137); 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.MinimumSize = new System.Drawing.Size(400, 164); + this.Name = "EditMathsOperation"; this.ShowIcon = false; this.ShowInTaskbar = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; - this.Text = "String Operation"; + this.Text = "Maths Operation"; this.ResumeLayout(false); this.PerformLayout(); @@ -191,9 +166,7 @@ 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; Modified: trunk/plugins/IR Server Suite/Commands/CommandProcessor/Forms/EditMathsOperation.cs =================================================================== --- trunk/plugins/IR Server Suite/Commands/CommandProcessor/Forms/EditMathsOperation.cs 2008-01-21 07:03:10 UTC (rev 1290) +++ trunk/plugins/IR Server Suite/Commands/CommandProcessor/Forms/EditMathsOperation.cs 2008-01-21 14:07:12 UTC (rev 1291) @@ -24,12 +24,10 @@ { get { - return new string[] { - comboBoxOperation.SelectedItem as string, - textBoxInput1.Text.Trim(), - textBoxInput2.Text.Trim(), - textBoxOutputVar.Text.Trim() - }; + if (labelInput2.Visible) + return new string[] { textBoxInput1.Text.Trim(), textBoxInput2.Text.Trim(), textBoxOutputVar.Text.Trim() }; + else + return new string[] { textBoxInput1.Text.Trim(), textBoxOutputVar.Text.Trim() }; } } @@ -45,18 +43,6 @@ 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> @@ -66,10 +52,23 @@ public EditMathsOperation(string[] parameters) : this() { - comboBoxOperation.SelectedItem = parameters[0]; - textBoxInput1.Text = parameters[1]; - textBoxInput2.Text = parameters[2]; - textBoxOutputVar.Text = parameters[3]; + if (parameters.Length == 3) + { + textBoxInput1.Text = parameters[0]; + textBoxInput2.Text = parameters[1]; + textBoxOutputVar.Text = parameters[2]; + } + else if (parameters.Length == 2) + { + textBoxInput1.Text = parameters[0]; + labelInput2.Visible = false; + textBoxInput2.Visible = false; + textBoxOutputVar.Text = parameters[1]; + } + else + { + throw new ArgumentException("Parameter array size must be 2 or 3", "parameters"); + } } #endregion Constructors Added: trunk/plugins/IR Server Suite/Commands/CommandProcessor/Forms/EditStackFile.cs =================================================================== --- trunk/plugins/IR Server Suite/Commands/CommandProcessor/Forms/EditStackFile.cs (rev 0) +++ trunk/plugins/IR Server Suite/Commands/CommandProcessor/Forms/EditStackFile.cs 2008-01-21 14:07:12 UTC (rev 1291) @@ -0,0 +1,81 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.IO; +using System.Text; +using System.Windows.Forms; + +namespace Commands +{ + + /// <summary> + /// Stack file filename collection form. + /// </summary> + partial class EditStackFile : Form + { + + #region Properties + + /// <summary> + /// Gets the file name. + /// </summary> + /// <value>The file name.</value> + public string FileName + { + get + { + return textBoxLabel.Text.Trim(); + } + } + + #endregion Properties + + #region Constructors + + /// <summary> + /// Initializes a new instance of the <see cref="EditStackFile"/> class. + /// </summary> + public EditStackFile() + { + InitializeComponent(); + } + + /// <summary> + /// Initializes a new instance of the <see cref="EditStackFile"/> class. + /// </summary> + /// <param name="name">The existing file name.</param> + public EditStackFile(string name) + : this() + { + if (!String.IsNullOrEmpty(name)) + textBoxLabel.Text = name; + } + + #endregion + + #region Buttons + + private void buttonOK_Click(object sender, EventArgs e) + { + if (String.IsNullOrEmpty(textBoxLabel.Text.Trim())) + { + MessageBox.Show(this, "You must include a stack file name", "Missing file name", MessageBoxButtons.OK, MessageBoxIcon.Warning); + return; + } + + this.DialogResult = DialogResult.OK; + this.Close(); + } + + private void buttonCancel_Click(object sender, EventArgs e) + { + this.DialogResult = DialogResult.Cancel; + this.Close(); + } + + #endregion Buttons + + } + +} Added: trunk/plugins/IR Server Suite/Commands/CommandProcessor/Forms/EditStackFile.designer.cs =================================================================== --- trunk/plugins/IR Server Suite/Commands/CommandProcessor/Forms/EditStackFile.designer.cs (rev 0) +++ trunk/plugins/IR Server Suite/Commands/CommandProcessor/Forms/EditStackFile.designer.cs 2008-01-21 14:07:12 UTC (rev 1291) @@ -0,0 +1,111 @@ +namespace Commands +{ + + partial class EditStackFile + { + + /// <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.buttonCancel = new System.Windows.Forms.Button(); + this.buttonOK = new System.Windows.Forms.Button(); + this.labelLabelName = new System.Windows.Forms.Label(); + this.textBoxLabel = new System.Windows.Forms.TextBox(); + this.SuspendLayout(); + // + // 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(120, 40); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(64, 24); + this.buttonCancel.TabIndex = 3; + this.buttonCancel.Text = "Cancel"; + this.buttonCancel.UseVisualStyleBackColor = true; + this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_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(48, 40); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(64, 24); + this.buttonOK.TabIndex = 2; + this.buttonOK.Text = "OK"; + this.buttonOK.UseVisualStyleBackColor = true; + this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); + // + // labelLabelName + // + this.labelLabelName.Location = new System.Drawing.Point(8, 8); + this.labelLabelName.Name = "labelLabelName"; + this.labelLabelName.Size = new System.Drawing.Size(56, 20); + this.labelLabelName.TabIndex = 0; + this.labelLabelName.Text = "File:"; + this.labelLabelName.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // + // textBoxLabel + // + this.textBoxLabel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.textBoxLabel.Location = new System.Drawing.Point(64, 8); + this.textBoxLabel.Name = "textBoxLabel"; + this.textBoxLabel.Size = new System.Drawing.Size(120, 20); + this.textBoxLabel.TabIndex = 1; + // + // EditStackFile + // + 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(192, 73); + this.Controls.Add(this.textBoxLabel); + this.Controls.Add(this.labelLabelName); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonOK); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.MinimumSize = new System.Drawing.Size(160, 100); + this.Name = "EditStackFile"; + this.ShowIcon = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Stack File"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.Button buttonOK; + private System.Windows.Forms.Label labelLabelName; + private System.Windows.Forms.TextBox textBoxLabel; + } + +} Added: trunk/plugins/IR Server Suite/Commands/CommandProcessor/Forms/EditStackFile.resx =================================================================== --- trunk/plugins/IR Server Suite/Commands/CommandProcessor/Forms/EditStackFile.resx (rev 0) +++ trunk/plugins/IR Server Suite/Commands/CommandProcessor/Forms/EditStackFile.resx 2008-01-21 14:07:12 UTC (rev 1291) @@ -0,0 +1,120 @@ +<?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 + ... [truncated message content] |