示例#1
0
        private bool ImportComment(EjpLib.BaseClasses.ejpCAComment comment)
        {
            TextPointer commentStart = this._textArea.Document.ContentStart.GetPositionAtOffset(Math.Abs((int)comment.OriginalPositionX));

            if (commentStart == null)
            {
                return(false);
            }
            TextPointer commentEnd = commentStart.GetPositionAtOffset(Math.Abs((int)comment.OriginalPositionY));

            if (commentEnd == null)
            {
                return(false);
            }
            Point commmentInsertPoint = commentStart.GetCharacterRect(LogicalDirection.Forward).TopLeft;

            KnowledgeMapComment commentToAdd = new KnowledgeMapComment()
            {
                OriginalAuthorId   = comment.AuthorId,
                OriginalAuthorName = comment.AuthorName,
                CurrentAuthorId    = this.CurrentOwnerId,
                CurrentAuthorName  = this.CurrentOwnerName,
                CommentId          = comment.CommentId,
                Width  = 200,
                Height = 300,
                CommentTextInDocument = comment.CommentedTextInDocument,
                OriginalCoordinates   = new Point(comment.OriginalPositionX, comment.OriginalPositionY),
                CommentedTextStart    = commentStart
            };

            commentToAdd.DisableReturnToOriginalPosition();

            foreach (EjpLib.BaseClasses.ejpCACommentMessage message in comment.Messages)
            {
                commentToAdd.Messages.Add(
                    new CommentMessage()
                {
                    Author   = message.Author,
                    AuthorId = message.AuthorId,
                    Date     = message.Date,
                    Message  = message.Message
                }
                    );
            }

            this._c_FakeAdornerLayer.Children.Add(commentToAdd);

            Point p =
                commentToAdd.CommentedTextStart.GetCharacterRect(
                    LogicalDirection.Forward).TopLeft;

            if (((p.Y - 10) + 300) < this._c_FakeAdornerLayer.ActualHeight)
            {
                Canvas.SetTop(commentToAdd, p.Y - 10);
            }
            else
            {
                Canvas.SetTop(commentToAdd, (p.Y - 10) - 300);
            }

            if ((p.X + 200) < this._c_FakeAdornerLayer.ActualWidth)
            {
                Canvas.SetLeft(commentToAdd, p.X);
            }
            else
            {
                Canvas.SetLeft(commentToAdd, p.X - 178);
            }

            commentToAdd.OnDeleteComment   += new DeleteKnowledgeMapComment(comment_OnDeleteComment);
            commentToAdd.OnMinimizeComment += new KnowledgeMapCommentViewStateChanged(comment_OnMinimizeComment);
            commentToAdd.OnMaximizeComment += new KnowledgeMapCommentViewStateChanged(comment_OnMaximizeComment);

            //this._comments.Add(commentToAdd);


            //090126
            Rect tStartRect = commentStart.GetCharacterRect(LogicalDirection.Forward);
            Rect tEndRect   = commentEnd.GetCharacterRect(LogicalDirection.Forward);

            DrawingBrush lineHandleSBrush = this.Resources["commentLineHandleS_default"] as DrawingBrush;
            DrawingBrush lineHandleEBrush = this.Resources["commentLineHandleE_default"] as DrawingBrush;

            commentToAdd.StartHandleRectangle = new Rectangle()
            {
                Fill = lineHandleSBrush
            };
            commentToAdd.StartHandleRectangle.Width  = 9;
            commentToAdd.StartHandleRectangle.Height = (tStartRect.Height < 5) ? 10 : tStartRect.Height;;
            commentToAdd.EndHandleRectangle          = new Rectangle()
            {
                Fill = lineHandleEBrush
            };
            commentToAdd.EndHandleRectangle.Width  = 9;
            commentToAdd.EndHandleRectangle.Height = (tEndRect.Height < 5) ? 10 : tEndRect.Height;
            commentToAdd.StartHandleRectangle.SetValue(Canvas.TopProperty, tStartRect.TopLeft.Y);
            commentToAdd.StartHandleRectangle.SetValue(Canvas.LeftProperty, tStartRect.TopLeft.X);
            commentToAdd.EndHandleRectangle.SetValue(Canvas.TopProperty, tEndRect.TopLeft.Y);
            commentToAdd.EndHandleRectangle.SetValue(Canvas.LeftProperty, tEndRect.TopLeft.X);

            this._c_FakeAdornerLayer.Children.Insert(0, commentToAdd.StartHandleRectangle);
            this._c_FakeAdornerLayer.Children.Insert(0, commentToAdd.EndHandleRectangle);

            this._comments.Add(commentToAdd);
            return(true);
        }
