public void OnUserVoteChecked(QuestionModel model) { while (!this.IsHandleCreated) ; if (this.InvokeRequired) { this.Invoke((QuestionController.ExternalEventHandler) OnUserVoteChecked, model); return; } foreach (KeyValuePair<RatingControl, UserData> pair in ratingUsers) if (model.My_votes.ContainsKey(pair.Value.Id)) pair.Key.Rating = model.My_votes[pair.Value.Id]; }
private void OnThisUserStateChanged(QuestionModel model) { while (!this.IsHandleCreated); if (this.InvokeRequired) { this.Invoke((QuestionController.ExternalEventHandler) OnThisUserStateChanged, model); return; } changeStateIMButtons(model); }
private void OnUserRankUpdated(QuestionModel model) { while (!this.IsHandleCreated); if (this.InvokeRequired) { this.Invoke((QuestionController.ExternalEventHandler) OnUserRankUpdated, model); return; } foreach(Label userLabel in userLabels.Keys) { uint id = userLabels[userLabel]; foreach(UserData user in model.AnswerOwners) if(user.Id == id) userLabel.Text = user.Username + " (" + String.Format("{0:0.##}", user.Rank) +")"; } }
private void OnQuestionResourcesReceived(QuestionModel model) { while (!this.IsHandleCreated) ; if (this.InvokeRequired) { this.Invoke((QuestionController.ExternalEventHandler) OnQuestionResourcesReceived, model); return; } referencesPanel.Controls.Clear(); int index = 0; resourceLabels.Clear(); foreach (ResourceData question in model.QuestionResources) { Label referenceLabel = new Label(); referenceLabel.Text = question.Title; referenceLabel.Location = new Point(10, 15 + index * 22); referenceLabel.AutoSize = true; referenceLabel.MouseClick += new System.Windows.Forms.MouseEventHandler(referenceClicked); referencesPanel.Controls.Add(referenceLabel); resourceLabels.Add(referenceLabel, question.Id); index++; } }
private void OnQuestionStatusChanged(QuestionModel model) { while (!this.IsHandleCreated); if (this.InvokeRequired) { this.Invoke((QuestionController.ExternalEventHandler) OnQuestionStatusChanged, model); return; } if (model.Question.Status == true) { QuestionTitleLabel.ForeColor = System.Drawing.Color.MediumBlue; stateButton.ForeColor = System.Drawing.Color.MediumBlue; stateButton.Text = "solved"; } else { QuestionTitleLabel.ForeColor = System.Drawing.Color.Green; stateButton.ForeColor = System.Drawing.Color.Green; stateButton.Text = "unsolved"; } if (LoggedInUserModel.Instance.User.Id == model.Question.Owner) stateButton.Enabled = true; else stateButton.Enabled = false; }
private void OnQuestionOwnerReceived(QuestionModel model) { while (!this.IsHandleCreated) ; if (this.InvokeRequired) { this.Invoke((QuestionController.ExternalEventHandler) OnQuestionOwnerReceived, model); return; } QuestionOwnerButton.Text = model.QuestionOwner.Username; if (LoggedInUserModel.Instance.User.Id == model.Question.Owner) stateButton.Enabled = true; else stateButton.Enabled = false; changeStateIMButtons(model); }
private void OnQuestionDomainsResourcesReceived(QuestionModel model) { while (!this.IsHandleCreated) ; if (this.InvokeRequired) { this.Invoke((QuestionController.ExternalEventHandler) OnQuestionDomainsResourcesReceived, model); return; } List<String> descriptions = new List<String>(); resourceIds.Clear(); for (int i = 0; i < model.Resources.Count; i++) { descriptions.Add(model.Resources[i].Title); resourceIds.Add(model.Resources[i].Id); } addReferenceListBox.DataSource = descriptions; for (int i = 0; i < model.Resources.Count; i++) addReferenceListBox.SetSelected(i, false); }
private void OnQuestionDomainsReceived(QuestionModel model) { while (!this.IsHandleCreated); if (this.InvokeRequired) { this.Invoke((QuestionController.ExternalEventHandler) OnQuestionDomainsReceived, model); return; } int index = 0; foreach (DomainData domain in model.Domains) { Label domainLabel = new Label(); domainLabel.Text = domain.Name; domainLabel.Location = new Point(10, 15 + index * 22); domainLabel.AutoSize = true; domainsPanel.Controls.Add(domainLabel); index ++; } }
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 changeStateIMButtons(QuestionModel model) { QuestionOwnerButton.Enabled = LoggedInUserModel.Instance.User.Status && (model.QuestionOwner.Id != LoggedInUserModel.Instance.User.Id); foreach (Label label in userLabels.Keys) label.Enabled = LoggedInUserModel.Instance.User.Status && (userLabels[label] != LoggedInUserModel.Instance.User.Id); }