public fIRC(IRCServer pServer, IRCLogInDetails pLogin) { InitializeComponent(); // set window-title this.Text = pServer.Address; // plug-in to connection via event-handlers connection.Connected += new EventHandler(ConnectionConnected); connection.ConnectionClosed += new EventHandler(ConnectionDisconnected); connection.GotMessage += new IRCConnection.MessageEventHandler(ConnectionGotMessage); connection.SentMessage += new IRCConnection.MessageEventHandler(ConnectionSentMessage); connection.NickChanged += new EventHandler(ConnectionNickChanged); connection.ConnectionSocketError += new ClientSocket.ExceptionEventHandler(ConnectionError); // setup server = pServer; login = pLogin; // build IRCManager manager = new IRCManager(connection, server, login); // plug-in to manager via event-handlers manager.JoinedChannel += new IRCManager.ChannelEventHandler(ManagerJoinedChannel); manager.LeftChannel += new IRCManager.ChannelEventHandler(ManagerLeftChannel); manager.KickedFromChannel += new IRCManager.ChannelEventHandler(ManagerKickedFromChannel); manager.GotPrivateMessage += new IRCConnection.MessageEventHandler(ManagerGotPrivateMessage); // connect to server manager.Connect(); }
public IRCManager(IRCConnection pConnection, IRCServer pServer, IRCLogInDetails pLogIn) { connection = pConnection; server = pServer; logininfo = pLogIn; // plug into IRCConnection's events connectionMade = new EventHandler(ConnectionMade); connection.Connected += connectionMade; connectionClosed = new EventHandler(ConnectionClosed); connection.ConnectionClosed += connectionClosed; connectionGotMessage = new IRCConnection.MessageEventHandler(ConnectionGotMessage); connection.GotMessage += connectionGotMessage; connectionSentMessage = new IRCConnection.MessageEventHandler(ConnectionSentMessage); }
public static void SaveOptions(IRCServer pServer, IRCLogInDetails pLogIn) { // setup settings XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; settings.IndentChars = "\t"; using (XmlWriter writer = XmlWriter.Create(FILE_NAME, settings)) { // setup writer writer.WriteStartDocument(); writer.WriteStartElement(ROOT_ELEMENT); // IRCServer-Info writer.WriteStartElement("IRCServer"); writer.WriteElementString("Address", pServer.Address); writer.WriteElementString("Port", pServer.Port); writer.WriteEndElement(); // LogIn-Details writer.WriteStartElement("IRCLogin"); writer.WriteElementString("Username", pLogIn.Username); writer.WriteElementString("Realname", pLogIn.Realname); foreach (string n in pLogIn.Nicknames) { writer.WriteElementString("Nickname", n); } writer.WriteEndElement(); // finish writer.WriteEndElement(); writer.WriteEndDocument(); writer.Flush(); } }
private void fConnectBtnConnect_Click(object sender, EventArgs e) { if (InvokeRequired) { Invoke(new Action(delegate { fConnectBtnConnect_Click(sender, e); })); return; } // Get input string address = fConnectBoxAddress.Text; string port = fConnectBoxPort.Text; string username = fConnectBoxUserName.Text; string realname = fConnectBoxRealName.Text; string nicknames = fConnectBoxNicknames.Text; // check input if (address == null || address.Trim() == "") { ErrorBox("Invalid server address!"); return; } if (port == null || port.Trim() == "") { ErrorBox("Invalid port number!"); return; } if (username == null || username.Trim() == "") { ErrorBox("Invalid username!"); return; } if (realname == null || realname.Trim() == "") { ErrorBox("Invalid real name!"); return; } if (nicknames == null || nicknames.Trim() == "") { ErrorBox("Invalid nickname!"); return; } // here all input should be fine // build server server = new IRCServer(address, port); // build login login = new IRCLogInDetails(username, realname, nicknames); // save data, if checkbox is checked if (fConnectCheckBoxData.Checked) { Options.SaveOptions(server, login); } // hide me this.Hide(); // setup IRC-form fIRC wndIRC = new fIRC(server, login); wndIRC.MdiParent = this.MdiParent; wndIRC.Show(); // clean-up this.Close(); }