Esempio n. 1
0
        private void cmdConnect_Click(object sender, System.EventArgs e)
        {
            string[] tmp;
            if (this.txtNickname.Text == null ||
                this.txtUsername.Text == null ||
                this.txtRealname.Text == null ||
                this.cmbServers.Items.Count == 0)
            {
                MessageBox.Show("Some information is missing. Please double check and try again.");
                return;
            }

            System.Random rnd       = new System.Random();
            mcServer      NewServer = Obsidian.mainForm.AddServer();

            NewServer.MyNickname = this.txtNickname.Text;
            NewServer.MyUsername = this.txtUsername.Text;
            NewServer.MyRealname = this.txtRealname.Text;

            /*
             * pick a random server, they're stored as either
             * servername, or servername:serverport - so split ;)
             */
            tmp = this.cmbServers.Items[rnd.Next(cmbServers.Items.Count)].ToString().Split(':');
            NewServer.ServerName = tmp[0];
            if (tmp[1] != null)
            {
                NewServer.ServerPort = System.Int32.Parse(tmp[1]);
            }
            /* todo: remove unconnectable instances from the list? */
            NewServer.Connect();
        }
Esempio n. 2
0
        public mcPage(mcServer Server, string Title, bool IsChannel)
        {
            // This call is required by the Windows.Forms Form Designer.
            InitializeComponent();

            this.Server = Server;
            this.Text = Title;

            if (!IsChannel)
            {
                this.txtData.Dock = DockStyle.Fill;
                this.panel1.Top = 0;
                this.panel1.Height = this.Height - this.txtToSend.Height;
                this.lstUsers.Visible = false;
                this.txtTopic.Visible = false;
                this.Topic = null;
            }

            this.Dock = System.Windows.Forms.DockStyle.Fill;

            if (Obsidian.mainForm != null)
                Obsidian.mainForm.Controls.Add(this);

            this.SetIndent(StringWidth(TimeStamp()+"<> ", this.txtData.Font));
        }
Esempio n. 3
0
        private void tvcWindows_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e)
        {
            mcPage   aPage;
            mcServer aServer = (mcServer)Servers.GetByIndex(Servers.IndexOfKey(e.Node.Tag));

            /*
             * Locate the server instance.
             * aServer will never be null, as if the above fails
             * the client will crash. This should be OK though
             * s we should NOT be trying to select a non-existant window ;)
             */

            /* find our page */
            aPage = aServer.FindPage(e.Node.Text);
            if (aPage == null)
            {
                /*
                 * all this generally means is that they selected, for example,
                 * a "messages" or "channels" node.
                 */
                aPage = aServer.CurrentPage;
            }
            /* now, we should have a page - focus on it */
            aPage.DoFocus();
        }
Esempio n. 4
0
        public mcPage(mcServer Server, string Title, bool IsChannel)
        {
            // This call is required by the Windows.Forms Form Designer.
            InitializeComponent();

            this.Server = Server;
            this.Text   = Title;

            if (!IsChannel)
            {
                this.txtData.Dock     = DockStyle.Fill;
                this.panel1.Top       = 0;
                this.panel1.Height    = this.Height - this.txtToSend.Height;
                this.lstUsers.Visible = false;
                this.txtTopic.Visible = false;
                this.Topic            = null;
            }


            this.Dock = System.Windows.Forms.DockStyle.Fill;

            if (Obsidian.mainForm != null)
            {
                Obsidian.mainForm.Controls.Add(this);
            }

            this.SetIndent(StringWidth(TimeStamp() + "<> ", this.txtData.Font));
        }
