Ejemplo n.º 1
0
 public static bool IsAxisAlignedRectangle(SketchPath path)
 {
     return(path.Points.Count == 4 &&
            path.IsClosed &&
            path.Points.All(p => p.Mode == SketchCurvePoint.CurveMode.Line) &&
            EdgesAreAxisAligned(path.Points));
 }
Ejemplo n.º 2
0
        public void Oval()
        {
            var points = new[]
            {
                CurvePointUtils.CurvePoint(new[]
                {
                    0.5, 1, 0.77614237490000004, 1, 0.22385762510000001, 1
                }),
                CurvePointUtils.CurvePoint(new[]
                {
                    1, 0.5, 1, 0.22385762510000001, 1, 0.77614237490000004
                }),
                CurvePointUtils.CurvePoint(new[]
                {
                    0.5, 0, 0.22385762510000001, 0, 0.77614237490000004, 0
                }),
                CurvePointUtils.CurvePoint(new[]
                {
                    0, 0.5, 0, 0.77614237490000004, 0, 0.22385762510000001
                }),
            };

            var oval = new SketchPath(points, true);
            var svg  = SketchCurvePointsToSvg.ToSvgString(oval);

            Assert.That(svg, Does.Match("^M 0.5 1 C 0.7761423749 1 1 0.7761423749 1 0.5 C 1 0.2238576251 0.7761423749 0 0.5 0 C 0.2238576251 0 0 0.2238576251 0 0.5 C 0 0.7761423749 0.2238576251 1 0.5 1$"));
        }
Ejemplo n.º 3
0
        public void StraightLineToSvgString()
        {
            var points = StraightLine(new SketchPoint(10.0, 2.0), new SketchPoint(10.0, 10.0));
            var path   = new SketchPath(points: points, isClosed: false);

            var svg = SketchCurvePointsToSvg.ToSvgString(path);

            Assert.That(svg, Does.Match("^M 10 2 L 10 10$"));
        }
Ejemplo n.º 4
0
        public void PathWithMoreThanFourPointsIsNotRectangle()
        {
            var points = CurvePointUtils.RectanglePath(new CornerRadius(0));

            points.Add(CurvePointUtils.LinePoint(0.5, 0.5));
            var path = new SketchPath(points, true);

            Assert.That(Geometry.IsAxisAlignedRectangle(path), Is.False);
        }
Ejemplo n.º 5
0
 public SketchShapePath(
     SketchLayer layer,
     SketchPath path,
     SketchBooleanOperation operation)
     : base(layer)
 {
     Path             = path;
     BooleanOperation = operation;
 }
Ejemplo n.º 6
0
        public void StartWithCurve()
        {
            var points = new[]
            {
                CurvePointUtils.CurvePoint(new [] { 0.0, 100, 0, 0, 0, 200 }),
                CurvePointUtils.LinePoint(50, 0),
                CurvePointUtils.LinePoint(100, 100)
            };
            var curve = new SketchPath(points, false);
            var svg   = SketchCurvePointsToSvg.ToSvgString(curve);

            Console.WriteLine(svg);
            Assert.That(svg, Does.Match("^M 0 100 C 0 33.33333333333 16.66666666667 0 50 0 L 100 100$"));
        }
Ejemplo n.º 7
0
        public void EndWithCurve()
        {
            var points = new[]
            {
                CurvePointUtils.LinePoint(0, 100),
                CurvePointUtils.LinePoint(50, 0),
                CurvePointUtils.CurvePoint(new [] { 100.0, 100, 100, 200, 100, 0 })
            };

            var curve = new SketchPath(points, false);
            var svg   = SketchCurvePointsToSvg.ToSvgString(curve);

            Console.WriteLine(svg);
            Assert.That(svg, Does.Match("M 0 100 L 50 0 C 83.33333333333 0 100 33.33333333333 100 100$"));
        }
Ejemplo n.º 8
0
        public void CurveFromFirstPoint()
        {
            var points = new[]
            {
                CurvePointUtils.CurvePoint(new[] { 0.0, 0.0 },
                                           new[] { 123.20975114271207, 8.196425347535656 },
                                           new[] { -123.20975114271207, -8.1964253475356769 }),
                CurvePointUtils.LinePoint(94.613074518933793, 99)
            };

            var curve = new SketchPath(points, false);
            var svg   = SketchCurvePointsToSvg.ToSvgString(curve);

            Console.WriteLine(svg);
            Assert.That(svg, Does.Match("^M 0 0 C 82.13983409514 5.464283565024 113.6775256015 38.46428356502 94.61307451893 99$"));
        }