示例#2
0
        private void AddCommentToSelection()
        {
            try
            {
                if (this._textArea.Selection.IsEmpty)
                {
                    return;
                }

                //New comment system 081119
                Point p =
                    this._textArea.Selection.Start.GetCharacterRect(
                        LogicalDirection.Forward).TopLeft;

                TextPointer tp1   = this._textArea.Selection.Start;
                TextPointer tp2   = this._textArea.Selection.End;
                TextRange   range = new TextRange(tp1, tp2);

                KnowledgeMapComment comment = new KnowledgeMapComment()
                {
                    OriginalAuthorId   = this.CurrentOwnerId,
                    OriginalAuthorName = this.CurrentOwnerName,
                    CurrentAuthorId    = this.CurrentOwnerId,
                    CurrentAuthorName  = this.CurrentOwnerName,
                    CommentId          = Guid.NewGuid(),
                    Width  = 200,
                    Height = 300,
                    CommentTextInDocument = range.Text,
                    OriginalCoordinates   = p,
                    CommentedTextStart    = tp1
                };

                comment.DisableReturnToOriginalPosition();

                this._c_FakeAdornerLayer.Children.Add(comment);

                if (((p.Y - 10) + 300) < this._c_FakeAdornerLayer.ActualHeight)
                {
                    Canvas.SetTop(comment, p.Y - 10);
                }
                else
                {
                    Canvas.SetTop(comment, (p.Y - 10) - 300);
                }

                if ((p.X + 200) < this._c_FakeAdornerLayer.ActualWidth)
                {
                    Canvas.SetLeft(comment, p.X);
                }
                else
                {
                    Canvas.SetLeft(comment, p.X - 178);
                }

                comment.OnDeleteComment   += new DeleteKnowledgeMapComment(comment_OnDeleteComment);
                comment.OnMinimizeComment += new KnowledgeMapCommentViewStateChanged(comment_OnMinimizeComment);
                comment.OnMaximizeComment += new KnowledgeMapCommentViewStateChanged(comment_OnMaximizeComment);
                this._comments.Add(comment);

                return;
            }
            catch (Exception ex)
            {
                SiliconStudio.DebugManagers.DebugReporter.Report(
                    SiliconStudio.DebugManagers.MessageType.Error,
                    "EjpControls - Report Editor",
                    "Failed to Add Comment to Selection" +
                    "\nParent Study ID: " + this.ParentStudyId.ToString() +
                    "\nReport ID: " + this._reportObject.Id.ToString() +
                    "\nError: " + ex.Message);
                throw;
            }
        }
示例#3
0
        private void AddCommentToSelection()
        {
            try
            {
                if (this._textArea.Selection.IsEmpty)
                {
                    return;
                }

                //New comment system 081119
                Rect tStartRect =
                    this._textArea.Selection.Start.GetCharacterRect(LogicalDirection.Forward);
                Rect tEndRect =
                    this._textArea.Selection.End.GetCharacterRect(LogicalDirection.Forward);

                TextPointer tp1   = this._textArea.Selection.Start;
                TextPointer tp2   = this._textArea.Selection.End;
                TextRange   range = new TextRange(tp1, tp2);

                int cStartOffset = tp1.GetOffsetToPosition(this._textArea.Document.ContentStart);
                int cEndOffset   = tp2.GetOffsetToPosition(tp1);

                KnowledgeMapComment comment = new KnowledgeMapComment()
                {
                    OriginalAuthorId   = this.CurrentOwnerId,
                    OriginalAuthorName = this.CurrentOwnerName,
                    CurrentAuthorId    = this.CurrentOwnerId,
                    CurrentAuthorName  = this.CurrentOwnerName,
                    CommentId          = Guid.NewGuid(),
                    Width  = 200,
                    Height = 300,
                    CommentTextInDocument = range.Text,
                    OriginalCoordinates   = new Point(cStartOffset, cEndOffset),
                    CommentedTextStart    = tp1
                };

                comment.DisableReturnToOriginalPosition();

                this._c_FakeAdornerLayer.Children.Add(comment);

                if (((tStartRect.TopLeft.Y - 10) + 300) < this._c_FakeAdornerLayer.ActualHeight)
                {
                    Canvas.SetTop(comment, tStartRect.TopLeft.Y - 10);
                }
                else
                {
                    Canvas.SetTop(comment, (tStartRect.TopLeft.Y - 10) - 300);
                }

                if ((tStartRect.TopLeft.X + 200) < this._c_FakeAdornerLayer.ActualWidth)
                {
                    Canvas.SetLeft(comment, tStartRect.TopLeft.X);
                }
                else
                {
                    Canvas.SetLeft(comment, tStartRect.TopLeft.X - 178);
                }

                comment.OnDeleteComment += new
                                           DeleteKnowledgeMapComment(comment_OnDeleteComment);
                comment.OnMinimizeComment += new
                                             KnowledgeMapCommentViewStateChanged(comment_OnMinimizeComment);
                comment.OnMaximizeComment += new
                                             KnowledgeMapCommentViewStateChanged(comment_OnMaximizeComment);
                this._comments.Add(comment);

                //090126
                DrawingBrush lineHandleSBrush =
                    this.Resources["commentLineHandleS_default"] as DrawingBrush;
                DrawingBrush lineHandleEBrush =
                    this.Resources["commentLineHandleE_default"] as DrawingBrush;
                comment.StartHandleRectangle = new Rectangle()
                {
                    Fill
                        = lineHandleSBrush
                };
                comment.StartHandleRectangle.Width  = 9;
                comment.StartHandleRectangle.Height = (tStartRect.Height < 5) ? 10 : tStartRect.Height;;
                comment.EndHandleRectangle          = new Rectangle()
                {
                    Fill =
                        lineHandleEBrush
                };
                comment.EndHandleRectangle.Width  = 9;
                comment.EndHandleRectangle.Height = (tEndRect.Height < 5) ? 10 : tEndRect.Height;

                comment.StartHandleRectangle.SetValue(Canvas.TopProperty,
                                                      tStartRect.TopLeft.Y);

                comment.StartHandleRectangle.SetValue(Canvas.LeftProperty,
                                                      tStartRect.TopLeft.X);

                comment.EndHandleRectangle.SetValue(Canvas.TopProperty,
                                                    tEndRect.TopLeft.Y);

                comment.EndHandleRectangle.SetValue(Canvas.LeftProperty,
                                                    tEndRect.TopLeft.X);


                this._c_FakeAdornerLayer.Children.Insert(0, comment.StartHandleRectangle);
                this._c_FakeAdornerLayer.Children.Insert(0, comment.EndHandleRectangle);

                return;
            }
            catch (Exception)
            {
                throw;
            }
        }
