static void Main(string[] args) { // TEST EDİYORUZ, BU YÜZDEN UZUN OLDU :) Artboard artboard = Artboard.Create(); Element a1 = new Element(Elements.A); Element b1 = new Element(Elements.B); Element c1 = new Element(Elements.C); Element d1 = new Element(Elements.D); Element a2 = new Element(Elements.A); Element b2 = new Element(Elements.B); Element d2 = new Element(Elements.D); Element b3 = new Element(Elements.B); Element d3 = new Element(Elements.D); Element d4 = new Element(Elements.D); Artboard.AddElement(a1); Artboard.AddElement(b1); Artboard.AddElement(c1); Artboard.AddElement(d1); Artboard.AddElement(a2); Artboard.AddElement(b2); Artboard.AddElement(d2); Artboard.AddElement(b3); Artboard.AddElement(d3); Artboard.AddElement(d4); Console.WriteLine("\n" + artboard.CountElement + " adet nesne üretildi !"); }
private void ApplyEyedropperTextElement(BaseTextElement textElement) { PropertyManager propertyManager = (PropertyManager)this.ToolBehaviorContext.PropertyManager; IPlatform platform = this.ActiveDocument.ProjectContext.Platform; IPlatformMetadata platformMetadata = (IPlatformMetadata)platform.Metadata; Artboard artboard = this.ActiveView.Artboard; Matrix matrix = artboard.CalculateTransformFromArtboardToContent().Value; Matrix transformFromRoot = this.ActiveView.GetComputedTransformFromRoot((SceneElement)textElement); Point position = this.MouseDevice.GetPosition((IInputElement)artboard); Point point1 = matrix.Transform(position); Point point2 = transformFromRoot.Transform(point1); this.EnsureEditTransaction(); foreach (IPropertyId propertyId in PropertyToolBehavior.PropertyList) { ReferenceStep singleStep = platformMetadata.ResolveProperty(propertyId) as ReferenceStep; if (singleStep != null && singleStep.PropertyType.PlatformMetadata == platform.Metadata) { PropertyReference propertyReference1 = new PropertyReference(singleStep); PropertyReference propertyReference2 = propertyManager.FilterProperty((SceneNode)textElement, propertyReference1); if (propertyReference2 != null) { object textValueAtPoint = textElement.GetTextValueAtPoint(point2, true, propertyReference2); propertyManager.SetValue(propertyReference2, textValueAtPoint); } } } this.UpdateEditTransaction(); }
public FrameworkElementCapturer(WPFSceneView sceneView, Size targetSize) : base(targetSize) { Artboard artboard = sceneView.Artboard; FrameworkElement frameworkElement = (FrameworkElement)sceneView.DesignSurfaceRoot; SceneNode viewRoot = sceneView.ViewModel.ViewRoot; if (frameworkElement == null || viewRoot == null) { return; } this.element = frameworkElement; double?nullable1 = viewRoot.GetComputedValue(BaseFrameworkElement.WidthProperty) as double?; double?nullable2 = viewRoot.GetComputedValue(BaseFrameworkElement.HeightProperty) as double?; if (nullable1.HasValue && nullable2.HasValue && (!double.IsNaN(nullable1.Value) && !double.IsNaN(nullable2.Value))) { return; } Rect finalRect = new Rect(0.0, 0.0, 0.0, 0.0); artboard.Measure(finalRect.Size); artboard.Arrange(finalRect); artboard.UpdateLayout(); }
private Point GetSnappedPointInAdornerLayer() { Artboard artboard = this.ActiveView.Artboard; Point position = this.MouseDevice.GetPosition((IInputElement)artboard); Matrix matrix1 = artboard.CalculateTransformFromArtboardToContent().Value; Point point = this.ToolBehaviorContext.SnappingEngine.SnapPoint(matrix1.Transform(position)); Matrix matrix2 = matrix1; matrix2.Invert(); return(matrix2.Transform(point)); }
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); }
internal void ArrangeChild(UIElement child, bool forceMeasure = false) { if (forceMeasure) { child.Measure(XamlConstants.InfiniteSize); } var rect = new Rect(new Point(GetX(child), GetY(child)), child.DesiredSize); child.Arrange(rect); Artboard?.ArrangeAdorners(child, rect); }
public void StartScroll(Point startPoint, Point currentPoint) { this.startPosition = startPoint; this.currentPosition = currentPoint; Artboard artboard = this.SceneView.Artboard; this.mousePosition = Mouse.GetPosition((IInputElement)artboard); this.artboardBoundary = new Rect(0.0, 0.0, artboard.ActualWidth, artboard.ActualHeight); if (this.Behavior.ShouldMotionlessAutoScroll(this.mousePosition, this.artboardBoundary)) { this.scrollDirection = this.ComputeScrollDirection(); this.ScrollTimer.Start(); } else { this.ScrollTimer.Stop(); } }
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); } }