Esempio n. 5
0
        public mcServer AddServer()
        {
            mcServer Server = new mcServer();

            System.Random Rnd = new Random();

            /*
             * generate a random key.
             * this should break out eventually.
             */
            for (;;)
            {
                //100 chars should be sufficient entropy ;)...
                Server.HashKey = Server.HashKey + Rnd.Next(500000).ToString();
                if (!Servers.Contains(Server.HashKey))
                {
                    //we have generated a unique hashkey
                    Server.ServerPage.MyNode.Tag = Server.HashKey;
                    TreeNode lvi = new      TreeNode("My Status");
                    lvi.Tag = Server.HashKey;
                    tvcWindows.Nodes.Add(lvi);
                    Server.ServerPage.MyNode = lvi;

                    lvi     = new TreeNode("My Channels");
                    lvi.Tag = Server.HashKey;
                    Server.ServerPage.MyNode.Nodes.Add(lvi);
                    Server.ServerPage.ChannelsNode = lvi;

                    lvi     = new TreeNode("My Messages");
                    lvi.Tag = Server.HashKey;
                    Server.ServerPage.MyNode.Nodes.Add(lvi);
                    Server.ServerPage.MessagesNode = lvi;

                    lvi     = new TreeNode("My Buddies");
                    lvi.Tag = Server.HashKey;
                    Server.ServerPage.MyNode.Nodes.Add(lvi);
                    Server.ServerPage.BuddiesNode = lvi;

                    Servers.Add(Server.HashKey, Server);

                    this.tvcWindows.ExpandAll();

                    //fix: select this Server as active.
                    this.tvcWindows_AfterSelect(this, new TreeViewEventArgs(Server.ServerPage.MyNode, TreeViewAction.ByMouse));
                    return(Server);
                }
            }
        }
Esempio n. 6
0
        public mcServer AddServer()
        {
            mcServer Server = new mcServer();
            System.Random Rnd = new Random();

            /*
             * generate a random key.
             * this should break out eventually.
             */
            for (;;)
            {
                //100 chars should be sufficient entropy ;)...
                Server.HashKey = Server.HashKey + Rnd.Next(500000).ToString();
                if (!Servers.Contains(Server.HashKey))
                {
                    //we have generated a unique hashkey
                    Server.ServerPage.MyNode.Tag = Server.HashKey;
                    TreeNode lvi = new	TreeNode("My Status");
                    lvi.Tag = Server.HashKey;
                    tvcWindows.Nodes.Add(lvi);
                    Server.ServerPage.MyNode = lvi;

                    lvi = new TreeNode("My Channels");
                    lvi.Tag = Server.HashKey;
                    Server.ServerPage.MyNode.Nodes.Add(lvi);
                    Server.ServerPage.ChannelsNode = lvi;

                    lvi = new TreeNode("My Messages");
                    lvi.Tag = Server.HashKey;
                    Server.ServerPage.MyNode.Nodes.Add(lvi);
                    Server.ServerPage.MessagesNode = lvi;

                    lvi = new TreeNode("My Buddies");
                    lvi.Tag = Server.HashKey;
                    Server.ServerPage.MyNode.Nodes.Add(lvi);
                    Server.ServerPage.BuddiesNode = lvi;

                    Servers.Add(Server.HashKey, Server);

                    this.tvcWindows.ExpandAll();

                    //fix: select this Server as active.
                    this.tvcWindows_AfterSelect(this, new TreeViewEventArgs(Server.ServerPage.MyNode, TreeViewAction.ByMouse));
                    return Server;
                }
            }
        }
Esempio n. 7
0
 private void cmdClosePage_Click(object sender, System.EventArgs e)
 {
     if (this.Server.ServerPage.Equals(this))
     {
         /* todo: this needs to be configurable */
         this.Server.Disconnect("Departing.");
         Obsidian.mainForm.DeleteServer(this.Server);
         this.Server.CloseAllPages();
         this.Server.ServerPage.ClosePage();
         this.Server = null;
         return;
     }
     if (this.IsChannel)
     {
         this.Server.IRCSend("PART " + this.Text);
     }
     this.ClosePage();
 }
Esempio n. 8
0
 public void DeleteServer(mcServer Server)
 {
     Servers.Remove(Server.HashKey);
 }
Esempio n. 9
0
 private void cmdClosePage_Click(object sender, System.EventArgs e)
 {
     if (this.Server.ServerPage.Equals(this))
     {
         /* todo: this needs to be configurable */
         this.Server.Disconnect("Departing.");
         Obsidian.mainForm.DeleteServer(this.Server);
         this.Server.CloseAllPages();
         this.Server.ServerPage.ClosePage();
         this.Server = null;
         return;
     }
     if (this.IsChannel)
         this.Server.IRCSend("PART " + this.Text);
     this.ClosePage();
 }
Esempio n. 10
0
 public void DeleteServer(mcServer Server)
 {
     Servers.Remove(Server.HashKey);
 }