Esempio n. 1
0
        internal IEnumerable <SceneElement> GetAttachedElements(AnnotationSceneNode annotation)
        {
            ExceptionChecks.CheckNullArgument <AnnotationSceneNode>(annotation, "annotation");
            List <SceneElement> list = new List <SceneElement>();

            if (annotation.IsInDocument)
            {
                if (annotation.Parent != annotation.ViewModel.RootNode)
                {
                    SceneElement sceneElement = annotation.Parent as SceneElement;
                    if (sceneElement != null)
                    {
                        list.Add(sceneElement);
                    }
                }
                IEnumerable <SceneElement> collection = Enumerable.Select(Enumerable.Where(Enumerable.Select(this.referenceSub.PathNodes, pathNode => new
                {
                    pathNode      = pathNode,
                    referenceInfo = pathNode.Info
                }), param0 =>
                {
                    if (param0.referenceInfo.ReferencedAnnotations.Contains(annotation))
                    {
                        return(param0.referenceInfo.ReferenceOwner != annotation.ViewModel.RootNode);
                    }
                    return(false);
                }), param0 => param0.referenceInfo.ReferenceOwner);
                list.AddRange(collection);
            }
            return((IEnumerable <SceneElement>)list);
        }
Esempio n. 2
0
 public void CopyToClipboardAsText(AnnotationSceneNode annotation)
 {
     ExceptionChecks.CheckNullArgument <AnnotationSceneNode>(annotation, "annotation");
     this.CopyToClipboardAsText((IEnumerable <AnnotationSceneNode>) new AnnotationSceneNode[1]
     {
         annotation
     });
 }
Esempio n. 3
0
 private void FireAnnotationEvent(AnnotationSceneNode annotation, EventHandler <AnnotationEventArgs> e)
 {
     if (e == null)
     {
         return;
     }
     e((object)this, new AnnotationEventArgs(annotation));
 }
Esempio n. 4
0
 internal AnnotationVisual GetAnnotationVisual(AnnotationSceneNode annotation)
 {
     AnnotationEditor.AnnotationInfo annotationInfo = this.annotationSub.FindPathNode((SceneNode)annotation).Info;
     if (annotationInfo != null)
     {
         return(annotationInfo.Visual);
     }
     return(Enumerable.FirstOrDefault <AnnotationVisual>(Enumerable.OfType <AnnotationVisual>((IEnumerable)this.sceneViewModel.DefaultView.Artboard.AnnotationLayer.Children), (Func <AnnotationVisual, bool>)(visual => visual.Annotation == annotation)));
 }
Esempio n. 5
0
        private AnnotationEditor.AnnotationInfo Annotation_InsertedHandler(object sender, SceneNode basisNode, object basisContent, SceneNode newPathNode)
        {
            AnnotationSceneNode annotationSceneNode = (AnnotationSceneNode)newPathNode;

            return(new AnnotationEditor.AnnotationInfo()
            {
                Annotation = annotationSceneNode,
                AnnotationOwner = (SceneElement)annotationSceneNode.Parent
            });
        }
Esempio n. 6
0
            public string GetUndoString(object obj)
            {
                AnnotationSceneNode annotationSceneNode = obj as AnnotationSceneNode;

                if (annotationSceneNode != null)
                {
                    return(annotationSceneNode.Type.Name);
                }
                return("");
            }
Esempio n. 7
0
 public void Delete(AnnotationSceneNode annotation)
 {
     using (SceneEditTransaction editTransaction = annotation.ViewModel.CreateEditTransaction(StringTable.DeleteAnnotationUndoUnit))
     {
         this.DeleteCore((IEnumerable <AnnotationSceneNode>) new AnnotationSceneNode[1]
         {
             annotation
         });
         editTransaction.Commit();
     }
 }
Esempio n. 8
0
 public RawAnnotation(AnnotationSceneNode annotation)
 {
     this.Id               = annotation.Id;
     this.Text             = annotation.Text;
     this.Top              = annotation.Top;
     this.Left             = annotation.Left;
     this.Author           = annotation.Author;
     this.AuthorInitials   = annotation.AuthorInitials;
     this.SerialNumber     = annotation.SerialNumber;
     this.VisibleAtRuntime = annotation.VisibleAtRuntime;
     this.Timestamp        = annotation.Timestamp;
 }
Esempio n. 9
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));
        }
