コード例 #1
0
ファイル: fIRC.cs プロジェクト: lpradel/lpIRC
        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();
        }
コード例 #2
0
ファイル: IRCManager.cs プロジェクト: lpradel/lpIRC
        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);
        }
コード例 #3
0
ファイル: Options.cs プロジェクト: lpradel/lpIRC
        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();
            }
        }
コード例 #4
0
ファイル: fConnect.cs プロジェクト: lpradel/lpIRC
        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();
        }