From: <an...@us...> - 2007-12-17 05:55:31
|
Revision: 1161 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=1161&view=rev Author: and-81 Date: 2007-12-16 21:55:29 -0800 (Sun, 16 Dec 2007) Log Message: ----------- Modified Paths: -------------- trunk/plugins/IR Server Suite/Applications/Debug Client/MainForm.Designer.cs trunk/plugins/IR Server Suite/Applications/Debug Client/MainForm.cs trunk/plugins/IR Server Suite/Applications/Translator/Forms/ButtonMappingForm.cs trunk/plugins/IR Server Suite/Applications/Translator/Forms/EditProgramForm.cs trunk/plugins/IR Server Suite/Applications/Translator/Program.cs trunk/plugins/IR Server Suite/Applications/Tray Launcher/Tray.cs trunk/plugins/IR Server Suite/Common/IrssUtils/Common.cs trunk/plugins/IR Server Suite/Common/IrssUtils/Forms/ExternalProgram.cs trunk/plugins/IR Server Suite/Common/IrssUtils/Forms/HttpMessageCommand.cs trunk/plugins/IR Server Suite/Common/IrssUtils/Forms/MessageCommand.cs trunk/plugins/IR Server Suite/Common/IrssUtils/IRServerInfo.cs trunk/plugins/IR Server Suite/Common/IrssUtils/IrssUtils.csproj trunk/plugins/IR Server Suite/Documentation/ehome_driver.html trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/Configure.Designer.cs trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/Configure.cs trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/Microsoft MCE Transceiver.csproj trunk/plugins/IR Server Suite/IR Server Suite - Debug.nsi trunk/plugins/IR Server Suite/IR Server Suite - Release.nsi trunk/plugins/IR Server Suite/IR Server Suite.sln trunk/plugins/IR Server Suite/Input Service/Input Service/Program.cs trunk/plugins/IR Server Suite/MediaPortal Plugins/MP Blast Zone Plugin/MPBlastZonePlugin.cs trunk/plugins/IR Server Suite/MediaPortal Plugins/MP Control Plugin/MPControlPlugin.cs trunk/plugins/IR Server Suite/MediaPortal Plugins/TV2 Blaster Plugin/Forms/ExternalChannels.cs trunk/plugins/IR Server Suite/MediaPortal Plugins/TV2 Blaster Plugin/Forms/ExternalChannels.designer.cs trunk/plugins/IR Server Suite/MediaPortal Plugins/TV2 Blaster Plugin/Forms/StbSetup.cs trunk/plugins/IR Server Suite/MediaPortal Plugins/TV2 Blaster Plugin/TV2BlasterPlugin.cs trunk/plugins/IR Server Suite/MediaPortal Plugins/TV3 Blaster Plugin/Forms/ExternalChannels.cs trunk/plugins/IR Server Suite/MediaPortal Plugins/TV3 Blaster Plugin/Forms/StbSetup.cs trunk/plugins/IR Server Suite/MediaPortal Plugins/TV3 Blaster Plugin/TV3BlasterPlugin.cs trunk/plugins/MCEReplacement/Forms/ExternalChannels.cs trunk/plugins/MCEReplacement/Forms/ExternalChannels.designer.cs trunk/plugins/MCEReplacement/Forms/StbSetup.cs trunk/plugins/MCEReplacement/MCEReplacement.cs Added Paths: ----------- trunk/plugins/IR Server Suite/Common/IrssUtils/Forms/CloseProgramCommand.Designer.cs trunk/plugins/IR Server Suite/Common/IrssUtils/Forms/CloseProgramCommand.cs trunk/plugins/IR Server Suite/Common/IrssUtils/Forms/CloseProgramCommand.resx trunk/plugins/IR Server Suite/Common/IrssUtils/Forms/ShowPopupMessage.Designer.cs trunk/plugins/IR Server Suite/Common/IrssUtils/Forms/ShowPopupMessage.cs trunk/plugins/IR Server Suite/Common/IrssUtils/Forms/ShowPopupMessage.resx trunk/plugins/IR Server Suite/Set Top Boxes/Dreambox HTTP TEST.xml Removed Paths: ------------- trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/Advanced.Designer.cs trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/Advanced.cs trunk/plugins/IR Server Suite/IR Server Plugins/Microsoft MCE Transceiver/Advanced.resx Modified: trunk/plugins/IR Server Suite/Applications/Debug Client/MainForm.Designer.cs =================================================================== --- trunk/plugins/IR Server Suite/Applications/Debug Client/MainForm.Designer.cs 2007-12-14 15:40:14 UTC (rev 1160) +++ trunk/plugins/IR Server Suite/Applications/Debug Client/MainForm.Designer.cs 2007-12-17 05:55:29 UTC (rev 1161) @@ -48,7 +48,6 @@ this.groupBoxCommands = new System.Windows.Forms.GroupBox(); this.comboBoxPort = new System.Windows.Forms.ComboBox(); this.toolTips = new System.Windows.Forms.ToolTip(this.components); - this.buttonIRBlastAutoTest = new System.Windows.Forms.Button(); this.buttonHelp = new System.Windows.Forms.Button(); this.groupBoxStatus.SuspendLayout(); this.groupBoxRemoteButton.SuspendLayout(); @@ -270,18 +269,6 @@ this.comboBoxPort.TabIndex = 2; this.toolTips.SetToolTip(this.comboBoxPort, "Port for blasting IR"); // - // buttonIRBlastAutoTest - // - this.buttonIRBlastAutoTest.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonIRBlastAutoTest.Location = new System.Drawing.Point(336, 416); - this.buttonIRBlastAutoTest.Name = "buttonIRBlastAutoTest"; - this.buttonIRBlastAutoTest.Size = new System.Drawing.Size(112, 24); - this.buttonIRBlastAutoTest.TabIndex = 5; - this.buttonIRBlastAutoTest.Text = "IRBlast Auto-Test"; - this.toolTips.SetToolTip(this.buttonIRBlastAutoTest, "Runs a random number blasting test"); - this.buttonIRBlastAutoTest.UseVisualStyleBackColor = true; - this.buttonIRBlastAutoTest.Click += new System.EventHandler(this.buttonAutoTest_Click); - // // buttonHelp // this.buttonHelp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); @@ -297,8 +284,7 @@ // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(456, 446); - this.Controls.Add(this.buttonIRBlastAutoTest); + this.ClientSize = new System.Drawing.Size(464, 455); this.Controls.Add(this.buttonHelp); this.Controls.Add(this.groupBoxCommands); this.Controls.Add(this.groupBoxSetup); @@ -341,7 +327,6 @@ private System.Windows.Forms.ComboBox comboBoxPort; private System.Windows.Forms.ComboBox comboBoxComputer; private System.Windows.Forms.Button buttonHelp; - private System.Windows.Forms.Button buttonIRBlastAutoTest; } } Modified: trunk/plugins/IR Server Suite/Applications/Debug Client/MainForm.cs =================================================================== --- trunk/plugins/IR Server Suite/Applications/Debug Client/MainForm.cs 2007-12-14 15:40:14 UTC (rev 1160) +++ trunk/plugins/IR Server Suite/Applications/Debug Client/MainForm.cs 2007-12-17 05:55:29 UTC (rev 1161) @@ -527,41 +527,6 @@ #endregion Controls - Thread AutoTest; - - private void buttonAutoTest_Click(object sender, EventArgs e) - { - AutoTest = new Thread(new ThreadStart(AutoTestThread)); - AutoTest.Name = "DebugClient.AutoTest"; - AutoTest.IsBackground = true; - AutoTest.Start(); - } - - void AutoTestThread() - { - Random rand = new Random(); - - int randomNumber; - - Process process = new Process(); - process.StartInfo.FileName = "IRBlast-NoWindow.exe"; - process.StartInfo.WorkingDirectory = "C:\\Program Files\\IR Server Suite\\IR Blast\\"; - - while (true) - { - randomNumber = rand.Next(100000); - - this.Invoke(_addStatusLine, new Object[] { String.Format("AutoTest: {0}", randomNumber) }); - - process.StartInfo.Arguments = "-host localhost -pad 4 -channel " + randomNumber.ToString(); - - process.Start(); - process.WaitForExit(); - - Thread.Sleep(10000); - } - } - } } Modified: trunk/plugins/IR Server Suite/Applications/Translator/Forms/ButtonMappingForm.cs =================================================================== --- trunk/plugins/IR Server Suite/Applications/Translator/Forms/ButtonMappingForm.cs 2007-12-14 15:40:14 UTC (rev 1160) +++ trunk/plugins/IR Server Suite/Applications/Translator/Forms/ButtonMappingForm.cs 2007-12-17 05:55:29 UTC (rev 1161) @@ -222,10 +222,10 @@ tabControl.SelectTab(tabPageMessage); switch (commands[0].ToUpperInvariant()) { - case Common.WMTargetActive: radioButtonActiveWindow.Checked = true; break; - case Common.WMTargetApplication: radioButtonApplication.Checked = true; break; - case Common.WMTargetClass: radioButtonClass.Checked = true; break; - case Common.WMTargetWindow: radioButtonWindowTitle.Checked = true; break; + case Common.TargetActive: radioButtonActiveWindow.Checked = true; break; + case Common.TargetApplication: radioButtonApplication.Checked = true; break; + case Common.TargetClass: radioButtonClass.Checked = true; break; + case Common.TargetWindow: radioButtonWindowTitle.Checked = true; break; } textBoxMsgTarget.Text = commands[1]; @@ -386,20 +386,20 @@ if (radioButtonActiveWindow.Checked) { - target = Common.WMTargetActive; + target = Common.TargetActive; textBoxMsgTarget.Text = "*"; } else if (radioButtonApplication.Checked) { - target = Common.WMTargetApplication; + target = Common.TargetApplication; } else if (radioButtonClass.Checked) { - target = Common.WMTargetClass; + target = Common.TargetClass; } else if (radioButtonWindowTitle.Checked) { - target = Common.WMTargetWindow; + target = Common.TargetWindow; } textBoxCommand.Text = _command = Modified: trunk/plugins/IR Server Suite/Applications/Translator/Forms/EditProgramForm.cs =================================================================== --- trunk/plugins/IR Server Suite/Applications/Translator/Forms/EditProgramForm.cs 2007-12-14 15:40:14 UTC (rev 1160) +++ trunk/plugins/IR Server Suite/Applications/Translator/Forms/EditProgramForm.cs 2007-12-17 05:55:29 UTC (rev 1161) @@ -120,30 +120,32 @@ { try { - Process process = new Process(); - process.StartInfo.FileName = Filename; - process.StartInfo.WorkingDirectory = StartupFolder; - process.StartInfo.Arguments = Parameters; - process.StartInfo.WindowStyle = StartState; - process.StartInfo.UseShellExecute = UseShellExecute; + using (Process process = new Process()) + { + process.StartInfo.FileName = Filename; + process.StartInfo.WorkingDirectory = StartupFolder; + process.StartInfo.Arguments = Parameters; + process.StartInfo.WindowStyle = StartState; + process.StartInfo.UseShellExecute = UseShellExecute; - IrssLog.Info("Launching program {0}", DisplayName); + IrssLog.Info("Launching program {0}", DisplayName); - process.Start(); + process.Start(); - // Give new process focus ... - if (StartState != ProcessWindowStyle.Hidden && ForceWindowFocus) - { - int attempt = 0; - while (!process.HasExited && attempt++ < 50) + // Give new process focus ... + if (StartState != ProcessWindowStyle.Hidden && ForceWindowFocus) { - if (process.MainWindowHandle != IntPtr.Zero) + int attempt = 0; + while (!process.HasExited && attempt++ < 50) { - Win32.SetForegroundWindow(process.MainWindowHandle, true); - break; + if (process.MainWindowHandle != IntPtr.Zero) + { + Win32.SetForegroundWindow(process.MainWindowHandle, true); + break; + } + + Thread.Sleep(500); } - - Thread.Sleep(500); } } } Modified: trunk/plugins/IR Server Suite/Applications/Translator/Program.cs =================================================================== --- trunk/plugins/IR Server Suite/Applications/Translator/Program.cs 2007-12-14 15:40:14 UTC (rev 1160) +++ trunk/plugins/IR Server Suite/Applications/Translator/Program.cs 2007-12-17 05:55:29 UTC (rev 1161) @@ -1052,6 +1052,16 @@ string[] commands = Common.SplitWindowMessageCommand(command.Substring(Common.CmdPrefixWindowMsg.Length)); Common.ProcessWindowMessageCommand(commands); } + else if (command.StartsWith(Common.CmdPrefixTcpMsg, StringComparison.OrdinalIgnoreCase)) + { + string[] commands = Common.SplitTcpMessageCommand(command.Substring(Common.CmdPrefixTcpMsg.Length)); + Common.ProcessTcpMessageCommand(commands); + } + else if (command.StartsWith(Common.CmdPrefixHttpMsg, StringComparison.OrdinalIgnoreCase)) + { + string[] commands = Common.SplitHttpMessageCommand(command.Substring(Common.CmdPrefixHttpMsg.Length)); + Common.ProcessHttpCommand(commands); + } else if (command.StartsWith(Common.CmdPrefixKeys, StringComparison.OrdinalIgnoreCase)) { string keyCommand = command.Substring(Common.CmdPrefixKeys.Length); @@ -1070,6 +1080,11 @@ string ejectCommand = command.Substring(Common.CmdPrefixEject.Length); Common.ProcessEjectCommand(ejectCommand); } + else if (command.StartsWith(Common.CmdPrefixPopup, StringComparison.OrdinalIgnoreCase)) + { + string[] commands = Common.SplitPopupCommand(command.Substring(Common.CmdPrefixPopup.Length)); + MessageBox.Show(commands[1], commands[0], MessageBoxButtons.OK, MessageBoxIcon.Information); + } else if (command.StartsWith(Common.CmdPrefixHibernate, StringComparison.OrdinalIgnoreCase)) { if (_inConfiguration) Modified: trunk/plugins/IR Server Suite/Applications/Tray Launcher/Tray.cs =================================================================== --- trunk/plugins/IR Server Suite/Applications/Tray Launcher/Tray.cs 2007-12-14 15:40:14 UTC (rev 1160) +++ trunk/plugins/IR Server Suite/Applications/Tray Launcher/Tray.cs 2007-12-17 05:55:29 UTC (rev 1161) @@ -436,22 +436,24 @@ } // Launch program - Process launch = new Process(); - launch.StartInfo.FileName = _programFile; - launch.StartInfo.WindowStyle = ProcessWindowStyle.Normal; - launch.StartInfo.UseShellExecute = true; - launch.Start(); + using (Process launch = new Process()) + { + launch.StartInfo.FileName = _programFile; + launch.StartInfo.WindowStyle = ProcessWindowStyle.Normal; + launch.StartInfo.UseShellExecute = true; + launch.Start(); - int attempt = 0; - while (!launch.HasExited && attempt++ < 50) - { - if (launch.MainWindowHandle != IntPtr.Zero) + int attempt = 0; + while (!launch.HasExited && attempt++ < 50) { - Win32.SetForegroundWindow(launch.MainWindowHandle, true); - break; + if (launch.MainWindowHandle != IntPtr.Zero) + { + Win32.SetForegroundWindow(launch.MainWindowHandle, true); + break; + } + + Thread.Sleep(500); } - - Thread.Sleep(500); } } catch (Exception ex) Modified: trunk/plugins/IR Server Suite/Common/IrssUtils/Common.cs =================================================================== --- trunk/plugins/IR Server Suite/Common/IrssUtils/Common.cs 2007-12-14 15:40:14 UTC (rev 1160) +++ trunk/plugins/IR Server Suite/Common/IrssUtils/Common.cs 2007-12-17 05:55:29 UTC (rev 1161) @@ -99,6 +99,7 @@ public const string CmdPrefixGoto = "Goto: "; public const string CmdPrefixPopup = "Popup: "; public const string CmdPrefixMouseMode = "Mouse Mode: "; + public const string CmdPrefixCloseProgram = "Close Program: "; // public const string CmdPrefixWindowState = "Toggle Window State"; public const string CmdPrefixStandby = "Standby"; @@ -139,7 +140,7 @@ public const string UITextMultiMap = "Set Multi-Mapping"; public const string UITextMouseMode = "Set Mouse Mode"; public const string UITextInputLayer = "Toggle Input Handler Layer"; -// public const string UITextWindowState = "Change Window State"; + //public const string UITextWindowState = "Toggle Window State"; public const string UITextFocus = "Get Focus"; public const string UITextExit = "Exit MediaPortal"; @@ -183,26 +184,26 @@ #endregion Mouse Commands - #region Windows Message Target + #region Command Targets /// <summary> - /// Windows Message target the active window. + /// Target the active window. /// </summary> - public const string WMTargetActive = "ACTIVE"; + public const string TargetActive = "ACTIVE"; /// <summary> - /// Windows Message target an application. + /// Target an application. /// </summary> - public const string WMTargetApplication = "APPLICATION"; + public const string TargetApplication = "APPLICATION"; /// <summary> - /// Windows Message target a class. + /// Target a class. /// </summary> - public const string WMTargetClass = "CLASS"; + public const string TargetClass = "CLASS"; /// <summary> - /// Windows Message target a window title. + /// Target a window title. /// </summary> - public const string WMTargetWindow = "WINDOW"; + public const string TargetWindow = "WINDOW"; - #endregion Windows Message Target + #endregion Commad Targets #endregion Strings @@ -244,6 +245,10 @@ /// Number of Segments in a Display Mode Command. /// </summary> public const int SegmentsDisplayModeCommand = 4; + /// <summary> + /// Number of Segments in a Close Program Command. + /// </summary> + public const int SegmentsCloseProgramCommand = 2; #endregion Command Segments @@ -343,6 +348,16 @@ return SplitCommand(command, SegmentsDisplayModeCommand); } + /// <summary> + /// Splits a Close Program Command into it's component parts. + /// </summary> + /// <param name="command">The command to be split.</param> + /// <returns>Returns string[] of command elements.</returns> + public static string[] SplitCloseProgramCommand(string command) + { + return SplitCommand(command, SegmentsCloseProgramCommand); + } + static string[] SplitCommand(string command, int elements) { if (String.IsNullOrEmpty(command)) @@ -369,39 +384,39 @@ if (commands == null) throw new ArgumentNullException("commands"); - Process process = new Process(); - process.StartInfo.FileName = commands[0]; - process.StartInfo.WorkingDirectory = commands[1]; - process.StartInfo.Arguments = commands[2]; - process.StartInfo.WindowStyle = (ProcessWindowStyle)Enum.Parse(typeof(ProcessWindowStyle), commands[3], true); - process.StartInfo.CreateNoWindow = bool.Parse(commands[4]); - process.StartInfo.UseShellExecute = bool.Parse(commands[5]); + using (Process process = new Process()) + { + process.StartInfo.FileName = commands[0]; + process.StartInfo.WorkingDirectory = commands[1]; + process.StartInfo.Arguments = commands[2]; + process.StartInfo.WindowStyle = (ProcessWindowStyle)Enum.Parse(typeof(ProcessWindowStyle), commands[3], true); + process.StartInfo.CreateNoWindow = bool.Parse(commands[4]); + process.StartInfo.UseShellExecute = bool.Parse(commands[5]); - bool waitForExit = bool.Parse(commands[6]); - bool forceFocus = bool.Parse(commands[7]); + bool waitForExit = bool.Parse(commands[6]); + bool forceFocus = bool.Parse(commands[7]); - process.Start(); + process.Start(); - // Give new process focus ... - if (!process.StartInfo.CreateNoWindow && - process.StartInfo.WindowStyle != ProcessWindowStyle.Hidden && - forceFocus) - { - int attempt = 0; - while (!process.HasExited && attempt++ < 50) + // Give new process focus ... + if (!process.StartInfo.CreateNoWindow && process.StartInfo.WindowStyle != ProcessWindowStyle.Hidden && forceFocus) { - if (process.MainWindowHandle != IntPtr.Zero) + int attempt = 0; + while (!process.HasExited && attempt++ < 50) { - Win32.SetForegroundWindow(process.MainWindowHandle, true); - break; + if (process.MainWindowHandle != IntPtr.Zero) + { + Win32.SetForegroundWindow(process.MainWindowHandle, true); + break; + } + + Thread.Sleep(500); } + } - Thread.Sleep(500); - } + if (waitForExit) + process.WaitForExit(); } - - if (waitForExit) - process.WaitForExit(); } /// <summary> @@ -413,7 +428,7 @@ if (commands == null) throw new ArgumentNullException("commands"); - string command = Common.ReplaceEscapeCodes(commands[0]); + string command = ReplaceEscapeCodes(commands[0]); string comPort = commands[1]; int baudRate = int.Parse(commands[2]); @@ -463,11 +478,11 @@ string matchType = commands[0].ToUpperInvariant(); switch (matchType) { - case WMTargetActive: + case TargetActive: windowHandle = Win32.ForegroundWindow(); break; - case WMTargetApplication: + case TargetApplication: foreach (Process proc in Process.GetProcesses()) { try @@ -484,11 +499,11 @@ } break; - case WMTargetClass: + case TargetClass: windowHandle = Win32.FindWindowByClass(commands[1]); break; - case WMTargetWindow: + case TargetWindow: windowHandle = Win32.FindWindowByTitle(commands[1]); break; @@ -709,6 +724,48 @@ Display.ChangeDisplayMode(width, height, bpp, refresh); } + /// <summary> + /// Given a split Close Program Command this method will attempt to close a program by command structure supplied. + /// </summary> + /// <param name="commands">An array of arguments for the method (the output of SplitCloseProgramCommand).</param> + public static void ProcessCloseProgramCommand(string[] commands) + { + if (commands == null) + throw new ArgumentNullException("commands"); + + Process process; + + string matchType = commands[0].ToUpperInvariant(); + switch (matchType) + { + case TargetActive: + process = GetProcessByWindowHandle(Win32.ForegroundWindow()); + break; + + case TargetApplication: + process = GetProcessByFilePath(commands[1]); + break; + + case TargetClass: + process = GetProcessByWindowHandle(Win32.FindWindowByClass(commands[1])); + break; + + case TargetWindow: + process = GetProcessByWindowTitle(commands[1]); + break; + + default: + throw new ArgumentOutOfRangeException("commands", commands[0], "Invalid close program target"); + } + + if (process == null) + throw new ApplicationException(String.Format("Close Program target ({0}) not found", commands[0])); + + EndProcess(process, 5000); + + process.Close(); + } + #endregion Command Execution #region Misc @@ -919,6 +976,77 @@ return Win32.WindowsExit(Win32.ExitWindows.ShutDown, Win32.ShutdownReasons.FlagUserDefined); } + + static Process GetProcessByWindowHandle(IntPtr windowHandle) + { + foreach (Process process in Process.GetProcesses()) + { + IntPtr procWindowHandle; + try { procWindowHandle = process.MainWindowHandle; } + catch { continue; } + + if (procWindowHandle == windowHandle) + return process; + } + + return null; + } + + static Process GetProcessByWindowTitle(string windowTitle) + { + foreach (Process process in Process.GetProcesses()) + { + string procWindowTitle; + try { procWindowTitle = process.MainWindowTitle; } + catch { continue; } + + if (procWindowTitle.Equals(windowTitle, StringComparison.OrdinalIgnoreCase)) + return process; + } + + return null; + } + + static Process GetProcessByFilePath(string filePath) + { + foreach (Process process in Process.GetProcesses()) + { + string procFilePath; + try { procFilePath = process.MainModule.FileName; } + catch { continue; } + + if (procFilePath.Equals(filePath, StringComparison.OrdinalIgnoreCase)) + return process; + } + + return null; + } + + static Process GetProcessByFileName(string fileName) + { + foreach (Process process in Process.GetProcesses()) + { + string procFileName; + try { procFileName = process.MainModule.ModuleName; } + catch { continue; } + + if (procFileName.Equals(fileName, StringComparison.OrdinalIgnoreCase)) + return process; + } + + return null; + } + + static void EndProcess(Process process, int timeout) + { + if (process.CloseMainWindow()) + process.WaitForExit(timeout); + + if (!process.HasExited) + process.Kill(); + } + + #endregion Misc #endregion Methods Added: trunk/plugins/IR Server Suite/Common/IrssUtils/Forms/CloseProgramCommand.Designer.cs =================================================================== --- trunk/plugins/IR Server Suite/Common/IrssUtils/Forms/CloseProgramCommand.Designer.cs (rev 0) +++ trunk/plugins/IR Server Suite/Common/IrssUtils/Forms/CloseProgramCommand.Designer.cs 2007-12-17 05:55:29 UTC (rev 1161) @@ -0,0 +1,189 @@ +namespace IrssUtils.Forms +{ + + partial class CloseProgramCommand + { + + /// <summary> + /// Required designer variable. + /// </summary> + private System.ComponentModel.IContainer components = null; + + /// <summary> + /// Clean up any resources being used. + /// </summary> + /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// <summary> + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// </summary> + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.buttonFindTarget = new System.Windows.Forms.Button(); + this.textBoxTarget = new System.Windows.Forms.TextBox(); + this.buttonCancel = new System.Windows.Forms.Button(); + this.buttonOK = new System.Windows.Forms.Button(); + this.groupBoxTarget = new System.Windows.Forms.GroupBox(); + this.radioButtonWindowTitle = new System.Windows.Forms.RadioButton(); + this.radioButtonClass = new System.Windows.Forms.RadioButton(); + this.radioButtonApplication = new System.Windows.Forms.RadioButton(); + this.radioButtonActiveWindow = new System.Windows.Forms.RadioButton(); + this.toolTips = new System.Windows.Forms.ToolTip(this.components); + this.groupBoxTarget.SuspendLayout(); + this.SuspendLayout(); + // + // buttonFindTarget + // + this.buttonFindTarget.Location = new System.Drawing.Point(240, 80); + this.buttonFindTarget.Name = "buttonFindTarget"; + this.buttonFindTarget.Size = new System.Drawing.Size(24, 20); + this.buttonFindTarget.TabIndex = 5; + this.buttonFindTarget.Text = "..."; + this.toolTips.SetToolTip(this.buttonFindTarget, "Locate a target to close"); + this.buttonFindTarget.UseVisualStyleBackColor = true; + this.buttonFindTarget.Click += new System.EventHandler(this.buttonFindMsgApp_Click); + // + // textBoxTarget + // + this.textBoxTarget.Location = new System.Drawing.Point(8, 80); + this.textBoxTarget.Name = "textBoxTarget"; + this.textBoxTarget.Size = new System.Drawing.Size(224, 20); + this.textBoxTarget.TabIndex = 4; + this.toolTips.SetToolTip(this.textBoxTarget, "Program to close"); + // + // buttonCancel + // + this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.buttonCancel.Location = new System.Drawing.Point(216, 128); + this.buttonCancel.Name = "buttonCancel"; + this.buttonCancel.Size = new System.Drawing.Size(64, 24); + this.buttonCancel.TabIndex = 2; + 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.Top | System.Windows.Forms.AnchorStyles.Right))); + this.buttonOK.Location = new System.Drawing.Point(144, 128); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(64, 24); + this.buttonOK.TabIndex = 1; + this.buttonOK.Text = "OK"; + this.buttonOK.UseVisualStyleBackColor = true; + this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); + // + // groupBoxTarget + // + this.groupBoxTarget.Controls.Add(this.radioButtonWindowTitle); + this.groupBoxTarget.Controls.Add(this.radioButtonClass); + this.groupBoxTarget.Controls.Add(this.radioButtonApplication); + this.groupBoxTarget.Controls.Add(this.radioButtonActiveWindow); + this.groupBoxTarget.Controls.Add(this.textBoxTarget); + this.groupBoxTarget.Controls.Add(this.buttonFindTarget); + this.groupBoxTarget.Location = new System.Drawing.Point(8, 8); + this.groupBoxTarget.Name = "groupBoxTarget"; + this.groupBoxTarget.Size = new System.Drawing.Size(272, 112); + this.groupBoxTarget.TabIndex = 0; + this.groupBoxTarget.TabStop = false; + this.groupBoxTarget.Text = "Target"; + // + // radioButtonWindowTitle + // + this.radioButtonWindowTitle.Location = new System.Drawing.Point(152, 48); + this.radioButtonWindowTitle.Name = "radioButtonWindowTitle"; + this.radioButtonWindowTitle.Size = new System.Drawing.Size(112, 16); + this.radioButtonWindowTitle.TabIndex = 3; + this.radioButtonWindowTitle.TabStop = true; + this.radioButtonWindowTitle.Text = "Window title"; + this.toolTips.SetToolTip(this.radioButtonWindowTitle, "Close the window with the specified title"); + this.radioButtonWindowTitle.UseVisualStyleBackColor = true; + this.radioButtonWindowTitle.CheckedChanged += new System.EventHandler(this.radioButtonWindowTitle_CheckedChanged); + // + // radioButtonClass + // + this.radioButtonClass.Location = new System.Drawing.Point(8, 48); + this.radioButtonClass.Name = "radioButtonClass"; + this.radioButtonClass.Size = new System.Drawing.Size(112, 16); + this.radioButtonClass.TabIndex = 2; + this.radioButtonClass.TabStop = true; + this.radioButtonClass.Text = "Class"; + this.toolTips.SetToolTip(this.radioButtonClass, "Close the window with the specified class"); + this.radioButtonClass.UseVisualStyleBackColor = true; + this.radioButtonClass.CheckedChanged += new System.EventHandler(this.radioButtonClass_CheckedChanged); + // + // radioButtonApplication + // + this.radioButtonApplication.Location = new System.Drawing.Point(152, 24); + this.radioButtonApplication.Name = "radioButtonApplication"; + this.radioButtonApplication.Size = new System.Drawing.Size(112, 16); + this.radioButtonApplication.TabIndex = 1; + this.radioButtonApplication.TabStop = true; + this.radioButtonApplication.Text = "Application"; + this.toolTips.SetToolTip(this.radioButtonApplication, "Close the specified application"); + this.radioButtonApplication.UseVisualStyleBackColor = true; + this.radioButtonApplication.CheckedChanged += new System.EventHandler(this.radioButtonApplication_CheckedChanged); + // + // radioButtonActiveWindow + // + this.radioButtonActiveWindow.Location = new System.Drawing.Point(8, 24); + this.radioButtonActiveWindow.Name = "radioButtonActiveWindow"; + this.radioButtonActiveWindow.Size = new System.Drawing.Size(112, 16); + this.radioButtonActiveWindow.TabIndex = 0; + this.radioButtonActiveWindow.Text = "Active window"; + this.toolTips.SetToolTip(this.radioButtonActiveWindow, "Close the active window"); + this.radioButtonActiveWindow.UseVisualStyleBackColor = true; + this.radioButtonActiveWindow.CheckedChanged += new System.EventHandler(this.radioButtonActiveWindow_CheckedChanged); + // + // CloseProgramCommand + // + 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(288, 161); + this.Controls.Add(this.groupBoxTarget); + this.Controls.Add(this.buttonCancel); + this.Controls.Add(this.buttonOK); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.MinimumSize = new System.Drawing.Size(296, 188); + this.Name = "CloseProgramCommand"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; + this.Text = "Close Program Command"; + this.groupBoxTarget.ResumeLayout(false); + this.groupBoxTarget.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Button buttonFindTarget; + private System.Windows.Forms.TextBox textBoxTarget; + private System.Windows.Forms.Button buttonCancel; + private System.Windows.Forms.Button buttonOK; + private System.Windows.Forms.GroupBox groupBoxTarget; + private System.Windows.Forms.ToolTip toolTips; + private System.Windows.Forms.RadioButton radioButtonActiveWindow; + private System.Windows.Forms.RadioButton radioButtonWindowTitle; + private System.Windows.Forms.RadioButton radioButtonClass; + private System.Windows.Forms.RadioButton radioButtonApplication; + } + +} Added: trunk/plugins/IR Server Suite/Common/IrssUtils/Forms/CloseProgramCommand.cs =================================================================== --- trunk/plugins/IR Server Suite/Common/IrssUtils/Forms/CloseProgramCommand.cs (rev 0) +++ trunk/plugins/IR Server Suite/Common/IrssUtils/Forms/CloseProgramCommand.cs 2007-12-17 05:55:29 UTC (rev 1161) @@ -0,0 +1,153 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.IO; +using System.Text; +using System.Windows.Forms; + +namespace IrssUtils.Forms +{ + + /// <summary> + /// Close Program Command form. + /// </summary> + public partial class CloseProgramCommand : Form + { + + #region Properties + + /// <summary> + /// Gets the command string. + /// </summary> + /// <value>The command string.</value> + public string CommandString + { + get + { + string target = "ERROR"; + + if (radioButtonActiveWindow.Checked) + { + target = Common.TargetActive; + textBoxTarget.Text = "*"; + } + else if (radioButtonApplication.Checked) + { + target = Common.TargetApplication; + } + else if (radioButtonClass.Checked) + { + target = Common.TargetClass; + } + else if (radioButtonWindowTitle.Checked) + { + target = Common.TargetWindow; + } + + return String.Format("{0}|{1}", + target, + textBoxTarget.Text); + } + } + + #endregion Properties + + #region Constructors + + /// <summary> + /// Initializes a new instance of the <see cref="CloseProgramCommand"/> class. + /// </summary> + public CloseProgramCommand() : this(new string[] { Common.TargetActive, String.Empty }) { } + /// <summary> + /// Initializes a new instance of the <see cref="CloseProgramCommand"/> class. + /// </summary> + /// <param name="commands">The command elements.</param> + public CloseProgramCommand(string[] commands) + { + InitializeComponent(); + + if (commands != null) + { + string target = commands[0].ToUpperInvariant(); + switch (target) + { + case Common.TargetActive: radioButtonActiveWindow.Checked = true; break; + case Common.TargetApplication: radioButtonApplication.Checked = true; break; + case Common.TargetClass: radioButtonClass.Checked = true; break; + case Common.TargetWindow: radioButtonWindowTitle.Checked = true; break; + default: + throw new ArgumentOutOfRangeException("commands", commands[0], "Invalid message target"); + } + + textBoxTarget.Text = commands[1]; + } + } + + #endregion Constructors + + #region Controls + + private void buttonFindMsgApp_Click(object sender, EventArgs e) + { + if (radioButtonApplication.Checked) + { + OpenFileDialog find = new OpenFileDialog(); + find.Filter = "All files|*.*"; + find.Multiselect = false; + find.Title = "Application to close"; + + if (find.ShowDialog(this) == DialogResult.OK) + textBoxTarget.Text = find.FileName; + } + else if (radioButtonClass.Checked) + { + // TODO: Locate Class + } + else if (radioButtonWindowTitle.Checked) + { + WindowList windowList = new WindowList(); + if (windowList.ShowDialog(this) == DialogResult.OK) + textBoxTarget.Text = windowList.SelectedWindowTitle; + } + } + + private void buttonOK_Click(object sender, EventArgs e) + { + this.DialogResult = DialogResult.OK; + this.Close(); + } + + private void buttonCancel_Click(object sender, EventArgs e) + { + this.DialogResult = DialogResult.Cancel; + this.Close(); + } + + private void radioButtonActiveWindow_CheckedChanged(object sender, EventArgs e) + { + buttonFindTarget.Enabled = false; + textBoxTarget.Enabled = false; + } + private void radioButtonApplication_CheckedChanged(object sender, EventArgs e) + { + buttonFindTarget.Enabled = true; + textBoxTarget.Enabled = true; + } + private void radioButtonClass_CheckedChanged(object sender, EventArgs e) + { + buttonFindTarget.Enabled = false; + textBoxTarget.Enabled = true; + } + private void radioButtonWindowTitle_CheckedChanged(object sender, EventArgs e) + { + buttonFindTarget.Enabled = true; + textBoxTarget.Enabled = true; + } + + #endregion Controls + + } + +} Added: trunk/plugins/IR Server Suite/Common/IrssUtils/Forms/CloseProgramCommand.resx =================================================================== --- trunk/plugins/IR Server Suite/Common/IrssUtils/Forms/CloseProgramCommand.resx (rev 0) +++ trunk/plugins/IR Server Suite/Common/IrssUtils/Forms/CloseProgramCommand.resx 2007-12-17 05:55:29 UTC (rev 1161) @@ -0,0 +1,123 @@ +<?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 + : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.soap.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Soap.SoapFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.bytearray.base64 + value : The object must be serialized into a byte array + : using a System.ComponentModel.TypeConverter + : and then encoded with base64 encoding. + --> + <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> + <xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> + <xsd:element name="root" msdata:IsDataSet="true"> + <xsd:complexType> + <xsd:choice maxOccurs="unbounded"> + <xsd:element name="metadata"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" /> + </xsd:sequence> + <xsd:attribute name="name" use="required" type="xsd:string" /> + <xsd:attribute name="type" type="xsd:string" /> + <xsd:attribute name="mimetype" type="xsd:string" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="assembly"> + <xsd:complexType> + <xsd:attribute name="alias" type="xsd:string" /> + <xsd:attribute name="name" type="xsd:string" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="data"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> + <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> + <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="resheader"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" /> + </xsd:complexType> + </xsd:element> + </xsd:choice> + </xsd:complexType> + </xsd:element> + </xsd:schema> + <resheader name="resmimetype"> + <value>text/microsoft-resx</value> + </resheader> + <resheader name="version"> + <value>2.0</value> + </resheader> + <resheader name="reader"> + <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <resheader name="writer"> + <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <metadata name="toolTips.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> + <value>17, 17</value> + </metadata> +</root> \ No newline at end of file Modified: trunk/plugins/IR Server Suite/Common/IrssUtils/Forms/ExternalProgram.cs =================================================================== --- trunk/plugins/IR Server Suite/Common/IrssUtils/Forms/ExternalProgram.cs 2007-12-14 15:40:14 UTC (rev 1160) +++ trunk/plugins/IR Server Suite/Common/IrssUtils/Forms/ExternalProgram.cs 2007-12-17 05:55:29 UTC (rev 1161) @@ -190,31 +190,33 @@ try { - Process process = new Process(); - process.StartInfo.FileName = textBoxProgram.Text; - process.StartInfo.WorkingDirectory = textBoxStartup.Text; - process.StartInfo.Arguments = textBoxParameters.Text; - process.StartInfo.WindowStyle = (ProcessWindowStyle)Enum.Parse(typeof(ProcessWindowStyle), comboBoxWindowStyle.SelectedItem as string, true); - process.StartInfo.CreateNoWindow = checkBoxNoWindow.Checked; - process.StartInfo.UseShellExecute = checkBoxShellExecute.Checked; + using (Process process = new Process()) + { + process.StartInfo.FileName = textBoxProgram.Text; + process.StartInfo.WorkingDirectory = textBoxStartup.Text; + process.StartInfo.Arguments = textBoxParameters.Text; + process.StartInfo.WindowStyle = (ProcessWindowStyle)Enum.Parse(typeof(ProcessWindowStyle), comboBoxWindowStyle.SelectedItem as string, true); + process.StartInfo.CreateNoWindow = checkBoxNoWindow.Checked; + process.StartInfo.UseShellExecute = checkBoxShellExecute.Checked; - process.Start(); + process.Start(); - // Give new process focus ... - if (!process.StartInfo.CreateNoWindow && - process.StartInfo.WindowStyle != ProcessWindowStyle.Hidden && - checkBoxForceFocus.Checked) - { - int attempt = 0; - while (!process.HasExited && attempt++ < 50) + // Give new process focus ... + if (!process.StartInfo.CreateNoWindow && + process.StartInfo.WindowStyle != ProcessWindowStyle.Hidden && + checkBoxForceFocus.Checked) { - if (process.MainWindowHandle != IntPtr.Zero) + int attempt = 0; + while (!process.HasExited && attempt++ < 50) { - Win32.SetForegroundWindow(process.MainWindowHandle, true); - break; + if (process.MainWindowHandle != IntPtr.Zero) + { + Win32.SetForegroundWindow(process.MainWindowHandle, true); + break; + } + + Thread.Sleep(500); } - - Thread.Sleep(500); } } } Modified: trunk/plugins/IR Server Suite/Common/IrssUtils/Forms/HttpMessageCommand.cs =================================================================== --- trunk/plugins/IR Server Suite/Common/IrssUtils/Forms/HttpMessageCommand.cs 2007-12-14 15:40:14 UTC (rev 1160) +++ trunk/plugins/IR Server Suite/Common/IrssUtils/Forms/HttpMessageCommand.cs 2007-12-17 05:55:29 UTC (rev 1161) @@ -38,14 +38,14 @@ #region Constructors /// <summary> - /// Initializes a new instance of the <see cref="TcpMessageCommand"/> class. + /// Initializes a new instance of the <see cref="HttpMessageCommand"/> class. /// </summary> public HttpMessageCommand() { InitializeComponent(); } /// <summary> - /// Initializes a new instance of the <see cref="TcpMessageCommand"/> class. + /// Initializes a new instance of the <see cref="HttpMessageCommand"/> class. /// </summary> /// <param name="commands">The command elements.</param> public HttpMessageCommand(string[] commands) @@ -58,6 +58,8 @@ numericUpDownTimeout.Value = Convert.ToDecimal(commands[1]); textBoxUsername.Text = commands[2]; textBoxPassword.Text = commands[3]; + + checkBoxUsernameAndPassword.Checked = !String.IsNullOrEmpty(commands[2]); } #endregion Constructors Modified: trunk/plugins/IR Server Suite/Common/IrssUtils/Forms/MessageCommand.cs =================================================================== --- trunk/plugins/IR Server Suite/Common/IrssUtils/Forms/MessageCommand.cs 2007-12-14 15:40:14 UTC (rev 1160) +++ trunk/plugins/IR Server Suite/Common/IrssUtils/Forms/MessageCommand.cs 2007-12-17 05:55:29 UTC (rev 1161) @@ -30,20 +30,20 @@ if (radioButtonActiveWindow.Checked) { - target = Common.WMTargetActive; + target = Common.TargetActive; textBoxMsgTarget.Text = "*"; } else if (radioButtonApplication.Checked) { - target = Common.WMTargetApplication; + target = Common.TargetApplication; } else if (radioButtonClass.Checked) { - target = Common.WMTargetClass; + target = Common.TargetClass; } else if (radioButtonWindowTitle.Checked) { - target = Common.WMTargetWindow; + target = Common.TargetWindow; } return String.Format("{0}|{1}|{2}|{3}|{4}", @@ -62,7 +62,7 @@ /// <summary> /// Initializes a new instance of the <see cref="MessageCommand"/> class. /// </summary> - public MessageCommand() : this(new string[] { Common.WMTargetActive, String.Empty, ((int)Win32.WindowsMessage.WM_USER).ToString(), "0", "0" }) { } + public MessageCommand() : this(new string[] { Common.TargetActive, String.Empty, ((int)Win32.WindowsMessage.WM_USER).ToString(), "0", "0" }) { } /// <summary> /// Initializes a new instance of the <see cref="MessageCommand"/> class. /// </summary> @@ -76,10 +76,10 @@ string target = commands[0].ToUpperInvariant(); switch (target) { - case Common.WMTargetActive: radioButtonActiveWindow.Checked = true; break; - case Common.WMTargetApplication: radioButtonApplication.Checked = true; break; - case Common.WMTargetClass: radioButtonClass.Checked = true; break; - case Common.WMTargetWindow: radioButtonWindowTitle.Checked = true; break; + case Common.TargetActive: radioButtonActiveWindow.Checked = true; break; + case Common.TargetApplication: radioButtonApplication.Checked = true; break; + case Common.TargetClass: radioButtonClass.Checked = true; break; + case Common.TargetWindow: radioButtonWindowTitle.Checked = true; break; default: throw new ArgumentOutOfRangeException("commands", commands[0], "Invalid message target"); } Added: trunk/plugins/IR Server Suite/Common/IrssUtils/Forms/ShowPopupMessage.Designer.cs =================================================================== --- trunk/plugins/IR Server Suite/Common/IrssUtils/Forms/ShowPopupMessage.Designer.cs (rev 0) +++ trunk/plugins/IR Server Suite/Common/IrssUtils/Forms/ShowPopupMessage.Designer.cs 2007-12-17 05:55:29 UTC (rev 1161) @@ -0,0 +1,103 @@ +namespace IrssUtils.Forms +{ + partial class ShowPopupMessage + { + /// <summary> + /// Required designer variable. + /// </summary> + private System.ComponentModel.IContainer components = null; + + /// <summary> + /// Clean up any resources being used. + /// </summary> + /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// <summary> + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// </summary> + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.buttonOK = new System.Windows.Forms.Button(); + this.timerOK = new System.Windows.Forms.Timer(this.components); + this.labelMessage = new System.Windows.Forms.Label(); + this.panel1 = new System.Windows.Forms.Panel(); + this.panel1.SuspendLayout(); + 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(178, 0); + this.buttonOK.Name = "buttonOK"; + this.buttonOK.Size = new System.Drawing.Size(72, 24); + this.buttonOK.TabIndex = 0; + this.buttonOK.Text = "OK (100)"; + this.buttonOK.UseVisualStyleBackColor = true; + this.buttonOK.Click += new System.EventHandler(this.buttonOK_Click); + // + // timerOK + // + this.timerOK.Interval = 1000; + this.timerOK.Tick += new System.EventHandler(this.timerOK_Tick); + // + // labelMessage + // + this.labelMessage.Dock = System.Windows.Forms.DockStyle.Fill; + this.labelMessage.Location = new System.Drawing.Point(0, 0); + this.labelMessage.Name = "labelMessage"; + this.labelMessage.Size = new System.Drawing.Size(250, 51); + this.labelMessage.TabIndex = 1; + this.labelMessage.Text = "Message"; + this.labelMessage.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // panel1 + // + this.panel1.Controls.Add(this.buttonOK); + this.panel1.Dock = System.Windows.Forms.DockStyle.Bottom; + this.panel1.Location = new System.Drawing.Point(0, 51); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(250, 24); + this.panel1.TabIndex = 2; + // + // ShowPopupMessage + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(250, 75); + this.Controls.Add(this.labelMessage); + this.Controls.Add(this.panel1); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.MinimumSize = new System.Drawing.Size(256, 100); + this.Name = "ShowPopupMessage"; + this.ShowIcon = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "Header"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ShowPopupMessage_FormClosing); + this.Load += new System.EventHandler(this.ShowPopupMessage_Load); + this.panel1.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Button buttonOK; + private System.Windows.Forms.Timer timerOK; + private System.Windows.Forms.Label labelMessage; + private System.Windows.Forms.Panel panel1; + } +} \ No newline at end of file Added: trunk/plugins/IR Server Suite/Common/IrssUtils/Forms/ShowPopupMessage.cs =================================================================== --- trunk/plugins/IR Server Suite/Common/IrssUtils/Forms/ShowPopupMessage.cs (rev 0) +++ trunk/plugins/IR Server Suite/Common/IrssUtils/Forms/ShowPopupMessage.cs 2007-12-17 05:55:29 UTC (rev 1161) @@ -0,0 +1,64 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Text; +using System.Windows.Forms; + +namespace IrssUtils.Forms +{ + + /// <summary> + /// Show a popup message. + /// </summary> + public partial class ShowPopupMessage : Form + { + + #region Variables + + int _timeout; + + #endregion Variables + + /// <summary> + /// Initializes a new instance of the <see cref="ShowPopupMessage"/> class. + /// </summary> + public ShowPopupMessage(string header, string text, int timeout) + { + InitializeComponent(); + + this.Text = header; + labelMessage.Text = text; + _timeout = timeout; + } + + + private void timerOK_Tick(object sender, EventArgs e) + { + _timeout--; + + if (_timeout <= 0) + this.Close(); + + buttonOK.Text = String.Format("OK ({0})", _timeout); + } + + private void ShowPopupMessage_Load(object sender, EventArgs e) + { + timerOK.Start(); + } + + private void ShowPopupMessage_FormClosing(object sender, FormClosingEventArgs e) + { + timerOK.Stop(); + } + + private void buttonOK_Click(object sender, EventArgs e) + { + this.Close(); + } + + } + +} Added: trunk/plugins/IR Server Suite/Common/IrssUtils/Forms/ShowPopupMessage.resx =================================================================== --- trunk/plugins/IR Server Suite/Common/IrssUtils/Forms/ShowPopupMessage.resx (rev 0) +++ trunk/plugins/IR Server Suite/Common/IrssUtils/Forms/ShowPopupMessage.resx 2007-12-17 05:55:29 UTC (rev 1161) @@ -0,0 +1,123 @@ +<?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... [truncated message content] |