Exemple #1
0
        private void References_Changed(object sender, SceneNode pathNode, AnnotationEditor.ReferenceInfo info, DocumentNodeMarker damageMarker, DocumentNodeChange damage)
        {
            IEnumerable <string> enumerable = AnnotationUtils.ParseAnnotationReferences(((DocumentPrimitiveNode)pathNode.DocumentNode).GetValue <string>());

            info.ReferencedAnnotationIds = Enumerable.ToList <string>(enumerable);
            info.ReferencedAnnotations   = this.ComputeReferencedAnnotations(enumerable);
            this.InvalidateAdorners(info.ReferenceOwner);
        }
Exemple #2
0
        private AnnotationEditor.ReferenceInfo References_InsertedHandler(object sender, SceneNode basisNode, object basisContent, SceneNode newPathNode)
        {
            SceneElement         sceneElement = (SceneElement)newPathNode.Parent;
            IEnumerable <string> enumerable   = AnnotationUtils.ParseAnnotationReferences(((DocumentPrimitiveNode)newPathNode.DocumentNode).GetValue <string>());

            return(new AnnotationEditor.ReferenceInfo()
            {
                ReferenceOwner = sceneElement,
                ReferencedAnnotationIds = Enumerable.ToList <string>(enumerable),
                ReferencedAnnotations = this.ComputeReferencedAnnotations(enumerable)
            });
        }
Exemple #3
0
        internal AnnotationSceneNode CreateAnnotation(IEnumerable <SceneElement> targets)
        {
            Artboard            artboard             = this.sceneViewModel.DefaultView.Artboard;
            SceneElement        sceneElement         = Enumerable.First <SceneElement>(targets);
            int                 num                  = Enumerable.Count <SceneElement>(targets);
            bool                treatTopLeftAsCenter = num > 1 || sceneElement.Equals((object)sceneElement.ViewModel.RootNode);
            AnnotationSceneNode annotation;

            using (SceneEditTransaction editTransaction = sceneElement.ViewModel.CreateEditTransaction(StringTable.AddAnnotationUndoUnit))
            {
                annotation = AnnotationManagerSceneNode.CreateAnnotation((SceneNode)sceneElement);
                foreach (SceneElement element in Enumerable.Skip <SceneElement>(targets, 1))
                {
                    AnnotationUtils.AddAnnotationReference(element, annotation);
                }
                Point point1;
                if (treatTopLeftAsCenter)
                {
                    Rect rect = Rect.Empty;
                    if (num > 1 || !sceneElement.Equals((object)annotation.ViewModel.RootNode))
                    {
                        rect = artboard.GetElementListBounds(targets);
                    }
                    if (rect.IsEmpty)
                    {
                        rect = artboard.ArtboardBounds;
                    }
                    point1 = new Point(rect.Left + rect.Width / 2.0, rect.Top + rect.Height / 2.0);
                }
                else
                {
                    point1 = artboard.GetElementBounds(sceneElement).TopRight;
                }
                Point point2 = RoundingHelper.RoundPosition(point1);
                annotation.Left = point2.X;
                annotation.Top  = point2.Y;
                string authorName = this.AnnotationService.DesignerContext.AnnotationsOptionsModel.AuthorName;
                if (!string.IsNullOrEmpty(authorName))
                {
                    annotation.Author = authorName;
                }
                string authorInitials = this.AnnotationService.DesignerContext.AnnotationsOptionsModel.AuthorInitials;
                if (!string.IsNullOrEmpty(authorInitials))
                {
                    annotation.AuthorInitials = authorInitials;
                }
                AnnotationUtils.SetSerialNumber(annotation);
                editTransaction.Commit();
            }
            this.CreateAnnotationVisual(annotation).Initialize(treatTopLeftAsCenter);
            return(annotation);
        }
 private void DeleteCore(IEnumerable <AnnotationSceneNode> annotations)
 {
     ExceptionChecks.CheckNullArgument <IEnumerable <AnnotationSceneNode> >(annotations, "annotations");
     ExceptionChecks.CheckEmptyListArgument <AnnotationSceneNode>(annotations, "annotations");
     foreach (AnnotationSceneNode annotationSceneNode in Enumerable.ToList <AnnotationSceneNode>(annotations))
     {
         foreach (SceneElement element in Enumerable.ToList <SceneElement>(annotationSceneNode.AttachedElements))
         {
             AnnotationUtils.RemoveAnnotationReference(element, annotationSceneNode);
         }
         AnnotationManagerSceneNode.DeleteAnnotation(annotationSceneNode);
     }
 }
