Ejemplo n.º 1
0
        void CreateRosterView()
        {
            createroster = true;
            Rosterpanel.Hide();
            Rosterpanel.Resize += new EventHandler(Rosterpanel_Resize);
             foreach (KeyValuePair<string,agsXMPP.protocol.iq.roster.RosterItem> item in contactsRoster)
            {

                //PresenceRoster.Add(item.Value.Jid.Bare,

                RosterItemControl.RosterItemControl roster = new RosterItemControl.RosterItemControl();
                roster.MainPanel.MouseHover += new EventHandler(roster_MouseHover);
                roster.MainPanel.MouseLeave += new EventHandler(MainPanel_MouseLeave);

                roster.NameLabel.MouseEnter+=new EventHandler(roster_MouseHover);
                roster.MainPanel.Click += new EventHandler(ChatImage_Click);
                roster.Name = item.Value.Jid.Bare;

                if (String.IsNullOrEmpty(item.Value.Name))
                {
                    roster.NameLabel.Text = item.Value.Jid.Bare;

                }
                else
                {
                    roster.NameLabel.Text = item.Value.Name;

                }

                if (VCardImage.ContainsKey(item.Value.Jid.Bare.ToLower()))
                        roster.VCardImage.Image = VCardImage[item.Value.Jid.Bare.ToLower()];
                    else
                        roster.VCardImage.Image = Properties.Resources.Moon;

                roster.Dock = DockStyle.Left;
                Rosterpanel.Controls.Add(roster);

            }
        }