Ejemplo n.º 9
0
        public void ClosedStarPolygon()
        {
            var points = new[]
            {
                CurvePointUtils.LinePoint(0.5, 0.75),
                CurvePointUtils.LinePoint(0.20610737385376349, 0.90450849718747373),
                CurvePointUtils.LinePoint(0.26223587092621159, 0.57725424859373686),
                CurvePointUtils.LinePoint(0.024471741852423179, 0.34549150281252639),
                CurvePointUtils.LinePoint(0.35305368692688166, 0.29774575140626314),
                CurvePointUtils.LinePoint(0.49999999999999989, 0),
                CurvePointUtils.LinePoint(0.64694631307311823, 0.29774575140626314),
                CurvePointUtils.LinePoint(0.97552825814757682, 0.34549150281252616),
                CurvePointUtils.LinePoint(0.73776412907378841, 0.57725424859373675),
                CurvePointUtils.LinePoint(0.79389262614623668, 0.90450849718747361),
            };
            var path = new SketchPath(points, true);

            var svg = SketchCurvePointsToSvg.ToSvgString(path);

            Assert.That(svg, Does.Match("^M 0.5 0.75 L 0.2061073738538 0.9045084971875 L 0.2622358709262 0.5772542485937 L 0.02447174185242 0.3454915028125 L 0.3530536869269 0.2977457514063 L 0.5 0 L 0.6469463130731 0.2977457514063 L 0.9755282581476 0.3454915028125 L 0.7377641290738 0.5772542485937 L 0.7938926261462 0.9045084971875 L 0.5 0.75$"));
        }
Ejemplo n.º 10
0
        public static string ToSvgString(SketchPath path)
        {
            var svg = new StringBuilder();

            using (var point = path.Points.GetEnumerator())
            {
                point.MoveNext();
                var first = point.Current;
                svg.MoveTo(first.Point);
                var previous = first;
                while (point.MoveNext())
                {
                    svg.Append(PointToSvg(previous, point.Current));
                    previous = point.Current;
                }
                if (path.IsClosed)
                {
                    svg.Append(PointToSvg(previous, first));
                }
            }
            return(svg.ToString());
        }
Ejemplo n.º 11
0
        public static SketchSymbolMaster SketchSymbolMaster(string symbolName)
        {
            var sketchPath =
                new SketchPath(
                    CurvePointUtils.RectanglePath(
                        new CornerRadius(0)),
                    true);
            var rectangle = new SketchRectangle(
                SketchLayer(frame: Frame),
                sketchPath, SketchBooleanOperation.NoOperation);

            var sketchSymbolMaster = new SketchSymbolMaster(
                SketchLayer(id: Guid.NewGuid(), name: symbolName, frame: Frame,
                            children: new List <SketchLayer> {
                rectangle
            }),
                Guid.NewGuid()
                );

            rectangle.Parent = sketchSymbolMaster;
            return(sketchSymbolMaster);
        }
Ejemplo n.º 12
0
        public void PathWithLessThanFourPointsIsNotARectangle()
        {
            var path = new SketchPath(new List <SketchCurvePoint>(), false);

            Assert.That(Geometry.IsAxisAlignedRectangle(path), Is.False);
        }
Ejemplo n.º 13
0
        public void ClosedAxisAlignedPathWithFourPointsIsARectangle()
        {
            var rectangle = new SketchPath(CurvePointUtils.RectanglePath(new CornerRadius(0)), true);

            Assert.That(Geometry.IsAxisAlignedRectangle(rectangle), Is.True);
        }
Ejemplo n.º 14
0
 public SketchRectangle(SketchLayer layer, SketchPath path, SketchBooleanOperation operation)
     : base(layer, path, operation)
 {
 }