Exemple #5
0
        public static void AddAnnotationReference(SceneElement element, AnnotationSceneNode annotation)
        {
            ExceptionChecks.CheckNullArgument <SceneElement>(element, "element");
            ExceptionChecks.CheckNullArgument <AnnotationSceneNode>(annotation, "annotation");
            string str = annotation.Id;

            if (string.IsNullOrEmpty(str))
            {
                str = AnnotationUtils.SetAnnotationId(annotation);
            }
            IEnumerable <string> referencedAnnotationIds = AnnotationUtils.GetReferencedAnnotationIds(element);

            AnnotationUtils.SetAnnotationReferences(element, EnumerableExtensions.AppendItem <string>(referencedAnnotationIds, str));
        }
        public void UnlinkAttachment(AnnotationSceneNode annotation, SceneElement target)
        {
            SceneViewModel viewModel = annotation.ViewModel;

            using (SceneEditTransaction editTransaction = viewModel.CreateEditTransaction(StringTable.UnlinkAnnotationUndoUnit))
            {
                bool flag = AnnotationUtils.RemoveAnnotationReference(target, annotation);
                if (target.Equals((object)annotation.Parent))
                {
                    flag = true;
                    AnnotationManagerSceneNode.SetAnnotationParent(annotation, viewModel.RootNode);
                }
                if (!flag)
                {
                    return;
                }
                editTransaction.Commit();
            }
        }
Exemple #7
0
        public static bool RemoveAnnotationReference(SceneElement element, AnnotationSceneNode annotation)
        {
            ExceptionChecks.CheckNullArgument <SceneElement>(element, "element");
            ExceptionChecks.CheckNullArgument <AnnotationSceneNode>(annotation, "annotation");
            string annotationId = annotation.Id;

            if (string.IsNullOrEmpty(annotationId))
            {
                return(false);
            }
            List <string>        list       = Enumerable.ToList <string>(AnnotationUtils.GetReferencedAnnotationIds(element));
            IEnumerable <string> enumerable = Enumerable.Where <string>((IEnumerable <string>)list, (Func <string, bool>)(id => id.Equals(annotationId, StringComparison.OrdinalIgnoreCase)));

            if (!Enumerable.Any <string>(enumerable))
            {
                return(false);
            }
            AnnotationUtils.SetAnnotationReferences(element, Enumerable.Except <string>((IEnumerable <string>)list, enumerable));
            return(true);
        }
        public void UnlinkAllAttachments(AnnotationSceneNode annotation)
        {
            IEnumerable <SceneElement> attachedElements = annotation.AttachedElements;

            if (!Enumerable.Any <SceneElement>(attachedElements))
            {
                return;
            }
            SceneViewModel viewModel = annotation.ViewModel;

            using (SceneEditTransaction editTransaction = viewModel.CreateEditTransaction(StringTable.UnlinkAnnotationUndoUnit))
            {
                EnumerableExtensions.ForEach <SceneElement>(attachedElements, (Action <SceneElement>)(element => AnnotationUtils.RemoveAnnotationReference(element, annotation)));
                AnnotationManagerSceneNode.SetAnnotationParent(annotation, viewModel.RootNode);
                editTransaction.Commit();
            }
        }
Exemple #9
0
 public static IEnumerable <string> GetReferencedAnnotationIds(SceneElement element)
 {
     ExceptionChecks.CheckNullArgument <SceneElement>(element, "element");
     return(AnnotationUtils.ParseAnnotationReferences(element.GetLocalOrDefaultValue(AnnotationSceneNode.ReferencesProperty) as string ?? string.Empty));
 }