/// <summary> /// Used to fire the new data event. /// </summary> /// <param name="e">E.</param> protected virtual void OnNewData(NewDataEventArgs e) { if (NewData != null) { NewData(this, e); } }
private void c_NewData(object sender, NewDataEventArgs e) { if (Active) { this.Icon = appIcon; } else { this.Icon = dataIcon; } }
private void timer_Tick(object sender, EventArgs e) { if (socket.Connected && socket.Poll(1, SelectMode.SelectRead)) { byte[] buffer = new byte[client.ReceiveBufferSize]; int recieved = 0; try { recieved = stream.Read(buffer, 0, client.ReceiveBufferSize); if (recieved == 0) { Disconnect(); OnDisconnected(EventArgs.Empty); return; } buffer = telnet.ProcessTelnet(buffer); string data = Encoding.UTF8.GetString(buffer); data = data.Trim(new char[1] {'\0'}); log.Write(data); ansi.AppendText(data, AnsiEdit.MessageType.ANSI); //Tell everyone there's new data NewDataEventArgs dataEvent = new NewDataEventArgs(data); OnNewData(dataEvent); if (((TabControl) tabPage.Parent).SelectedTab != tabPage) { tabPage.ImageIndex = 1; } } catch (SocketException se) { this.Ansi.AppendText("\nRead Error: " + se.Message + "\n", AnsiEdit.MessageType.Error); Disconnect(); OnDisconnected(EventArgs.Empty); } catch (IOException ioE) { this.Ansi.AppendText("\nRead Error: " + ioE.Message + "\n", AnsiEdit.MessageType.Error); Disconnect(); OnDisconnected(EventArgs.Empty); } } }