private void OnQuestionAnswersReceived(QuestionModel model) { while (!this.IsHandleCreated); if (this.InvokeRequired) { this.Invoke((QuestionController.ExternalEventHandler) OnQuestionAnswersReceived, model); return; } int start = 0; if (answersRichTextBox.Text.Length != 0) start = model.Answers.Count - 1; for (int i=start; i<model.Answers.Count; i++) { answersRichTextBox.SelectionStart = answersRichTextBox.Text.Length; answersRichTextBox.SelectionFont = new Font("Verdana", 8, FontStyle.Bold); answersRichTextBox.SelectionBackColor = Color.LightGray; UserData owner = new UserData("x","y"); for (int j = 0; j < model.AnswerOwners.Count; j++) if (model.Answers[i].Owner == model.AnswerOwners[j].Id) { owner = model.AnswerOwners[j]; break; } answersRichTextBox.SelectedText = owner.Username + "\t" + model.Answers[i].Timestamp + "\n"; answersRichTextBox.SelectedRtf = model.Answers[i].Content; answersRichTextBox.SelectedText = "\n\n"; } answersRichTextBox.ScrollToCaret(); int index = 0; ratingUsers = new Dictionary<RatingControl, UserData>(); usersPanel.Controls.Clear(); foreach (UserData user in model.AnswerOwners) { RatingControl voteWidget = new RatingControl(); voteWidget.Location = new Point(10, 27 + index * 45); voteWidget.AutoSize = false; voteWidget.Scale(new SizeF((float)0.45, (float)0.5)); voteWidget.Fixed = false; if (user.Id == LoggedInUserModel.Instance.User.Id) voteWidget.Enabled = false; voteWidget.SelectRating += new Rating.RatingControl.SelectRatingHandler(this.onVoteWidgetClick); if (model.My_votes.ContainsKey(user.Id)) voteWidget.Rating = model.My_votes[user.Id]; else controller.CheckUserVote(user); usersPanel.Controls.Add(voteWidget); Label userLabel = new Label(); userLabel.Text = user.Username + " (" + String.Format("{0:0.##}", user.Rank) + ")"; userLabel.Location = new Point(55, 15 + index * 22); userLabel.AutoSize = true; usersPanel.Controls.Add(userLabel); userLabels.Add(userLabel, user.Id); userLabel.MouseClick += new System.Windows.Forms.MouseEventHandler(userClicked); index++; ratingUsers.Add(voteWidget, user); } postRichTextBox.Focus(); changeStateIMButtons(model); }
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); }