/// <summary> /// Updates the <see cref="CommentControl"/> content visibility. /// </summary> /// <param name="value">Indicates whether the <see cref="CommentControl"/> content is visible.</param> private void UpdateCommentControlContentVisibility(bool value) { if (value) { CommentControl.UpdateUI(); CommentControl.SetSize(); } else { CommentControl.BackColor = TransformBackgroundColor; } try { foreach (Control control in CommentControl.Controls) { control.Visible = value; } } catch (System.ComponentModel.Win32Exception ex) { if (!_hasVisibilityUpdatingError) { // WinForms generates Win32Exception if 15 or more FlowLayoutPanel are nested MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); _hasVisibilityUpdatingError = true; } } CommentControl.Update(); }
/// <summary> /// Adds the comment control for specified commment. /// </summary> /// <param name="comment">The comment.</param> private void AddCommentControl(Comment comment) { if (comment == null) { throw new ArgumentNullException(); } CommentControl control = new CommentControl(); control.Comment = comment; control.AutoHeight = true; control.CanClose = false; control.CanExpand = true; SetCommentControlSize(control); control.IsCommentSelectedChanged += CommentControl_IsCommentSelectedChanged; commentsLayoutPanel.Controls.Add(control); }
/// <summary> /// Initializes a new instance of the <see cref="CommentControlTransformer"/> class. /// </summary> /// <param name="commentControl">The comment control.</param> /// <exception cref="System.ArgumentNullException">Thrown if <i>commentControl</i> is <b>null</b>.</exception> /// <exception cref="System.InvalidOperationException">Thrown if image viewer is not found.</exception> public CommentControlTransformer(CommentControl commentControl) { if (commentControl == null) { throw new ArgumentNullException(); } _commentControl = commentControl; _imageViewer = GetImageViewer(commentControl); if (_imageViewer == null) { throw new InvalidOperationException("The image viewer is not found."); } SizeChangeMargin = 6; LocationChangeTopMargin = Math.Max(1, commentControl.TopPanelSize.Height); SubscribeToControlEvents(commentControl); ShowMoveCursor = false; }