From: <an...@us...> - 2008-01-20 13:38:23
|
Revision: 1285 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=1285&view=rev Author: and-81 Date: 2008-01-20 05:38:06 -0800 (Sun, 20 Jan 2008) Log Message: ----------- Modified Paths: -------------- trunk/plugins/IR Server Suite/Commands/Command/Command.cs trunk/plugins/IR Server Suite/Commands/Command/CommandExecutionException.cs trunk/plugins/IR Server Suite/Commands/Command/CommandStructureException.cs trunk/plugins/IR Server Suite/Commands/Command/Properties/AssemblyInfo.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandBlastIR.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandCallMacro.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/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/CommandMathsOperation.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/CommandStringOperation.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandSwapVariables.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/EditMacro.resx trunk/plugins/IR Server Suite/Commands/CommandProcessor/MacroStructureException.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/Processor.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/Properties/AssemblyInfo.cs trunk/plugins/IR Server Suite/Commands/GeneralCommands/CommandKeystrokes.cs trunk/plugins/IR Server Suite/Commands/GeneralCommands/Properties/AssemblyInfo.cs trunk/plugins/IR Server Suite/Commands/MediaPortalCommands/CommandGotoScreen.cs trunk/plugins/IR Server Suite/Commands/MediaPortalCommands/Properties/AssemblyInfo.cs trunk/plugins/IR Server Suite/Commands/TestApp/Program.cs trunk/plugins/IR Server Suite/Commands/TestApp/Properties/AssemblyInfo.cs trunk/plugins/IR Server Suite/Commands/VariableList/Properties/AssemblyInfo.cs trunk/plugins/IR Server Suite/MediaPortal Plugins/MP Blast Zone Plugin/Forms/SetupForm.cs trunk/plugins/IR Server Suite/MediaPortal Plugins/MP Control Plugin/InputMapping/MPControlPlugin.xml Added Paths: ----------- trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandSwitch.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/Commands/ trunk/plugins/IR Server Suite/Commands/CommandProcessor/EditSwitch.Designer.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/EditSwitch.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/EditSwitch.resx trunk/plugins/IR Server Suite/Commands/CommandProcessor/Forms/ trunk/plugins/IR Server Suite/Commands/CommandProcessor/Graphics/ trunk/plugins/IR Server Suite/Commands/CommandProcessor/Graphics/Delete.png trunk/plugins/IR Server Suite/Commands/CommandProcessor/Graphics/DeleteAll.png trunk/plugins/IR Server Suite/Commands/CommandProcessor/Graphics/Edit.png trunk/plugins/IR Server Suite/Commands/CommandProcessor/Graphics/MoveBottom.png trunk/plugins/IR Server Suite/Commands/CommandProcessor/Graphics/MoveDown.png trunk/plugins/IR Server Suite/Commands/CommandProcessor/Graphics/MoveTop.png trunk/plugins/IR Server Suite/Commands/CommandProcessor/Graphics/MoveUp.png trunk/plugins/IR Server Suite/Commands/CommandProcessor/Graphics/Plus.png trunk/plugins/IR Server Suite/Commands/CommandProcessor/Properties/Resources.Designer.cs trunk/plugins/IR Server Suite/Commands/CommandProcessor/Properties/Resources.resx Modified: trunk/plugins/IR Server Suite/Commands/Command/Command.cs =================================================================== --- trunk/plugins/IR Server Suite/Commands/Command/Command.cs 2008-01-19 22:34:08 UTC (rev 1284) +++ trunk/plugins/IR Server Suite/Commands/Command/Command.cs 2008-01-20 13:38:06 UTC (rev 1285) @@ -19,17 +19,21 @@ /// <summary> /// Command parameters. /// </summary> - protected string[] _parameters; + string[] _parameters; #endregion Variables #region Properties /// <summary> - /// Gets the command parameters. + /// Gets or sets the command parameters. /// </summary> /// <value>The command parameters.</value> - public virtual string[] Parameters { get { return _parameters; } } + public virtual string[] Parameters + { + get { return _parameters; } + set { _parameters = value; } + } #endregion Properties @@ -38,13 +42,13 @@ /// <summary> /// Initializes a new instance of the <see cref="Command"/> class. /// </summary> - public Command() { } + protected Command() { } /// <summary> /// Initializes a new instance of the <see cref="Command"/> class. /// </summary> /// <param name="parameters">The command parameters.</param> - public Command(string[] parameters) { _parameters = parameters; } + protected Command(string[] parameters) { _parameters = parameters; } #endregion Constructors Modified: trunk/plugins/IR Server Suite/Commands/Command/CommandExecutionException.cs =================================================================== --- trunk/plugins/IR Server Suite/Commands/Command/CommandExecutionException.cs 2008-01-19 22:34:08 UTC (rev 1284) +++ trunk/plugins/IR Server Suite/Commands/Command/CommandExecutionException.cs 2008-01-20 13:38:06 UTC (rev 1285) @@ -8,7 +8,7 @@ /// The exception that is thrown when an error executing a command occurs. /// </summary> [Serializable] - public class CommandExecutionException : ApplicationException + public class CommandExecutionException : Exception { /// <summary> Modified: trunk/plugins/IR Server Suite/Commands/Command/CommandStructureException.cs =================================================================== --- trunk/plugins/IR Server Suite/Commands/Command/CommandStructureException.cs 2008-01-19 22:34:08 UTC (rev 1284) +++ trunk/plugins/IR Server Suite/Commands/Command/CommandStructureException.cs 2008-01-20 13:38:06 UTC (rev 1285) @@ -8,7 +8,7 @@ /// The exception that is thrown when a structural error in a command is discovered. /// </summary> [Serializable] - public class CommandStructureException : ApplicationException + public class CommandStructureException : Exception { /// <summary> Modified: trunk/plugins/IR Server Suite/Commands/Command/Properties/AssemblyInfo.cs =================================================================== --- trunk/plugins/IR Server Suite/Commands/Command/Properties/AssemblyInfo.cs 2008-01-19 22:34:08 UTC (rev 1284) +++ trunk/plugins/IR Server Suite/Commands/Command/Properties/AssemblyInfo.cs 2008-01-20 13:38:06 UTC (rev 1285) @@ -1,4 +1,5 @@ -using System.Reflection; +using System; +using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; @@ -33,3 +34,5 @@ // by using the '*' as shown below: [assembly: AssemblyVersion("1.0.4.2")] [assembly: AssemblyFileVersion("1.0.4.2")] + +[assembly: CLSCompliant(true)] \ No newline at end of file Modified: trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandBlastIR.cs =================================================================== --- trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandBlastIR.cs 2008-01-19 22:34:08 UTC (rev 1284) +++ trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandBlastIR.cs 2008-01-20 13:38:06 UTC (rev 1285) @@ -50,12 +50,12 @@ /// <returns>The user display text.</returns> public override string GetUserDisplayText() { - string fileName = _parameters[0]; + string fileName = Parameters[0]; - if (_parameters[0].StartsWith(Common.FolderAppData, StringComparison.OrdinalIgnoreCase)) - fileName = _parameters[0].Substring(Common.FolderAppData.Length); + if (Parameters[0].StartsWith(Common.FolderAppData, StringComparison.OrdinalIgnoreCase)) + fileName = Parameters[0].Substring(Common.FolderAppData.Length); - return String.Format("{0} ({1}, {2})", GetUserInterfaceText(), fileName, _parameters[1]); + return String.Format("{0} ({1}, {2})", GetUserInterfaceText(), fileName, Parameters[1]); } /// <summary> @@ -67,10 +67,10 @@ /// <returns><c>true</c> if the command was modified; otherwise <c>false</c>.</returns> public bool Edit(IWin32Window parent, BlastIrDelegate blastIrDelegate, string[] blastPorts) { - EditBlastIR edit = new EditBlastIR(blastIrDelegate, blastPorts, _parameters); + EditBlastIR edit = new EditBlastIR(blastIrDelegate, blastPorts, Parameters); if (edit.ShowDialog(parent) == DialogResult.OK) { - _parameters = edit.Parameters; + Parameters = edit.Parameters; return true; } @@ -83,8 +83,8 @@ /// <param name="blastIrDelegate">The blast ir delegate.</param> public void Execute(BlastIrDelegate blastIrDelegate) { - string irFile = _parameters[0] + Common.FileExtensionIR; - string port = _parameters[1]; + string irFile = Parameters[0] + Common.FileExtensionIR; + string port = Parameters[1]; blastIrDelegate(irFile, port); } Modified: trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandCallMacro.cs =================================================================== --- trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandCallMacro.cs 2008-01-19 22:34:08 UTC (rev 1284) +++ trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandCallMacro.cs 2008-01-20 13:38:06 UTC (rev 1285) @@ -50,10 +50,10 @@ /// <returns>The user display text.</returns> public override string GetUserDisplayText() { - string fileName = _parameters[0]; + string fileName = Parameters[0]; - if (_parameters[0].StartsWith(Common.FolderAppData, StringComparison.OrdinalIgnoreCase)) - fileName = _parameters[0].Substring(Common.FolderAppData.Length); + if (Parameters[0].StartsWith(Common.FolderAppData, StringComparison.OrdinalIgnoreCase)) + fileName = Parameters[0].Substring(Common.FolderAppData.Length); return String.Format("{0} ({1})", GetUserInterfaceText(), fileName); } @@ -64,7 +64,7 @@ /// <param name="commandProcessor">The command processor.</param> public void Execute(Processor commandProcessor) { - Macro macro = new Macro(_parameters[0]); + Macro macro = new Macro(Parameters[0]); macro.Execute(commandProcessor); } @@ -75,12 +75,12 @@ /// <returns><c>true</c> if the command was modified; otherwise <c>false</c>.</returns> public override bool Edit(IWin32Window parent) { - if (String.IsNullOrEmpty(_parameters[0])) + if (String.IsNullOrEmpty(Parameters[0])) { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "Macro Files|*" + Processor.FileExtensionMacro; if (openFileDialog.ShowDialog(parent) == DialogResult.OK) - _parameters[0] = Path.Combine(Path.GetDirectoryName(openFileDialog.FileName), Path.GetFileNameWithoutExtension(openFileDialog.FileName)); + Parameters[0] = Path.Combine(Path.GetDirectoryName(openFileDialog.FileName), Path.GetFileNameWithoutExtension(openFileDialog.FileName)); } return true; Modified: trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandGotoLabel.cs =================================================================== --- trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandGotoLabel.cs 2008-01-19 22:34:08 UTC (rev 1284) +++ trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandGotoLabel.cs 2008-01-20 13:38:06 UTC (rev 1285) @@ -48,10 +48,10 @@ /// <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]); + EditLabel edit = new EditLabel(Parameters[0]); if (edit.ShowDialog(parent) == DialogResult.OK) { - _parameters[0] = edit.LabelName; + Parameters[0] = edit.LabelName; return true; } Modified: trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandIf.cs =================================================================== --- trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandIf.cs 2008-01-19 22:34:08 UTC (rev 1284) +++ trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandIf.cs 2008-01-20 13:38:06 UTC (rev 1285) @@ -65,10 +65,10 @@ /// <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); + EditIf edit = new EditIf(Parameters); if (edit.ShowDialog(parent) == DialogResult.OK) { - _parameters = edit.Parameters; + Parameters = edit.Parameters; return true; } @@ -101,8 +101,8 @@ 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; + case IfStartsWith: comparisonResult = value1.StartsWith(value2, StringComparison.OrdinalIgnoreCase); break; + case IfEndsWith: comparisonResult = value1.EndsWith(value2, StringComparison.OrdinalIgnoreCase); break; // Use integer comparison ... case IfGreaterThan: Modified: trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandLabel.cs =================================================================== --- trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandLabel.cs 2008-01-19 22:34:08 UTC (rev 1284) +++ trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandLabel.cs 2008-01-20 13:38:06 UTC (rev 1285) @@ -48,10 +48,10 @@ /// <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]); + EditLabel edit = new EditLabel(Parameters[0]); if (edit.ShowDialog(parent) == DialogResult.OK) { - _parameters[0] = edit.LabelName; + Parameters[0] = edit.LabelName; return true; } Modified: trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandLoadVariables.cs =================================================================== --- trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandLoadVariables.cs 2008-01-19 22:34:08 UTC (rev 1284) +++ trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandLoadVariables.cs 2008-01-20 13:38:06 UTC (rev 1285) @@ -48,10 +48,10 @@ /// <returns><c>true</c> if the command was modified; otherwise <c>false</c>.</returns> public override bool Edit(IWin32Window parent) { - EditVariablesFile edit = new EditVariablesFile(_parameters[0]); + EditVariablesFile edit = new EditVariablesFile(Parameters[0]); if (edit.ShowDialog(parent) == DialogResult.OK) { - _parameters[0] = edit.FileName; + Parameters[0] = edit.FileName; return true; } @@ -64,7 +64,7 @@ /// <param name="variables">The variable list of the calling code.</param> public override void Execute(VariableList variables) { - variables.Load(_parameters[0]); + variables.Load(Parameters[0]); } #endregion Implementation Modified: trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandMathsOperation.cs =================================================================== --- trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandMathsOperation.cs 2008-01-19 22:34:08 UTC (rev 1284) +++ trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandMathsOperation.cs 2008-01-20 13:38:06 UTC (rev 1285) @@ -72,10 +72,10 @@ /// <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); + EditMathsOperation edit = new EditMathsOperation(Parameters); if (edit.ShowDialog(parent) == DialogResult.OK) { - _parameters = edit.Parameters; + Parameters = edit.Parameters; return true; } @@ -88,17 +88,17 @@ /// <param name="variables">The variable list of the calling code.</param> public override void Execute(VariableList variables) { - string input1 = Processor.ReplaceSpecial(_parameters[1]); + string input1 = Processor.ReplaceSpecial(Parameters[1]); int input1Int = 0; int.TryParse(input1, out input1Int); - string input2 = Processor.ReplaceSpecial(_parameters[2]); + string input2 = Processor.ReplaceSpecial(Parameters[2]); int input2Int = 0; int.TryParse(input2, out input2Int); int output = 0; - switch (_parameters[0]) + switch (Parameters[0]) { case MathOpAdd: output = input1Int + input2Int; break; case MathOpDivide: output = input1Int / input2Int; break; @@ -110,10 +110,10 @@ case MathOpRoot: output = (int)Math.Sqrt((double) input1Int); break; default: - throw new CommandStructureException(String.Format("Invalid Maths Operation: {0}", _parameters[0])); + throw new CommandStructureException(String.Format("Invalid Maths Operation: {0}", Parameters[0])); } - variables.SetVariable(_parameters[3], output.ToString()); + 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 22:34:08 UTC (rev 1284) +++ trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandProcessor.csproj 2008-01-20 13:38:06 UTC (rev 1285) @@ -41,6 +41,13 @@ <Compile Include="CommandStringOperation.cs" /> <Compile Include="CommandSwapVariables.cs" /> <Compile Include="CommandMathsOperation.cs" /> + <Compile Include="CommandSwitch.cs" /> + <Compile Include="EditSwitch.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="EditSwitch.Designer.cs"> + <DependentUpon>EditSwitch.cs</DependentUpon> + </Compile> <Compile Include="EditMathsOperation.cs"> <SubType>Form</SubType> </Compile> @@ -108,8 +115,17 @@ <Compile Include="EditVariablesFile.Designer.cs"> <DependentUpon>EditVariablesFile.cs</DependentUpon> </Compile> + <Compile Include="Properties\Resources.Designer.cs"> + <AutoGen>True</AutoGen> + <DesignTime>True</DesignTime> + <DependentUpon>Resources.resx</DependentUpon> + </Compile> </ItemGroup> <ItemGroup> + <EmbeddedResource Include="EditSwitch.resx"> + <DependentUpon>EditSwitch.cs</DependentUpon> + <SubType>Designer</SubType> + </EmbeddedResource> <EmbeddedResource Include="EditMathsOperation.resx"> <DependentUpon>EditMathsOperation.cs</DependentUpon> <SubType>Designer</SubType> @@ -146,6 +162,11 @@ <DependentUpon>EditVariablesFile.cs</DependentUpon> <SubType>Designer</SubType> </EmbeddedResource> + <EmbeddedResource Include="Properties\Resources.resx"> + <SubType>Designer</SubType> + <Generator>ResXFileCodeGenerator</Generator> + <LastGenOutput>Resources.Designer.cs</LastGenOutput> + </EmbeddedResource> </ItemGroup> <ItemGroup> <ProjectReference Include="..\..\Common\IrssUtils\IrssUtils.csproj"> @@ -164,6 +185,16 @@ <Private>False</Private> </ProjectReference> </ItemGroup> + <ItemGroup> + <Content Include="Graphics\Delete.png" /> + <Content Include="Graphics\DeleteAll.png" /> + <Content Include="Graphics\Edit.png" /> + <Content Include="Graphics\MoveBottom.png" /> + <Content Include="Graphics\MoveDown.png" /> + <Content Include="Graphics\MoveTop.png" /> + <Content Include="Graphics\MoveUp.png" /> + <Content Include="Graphics\Plus.png" /> + </ItemGroup> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets. Modified: trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandSaveVariables.cs =================================================================== --- trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandSaveVariables.cs 2008-01-19 22:34:08 UTC (rev 1284) +++ trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandSaveVariables.cs 2008-01-20 13:38:06 UTC (rev 1285) @@ -48,10 +48,10 @@ /// <returns><c>true</c> if the command was modified; otherwise <c>false</c>.</returns> public override bool Edit(IWin32Window parent) { - EditVariablesFile edit = new EditVariablesFile(_parameters[0]); + EditVariablesFile edit = new EditVariablesFile(Parameters[0]); if (edit.ShowDialog(parent) == DialogResult.OK) { - _parameters[0] = edit.FileName; + Parameters[0] = edit.FileName; return true; } @@ -64,7 +64,7 @@ /// <param name="variables">The variable list of the calling code.</param> public override void Execute(VariableList variables) { - variables.Save(_parameters[0]); + 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 22:34:08 UTC (rev 1284) +++ trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandSetVariable.cs 2008-01-20 13:38:06 UTC (rev 1285) @@ -48,10 +48,10 @@ /// <returns><c>true</c> if the command was modified; otherwise <c>false</c>.</returns> public override bool Edit(IWin32Window parent) { - EditSetVariable edit = new EditSetVariable(_parameters); + EditSetVariable edit = new EditSetVariable(Parameters); if (edit.ShowDialog(parent) == DialogResult.OK) { - _parameters = edit.Parameters; + Parameters = edit.Parameters; return true; } @@ -64,9 +64,9 @@ /// <param name="variables">The variable list of the calling code.</param> public override void Execute(VariableList variables) { - string value = Processor.ReplaceSpecial(_parameters[1]); + string value = Processor.ReplaceSpecial(Parameters[1]); - variables.SetVariable(_parameters[0], value); + variables.SetVariable(Parameters[0], value); } #endregion Implementation Modified: trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandStringOperation.cs =================================================================== --- trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandStringOperation.cs 2008-01-19 22:34:08 UTC (rev 1284) +++ trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandStringOperation.cs 2008-01-20 13:38:06 UTC (rev 1285) @@ -64,10 +64,10 @@ /// <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); + EditStringOperation edit = new EditStringOperation(Parameters); if (edit.ShowDialog(parent) == DialogResult.OK) { - _parameters = edit.Parameters; + Parameters = edit.Parameters; return true; } @@ -80,12 +80,12 @@ /// <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 input1 = Processor.ReplaceSpecial(Parameters[1]); + string input2 = Processor.ReplaceSpecial(Parameters[2]); string output = String.Empty; - switch (_parameters[0]) + switch (Parameters[0]) { case StrOpConcatenate: output = input1 + input2; break; case StrOpTrim: output = input1.Trim(); break; @@ -93,10 +93,10 @@ case StrOpLower: output = input1.ToLower(); break; default: - throw new CommandStructureException(String.Format("Invalid String Operation: {0}", _parameters[0])); + throw new CommandStructureException(String.Format("Invalid String Operation: {0}", Parameters[0])); } - variables.SetVariable(_parameters[3], output); + variables.SetVariable(Parameters[3], output); } #endregion Implementation Modified: trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandSwapVariables.cs =================================================================== --- trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandSwapVariables.cs 2008-01-19 22:34:08 UTC (rev 1284) +++ trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandSwapVariables.cs 2008-01-20 13:38:06 UTC (rev 1285) @@ -48,10 +48,10 @@ /// <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); + EditSwapVariables edit = new EditSwapVariables(Parameters); if (edit.ShowDialog(parent) == DialogResult.OK) { - _parameters = edit.Parameters; + Parameters = edit.Parameters; return true; } @@ -64,11 +64,11 @@ /// <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]); + string value0 = variables.GetVariable(Parameters[0]); + string value1 = variables.GetVariable(Parameters[1]); - variables.SetVariable(_parameters[0], value1); - variables.SetVariable(_parameters[1], value0); + variables.SetVariable(Parameters[0], value1); + variables.SetVariable(Parameters[1], value0); } #endregion Implementation Added: trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandSwitch.cs =================================================================== --- trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandSwitch.cs (rev 0) +++ trunk/plugins/IR Server Suite/Commands/CommandProcessor/CommandSwitch.cs 2008-01-20 13:38:06 UTC (rev 1285) @@ -0,0 +1,94 @@ +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.CategoryMacro; } + + /// <summary> + /// Gets the user interface text. + /// </summary> + /// <returns>User interface text.</returns> + public override string GetUserInterfaceText() { return "Switch Statement"; } + + /// <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/EditMacro.Designer.cs =================================================================== --- trunk/plugins/IR Server Suite/Commands/CommandProcessor/EditMacro.Designer.cs 2008-01-19 22:34:08 UTC (rev 1284) +++ trunk/plugins/IR Server Suite/Commands/CommandProcessor/EditMacro.Designer.cs 2008-01-20 13:38:06 UTC (rev 1285) @@ -34,9 +34,6 @@ this.groupBoxCommandSequence = new System.Windows.Forms.GroupBox(); this.listViewMacro = new System.Windows.Forms.ListView(); this.columnHeader = new System.Windows.Forms.ColumnHeader(); - this.buttonRemove = new System.Windows.Forms.Button(); - this.buttonMoveDown = new System.Windows.Forms.Button(); - this.buttonMoveUp = new System.Windows.Forms.Button(); this.groupBoxCommands = new System.Windows.Forms.GroupBox(); this.treeViewCommandList = new System.Windows.Forms.TreeView(); this.buttonCancel = new System.Windows.Forms.Button(); @@ -45,12 +42,23 @@ this.groupBoxMacroName = new System.Windows.Forms.GroupBox(); this.toolTips = new System.Windows.Forms.ToolTip(this.components); this.splitContainer = new System.Windows.Forms.SplitContainer(); + this.toolStripCommandSequence = new System.Windows.Forms.ToolStrip(); + this.toolStripButtonTop = new System.Windows.Forms.ToolStripButton(); + this.toolStripButtonUp = new System.Windows.Forms.ToolStripButton(); + this.toolStripButtonEdit = new System.Windows.Forms.ToolStripButton(); + this.toolStripButtonDelete = new System.Windows.Forms.ToolStripButton(); + this.toolStripButtonDeleteAll = new System.Windows.Forms.ToolStripButton(); + this.toolStripButtonDown = new System.Windows.Forms.ToolStripButton(); + this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); + this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator(); + this.toolStripButtonBottom = new System.Windows.Forms.ToolStripButton(); this.groupBoxCommandSequence.SuspendLayout(); this.groupBoxCommands.SuspendLayout(); this.groupBoxMacroName.SuspendLayout(); this.splitContainer.Panel1.SuspendLayout(); this.splitContainer.Panel2.SuspendLayout(); this.splitContainer.SuspendLayout(); + this.toolStripCommandSequence.SuspendLayout(); this.SuspendLayout(); // // textBoxName @@ -60,42 +68,36 @@ 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(324, 22); + this.textBoxName.Size = new System.Drawing.Size(488, 22); this.textBoxName.TabIndex = 0; this.toolTips.SetToolTip(this.textBoxName, "Provide a name for this macro (must be a valid windows file name)"); // // groupBoxCommandSequence // - this.groupBoxCommandSequence.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); this.groupBoxCommandSequence.Controls.Add(this.listViewMacro); - this.groupBoxCommandSequence.Controls.Add(this.buttonRemove); - this.groupBoxCommandSequence.Controls.Add(this.buttonMoveDown); - this.groupBoxCommandSequence.Controls.Add(this.buttonMoveUp); - this.groupBoxCommandSequence.Location = new System.Drawing.Point(0, 56); + this.groupBoxCommandSequence.Controls.Add(this.toolStripCommandSequence); + this.groupBoxCommandSequence.Dock = System.Windows.Forms.DockStyle.Fill; + this.groupBoxCommandSequence.Location = new System.Drawing.Point(0, 0); this.groupBoxCommandSequence.Name = "groupBoxCommandSequence"; - this.groupBoxCommandSequence.Size = new System.Drawing.Size(340, 304); - this.groupBoxCommandSequence.TabIndex = 1; + this.groupBoxCommandSequence.Size = new System.Drawing.Size(318, 232); + this.groupBoxCommandSequence.TabIndex = 0; this.groupBoxCommandSequence.TabStop = false; - this.groupBoxCommandSequence.Text = "Macro"; + this.groupBoxCommandSequence.Text = "Command Sequence"; // // listViewMacro // - this.listViewMacro.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); this.listViewMacro.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { this.columnHeader}); + this.listViewMacro.Dock = System.Windows.Forms.DockStyle.Fill; this.listViewMacro.FullRowSelect = true; this.listViewMacro.GridLines = true; - this.listViewMacro.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; + this.listViewMacro.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None; this.listViewMacro.HideSelection = false; - this.listViewMacro.Location = new System.Drawing.Point(8, 16); + this.listViewMacro.Location = new System.Drawing.Point(3, 16); this.listViewMacro.MultiSelect = false; this.listViewMacro.Name = "listViewMacro"; this.listViewMacro.ShowGroups = false; - this.listViewMacro.Size = new System.Drawing.Size(324, 248); + this.listViewMacro.Size = new System.Drawing.Size(280, 213); this.listViewMacro.TabIndex = 0; this.listViewMacro.UseCompatibleStateImageBehavior = false; this.listViewMacro.View = System.Windows.Forms.View.Details; @@ -103,64 +105,26 @@ // // columnHeader // - this.columnHeader.Text = "Commands"; - this.columnHeader.Width = 300; + this.columnHeader.Text = "Command Sequence"; + this.columnHeader.Width = 268; // - // 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(276, 272); - this.buttonRemove.Name = "buttonRemove"; - this.buttonRemove.Size = new System.Drawing.Size(56, 24); - this.buttonRemove.TabIndex = 3; - this.buttonRemove.Text = "Remove"; - this.toolTips.SetToolTip(this.buttonRemove, "Remove the selected command"); - this.buttonRemove.UseVisualStyleBackColor = true; - this.buttonRemove.Click += new System.EventHandler(this.buttonRemove_Click); - // - // 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, 272); - this.buttonMoveDown.Name = "buttonMoveDown"; - this.buttonMoveDown.Size = new System.Drawing.Size(48, 24); - this.buttonMoveDown.TabIndex = 2; - this.buttonMoveDown.Text = "Down"; - this.toolTips.SetToolTip(this.buttonMoveDown, "Move the selected command down one position"); - this.buttonMoveDown.UseVisualStyleBackColor = true; - this.buttonMoveDown.Click += new System.EventHandler(this.buttonMoveDown_Click); - // - // 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, 272); - this.buttonMoveUp.Name = "buttonMoveUp"; - this.buttonMoveUp.Size = new System.Drawing.Size(48, 24); - this.buttonMoveUp.TabIndex = 1; - this.buttonMoveUp.Text = "Up"; - this.toolTips.SetToolTip(this.buttonMoveUp, "Move the selected command up one position"); - this.buttonMoveUp.UseVisualStyleBackColor = true; - this.buttonMoveUp.Click += new System.EventHandler(this.buttonMoveUp_Click); - // // groupBoxCommands // this.groupBoxCommands.Controls.Add(this.treeViewCommandList); 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(190, 360); + this.groupBoxCommands.Size = new System.Drawing.Size(180, 232); this.groupBoxCommands.TabIndex = 0; this.groupBoxCommands.TabStop = false; this.groupBoxCommands.Text = "Commands"; // // treeViewCommandList // - this.treeViewCommandList.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.treeViewCommandList.Location = new System.Drawing.Point(8, 16); + this.treeViewCommandList.Dock = System.Windows.Forms.DockStyle.Fill; + this.treeViewCommandList.Location = new System.Drawing.Point(3, 16); this.treeViewCommandList.Name = "treeViewCommandList"; - this.treeViewCommandList.Size = new System.Drawing.Size(174, 336); + this.treeViewCommandList.Size = new System.Drawing.Size(174, 213); this.treeViewCommandList.TabIndex = 0; this.treeViewCommandList.DoubleClick += new System.EventHandler(this.treeViewCommandList_DoubleClick); // @@ -168,10 +132,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(488, 376); + this.buttonCancel.Location = new System.Drawing.Point(456, 304); this.buttonCancel.Name = "buttonCancel"; this.buttonCancel.Size = new System.Drawing.Size(56, 24); - this.buttonCancel.TabIndex = 3; + this.buttonCancel.TabIndex = 4; this.buttonCancel.Text = "Cancel"; this.buttonCancel.UseVisualStyleBackColor = true; this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); @@ -179,10 +143,10 @@ // 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, 376); + this.buttonTest.Location = new System.Drawing.Point(8, 304); this.buttonTest.Name = "buttonTest"; this.buttonTest.Size = new System.Drawing.Size(56, 24); - this.buttonTest.TabIndex = 1; + this.buttonTest.TabIndex = 2; this.buttonTest.Text = "Test"; this.toolTips.SetToolTip(this.buttonTest, "Test this macro"); this.buttonTest.UseVisualStyleBackColor = true; @@ -191,21 +155,22 @@ // 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(424, 376); + this.buttonOK.Location = new System.Drawing.Point(392, 304); this.buttonOK.Name = "buttonOK"; this.buttonOK.Size = new System.Drawing.Size(56, 24); - this.buttonOK.TabIndex = 2; + this.buttonOK.TabIndex = 3; this.buttonOK.Text = "OK"; this.buttonOK.UseVisualStyleBackColor = true; this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); // // groupBoxMacroName // + this.groupBoxMacroName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.groupBoxMacroName.Controls.Add(this.textBoxName); - this.groupBoxMacroName.Dock = System.Windows.Forms.DockStyle.Top; - this.groupBoxMacroName.Location = new System.Drawing.Point(0, 0); + this.groupBoxMacroName.Location = new System.Drawing.Point(8, 8); this.groupBoxMacroName.Name = "groupBoxMacroName"; - this.groupBoxMacroName.Size = new System.Drawing.Size(340, 48); + this.groupBoxMacroName.Size = new System.Drawing.Size(504, 48); this.groupBoxMacroName.TabIndex = 0; this.groupBoxMacroName.TabStop = false; this.groupBoxMacroName.Text = "Macro Name"; @@ -215,48 +180,151 @@ this.splitContainer.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.splitContainer.FixedPanel = System.Windows.Forms.FixedPanel.Panel2; - this.splitContainer.Location = new System.Drawing.Point(8, 8); + this.splitContainer.FixedPanel = System.Windows.Forms.FixedPanel.Panel1; + this.splitContainer.Location = new System.Drawing.Point(8, 64); this.splitContainer.Name = "splitContainer"; // // splitContainer.Panel1 // - this.splitContainer.Panel1.Controls.Add(this.groupBoxCommandSequence); - this.splitContainer.Panel1.Controls.Add(this.groupBoxMacroName); - this.splitContainer.Panel1MinSize = 256; + this.splitContainer.Panel1.Controls.Add(this.groupBoxCommands); + this.splitContainer.Panel1MinSize = 128; // // splitContainer.Panel2 // - this.splitContainer.Panel2.Controls.Add(this.groupBoxCommands); + this.splitContainer.Panel2.Controls.Add(this.groupBoxCommandSequence); this.splitContainer.Panel2MinSize = 128; - this.splitContainer.Size = new System.Drawing.Size(536, 360); - this.splitContainer.SplitterDistance = 340; + this.splitContainer.Size = new System.Drawing.Size(504, 232); + this.splitContainer.SplitterDistance = 180; this.splitContainer.SplitterWidth = 6; - this.splitContainer.TabIndex = 0; + this.splitContainer.TabIndex = 1; // + // toolStripCommandSequence + // + this.toolStripCommandSequence.Dock = System.Windows.Forms.DockStyle.Right; + this.toolStripCommandSequence.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden; + this.toolStripCommandSequence.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.toolStripButtonTop, + this.toolStripButtonUp, + this.toolStripSeparator1, + this.toolStripButtonEdit, + this.toolStripButtonDelete, + this.toolStripButtonDeleteAll, + this.toolStripSeparator2, + this.toolStripButtonDown, + this.toolStripButtonBottom}); + this.toolStripCommandSequence.Location = new System.Drawing.Point(283, 16); + this.toolStripCommandSequence.Name = "toolStripCommandSequence"; + this.toolStripCommandSequence.Size = new System.Drawing.Size(32, 213); + this.toolStripCommandSequence.TabIndex = 1; + this.toolStripCommandSequence.Text = "Command Sequence"; + // + // toolStripButtonTop + // + this.toolStripButtonTop.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.toolStripButtonTop.Image = global::Commands.Properties.Resources.MoveTop; + this.toolStripButtonTop.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolStripButtonTop.Name = "toolStripButtonTop"; + this.toolStripButtonTop.Size = new System.Drawing.Size(29, 20); + this.toolStripButtonTop.Text = "Move to Top"; + this.toolStripButtonTop.Click += new System.EventHandler(this.toolStripButtonTop_Click); + // + // toolStripButtonUp + // + this.toolStripButtonUp.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.toolStripButtonUp.Image = global::Commands.Properties.Resources.MoveUp; + this.toolStripButtonUp.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolStripButtonUp.Name = "toolStripButtonUp"; + this.toolStripButtonUp.Size = new System.Drawing.Size(29, 20); + this.toolStripButtonUp.Text = "Move Up"; + this.toolStripButtonUp.Click += new System.EventHandler(this.toolStripButtonUp_Click); + // + // toolStripButtonEdit + // + this.toolStripButtonEdit.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.toolStripButtonEdit.Image = global::Commands.Properties.Resources.Edit; + this.toolStripButtonEdit.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolStripButtonEdit.Name = "toolStripButtonEdit"; + this.toolStripButtonEdit.Size = new System.Drawing.Size(29, 20); + this.toolStripButtonEdit.Text = "Edit"; + this.toolStripButtonEdit.Click += new System.EventHandler(this.toolStripButtonEdit_Click); + // + // toolStripButtonDelete + // + this.toolStripButtonDelete.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.toolStripButtonDelete.Image = global::Commands.Properties.Resources.Delete; + this.toolStripButtonDelete.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolStripButtonDelete.Name = "toolStripButtonDelete"; + this.toolStripButtonDelete.Size = new System.Drawing.Size(29, 20); + this.toolStripButtonDelete.Text = "Delete"; + this.toolStripButtonDelete.Click += new System.EventHandler(this.toolStripButtonDelete_Click); + // + // toolStripButtonDeleteAll + // + this.toolStripButtonDeleteAll.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.toolStripButtonDeleteAll.Image = global::Commands.Properties.Resources.DeleteAll; + this.toolStripButtonDeleteAll.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolStripButtonDeleteAll.Name = "toolStripButtonDeleteAll"; + this.toolStripButtonDeleteAll.Size = new System.Drawing.Size(29, 20); + this.toolStripButtonDeleteAll.Text = "Delete All"; + this.toolStripButtonDeleteAll.Click += new System.EventHandler(this.toolStripButtonDeleteAll_Click); + // + // toolStripButtonDown + // + this.toolStripButtonDown.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.toolStripButtonDown.Image = global::Commands.Properties.Resources.MoveDown; + this.toolStripButtonDown.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolStripButtonDown.Name = "toolStripButtonDown"; + this.toolStripButtonDown.Size = new System.Drawing.Size(29, 20); + this.toolStripButtonDown.Text = "Move Down"; + this.toolStripButtonDown.Click += new System.EventHandler(this.toolStripButtonDown_Click); + // + // toolStripSeparator1 + // + this.toolStripSeparator1.Name = "toolStripSeparator1"; + this.toolStripSeparator1.Size = new System.Drawing.Size(29, 6); + // + // toolStripSeparator2 + // + this.toolStripSeparator2.Name = "toolStripSeparator2"; + this.toolStripSeparator2.Size = new System.Drawing.Size(29, 6); + // + // toolStripButtonBottom + // + this.toolStripButtonBottom.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image; + this.toolStripButtonBottom.Image = global::Commands.Properties.Resources.MoveBottom; + this.toolStripButtonBottom.ImageTransparentColor = System.Drawing.Color.Magenta; + this.toolStripButtonBottom.Name = "toolStripButtonBottom"; + this.toolStripButtonBottom.Size = new System.Drawing.Size(29, 20); + this.toolStripButtonBottom.Text = "Move to Bottom"; + this.toolStripButtonBottom.Click += new System.EventHandler(this.toolStripButtonBottom_Click); + // // EditMacro // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(552, 409); + this.ClientSize = new System.Drawing.Size(520, 337); + this.Controls.Add(this.groupBoxMacroName); 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(560, 436); + this.MinimumSize = new System.Drawing.Size(528, 364); this.Name = "EditMacro"; this.ShowIcon = false; this.ShowInTaskbar = false; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; this.Text = "Macro Editor"; this.groupBoxCommandSequence.ResumeLayout(false); + this.groupBoxCommandSequence.PerformLayout(); this.groupBoxCommands.ResumeLayout(false); this.groupBoxMacroName.ResumeLayout(false); this.groupBoxMacroName.PerformLayout(); this.splitContainer.Panel1.ResumeLayout(false); this.splitContainer.Panel2.ResumeLayout(false); this.splitContainer.ResumeLayout(false); + this.toolStripCommandSequence.ResumeLayout(false); + this.toolStripCommandSequence.PerformLayout(); this.ResumeLayout(false); } @@ -265,9 +333,6 @@ private System.Windows.Forms.TextBox textBoxName; private System.Windows.Forms.GroupBox groupBoxCommandSequence; - private System.Windows.Forms.Button buttonRemove; - private System.Windows.Forms.Button buttonMoveDown; - private System.Windows.Forms.Button buttonMoveUp; private System.Windows.Forms.GroupBox groupBoxCommands; private System.Windows.Forms.Button buttonCancel; private System.Windows.Forms.Button buttonTest; @@ -278,6 +343,16 @@ private System.Windows.Forms.ListView listViewMacro; private System.Windows.Forms.ColumnHeader columnHeader; private System.Windows.Forms.SplitContainer splitContainer; + private System.Windows.Forms.ToolStrip toolStripCommandSequence; + private System.Windows.Forms.ToolStripButton toolStripButtonTop; + private System.Windows.Forms.ToolStripButton toolStripButtonUp; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator1; + private System.Windows.Forms.ToolStripButton toolStripButtonEdit; + private System.Windows.Forms.ToolStripButton toolStripButtonDelete; + private System.Windows.Forms.ToolStripButton toolStripButtonDeleteAll; + private System.Windows.Forms.ToolStripSeparator toolStripSeparator2; + private System.Windows.Forms.ToolStripButton toolStripButtonDown; + private System.Windows.Forms.ToolStripButton toolStripButtonBottom; } } Modified: trunk/plugins/IR Server Suite/Commands/CommandProcessor/EditMacro.cs =================================================================== --- trunk/plugins/IR Server Suite/Commands/CommandProcessor/EditMacro.cs 2008-01-19 22:34:08 UTC (rev 1284) +++ trunk/plugins/IR Server Suite/Commands/CommandProcessor/EditMacro.cs 2008-01-20 13:38:06 UTC (rev 1285) @@ -33,6 +33,7 @@ Processor _commandProcessor; string _macroFolder; + string _fileName; Dictionary<string, Type> _commands; @@ -62,8 +63,9 @@ _commandProcessor = commandProcessor; _macroFolder = macroFolder; + _fileName = "New Macro"; - textBoxName.Text = "New"; + textBoxName.Text = _fileName; textBoxName.Enabled = true; PopulateCommandList(categories); @@ -73,13 +75,17 @@ /// Creates a Macro Editor windows form. /// </summary> /// <param name="commandProcessor">The command processor.</param> + /// <param name="macroFolder">The macro folder.</param> /// <param name="categories">The command categories to include.</param> /// <param name="fileName">Name of the macro file.</param> - public EditMacro(Processor commandProcessor, string[] categories, string fileName) + public EditMacro(Processor commandProcessor, string macroFolder, string[] categories, string fileName) { if (commandProcessor == null) throw new ArgumentNullException("commandProcessor"); + if (String.IsNullOrEmpty(macroFolder)) + throw new ArgumentNullException("macroFolder"); + if (categories == null) throw new ArgumentNullException("categories"); @@ -89,14 +95,16 @@ InitializeComponent(); _commandProcessor = commandProcessor; + _macroFolder = macroFolder; _fileName = fileName; - string macroName = fileName; + if (_fileName.StartsWith(_macroFolder, StringComparison.OrdinalIgnoreCase)) + _fileName = _fileName.Substring(macroFolder.Length); + + string macroName = _fileName; if (macroName.StartsWith(Common.FolderAppData, StringComparison.OrdinalIgnoreCase)) - macroName = fileName.Substring(Common.FolderAppData.Length); + macroName = macroName.Substring(Common.FolderAppData.Length); - _macroFolder = fileName.Substring(0, fileName.Length - macroName.Length); - textBoxName.Text = macroName; textBoxName.Enabled = false; @@ -204,6 +212,99 @@ treeViewCommandList.SelectedNode.Expand(); } + void EditMacroCommand() + { + if (listViewMacro.SelectedItems.Count != 1) + return; + + try + { + ListViewItem selected = listViewMacro.SelectedItems[0]; + + 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) + { + IrssLog.Error(ex); + MessageBox.Show(this, ex.Message, "Failed to edit macro command", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + void MoveToTop() + { + if (listViewMacro.SelectedItems.Count != 1) + return; + + int selected = listViewMacro.SelectedIndices[0]; + if (selected > 0) + { + ListViewItem item = listViewMacro.Items[selected]; + listViewMacro.Items.RemoveAt(selected); + listViewMacro.Items.Insert(0, item); + item.Selected = true; + } + } + void MoveUp() + { + if (listViewMacro.SelectedItems.Count != 1) + return; + + int selected = listViewMacro.SelectedIndices[0]; + if (selected > 0) + { + ListViewItem item = listViewMacro.Items[selected]; + listViewMacro.Items.RemoveAt(selected); + listViewMacro.Items.Insert(selected - 1, item); + item.Selected = true; + } + } + void MoveDown() + { + if (listViewMacro.SelectedItems.Count != 1) + return; + + int selected = listViewMacro.SelectedIndices[0]; + if (selected < listViewMacro.Items.Count - 1) + { + ListViewItem item = listViewMacro.Items[selected]; + listViewMacro.Items.RemoveAt(selected); + listViewMacro.Items.Insert(selected + 1, item); + item.Selected = true; + } + } + void MoveBottom() + { + if (listViewMacro.SelectedItems.Count != 1) + return; + + int selected = listViewMacro.SelectedIndices[0]; + if (selected < listViewMacro.Items.Count - 1) + { + ListViewItem item = listViewMacro.Items[selected]; + listViewMacro.Items.RemoveAt(selected); + listViewMacro.Items.Add(item); + item.Selected = true; + } + } + + void DeleteItem() + { + if (listViewMacro.SelectedItems.Count == 1) + listViewMacro.Items.RemoveAt(listViewMacro.SelectedIndices[0]); + } + void DeleteAllItems() + { + if (MessageBox.Show(this, "Are you sure you want to clear this entire macro?", "Clear macro", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) + listViewMacro.Clear(); + } + private void treeViewCommandList_DoubleClick(object sender, EventArgs e) { if (treeViewCommandList.SelectedNode == null || treeViewCommandList.SelectedNode.Level == 0) @@ -250,7 +351,7 @@ } else { - throw new ApplicationException(String.Format("Unknown macro command ({0})", selected)); + throw new MacroStructureException(String.Format("Unknown macro command ({0})", selected)); } } catch (Exception ex) @@ -259,41 +360,42 @@ MessageBox.Show(this, ex.Message, "Failed to add macro command", MessageBoxButtons.OK, MessageBoxIcon.Error); } } - - private void buttonMoveUp_Click(object sender, EventArgs e) + + private void listViewMacro_DoubleClick(object sender, EventArgs e) { - if (listViewMacro.SelectedItems.Count != 1) - return; - - int selected = listViewMacro.SelectedIndices[0]; - if (selected > 0) - { - ListViewItem item = listViewMacro.Items[selected]; - listViewMacro.Items.RemoveAt(selected); - listViewMacro.Items.Insert(selected - 1, item); - item.Selected = true; - } + EditMacroCommand(); } - private void buttonMoveDown_Click(object sender, EventArgs e) + + private void toolStripButtonTop_Click(object sender, EventArgs e) { - if (listViewMacro.SelectedItems.Count != 1) - return; + MoveToTop(); + } + private void toolStri... [truncated message content] |