public Form1() { InitializeComponent(); bnetWatcher = new BNetWatcher(); bnetWatcher.open(selectedInterface1.CurrentDevice); selectedInterface1.onInterfaceSelected += bnetWatcher.open; bnetWatcher.BNCSParser.OnCommand += delegate(DateTime Timestamp, string Text) { listBox1.Items.Add(Timestamp.ToShortTimeString() + ": " + "You: " + Text); }; bnetWatcher.BNCSParser.OnTalk += delegate(DateTime Timestamp, string User, string Text) { listBox1.Items.Add(Timestamp.ToShortTimeString() + ": " + User + ": " + Text); }; bnetWatcher.BNCSParser.OnEmote += delegate(DateTime Timestamp, string User, string Text) { listBox1.Items.Add(Timestamp.ToShortTimeString() + ": " + User + " " + Text); }; bnetWatcher.BNCSParser.OnWhisper += delegate(DateTime Timestamp, string User, string Text) { listBox1.Items.Add(Timestamp.ToShortTimeString() + ": " + User + " whispered to you: " + Text); }; bnetWatcher.BNCSParser.OnJoinGame += delegate(DateTime Timestamp, string User, string GameName) { listBox1.Items.Add(Timestamp.ToShortTimeString() + ": " + User + " joined the game '" + GameName + "'"); Clipboard.SetText(GameName); }; }
private void Form1_FormClosed(object sender, FormClosedEventArgs e) { bnetWatcher.open(null); bnetWatcher = null; }