Esempio n. 10
0
        public AnnotationSceneNode Create(IEnumerable <SceneElement> targets, bool forceAnnotationsVisible)
        {
            ExceptionChecks.CheckNullArgument <IEnumerable <SceneElement> >(targets, "targets");
            ExceptionChecks.CheckEmptyListArgument <SceneElement>(targets, "targets");
            if (forceAnnotationsVisible)
            {
                this.ShowAnnotations = true;
            }
            AnnotationSceneNode annotation = this.designerContext.ActiveSceneViewModel.AnnotationEditor.CreateAnnotation(targets);

            if (Enumerable.Any <SceneElement>(annotation.AttachedElements) && this.ShowAnnotations)
            {
                this.MakeVisible(annotation, targets);
            }
            return(annotation);
        }
Esempio n. 11
0
        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();
            }
        }
Esempio n. 12
0
        internal void InvalidateAdorners(AnnotationSceneNode annotation, bool fullRebuild)
        {
            IEnumerable <AnnotationAdornerSet> items = Enumerable.Select(Enumerable.Where(Enumerable.Select(annotation.AttachedElements, element => new
            {
                element    = element,
                adornerSet = this.GetOrCreateAdornerSet(element)
            }), param0 => param0.adornerSet != null), param0 => param0.adornerSet);

            if (fullRebuild)
            {
                EnumerableExtensions.ForEach <AnnotationAdornerSet>(items, (Action <AnnotationAdornerSet>)(adornerSet => adornerSet.InvalidateStructure()));
            }
            else
            {
                EnumerableExtensions.ForEach <AnnotationAdornerSet>(items, (Action <AnnotationAdornerSet>)(adornerSet => adornerSet.InvalidateRender()));
            }
        }
Esempio n. 13
0
        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();
            }
        }
Esempio n. 14
0
        public static void SetSerialNumber(AnnotationSceneNode annotation)
        {
            ExceptionChecks.CheckNullArgument <AnnotationSceneNode>(annotation, "annotation");
            string            authorInitials = annotation.AuthorInitials;
            IEnumerable <int> source         = Enumerable.Select <AnnotationSceneNode, int>(Enumerable.Where <AnnotationSceneNode>(annotation.ViewModel.AnnotationEditor.GetAnnotationsWithoutCache(), (Func <AnnotationSceneNode, bool>)(anno =>
            {
                if (anno != annotation)
                {
                    return(StringComparer.CurrentCultureIgnoreCase.Equals(anno.AuthorInitials, authorInitials));
                }
                return(false);
            })), (Func <AnnotationSceneNode, int>)(anno => anno.SerialNumber));
            int num = 1;

            if (Enumerable.Any <int>(source))
            {
                num = Enumerable.Max(source) + 1;
            }
            annotation.SerialNumber = num;
        }
Esempio n. 15
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);
        }
Esempio n. 16
0
        private AnnotationVisual CreateAnnotationVisual(AnnotationSceneNode annotation)
        {
            ExceptionChecks.CheckNullArgument <AnnotationSceneNode>(annotation, "annotation");
            if (this.AnnotationLayer == null)
            {
                return((AnnotationVisual)null);
            }
            AnnotationVisual annotationVisual1 = Enumerable.FirstOrDefault <AnnotationVisual>(Enumerable.Cast <AnnotationVisual>((IEnumerable)this.AnnotationLayer.Children), (Func <AnnotationVisual, bool>)(v => v.Annotation == annotation));

            if (annotationVisual1 != null)
            {
                return(annotationVisual1);
            }
            AnnotationVisual annotationVisual2 = new AnnotationVisual(new AnnotationViewModel(annotation)
            {
                ShowVisibleAtRuntime = annotation.ProjectContext.IsCapabilitySet(PlatformCapability.SupportPrototyping)
            });

            annotationVisual2.Visibility = Visibility.Hidden;
            this.AnnotationLayer.Children.Add((UIElement)annotationVisual2);
            this.AnnotationLayer.UpdateLayout();
            return(annotationVisual2);
        }
Esempio n. 17
0
        public static string SetAnnotationId(AnnotationSceneNode annotation)
        {
            ExceptionChecks.CheckNullArgument <AnnotationSceneNode>(annotation, "annotation");
            Func <string, int> ParseOrZero = (Func <string, int>)(s =>
            {
                int result;
                if (!int.TryParse(s, out result))
                {
                    return(0);
                }
                return(result);
            });
            IEnumerable <AnnotationSceneNode> annotations = annotation.ViewModel.AnnotationEditor.Annotations;
            int num = 1;

            if (Enumerable.Any <AnnotationSceneNode>(annotations))
            {
                num = Enumerable.Max(Enumerable.Select <AnnotationSceneNode, int>(annotations, (Func <AnnotationSceneNode, int>)(anno => ParseOrZero(anno.Id)))) + 1;
            }
            string str = num.ToString((IFormatProvider)CultureInfo.CurrentCulture);

            annotation.Id = str;
            return(str);
        }
