/// <summary> /// Update an existing comment. /// </summary> /// <param name="comment">The comment being updated.</param> private void UpdateComment(Comment comment) { InkComment inkComment = comment as InkComment; if (inkComment != null) { var strokes = new StrokeCollection(); if (this.InkCommentStrokes != null) { foreach (Stroke stroke in this.InkCommentStrokes) { strokes.Add(stroke); } } inkComment.Text = this.Text ?? string.Empty; inkComment.Modified = DateTime.Now; inkComment.InkCommentStrokes = strokes; } else { comment.Text = this.Text ?? string.Empty; comment.Modified = DateTime.Now; } }
/// <summary> /// Converts the <see cref="SqlComment"/> to <see cref="Comment"/>. /// </summary> /// <param name="sqlComment">The <see cref="SqlComment"/>.</param> /// <returns>The <see cref="Comment"/>.</returns> private static Comment ConvertToComment(SqlComment sqlComment) { Comment comment; if (string.IsNullOrEmpty(sqlComment.Strokes)) { comment = new Comment(); } else { comment = new InkComment { Strokes = sqlComment.Strokes }; } comment.Id = CreateUri(sqlComment.Id); comment.Created = sqlComment.Created; comment.Creator = sqlComment.Creator; comment.Text = sqlComment.Text; comment.Type = sqlComment.CommentType; comment.MarkIn = sqlComment.MarkIn; comment.MarkOut = sqlComment.MarkOut; return(comment); }
/// <summary> /// This method displays all the comments for the given shot or asset. /// </summary> /// <param name="comments">Comments collection associated with the current playing asset.</param> private void ShowAllComments(IEnumerable <Comment> comments) { foreach (Comment comment in comments) { switch (comment.CommentType) { case CommentType.Ink: this.InkComment.Visibility = Visibility.Visible; InkComment inkComment = (InkComment)comment; foreach (Stroke stroke in inkComment.InkCommentStrokes) { this.InkComment.Strokes.Add(stroke); } this.AddTextBlock(inkComment.Text); break; default: this.AddTextBlock(comment.Text); break; } } }
/// <summary> /// Converts a <see cref="Comment"/> into a <see cref="Sql.Comment"/>. /// </summary> /// <param name="comment">The <see cref="Comment"/> being converted.</param> /// <param name="sqlComment">The converted <see cref="Sql.Comment"/> that contains equivalent values from the <paramref name="comment"/>.</param> public static void ConvertToSqlComment(Comment comment, SqlComment sqlComment) { sqlComment.Creator = comment.Creator; sqlComment.Created = comment.Created; sqlComment.CommentType = comment.Type; sqlComment.Text = comment.Text; sqlComment.MarkIn = comment.MarkIn; sqlComment.MarkOut = comment.MarkOut; InkComment inkComment = comment as InkComment; if (inkComment != null) { sqlComment.Strokes = inkComment.Strokes; } }
/// <summary> /// Asserts that the <paramref name="sqlComment"/> contains equivalent values from the <paramref name="comment"/>. /// </summary> /// <param name="comment">The comment with expected values.</param> /// <param name="sqlComment">The comment with actual values.</param> public static void AssertComment(Comment comment, SqlComment sqlComment) { Assert.AreEqual(comment.Creator, sqlComment.Creator); Assert.AreEqual(comment.Created, sqlComment.Created); Assert.AreEqual(comment.MarkIn, sqlComment.MarkIn); Assert.AreEqual(comment.MarkOut, sqlComment.MarkOut); Assert.AreEqual(comment.Text, sqlComment.Text); Assert.AreEqual(comment.Type, sqlComment.CommentType); InkComment inkComment = comment as InkComment; if (inkComment != null) { Assert.AreEqual(inkComment.Strokes, sqlComment.Strokes); } }
/// <summary> /// Creates a ink comment for testing. /// </summary> /// <returns>A ink comment with values.</returns> public static InkComment CreateInkComment() { string strokes = @"<?xml version=""1.0"" encoding=""utf-16"" ?> <StrokeCollection xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""> <Stroke> <Stroke.DrawingAttributes> <DrawingAttributes Width=""200"" Height=""300"" Color=""#01020304"" OutlineColor=""#02020304""/> </Stroke.DrawingAttributes> <Stroke.StylusPoints> <StylusPointCollection> <StylusPoint X=""100"" Y=""40""/> </StylusPointCollection> </Stroke.StylusPoints> </Stroke> </StrokeCollection>"; var comment = new InkComment(); comment.Id = CreateUri(); comment.Type = "Ink"; comment.MarkIn = 5; comment.MarkOut = 7.6; comment.Text = "Text"; comment.Creator = "Creator"; comment.Created = new DateTime(2009, 1, 1); comment.Strokes = strokes; return(comment); }
/// <summary> /// Edits the comment with the specified id. /// </summary> /// <param name="id">The id of the comment.</param> private void Edit(object id) { if (id is Guid) { Guid commentId = (Guid)id; Comment comment = this.currentComments.SingleOrDefault(x => x.CommentId == commentId); if (comment != null) { this.CurrentComment = comment; this.Text = comment.Text; this.EditMode = true; InkComment inkComment = comment as InkComment; if (inkComment != null) { var strokes = new StrokeCollection(); foreach (var stroke in inkComment.InkCommentStrokes) { strokes.Add(stroke); } TimelineElement element = this.GetElementAssociatedToComment(inkComment); if (element != null) { TimeCode markInTimeCode = TimeCode.FromSeconds(inkComment.MarkIn.GetValueOrDefault(), this.sequenceRegistry.CurrentSequenceModel.Duration.FrameRate); TimeCode currentFramePosition = (markInTimeCode - element.Position) + element.InPosition; this.FrameImage = this.thumbnailService.GetThumbnailSource(element.Asset, currentFramePosition); } this.InkCommentStrokes = strokes; this.View.SetInkEditingMode(InkEditingMode.Ink); } } } }