示例#4
0
        private void ImportComment(EjpLib.BaseClasses.ejpCAComment comment)
        {
            TextPointer commentStart = this._textArea.GetPositionFromPoint(
                new Point(comment.OriginalPositionX, comment.OriginalPositionY), true);

            TextPointer commentEnd = commentStart.GetPositionAtOffset(comment.CommentedTextInDocument.Length);

            KnowledgeMapComment commentToAdd = new KnowledgeMapComment()
            {
                OriginalAuthorId   = comment.AuthorId,
                OriginalAuthorName = comment.AuthorName,
                CurrentAuthorId    = this.CurrentOwnerId,
                CurrentAuthorName  = this.CurrentOwnerName,
                CommentId          = comment.CommentId,
                Width  = 200,
                Height = 300,
                CommentTextInDocument = comment.CommentedTextInDocument,
                OriginalCoordinates   = new Point(comment.OriginalPositionX, comment.OriginalPositionY),
                CommentedTextStart    = commentStart
            };

            commentToAdd.DisableReturnToOriginalPosition();

            foreach (EjpLib.BaseClasses.ejpCACommentMessage message in comment.Messages)
            {
                commentToAdd.Messages.Add(
                    new CommentMessage()
                {
                    Author   = message.Author,
                    AuthorId = message.AuthorId,
                    Date     = message.Date,
                    Message  = message.Message
                }
                    );
            }

            this._c_FakeAdornerLayer.Children.Add(commentToAdd);

            Point p =
                commentToAdd.CommentedTextStart.GetCharacterRect(
                    LogicalDirection.Forward).TopLeft;

            if (((p.Y - 10) + 300) < this._c_FakeAdornerLayer.ActualHeight)
            {
                Canvas.SetTop(commentToAdd, p.Y - 10);
            }
            else
            {
                Canvas.SetTop(commentToAdd, (p.Y - 10) - 300);
            }

            if ((p.X + 200) < this._c_FakeAdornerLayer.ActualWidth)
            {
                Canvas.SetLeft(commentToAdd, p.X);
            }
            else
            {
                Canvas.SetLeft(commentToAdd, p.X - 178);
            }

            commentToAdd.OnDeleteComment   += new DeleteKnowledgeMapComment(comment_OnDeleteComment);
            commentToAdd.OnMinimizeComment += new KnowledgeMapCommentViewStateChanged(comment_OnMinimizeComment);
            commentToAdd.OnMaximizeComment += new KnowledgeMapCommentViewStateChanged(comment_OnMaximizeComment);

            this._comments.Add(commentToAdd);
        }