Ejemplo n.º 15
0
        void ReleaseDesignerOutlets()
        {
            if (PointInspector != null)
            {
                PointInspector.Dispose();
                PointInspector = null;
            }

            if (ArrowInspector != null)
            {
                ArrowInspector.Dispose();
                ArrowInspector = null;
            }

            if (AttachedStyleInspector != null)
            {
                AttachedStyleInspector.Dispose();
                AttachedStyleInspector = null;
            }

            if (BackButton != null)
            {
                BackButton.Dispose();
                BackButton = null;
            }

            if (BooleanPropertyInspector != null)
            {
                BooleanPropertyInspector.Dispose();
                BooleanPropertyInspector = null;
            }

            if (BorderInspectorsButton != null)
            {
                BorderInspectorsButton.Dispose();
                BorderInspectorsButton = null;
            }

            if (ColorPaletteInspector != null)
            {
                ColorPaletteInspector.Dispose();
                ColorPaletteInspector = null;
            }

            if (ConnectionInspectorsButton != null)
            {
                ConnectionInspectorsButton.Dispose();
                ConnectionInspectorsButton = null;
            }

            if (ConnectionsInspector != null)
            {
                ConnectionsInspector.Dispose();
                ConnectionsInspector = null;
            }

            if (DesignSurface != null)
            {
                DesignSurface.Dispose();
                DesignSurface = null;
            }

            if (DetailsInspectorButton != null)
            {
                DetailsInspectorButton.Dispose();
                DetailsInspectorButton = null;
            }

            if (DocumentScrollView != null)
            {
                DocumentScrollView.Dispose();
                DocumentScrollView = null;
            }

            if (DocumentView != null)
            {
                DocumentView.Dispose();
                DocumentView = null;
            }

            if (DocumentViewHeight != null)
            {
                DocumentViewHeight.Dispose();
                DocumentViewHeight = null;
            }

            if (DocumentViewWidth != null)
            {
                DocumentViewWidth.Dispose();
                DocumentViewWidth = null;
            }

            if (ExportButton != null)
            {
                ExportButton.Dispose();
                ExportButton = null;
            }

            if (FillInspector != null)
            {
                FillInspector.Dispose();
                FillInspector = null;
            }

            if (FillInspectorsButton != null)
            {
                FillInspectorsButton.Dispose();
                FillInspectorsButton = null;
            }

            if (FontInspector != null)
            {
                FontInspector.Dispose();
                FontInspector = null;
            }

            if (FrameInspector != null)
            {
                FrameInspector.Dispose();
                FrameInspector = null;
            }

            if (GeneralInfoInspector != null)
            {
                GeneralInfoInspector.Dispose();
                GeneralInfoInspector = null;
            }

            if (GradientInspector != null)
            {
                GradientInspector.Dispose();
                GradientInspector = null;
            }

            if (GroupInspector != null)
            {
                GroupInspector.Dispose();
                GroupInspector = null;
            }

            if (InspectorScrollView != null)
            {
                InspectorScrollView.Dispose();
                InspectorScrollView = null;
            }

            if (InspectorView != null)
            {
                InspectorView.Dispose();
                InspectorView = null;
            }

            if (LanguageSelector != null)
            {
                LanguageSelector.Dispose();
                LanguageSelector = null;
            }

            if (LibrarySelector != null)
            {
                LibrarySelector.Dispose();
                LibrarySelector = null;
            }

            if (NumberPropertyInspector != null)
            {
                NumberPropertyInspector.Dispose();
                NumberPropertyInspector = null;
            }

            if (OSSelector != null)
            {
                OSSelector.Dispose();
                OSSelector = null;
            }

            if (PolygonInspector != null)
            {
                PolygonInspector.Dispose();
                PolygonInspector = null;
            }

            if (PortfolioInspector != null)
            {
                PortfolioInspector.Dispose();
                PortfolioInspector = null;
            }

            if (PropertyInspector != null)
            {
                PropertyInspector.Dispose();
                PropertyInspector = null;
            }

            if (RectPropertyInspector != null)
            {
                RectPropertyInspector.Dispose();
                RectPropertyInspector = null;
            }

            if (RoundRectInspector != null)
            {
                RoundRectInspector.Dispose();
                RoundRectInspector = null;
            }

            if (ScriptDebuggerInspector != null)
            {
                ScriptDebuggerInspector.Dispose();
                ScriptDebuggerInspector = null;
            }

            if (SketchInspector != null)
            {
                SketchInspector.Dispose();
                SketchInspector = null;
            }

            if (SketchPath != null)
            {
                SketchPath.Dispose();
                SketchPath = null;
            }

            if (SourceList != null)
            {
                SourceList.Dispose();
                SourceList = null;
            }

            if (StarInspector != null)
            {
                StarInspector.Dispose();
                StarInspector = null;
            }

            if (StyleInspector != null)
            {
                StyleInspector.Dispose();
                StyleInspector = null;
            }

            if (TextEditor != null)
            {
                TextEditor.Dispose();
                TextEditor = null;
            }

            if (TextEditorMode != null)
            {
                TextEditorMode.Dispose();
                TextEditorMode = null;
            }

            if (TextEditorTitle != null)
            {
                TextEditorTitle.Dispose();
                TextEditorTitle = null;
            }

            if (TextInspector != null)
            {
                TextInspector.Dispose();
                TextInspector = null;
            }

            if (TextPropertyInspector != null)
            {
                TextPropertyInspector.Dispose();
                TextPropertyInspector = null;
            }

            if (ToolArrow != null)
            {
                ToolArrow.Dispose();
                ToolArrow = null;
            }

            if (ToolBezier != null)
            {
                ToolBezier.Dispose();
                ToolBezier = null;
            }

            if (ToolCursor != null)
            {
                ToolCursor.Dispose();
                ToolCursor = null;
            }

            if (ToolLine != null)
            {
                ToolLine.Dispose();
                ToolLine = null;
            }

            if (ToolOval != null)
            {
                ToolOval.Dispose();
                ToolOval = null;
            }

            if (ToolPolygon != null)
            {
                ToolPolygon.Dispose();
                ToolPolygon = null;
            }

            if (ToolRect != null)
            {
                ToolRect.Dispose();
                ToolRect = null;
            }

            if (ToolRoundRect != null)
            {
                ToolRoundRect.Dispose();
                ToolRoundRect = null;
            }

            if (ToolStar != null)
            {
                ToolStar.Dispose();
                ToolStar = null;
            }

            if (ToolText != null)
            {
                ToolText.Dispose();
                ToolText = null;
            }

            if (ToolTriangle != null)
            {
                ToolTriangle.Dispose();
                ToolTriangle = null;
            }

            if (ToolVector != null)
            {
                ToolVector.Dispose();
                ToolVector = null;
            }
        }