private void saveNoteText(int index, string text) { if (index == getNewNoteFakeIndex()) { _cachedNewNoteText = text; } else { ReportedDiscussionNote note = _reportedNotes[index]; if (note.Content.Body != text) { _modifiedNoteTexts[note.Key] = text; } else { _modifiedNoteTexts.Remove(note.Key); } } }
private void updateRelatedDiscussionControlState() { bool areRelatedDisussionsAvailable = _relatedDiscussions.Any(); if (areRelatedDisussionsAvailable) { if (!_relatedDiscussionIndex.HasValue) { _relatedDiscussionIndex = 0; } else { _relatedDiscussionIndex = Math.Min(_relatedDiscussionIndex.Value, _relatedDiscussions.Count() - 1); } checkBoxShowRelated.Enabled = true; } else { _relatedDiscussionIndex = null; checkBoxShowRelated.Enabled = false; } checkBoxShowRelated.Text = String.Format("Show related threads ({0})", _relatedDiscussions.Count()); int currentRelatedIndex = areRelatedDisussionsAvailable ? _relatedDiscussionIndex.Value : 0; int currentRelatedIndexOneBased = areRelatedDisussionsAvailable ? _relatedDiscussionIndex.Value + 1 : 0; int totalRelatedIndex = areRelatedDisussionsAvailable ? _relatedDiscussions.Count() : 0; labelRelatedDiscussionCounter.Text = String.Format("{0} / {1}", currentRelatedIndexOneBased, totalRelatedIndex); labelRelatedDiscussionCounter.Visible = areRelatedDisussionsAvailable; bool allowScrollForward = areRelatedDisussionsAvailable && currentRelatedIndex < totalRelatedIndex - 1; bool allowScrollBackward = areRelatedDisussionsAvailable && currentRelatedIndex > 0; buttonPrevRelatedDiscussion.Enabled = allowScrollBackward; buttonNextRelatedDiscussion.Enabled = allowScrollForward; htmlPanelPreview.Enabled = areRelatedDisussionsAvailable; labelRelatedDiscussionAuthor.Visible = areRelatedDisussionsAvailable; updateRelatedThreadsGroupBoxVisibility(); if (needShowRelatedDiscussions()) { ReportedDiscussionNote note = _relatedDiscussions[_relatedDiscussionIndex.Value]; bool areRefsEqual = note.Position.DiffPosition.Refs.Equals(NewDiscussionPosition.Refs); labelDifferentContextHint.Visible = !areRefsEqual; labelRelatedDiscussionAuthor.Text = String.Format("{0} -- {1}", note.Details.AuthorName, TimeUtils.DateTimeToStringAgo(note.Details.CreatedAt)); toolTip.SetToolTip(labelRelatedDiscussionAuthor, TimeUtils.DateTimeToString(note.Details.CreatedAt)); updatePreview(htmlPanelPreviewRelatedDiscussion, note.Content.Body); showDiscussionContext(note.Position.DiffPosition, htmlPanelRelatedDiscussionContext); } else { labelRelatedDiscussionAuthor.Text = String.Empty; toolTip.SetToolTip(labelRelatedDiscussionAuthor, String.Empty); htmlPanelPreviewRelatedDiscussion.Text = String.Empty; htmlPanelRelatedDiscussionContext.Text = String.Empty; } // We want to hide "Show related" check box when related discussions don't make sense or unwanted checkBoxShowRelated.Visible = needShowDiffContext(); }