Ejemplo n.º 2
0
        void CreateOnlineRoster()
        {
            OnlinePanel.Controls.Clear();
            OnlinePanel.Hide();

            foreach (KeyValuePair<string, agsXMPP.protocol.client.Presence> item in availableRoster)
            {
                RosterItemControl.RosterItemControl roster = new RosterItemControl.RosterItemControl();

                try
                {
                    roster.MainPanel.MouseHover += new EventHandler(roster_MouseHover);
                    roster.MainPanel.MouseLeave += new EventHandler(MainPanel_MouseLeave);
                    roster.MainPanel.Click += new EventHandler(ChatImage_Click);
                    roster.NameLabel.MouseEnter += new EventHandler(roster_MouseHover);
                    roster.Name = item.Value.From.Bare.ToLower();
                }
                catch
                {
                    MessageBox.Show("Available:Roster Creation PLace");
                }

                try
                {

                    if (contactsRoster.ContainsKey(item.Value.From.Bare.ToLower()))
                    {
                        if (String.IsNullOrEmpty(contactsRoster[item.Value.From.Bare.ToLower()].Name))
                        {
                            roster.NameLabel.Text = contactsRoster[item.Value.From.Bare.ToLower()].Jid.Bare;

                        }
                        else
                        {
                            roster.NameLabel.Text = contactsRoster[item.Value.From.Bare.ToLower()].Name;

                        }
                    }
                    if(string.IsNullOrEmpty(item.Value.Status))
                              roster.StatusLabel.Text="Available";

                    else
                    roster.StatusLabel.Text = item.Value.Status;

                    roster.StatusImage.Image = Properties.Resources.green;
                }
                catch
                {
                    MessageBox.Show("Available:check contacts roster");
                }

                try
                {
                    if (VCardImage.ContainsKey(item.Value.From.Bare.ToLower()))
                    {
                        if (VCardImage[item.Value.From.Bare] != null)
                        {
                            roster.VCardImage.Image = VCardImage[item.Value.From.Bare.ToLower()];
                        }
                        else
                        {
                            roster.VCardImage.Image = Properties.Resources.Moon;
                        }
                    }
                    else
                    {
                        roster.VCardImage.Image = Properties.Resources.Moon;
                    }
                }
                catch
                {
                    MessageBox.Show("Available:vcard");
                }
                roster.Dock = DockStyle.Left;
               OnlinePanel.Controls.Add(roster);

            }
            foreach (KeyValuePair<string, agsXMPP.protocol.client.Presence> item in busyRoster)
            {
                RosterItemControl.RosterItemControl roster = new RosterItemControl.RosterItemControl();

                try
                {
                    roster.MainPanel.MouseHover += new EventHandler(roster_MouseHover);
                    roster.MainPanel.MouseLeave += new EventHandler(MainPanel_MouseLeave);
                    roster.NameLabel.MouseEnter += new EventHandler(roster_MouseHover);
                    roster.MainPanel.Click += new EventHandler(ChatImage_Click);

                    roster.Name = item.Value.From.Bare.ToLower();
                }
                catch
                {
                    MessageBox.Show("busy:roster create");
                }

                try
                {
                    if (contactsRoster.ContainsKey(item.Value.From.Bare.ToLower()))
                    {
                        if (String.IsNullOrEmpty(contactsRoster[item.Value.From.Bare.ToLower()].Name))
                        {
                            roster.NameLabel.Text = contactsRoster[item.Value.From.Bare.ToLower()].Jid.Bare;

                        }
                        else
                        {
                            roster.NameLabel.Text = contactsRoster[item.Value.From.Bare.ToLower()].Name;

                        }
                        if (string.IsNullOrEmpty(item.Value.Status))
                            roster.StatusLabel.Text = "Busy";

                        else
                        roster.StatusLabel.Text = item.Value.Status;
                        roster.StatusImage.Image = Properties.Resources.red;
                    }
                }
                catch
                {
                    MessageBox.Show("busy:check contacts roster");
                }

                try
                {
                    if (VCardImage.ContainsKey(item.Value.From.Bare.ToLower()))
                    {
                        if (VCardImage[item.Value.From.Bare.ToLower()] != null)
                        {
                            roster.VCardImage.Image = VCardImage[item.Value.From.Bare.ToLower()];
                        }
                        else
                        {
                            roster.VCardImage.Image = Properties.Resources.Moon;
                        }
                    }
                    else
                    {
                        roster.VCardImage.Image = Properties.Resources.Moon;
                    }
                }
                catch
                {
                    MessageBox.Show("busy:vcard");
                }
                roster.Dock = DockStyle.Left;
                OnlinePanel.Controls.Add(roster);

            }
            foreach (KeyValuePair<string, agsXMPP.protocol.client.Presence> item in idleRoster)
            {
                RosterItemControl.RosterItemControl roster = new RosterItemControl.RosterItemControl();

                try
                {

                    roster.MainPanel.MouseHover += new EventHandler(roster_MouseHover);
                    roster.MainPanel.MouseLeave += new EventHandler(MainPanel_MouseLeave);
                    roster.NameLabel.MouseEnter += new EventHandler(roster_MouseHover);
                    roster.MainPanel.Click += new EventHandler(ChatImage_Click);
                    roster.Name = item.Value.From.Bare.ToLower();
                }
                catch
                {
                    MessageBox.Show("idle:create roster");
                }
                try
                {
                    if (contactsRoster.ContainsKey(item.Value.From.Bare.ToLower()))
                    {
                        if (String.IsNullOrEmpty(contactsRoster[item.Value.From.Bare.ToLower()].Name))
                        {
                            roster.NameLabel.Text = contactsRoster[item.Value.From.Bare.ToLower()].Jid.Bare;

                        }
                        else
                        {
                            roster.NameLabel.Text = contactsRoster[item.Value.From.Bare.ToLower()].Name;

                        }
                    }
                    if (string.IsNullOrEmpty(item.Value.Status))
                        roster.StatusLabel.Text = "Idle";

                    else
                    roster.StatusLabel.Text = item.Value.Status;
                    roster.StatusImage.Image = Properties.Resources.orange;
                }
                catch
                {
                    MessageBox.Show("idle:check contacts roster");
                }
                try
                {
                    if (VCardImage.ContainsKey(item.Value.From.Bare.ToLower()))
                    {
                        if (VCardImage[item.Value.From.Bare.ToLower()] != null)
                        {
                            roster.VCardImage.Image = VCardImage[item.Value.From.Bare.ToLower()];
                        }
                        else
                        {
                            roster.VCardImage.Image = Properties.Resources.Moon;
                        }
                    }
                    else
                    {
                        roster.VCardImage.Image = Properties.Resources.Moon;
                    }
                }
                 catch
                {
                    MessageBox.Show("idle:vcard");
                }
                roster.Dock = DockStyle.Left;
                OnlinePanel.Controls.Add(roster);

            }

            if (OnlinePanel.Controls.Count < 8)
                  OnlinePanel.AutoScroll = false;
            else
                OnlinePanel.AutoScroll = true;

              OnlinePanel.Show();
        }