From: <an...@us...> - 2007-02-10 10:33:00
|
Revision: 108 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=108&view=rev Author: and-81 Date: 2007-02-10 02:32:57 -0800 (Sat, 10 Feb 2007) Log Message: ----------- Modified Paths: -------------- trunk/plugins/MCEReplacement/MCEReplacement.cs Modified: trunk/plugins/MCEReplacement/MCEReplacement.cs =================================================================== --- trunk/plugins/MCEReplacement/MCEReplacement.cs 2007-02-10 06:48:49 UTC (rev 107) +++ trunk/plugins/MCEReplacement/MCEReplacement.cs 2007-02-10 10:32:57 UTC (rev 108) @@ -1776,11 +1776,14 @@ } /// <summary> - /// Given a command name this method checks if the file exists as an IR code - /// or a macro and then processes the request accordingly. + /// Given a command this method checks if the file exists as an IR + /// command, macro or other command and then processes the request + /// accordingly. /// </summary> - /// <param name="command">The command name stored in the mapping XML</param> - /// <returns>success</returns> + /// <param name="command">Command to process.</param> + /// <param name="port">Blaster port to IR commands to.</param> + /// <param name="speed">Blaster speed to execute IR commands at.</param> + /// <returns>Success.</returns> public static bool ProcessCommand(string command, MceIrApi.BlasterPort port, MceIrApi.BlasterSpeed speed) { if (String.IsNullOrEmpty(command)) @@ -1874,15 +1877,15 @@ } else if (command.StartsWith(KeyCommandPrefix)) // Keystroke Command { - string commands = command.Substring(KeyCommandPrefix.Length); + string keyCommand = command.Substring(KeyCommandPrefix.Length); if (InConfiguration) { - MessageBox.Show(commands, "Keystroke Command", MessageBoxButtons.OK, MessageBoxIcon.Information); + MessageBox.Show(keyCommand, "Keystroke Command", MessageBoxButtons.OK, MessageBoxIcon.Information); return true; } else { - return ProcessKeyCommand(commands); + return ProcessKeyCommand(keyCommand); } } else if (command.StartsWith(GoToCommandPrefix)) // Go To Screen @@ -2098,14 +2101,22 @@ /// <returns>string[] of IR Commands</returns> public static string[] GetIRList() { - string[] files = Directory.GetFiles(AppDataFolder + IRFolder, "*" + IRExtension); - string[] list = new string[files.Length]; + try + { + string[] files = Directory.GetFiles(AppDataFolder + IRFolder, "*" + IRExtension); + string[] list = new string[files.Length]; - int i = 0; - foreach (string file in files) - list[i++] = IRFolder + Path.GetFileNameWithoutExtension(file).ToUpperInvariant(); + int i = 0; + foreach (string file in files) + list[i++] = IRFolder + Path.GetFileNameWithoutExtension(file).ToUpperInvariant(); - return list; + return list; + } + catch (Exception ex) + { + Log.Error(ex.Message); + return null; + } } /// <summary> @@ -2114,14 +2125,22 @@ /// <returns>string[] of Macros</returns> public static string[] GetMacroList() { - string[] files = Directory.GetFiles(AppDataFolder + MacroFolder, "*" + MacroExtension); - string[] list = new string[files.Length]; + try + { + string[] files = Directory.GetFiles(AppDataFolder + MacroFolder, "*" + MacroExtension); + string[] list = new string[files.Length]; - int i = 0; - foreach (string file in files) - list[i++] = MacroFolder + Path.GetFileNameWithoutExtension(file).ToUpperInvariant(); + int i = 0; + foreach (string file in files) + list[i++] = MacroFolder + Path.GetFileNameWithoutExtension(file).ToUpperInvariant(); - return list; + return list; + } + catch (Exception ex) + { + Log.Error(ex.Message); + return null; + } } /// <summary> @@ -2151,16 +2170,11 @@ /// <returns>Modified string with escape codes processed</returns> public static string ReplaceEscapeCodes(string input) { - if (input == null) + if (String.IsNullOrEmpty(input)) { - Log.Error("MCEReplacement: Null escape code string"); + Log.Error("MCEReplacement: Null or empty escape code string"); return ""; } - else if (input.Length == 0) - { - Log.Warn("MCEReplacement: Empty escape code string"); - return ""; - } bool inEscapeCode = false; bool inHexCode = false; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |