From: <an...@us...> - 2007-11-27 15:53:10
|
Revision: 1092 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=1092&view=rev Author: and-81 Date: 2007-11-27 07:53:02 -0800 (Tue, 27 Nov 2007) Log Message: ----------- Modified Paths: -------------- trunk/plugins/MCEReplacement/Forms/ExternalChannels.cs trunk/plugins/MCEReplacement/Forms/MacroEditor.cs trunk/plugins/MCEReplacement/Forms/SetupForm.cs trunk/plugins/MCEReplacement/InputMapper/InputHandler.cs trunk/plugins/MCEReplacement/MCEReplacement.cs Modified: trunk/plugins/MCEReplacement/Forms/ExternalChannels.cs =================================================================== --- trunk/plugins/MCEReplacement/Forms/ExternalChannels.cs 2007-11-27 15:50:44 UTC (rev 1091) +++ trunk/plugins/MCEReplacement/Forms/ExternalChannels.cs 2007-11-27 15:53:02 UTC (rev 1092) @@ -153,7 +153,7 @@ else if (setup.PreChangeCommand.StartsWith(Common.CmdPrefixSerial)) ProcessSerialCommand(setup.PreChangeCommand.Substring(Common.CmdPrefixSerial.Length), -1, channel); else - MCEReplacement.ProcessCommand(setup.PreChangeCommand); + MCEReplacement.ProcessCommand(setup.PreChangeCommand, false); if (setup.PauseTime > 0) Thread.Sleep(setup.PauseTime); @@ -171,7 +171,7 @@ else if (command.StartsWith(Common.CmdPrefixSerial)) ProcessSerialCommand(command.Substring(Common.CmdPrefixSerial.Length), charVal, channel); else - MCEReplacement.ProcessCommand(command); + MCEReplacement.ProcessCommand(command, false); if (setup.PauseTime > 0) Thread.Sleep(setup.PauseTime); @@ -206,14 +206,14 @@ } else { - MCEReplacement.ProcessCommand(setup.SelectCommand); + MCEReplacement.ProcessCommand(setup.SelectCommand, false); if (setup.DoubleChannelSelect) { if (setup.PauseTime > 0) Thread.Sleep(setup.PauseTime); - MCEReplacement.ProcessCommand(setup.SelectCommand); + MCEReplacement.ProcessCommand(setup.SelectCommand, false); } } } Modified: trunk/plugins/MCEReplacement/Forms/MacroEditor.cs =================================================================== --- trunk/plugins/MCEReplacement/Forms/MacroEditor.cs 2007-11-27 15:50:44 UTC (rev 1091) +++ trunk/plugins/MCEReplacement/Forms/MacroEditor.cs 2007-11-27 15:53:02 UTC (rev 1092) @@ -543,7 +543,7 @@ try { - MCEReplacement.ProcessMacro(fileName); + MCEReplacement.ProcessCommand(Common.CmdPrefixMacro + name, false); } catch (Exception ex) { Modified: trunk/plugins/MCEReplacement/Forms/SetupForm.cs =================================================================== --- trunk/plugins/MCEReplacement/Forms/SetupForm.cs 2007-11-27 15:50:44 UTC (rev 1091) +++ trunk/plugins/MCEReplacement/Forms/SetupForm.cs 2007-11-27 15:53:02 UTC (rev 1092) @@ -440,9 +440,7 @@ try { - string fileName = MCEReplacement.MacroFolder + listViewMacro.SelectedItems[0].Text + Common.FileExtensionMacro; - - MCEReplacement.ProcessMacro(fileName); + MCEReplacement.ProcessCommand(Common.CmdPrefixMacro + listViewMacro.SelectedItems[0].Text, false); } catch (Exception ex) { Modified: trunk/plugins/MCEReplacement/InputMapper/InputHandler.cs =================================================================== --- trunk/plugins/MCEReplacement/InputMapper/InputHandler.cs 2007-11-27 15:50:44 UTC (rev 1091) +++ trunk/plugins/MCEReplacement/InputMapper/InputHandler.cs 2007-11-27 15:53:02 UTC (rev 1092) @@ -413,7 +413,7 @@ } break; case "BLAST": - MCEReplacement.ProcessCommand(map.CmdProperty); + MCEReplacement.ProcessCommand(map.CmdProperty, true); break; default: return false; Modified: trunk/plugins/MCEReplacement/MCEReplacement.cs =================================================================== --- trunk/plugins/MCEReplacement/MCEReplacement.cs 2007-11-27 15:50:44 UTC (rev 1091) +++ trunk/plugins/MCEReplacement/MCEReplacement.cs 2007-11-27 15:53:02 UTC (rev 1092) @@ -108,7 +108,7 @@ static int[] _mceRemoteMap; static int[] _differentRemoteMap; - static List<string> _macroStack; + static Hashtable _macroStacks; #endregion Variables @@ -340,6 +340,9 @@ Log.Info("MCEReplacement: Starting ({0})", PluginVersion); + // Hashtable for storing active macro stacks in. + _macroStacks = new Hashtable(); + // Load basic settings LoadSettings(); @@ -1137,7 +1140,7 @@ try { - ProcessCommand(mappedEvent.Command); + ProcessCommand(mappedEvent.Command, false); } catch (Exception ex) { @@ -1165,7 +1168,7 @@ try { - ProcessCommand(mappedEvent.Command); + ProcessCommand(mappedEvent.Command, false); } catch (Exception ex) { @@ -1241,7 +1244,7 @@ else if (command.StartsWith(Common.CmdPrefixSerial)) ProcessExternalSerialCommand(command.Substring(Common.CmdPrefixSerial.Length), -1, channel.ToString()); else - ProcessCommand(command); + ProcessCommand(command, false); if (config.PauseTime > 0) Thread.Sleep(config.PauseTime); @@ -1260,7 +1263,7 @@ else if (command.StartsWith(Common.CmdPrefixSerial)) ProcessExternalSerialCommand(command.Substring(Common.CmdPrefixSerial.Length), charVal, channel.ToString()); else - ProcessCommand(command); + ProcessCommand(command, false); if (config.PauseTime > 0) Thread.Sleep(config.PauseTime); @@ -1298,14 +1301,14 @@ } else { - ProcessCommand(command); + ProcessCommand(command, false); if (config.DoubleChannelSelect) { if (config.PauseTime > 0) Thread.Sleep(config.PauseTime); - ProcessCommand(command); + ProcessCommand(command, false); } } } @@ -1416,118 +1419,199 @@ MapEvent(MappedEvent.MappingEvent.PC_Resume); } - static void Hibernate() + /// <summary> + /// Learn an IR command. + /// </summary> + /// <param name="fileName">File to place learned IR command in (absolute path).</param> + /// <returns>true if successful, otherwise false.</returns> + internal static IRServerPluginInterface.LearnStatus LearnIR(string fileName) { - if (InConfiguration) - return; + IRServerPluginInterface.LearnStatus status = IRServerPluginInterface.LearnStatus.Failure; - GUIGraphicsContext.ResetLastActivity(); - // Stop all media before hibernating - g_Player.Stop(); + try + { + byte[] data; + status = _mceTransceiver.Learn(out data); - GUIMessage msg; + if (status == IRServerPluginInterface.LearnStatus.Success) + { + if (data == null || data.Length == 0) + throw new ApplicationException("No data learned"); - if (_mpBasicHome) - msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_GOTO_WINDOW, 0, 0, 0, (int)GUIWindow.Window.WINDOW_SECOND_HOME, 0, null); - else - msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_GOTO_WINDOW, 0, 0, 0, (int)GUIWindow.Window.WINDOW_HOME, 0, null); + using (FileStream file = File.Create(fileName)) + file.Write(data, 0, data.Length); + } + } + catch (Exception ex) + { + Log.Error("MCEReplacement: LearnIRCommand() {0}", ex.ToString()); + } - GUIWindowManager.SendThreadMessage(msg); - - OnSuspend(); - WindowsController.ExitWindows(RestartOptions.Hibernate, false); + return status; } - static void Standby() + /// <summary> + /// Blast an IR command. + /// </summary> + /// <param name="fileName">File to blast (absolute path).</param> + /// <param name="port">Port to blast to.</param> + internal static void BlastIR(string fileName, string port) { - if (InConfiguration) - return; + try + { + using (FileStream file = File.OpenRead(fileName)) + { + if (file.Length == 0) + { + Log.Error("MCEReplacement: IR file \"{0}\" has no data, possible IR learn failure", fileName); + return; + } - GUIGraphicsContext.ResetLastActivity(); - // Stop all media before suspending - g_Player.Stop(); + byte[] bytes = new byte[file.Length]; + file.Read(bytes, 0, (int)file.Length); - GUIMessage msg; + if (_mceTransceiver.Transmit(port, bytes)) + { + if (LogVerbose) + Log.Info("MCEReplacement: Blast successful"); - if (_mpBasicHome) - msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_GOTO_WINDOW, 0, 0, 0, (int)GUIWindow.Window.WINDOW_SECOND_HOME, 0, null); - else - msg = new GUIMessage(GUIMessage.MessageType.GUI_MSG_GOTO_WINDOW, 0, 0, 0, (int)GUIWindow.Window.WINDOW_HOME, 0, null); + return; + } + } + } + catch (Exception ex) + { + Log.Error("MCEReplacement: BlastIR() {0}", ex.ToString()); + } - GUIWindowManager.SendThreadMessage(msg); - - OnSuspend(); - WindowsController.ExitWindows(RestartOptions.Suspend, false); + Log.Error("MCEReplacement: Failed to blast IR file \"{0}\"", fileName); } - static void Reboot() - { - if (!InConfiguration) - GUIGraphicsContext.OnAction(new Action(Action.ActionType.ACTION_SHUTDOWN, 0, 0)); - } - - static void ShutDown() - { - if (!InConfiguration) - GUIGraphicsContext.OnAction(new Action(Action.ActionType.ACTION_REBOOT, 0, 0)); - } - /// <summary> - /// Adds to the Macro Stack. + /// Given a command this method processes the request accordingly. /// </summary> - /// <param name="fileName">Name of the macro file.</param> - static void MacroStackAdd(string fileName) + /// <param name="command">Command to process.</param> + /// <param name="async">Process command asynchronously?</param> + internal static void ProcessCommand(string command, bool async) { - string upperCasedFileName = fileName.ToUpperInvariant(); + if (String.IsNullOrEmpty(command)) + throw new ArgumentNullException("command"); - if (_macroStack == null) + if (async) { - _macroStack = new List<string>(); + Thread newThread = new Thread(new ParameterizedThreadStart(ProcCommand)); + newThread.Name = "ProcessCommand"; + newThread.Priority = ThreadPriority.BelowNormal; + newThread.Start(command); } - else if (_macroStack.Contains(upperCasedFileName)) + else { - StringBuilder macroStackTrace = new StringBuilder(); - macroStackTrace.AppendLine("Macro infinite loop detected!"); - macroStackTrace.AppendLine(); - macroStackTrace.AppendLine("Stack trace:"); - - foreach (string macro in _macroStack) - { - if (macro.Equals(upperCasedFileName)) - macroStackTrace.AppendLine(String.Format("--> {0}", macro)); - else - macroStackTrace.AppendLine(macro); - } - - macroStackTrace.AppendLine(String.Format("--> {0}", upperCasedFileName)); - - throw new ApplicationException(macroStackTrace.ToString()); + ProcCommand(command); } + } - _macroStack.Add(upperCasedFileName); - } /// <summary> - /// Removes from the Macro Stack. + /// Used by ProcessCommand to actually handle the command. + /// Can be called Synchronously or as a Parameterized Thread. /// </summary> - /// <param name="fileName">Name of the macro file.</param> - static void MacroStackRemove(string fileName) + /// <param name="commandObj">Command string to process.</param> + static void ProcCommand(object commandObj) { - string upperCasedFileName = fileName.ToUpperInvariant(); + string command = commandObj as string; - if (_macroStack.Contains(upperCasedFileName)) - _macroStack.Remove(upperCasedFileName); - - if (_macroStack.Count == 0) - _macroStack = null; + if (command.StartsWith(Common.CmdPrefixMacro, StringComparison.OrdinalIgnoreCase)) + { + string fileName = MacroFolder + command.Substring(Common.CmdPrefixMacro.Length) + Common.FileExtensionMacro; + ProcMacro(fileName); + } + else if (command.StartsWith(Common.CmdPrefixBlast, StringComparison.OrdinalIgnoreCase)) + { + string[] commands = Common.SplitBlastCommand(command.Substring(Common.CmdPrefixBlast.Length)); + BlastIR(IRFolder + commands[0] + Common.FileExtensionIR, commands[1]); + } + else if (command.StartsWith(Common.CmdPrefixSTB, StringComparison.OrdinalIgnoreCase)) + { + string[] commands = Common.SplitBlastCommand(command.Substring(Common.CmdPrefixSTB.Length)); + BlastIR(STBFolder + commands[0] + Common.FileExtensionIR, commands[1]); + } + else if (command.StartsWith(Common.CmdPrefixRun, StringComparison.OrdinalIgnoreCase)) + { + string[] commands = Common.SplitRunCommand(command.Substring(Common.CmdPrefixRun.Length)); + Common.ProcessRunCommand(commands); + } + else if (command.StartsWith(Common.CmdPrefixSerial, StringComparison.OrdinalIgnoreCase)) + { + string[] commands = Common.SplitSerialCommand(command.Substring(Common.CmdPrefixSerial.Length)); + Common.ProcessSerialCommand(commands); + } + else if (command.StartsWith(Common.CmdPrefixWindowMsg, StringComparison.OrdinalIgnoreCase)) + { + string[] commands = Common.SplitWindowMessageCommand(command.Substring(Common.CmdPrefixWindowMsg.Length)); + Common.ProcessWindowMessageCommand(commands); + } + else if (command.StartsWith(Common.CmdPrefixKeys, StringComparison.OrdinalIgnoreCase)) + { + string keyCommand = command.Substring(Common.CmdPrefixKeys.Length); + if (InConfiguration) + MessageBox.Show(keyCommand, Common.UITextKeys, MessageBoxButtons.OK, MessageBoxIcon.Information); + else + Common.ProcessKeyCommand(keyCommand); + } + else if (command.StartsWith(Common.CmdPrefixMouse, StringComparison.OrdinalIgnoreCase)) + { + string mouseCommand = command.Substring(Common.CmdPrefixMouse.Length); + Common.ProcessMouseCommand(mouseCommand); + } + else if (command.StartsWith(Common.CmdPrefixEject, StringComparison.OrdinalIgnoreCase)) + { + string ejectCommand = command.Substring(Common.CmdPrefixEject.Length); + Common.ProcessEjectCommand(ejectCommand); + } + else if (command.StartsWith(Common.CmdPrefixHibernate, StringComparison.OrdinalIgnoreCase)) + { + if (InConfiguration) + MessageBox.Show("Cannot Hibernate in configuration", Common.UITextHibernate, MessageBoxButtons.OK, MessageBoxIcon.Information); + else + MPCommon.Hibernate(); + } + else if (command.StartsWith(Common.CmdPrefixReboot, StringComparison.OrdinalIgnoreCase)) + { + if (InConfiguration) + MessageBox.Show("Cannot Reboot in configuration", Common.UITextReboot, MessageBoxButtons.OK, MessageBoxIcon.Information); + else + MPCommon.Reboot(); + } + else if (command.StartsWith(Common.CmdPrefixShutdown, StringComparison.OrdinalIgnoreCase)) + { + if (InConfiguration) + MessageBox.Show("Cannot Shutdown in configuration", Common.UITextShutdown, MessageBoxButtons.OK, MessageBoxIcon.Information); + else + MPCommon.ShutDown(); + } + else if (command.StartsWith(Common.CmdPrefixStandby, StringComparison.OrdinalIgnoreCase)) + { + if (InConfiguration) + MessageBox.Show("Cannot enter Standby in configuration", Common.UITextStandby, MessageBoxButtons.OK, MessageBoxIcon.Information); + else + MPCommon.Standby(); + } + else if (command.StartsWith(Common.CmdPrefixGoto, StringComparison.OrdinalIgnoreCase)) + { + MPCommon.ProcessGoTo(command.Substring(Common.CmdPrefixGoto.Length), MP_BasicHome); + } + else + { + throw new ArgumentException(String.Format("Cannot process unrecognized command \"{0}\"", command), "command"); + } } /// <summary> /// Process the supplied Macro file. /// </summary> /// <param name="fileName">Macro file to process (absolute path).</param> - internal static void ProcessMacro(string fileName) + static void ProcMacro(string fileName) { - MacroStackAdd(fileName); + MacroStackAdd(Thread.CurrentThread.ManagedThreadId, fileName); try { @@ -1545,7 +1629,7 @@ { case Common.XmlTagMacro: { - ProcessMacro(MacroFolder + commandProperty + Common.FileExtensionMacro); + ProcMacro(MacroFolder + commandProperty + Common.FileExtensionMacro); break; } @@ -1758,25 +1842,37 @@ case Common.XmlTagStandby: { - Standby(); + if (InConfiguration) + MessageBox.Show("Cannot enter Standby in configuration", Common.UITextStandby, MessageBoxButtons.OK, MessageBoxIcon.Information); + else + MPCommon.Standby(); break; } case Common.XmlTagHibernate: { - Hibernate(); + if (InConfiguration) + MessageBox.Show("Cannot Hibernate in configuration", Common.UITextHibernate, MessageBoxButtons.OK, MessageBoxIcon.Information); + else + MPCommon.Hibernate(); break; } case Common.XmlTagShutdown: { - ShutDown(); + if (InConfiguration) + MessageBox.Show("Cannot ShutDown in configuration", Common.UITextShutdown, MessageBoxButtons.OK, MessageBoxIcon.Information); + else + MPCommon.ShutDown(); break; } case Common.XmlTagReboot: { - Reboot(); + if (InConfiguration) + MessageBox.Show("Cannot Reboot in configuration", Common.UITextReboot, MessageBoxButtons.OK, MessageBoxIcon.Information); + else + MPCommon.Reboot(); break; } } @@ -1784,161 +1880,81 @@ } finally { - MacroStackRemove(fileName); + MacroStackRemove(Thread.CurrentThread.ManagedThreadId, fileName); } } - + /// <summary> - /// Learn an IR command. + /// Retreives the required Macro Stack from the Hashtable. /// </summary> - /// <param name="fileName">File to place learned IR command in (absolute path).</param> - /// <returns>true if successful, otherwise false.</returns> - internal static IRServerPluginInterface.LearnStatus LearnIR(string fileName) + /// <param name="hash">Hash table lookup value.</param> + /// <returns>Macro Stack.</returns> + static List<string> GetMacroStack(int hash) { - IRServerPluginInterface.LearnStatus status = IRServerPluginInterface.LearnStatus.Failure; - - try + if (_macroStacks.ContainsKey(hash)) { - byte[] data; - status = _mceTransceiver.Learn(out data); - - if (status == IRServerPluginInterface.LearnStatus.Success) - { - if (data == null || data.Length == 0) - throw new ApplicationException("No data learned"); - - using (FileStream file = File.Create(fileName)) - file.Write(data, 0, data.Length); - } + return (List<string>)_macroStacks[hash]; } - catch (Exception ex) + else { - Log.Error("MCEReplacement: LearnIRCommand() {0}", ex.ToString()); + List<string> newStack = new List<string>(); + _macroStacks.Add(hash, newStack); + return newStack; } - - return status; } /// <summary> - /// Blast an IR command. + /// Adds to the Macro Stack. /// </summary> - /// <param name="fileName">File to blast (absolute path).</param> - /// <param name="port">Port to blast to.</param> - internal static void BlastIR(string fileName, string port) + /// <param name="hash">Hash table lookup value.</param> + /// <param name="fileName">Name of the macro file.</param> + static void MacroStackAdd(int hash, string fileName) { - try + List<string> stack = GetMacroStack(hash); + + string upperCasedFileName = fileName.ToUpperInvariant(); + + if (stack.Contains(upperCasedFileName)) { - using (FileStream file = File.OpenRead(fileName)) + StringBuilder macroStackTrace = new StringBuilder(); + macroStackTrace.AppendLine("Macro infinite loop detected!"); + macroStackTrace.AppendLine(); + macroStackTrace.AppendLine("Stack trace:"); + + foreach (string macro in stack) { - if (file.Length == 0) - { - Log.Error("MCEReplacement: IR file \"{0}\" has no data, possible IR learn failure", fileName); - return; - } + if (macro.Equals(upperCasedFileName)) + macroStackTrace.AppendLine(String.Format("--> {0}", macro)); + else + macroStackTrace.AppendLine(macro); + } - byte[] bytes = new byte[file.Length]; - file.Read(bytes, 0, (int)file.Length); + macroStackTrace.AppendLine(String.Format("--> {0}", upperCasedFileName)); - if (_mceTransceiver.Transmit(port, bytes)) - { - if (LogVerbose) - Log.Info("MCEReplacement: Blast successful"); - - return; - } - } + throw new ApplicationException(macroStackTrace.ToString()); } - catch (Exception ex) - { - Log.Error("MCEReplacement: BlastIR() {0}", ex.ToString()); - } - Log.Error("MCEReplacement: Failed to blast IR file \"{0}\"", fileName); + stack.Add(upperCasedFileName); } /// <summary> - /// Given a command this method processes the request accordingly. + /// Removes from the Macro Stack. /// </summary> - /// <param name="command">Command to process.</param> - internal static void ProcessCommand(string command) + /// <param name="hash">Hash table lookup value.</param> + /// <param name="fileName">Name of the macro file.</param> + static void MacroStackRemove(int hash, string fileName) { - if (String.IsNullOrEmpty(command)) - throw new ArgumentNullException("command"); + List<string> stack = GetMacroStack(hash); - if (command.StartsWith(Common.CmdPrefixMacro, StringComparison.OrdinalIgnoreCase)) // Macro - { - string fileName = MacroFolder + command.Substring(Common.CmdPrefixMacro.Length) + Common.FileExtensionMacro; - ProcessMacro(fileName); - } - else if (command.StartsWith(Common.CmdPrefixBlast, StringComparison.OrdinalIgnoreCase)) // IR Code - { - string[] commands = Common.SplitBlastCommand(command.Substring(Common.CmdPrefixBlast.Length)); - BlastIR(IRFolder + commands[0] + Common.FileExtensionIR, commands[1]); - } - else if (command.StartsWith(Common.CmdPrefixSTB, StringComparison.OrdinalIgnoreCase)) // STB IR Code - { - string[] commands = Common.SplitBlastCommand(command.Substring(Common.CmdPrefixSTB.Length)); - BlastIR(STBFolder + commands[0] + Common.FileExtensionIR, commands[1]); - } - else if (command.StartsWith(Common.CmdPrefixRun, StringComparison.OrdinalIgnoreCase)) // External Program - { - string[] commands = Common.SplitRunCommand(command.Substring(Common.CmdPrefixRun.Length)); - Common.ProcessRunCommand(commands); - } - else if (command.StartsWith(Common.CmdPrefixSerial, StringComparison.OrdinalIgnoreCase)) // Serial Port Command - { - string[] commands = Common.SplitSerialCommand(command.Substring(Common.CmdPrefixSerial.Length)); - Common.ProcessSerialCommand(commands); - } - else if (command.StartsWith(Common.CmdPrefixWindowMsg, StringComparison.OrdinalIgnoreCase)) // Message Command - { - string[] commands = Common.SplitWindowMessageCommand(command.Substring(Common.CmdPrefixWindowMsg.Length)); - Common.ProcessWindowMessageCommand(commands); - } - else if (command.StartsWith(Common.CmdPrefixKeys, StringComparison.OrdinalIgnoreCase)) // Keystroke Command - { - string keyCommand = command.Substring(Common.CmdPrefixKeys.Length); - if (InConfiguration) - MessageBox.Show(keyCommand, Common.UITextKeys, MessageBoxButtons.OK, MessageBoxIcon.Information); - else - Common.ProcessKeyCommand(keyCommand); - } - else if (command.StartsWith(Common.CmdPrefixMouse, StringComparison.OrdinalIgnoreCase)) // Mouse Command - { - string mouseCommand = command.Substring(Common.CmdPrefixMouse.Length); - Common.ProcessMouseCommand(mouseCommand); - } - else if (command.StartsWith(Common.CmdPrefixEject, StringComparison.OrdinalIgnoreCase)) // Eject Command - { - string ejectCommand = command.Substring(Common.CmdPrefixEject.Length); - Common.ProcessEjectCommand(ejectCommand); - } - else if (command.StartsWith(Common.CmdPrefixHibernate, StringComparison.OrdinalIgnoreCase)) // Hibernate Command - { - Hibernate(); - } - else if (command.StartsWith(Common.CmdPrefixReboot, StringComparison.OrdinalIgnoreCase)) // Reboot Command - { - Reboot(); - } - else if (command.StartsWith(Common.CmdPrefixShutdown, StringComparison.OrdinalIgnoreCase)) // Shutdown Command - { - ShutDown(); - } - else if (command.StartsWith(Common.CmdPrefixStandby, StringComparison.OrdinalIgnoreCase)) // Standby Command - { - Standby(); - } - else if (command.StartsWith(Common.CmdPrefixGoto, StringComparison.OrdinalIgnoreCase)) // Go To Screen - { - MPCommon.ProcessGoTo(command.Substring(Common.CmdPrefixGoto.Length), MP_BasicHome); - } - else - { - throw new ArgumentException(String.Format("Cannot process unrecognized command \"{0}\"", command), "command"); - } + string upperCasedFileName = fileName.ToUpperInvariant(); + + if (stack.Contains(upperCasedFileName)) + stack.Remove(upperCasedFileName); + + if (stack.Count == 0) + _macroStacks.Remove(hash); } - + /// <summary> /// Returns a list of IR Commands /// </summary> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |