예제 #1
0
        private void RefreshToolRelatedSettings()
        {
            ToolManager toolManager = this.designerContext.ToolManager;

            if (toolManager == null || toolManager.ActiveTool == null || this.ActiveAnnotationLayer == null)
            {
                return;
            }
            string identifier = toolManager.ActiveTool.Identifier;

            this.ActiveAnnotationLayer.IsHitTestVisible = identifier.Equals("Selection") || identifier.Equals("Subselection");
            SceneViewModel activeSceneViewModel = this.designerContext.ActiveSceneViewModel;

            if (activeSceneViewModel == null)
            {
                return;
            }
            foreach (AnnotationSceneNode annotationSceneNode in activeSceneViewModel.AnnotationEditor.Annotations)
            {
                AnnotationVisual visual = annotationSceneNode.Visual;
                if (visual != null)
                {
                    visual.ViewModel.RefreshToolRelatedProperties();
                }
            }
        }
예제 #2
0
        internal void FindNextAnnotation()
        {
            this.UpdateMatches();
            this.MatchedAnnotation = this.MatchedAnnotation != null?Enumerable.ElementAtOrDefault <AnnotationSceneNode>((IEnumerable <AnnotationSceneNode>) this.matches, this.matches.IndexOf(this.MatchedAnnotation) + (this.SearchReverse ? -1 : 1)) : (this.SearchReverse ? Enumerable.LastOrDefault <AnnotationSceneNode>((IEnumerable <AnnotationSceneNode>) this.matches) : Enumerable.FirstOrDefault <AnnotationSceneNode>((IEnumerable <AnnotationSceneNode>) this.matches));

            if (this.MatchedAnnotation != null)
            {
                AnnotationVisual visual = this.MatchedAnnotation.Visual;
                using (visual.DisableFocusStealing())
                {
                    visual.ViewModel.Selected = true;
                    visual.ViewModel.ViewMode = ViewMode.Editing;
                }
                this.AnnotationService.MakeVisible(this.MatchedAnnotation);
            }
            if (this.MatchedAnnotation != null || this.showMessageAction == null)
            {
                return;
            }
            this.showMessageAction(StringTable.FindAnnotationCannotFind);
        }
예제 #3
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);
        }
예제 #4
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);
            }
        }
예제 #5
0
 public DisableFocusStealingToken(AnnotationVisual annotationVisual)
 {
     this.annotationVisual = annotationVisual;
     ++this.annotationVisual.disableFocusStealingCount;
 }