Exemplo n.º 1
0
 private void OnThisUserStateChanged(FriendListModel model)
 {
     while (!this.IsHandleCreated) ;
     if (this.InvokeRequired)
     {
         this.Invoke((FriendListController.ExternalEventHandler)
             OnThisUserStateChanged, model);
         return;
     }
     if (LoggedInUserModel.Instance.User.Status)
     {
         toggleStatusButton.Text = "Go Offline";
         panel1.Visible = true;
         addFriendTextBox.Visible = true;
         customStylesCheckbox.Visible = true;
         offlineCheckBox.Visible = true;
         invitingCheckBox.Visible = true;
         invitedCheckBox.Visible = true;
     }
     else
     {
         toggleStatusButton.Text = "Go Online";
         panel1.Visible = false;
         addFriendTextBox.Visible = false;
         customStylesCheckbox.Visible = false;
         offlineCheckBox.Visible = false;
         invitingCheckBox.Visible = false;
         invitedCheckBox.Visible = false;
     }
 }
Exemplo n.º 2
0
        private void PutUserOnList(uint thisUserId, int index, UserData user, FriendListModel model, bool friendshipStatus, bool onlineStatus)
        {
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FriendListView));
            PictureBox icon = new PictureBox();
            ((System.ComponentModel.ISupportInitialize)(icon)).BeginInit();
            if (!friendshipStatus)
                icon.Image = global::REACH.Client.Properties.Resources.user_pending;
            else if (onlineStatus)
                icon.Image = global::REACH.Client.Properties.Resources.user_online;
            else
                icon.Image = global::REACH.Client.Properties.Resources.user_offline;
            icon.Location = new Point(lineHeight - 20, index * lineHeight + 2);
            icon.Size = new Size(20, 20);
            panel1.Controls.Add(icon);

            FriendshipData friendship = model.GetFriendshipById(user.Id);
            if (!(friendship.Status))
            {
                if (friendship.Latter == thisUserId)
                {
                    Button acceptButton = new Button();
                    acceptButton.Text = "accept";
                    acceptButton.Location = new Point(130, index * lineHeight);
                    acceptButton.Size = new Size(80, lineHeight);
                    acceptButton.AutoSize = false;
                    acceptButton.Click += new System.EventHandler(this.OnAccept);
                    acceptButtons.Add(acceptButton, user.Id);
                    panel1.Controls.Add(acceptButton);

                    Button denyButton = new Button();
                    denyButton.Text = "deny";
                    denyButton.Location = new Point(210, index * lineHeight);
                    denyButton.Size = new Size(80, lineHeight);
                    denyButton.AutoSize = false;
                    denyButton.Click += new System.EventHandler(this.OnDeny);
                    denyButtons.Add(denyButton, user.Id);
                    panel1.Controls.Add(denyButton);
                }
            }

            Label friendname = new Label();
            friendname.Text = user.Username;
            friendname.Location = new Point(30, index * lineHeight);
            friendname.Font = new Font(
                "Microsoft Sans Serif",
                9.75F,
                FontStyle.Regular,
                GraphicsUnit.Point, ((byte)(0)));
            friendname.AutoSize = false;
            friendname.Size = new Size(panel1.Width - 55, lineHeight);
            friendname.Click += new System.EventHandler(this.OnNameClick);
            friendname.MouseEnter += new System.EventHandler(this.ColorNameLabel);
            friendname.MouseLeave += new System.EventHandler(this.UncolorNameLabel);
            nameLabels.Add(friendname, user.Id);
            panel1.Controls.Add(friendname);
        }
Exemplo n.º 3
0
 private void OnFriendListStateChanged(FriendListModel model)
 {
     while (!this.IsHandleCreated) ;
     if (this.InvokeRequired)
     {
         this.Invoke((FriendListController.ExternalEventHandler)
             OnFriendListStateChanged, model);
         return;
     }
     nameLabels.Clear();
     denyButtons.Clear();
     acceptButtons.Clear();
     uint thisUserId = LoggedInUserModel.Instance.User.Id;
     int index = 0;
     panel1.Controls.Clear();
     panel1.Focus();
     panel1.SuspendLayout();
     // Online users
     foreach (UserData user in model.Users)
     {
         FriendshipData friendship = model.GetFriendshipById(user.Id);
         if (friendship.Status && user.Status)
             PutUserOnList(thisUserId, index++, user, model, friendship.Status, user.Status);
     }
     // Offline users
     if (offlineCheckBox.Checked)
         foreach (UserData user in model.Users)
         {
             FriendshipData friendship = model.GetFriendshipById(user.Id);
             if (friendship.Status && !user.Status)
                 PutUserOnList(thisUserId, index++, user, model, friendship.Status, user.Status);
         }
     // Inviting users
     if (invitingCheckBox.Checked)
         foreach (UserData user in model.Users)
         {
             FriendshipData friendship = model.GetFriendshipById(user.Id);
             if (!friendship.Status && friendship.Latter == thisUserId)
                 PutUserOnList(thisUserId, index++, user, model, friendship.Status, user.Status);
         }
     // Invited users
     if (invitedCheckBox.Checked)
         foreach (UserData user in model.Users)
         {
             FriendshipData friendship = model.GetFriendshipById(user.Id);
             if (!friendship.Status && friendship.Latter != thisUserId)
                 PutUserOnList(thisUserId, index++, user, model, friendship.Status, user.Status);
         }
     panel1.ResumeLayout();
     panel1.PerformLayout();
 }