Esempio n. 18
0
 public AnnotationAdorner(AdornerSet adornerSet, AnnotationSceneNode annotation)
     : base(adornerSet)
 {
     this.Annotation = annotation;
 }
Esempio n. 19
0
 public AnnotationEventArgs(AnnotationSceneNode annotation)
 {
     this.Annotation = annotation;
 }
Esempio n. 20
0
 public AnnotationViewModel(AnnotationSceneNode annotationNode)
 {
     this.annotationNode = annotationNode;
 }
Esempio n. 21
0
 public UnlinkAnnotationCommand(AnnotationSceneNode annotationNode)
 {
   this.annotationNode = annotationNode;
 }
Esempio n. 22
0
 internal void OnAnnotationChanged(AnnotationSceneNode annotation)
 {
     this.FireAnnotationEvent(annotation, this.AnnotationChanged);
 }
Esempio n. 23
0
 public bool IsSelected(AnnotationSceneNode annotation)
 {
     ExceptionChecks.CheckNullArgument <AnnotationSceneNode>(annotation, "annotation");
     return(this.SelectedAnnotation == annotation);
 }
Esempio n. 24
0
 public void MakeVisible(AnnotationSceneNode annotation)
 {
     this.MakeVisible(annotation, Enumerable.Empty <SceneElement>());
 }
Esempio n. 25
0
 private string GetSearchText(AnnotationSceneNode annotation)
 {
     return(annotation.Text + "\n" + annotation.AuthorInitials + "\n" + annotation.Author + "\n" + annotation.Timestamp.ToString());
 }
Esempio n. 26
0
        public void MakeVisible(AnnotationSceneNode annotation, IEnumerable <SceneElement> targets)
        {
            Artboard artboard = this.designerContext.ActiveView.Artboard;

            artboard.AnnotationLayer.UpdateLayout();
            targets = Enumerable.Where <SceneElement>(targets, (Func <SceneElement, bool>)(element =>
            {
                if (element != null)
                {
                    return(element != element.ViewModel.RootNode);
                }
                return(false);
            }));
            Rect rect1 = Rect.Empty;

            foreach (SceneElement sceneElement in targets)
            {
                rect1 = Rect.Union(rect1, artboard.GetElementBounds(sceneElement));
            }
            Size             size   = new Size(250.0, 200.0);
            AnnotationVisual visual = annotation.Visual;

            if (visual != null)
            {
                size = visual.RenderSize;
            }
            Rect   rect2      = new Rect(annotation.Position, size);
            Size   renderSize = artboard.RenderSize;
            double zoom       = artboard.Zoom;
            Rect   rect2_1    = rect2;

            rect2_1.Width  /= zoom;
            rect2_1.Height /= zoom;
            Rect rect3 = Rect.Union(rect1, rect2_1);

            if (rect3.IsEmpty || artboard.ArtboardBounds.Contains(rect3))
            {
                return;
            }
            if (rect3.Width < artboard.ArtboardBounds.Width && rect3.Height < artboard.ArtboardBounds.Height)
            {
                Rect artboardBounds = artboard.ArtboardBounds;
                if (rect3.X < artboard.ArtboardBounds.X)
                {
                    artboardBounds.X = rect3.X;
                }
                else if (artboard.ArtboardBounds.Right < rect3.Right)
                {
                    artboardBounds.X -= artboard.ArtboardBounds.Right - rect3.Right;
                }
                if (rect3.Y < artboard.ArtboardBounds.Y)
                {
                    artboardBounds.Y = rect3.Y;
                }
                else if (artboard.ArtboardBounds.Bottom < rect3.Bottom)
                {
                    artboardBounds.Y -= artboard.ArtboardBounds.Bottom - rect3.Bottom;
                }
                artboard.ZoomToFitRectangle(artboardBounds);
            }
            else
            {
                double num     = Math.Max(0.01, Math.Min((renderSize.Width - rect2.Width) / rect1.Width, (renderSize.Height - rect2.Height) / rect1.Height));
                Rect   rect2_2 = rect2;
                rect2_2.Width  /= num;
                rect2_2.Height /= num;
                Rect rectangle = Rect.Union(rect1, rect2_2);
                artboard.ZoomToFitRectangle(rectangle);
            }
        }