6 namespace TechBot.Commands.Common
8 [Command("wm" , Help = "!wm <value> or !wm <name>")]
9 public class WMCommand : XmlCommand
15 public override string XmlFile
17 get { return Settings.Default.WMXml; }
20 [CommandParameter("wm", "The windows message to check" , DefaultParameter = true)]
23 get { return Parameters; }
24 set { Parameters = value; }
27 public override void ExecuteCommand()
29 if (string.IsNullOrEmpty(WMText))
31 Say("Please provide a valid window message value or name.");
36 NumberParser np = new NumberParser();
37 long wm = np.Parse(WMText);
41 // Assume "!wm <name>" form.
42 output = GetWmNumber(WMText);
46 output = GetWmDescription(wm);
57 Say("I don't know about window message {0}.", WMText);
62 private string GetWmDescription(long wm)
64 XmlElement root = base.m_XmlDocument.DocumentElement;
65 XmlNode node = root.SelectSingleNode(String.Format("WindowMessage[@value='{0}']",
69 XmlAttribute text = node.Attributes["text"];
71 throw new Exception("Node has no text attribute.");
78 private string GetWmNumber(string wmName)
80 XmlElement root = base.m_XmlDocument.DocumentElement;
81 XmlNode node = root.SelectSingleNode(String.Format("WindowMessage[@text='{0}']",
85 XmlAttribute value = node.Attributes["value"];
87 throw new Exception("Node has no value attribute.");