/// <summary> /// Transfer selection state to Point4. /// </summary> public void ToStatePoint4() { _helperPoint1 = PointShape.Create(0, 0, _point); _layer.Shapes = _layer.Shapes.Add(_helperPoint1); _helperPoint4 = PointShape.Create(0, 0, _point); _layer.Shapes = _layer.Shapes.Add(_helperPoint4); }
/// <summary> /// Transfer selection state to BottomRight. /// </summary> public void ToStateBottomRight() { _topLeftHelperPoint = PointShape.Create(0, 0, _point); _bottomRightHelperPoint = PointShape.Create(0, 0, _point); _layer.Shapes = _layer.Shapes.Add(_topLeftHelperPoint); _layer.Shapes = _layer.Shapes.Add(_bottomRightHelperPoint); }
/// <summary> /// Transfer selection state to End. /// </summary> public void ToStateEnd() { _startHelperPoint = PointShape.Create(0, 0, _point); _endHelperPoint = PointShape.Create(0, 0, _point); _layer.Shapes = _layer.Shapes.Add(_startHelperPoint); _layer.Shapes = _layer.Shapes.Add(_endHelperPoint); }
/// <summary> /// Transfer selection state to Point2. /// </summary> public void ToStatePoint2() { _line12 = LineShape.Create(0, 0, _style, null); _helperPoint2 = PointShape.Create(0, 0, _point); _layer.Shapes = _layer.Shapes.Add(_line12); _layer.Shapes = _layer.Shapes.Add(_helperPoint2); }
/// <summary> /// Transfer selection state to BottomRight. /// </summary> public void ToStateBottomRight() { _helperRectangle = RectangleShape.Create(0, 0, _style, null); _topLeftHelperPoint = PointShape.Create(0, 0, _point); _bottomRightHelperPoint = PointShape.Create(0, 0, _point); _layer.Shapes = _layer.Shapes.Add(_helperRectangle); _layer.Shapes = _layer.Shapes.Add(_topLeftHelperPoint); _layer.Shapes = _layer.Shapes.Add(_bottomRightHelperPoint); }
private static ImmutableArray <PointShape> ToPointShapes(this IEnumerable <Point> points, double dx, double dy) { var PointShapes = ImmutableArray.CreateBuilder <PointShape>(); foreach (var point in points) { PointShapes.Add(PointShape.Create(point.X + dx, point.Y + dy)); } return(PointShapes.ToImmutable()); }
/// <summary> /// Transfer selection state to Point3. /// </summary> public void ToStatePoint3() { _line43 = LineShape.Create(0, 0, _style, null); _line23 = LineShape.Create(0, 0, _style, null); _helperPoint3 = PointShape.Create(0, 0, _point); _layer.Shapes = _layer.Shapes.Add(_line43); _layer.Shapes = _layer.Shapes.Add(_line23); _layer.Shapes = _layer.Shapes.Add(_helperPoint3); }
/// <summary> /// Transfer selection state to Point2. /// </summary> public void ToStatePoint2() { _ellipse = EllipseShape.Create(0, 0, _style, null); _p1HelperPoint = PointShape.Create(0, 0, _point); _p2HelperPoint = PointShape.Create(0, 0, _point); _centerHelperPoint = PointShape.Create(0, 0, _point); _layer.Shapes = _layer.Shapes.Add(_ellipse); _layer.Shapes = _layer.Shapes.Add(_p1HelperPoint); _layer.Shapes = _layer.Shapes.Add(_p2HelperPoint); _layer.Shapes = _layer.Shapes.Add(_centerHelperPoint); }
/// <inheritdoc/> PointShape IShapeFactory.Point(double x, double y, bool isStandalone) { var point = PointShape.Create( x, y, _editor.Project.Options.PointShape); if (isStandalone) { _editor.Project.AddShape(_editor.Project.CurrentContainer.CurrentLayer, point); } return(point); }
/// <summary> /// Transfer selection state to Point4. /// </summary> public void ToStatePoint4() { if (_ellipse != null) { _layer.Shapes = _layer.Shapes.Remove(_ellipse); _ellipse = null; } _endLine = LineShape.Create(0, 0, _style, null); _endHelperPoint = PointShape.Create(0, 0, _point); _layer.Shapes = _layer.Shapes.Add(_endLine); _layer.Shapes = _layer.Shapes.Add(_endHelperPoint); }
protected void OnShapePointMouse(Event guiEvent) { if (guiEvent.type == EventType.MouseDown) { Vector2 shapePosition = MouseToShapePoint(mousePosition); PointShape newPoint = PointShape.Create(shapePosition); newPoint.penToMeshScale = mouseToShapeScale; newPoint.colorOutline = shapeOutlineColor; newPoint.colorFill = shapeFillColor; SetFocusedShape(newPoint); Repaint(); } }
/// <summary> /// Transfer selection state to Point3. /// </summary> public void ToStatePoint3() { if (_p1HelperPoint != null) { _layer.Shapes = _layer.Shapes.Remove(_p1HelperPoint); _p1HelperPoint = null; } if (_p2HelperPoint != null) { _layer.Shapes = _layer.Shapes.Remove(_p2HelperPoint); _p2HelperPoint = null; } _startLine = LineShape.Create(0, 0, _style, null); _startHelperPoint = PointShape.Create(0, 0, _point); _layer.Shapes = _layer.Shapes.Add(_startLine); _layer.Shapes = _layer.Shapes.Add(_startHelperPoint); }
/// <summary> /// /// </summary> /// <param name="pg"></param> /// <param name="dx"></param> /// <param name="dy"></param> /// <returns></returns> public static Path.PathGeometry ToPathGeometry(this System.Windows.Media.PathGeometry pg, double dx, double dy) { var geometry = Path.PathGeometry.Create( ImmutableArray.Create <Path.PathFigure>(), pg.FillRule == System.Windows.Media.FillRule.EvenOdd ? Path.FillRule.EvenOdd : Path.FillRule.Nonzero); var context = new PathGeometryContext(geometry); foreach (var pf in pg.Figures) { context.BeginFigure( PointShape.Create(pf.StartPoint.X + dx, pf.StartPoint.Y + dy), pf.IsFilled, pf.IsClosed); foreach (var segment in pf.Segments) { if (segment is ArcSegment) { var arcSegment = segment as ArcSegment; context.ArcTo( PointShape.Create(arcSegment.Point.X + dx, arcSegment.Point.Y + dy), PathSize.Create(arcSegment.Size.Width, arcSegment.Size.Height), arcSegment.RotationAngle, arcSegment.IsLargeArc, arcSegment.SweepDirection == System.Windows.Media.SweepDirection.Clockwise ? Path.SweepDirection.Clockwise : Path.SweepDirection.Counterclockwise, arcSegment.IsStroked, arcSegment.IsSmoothJoin); } else if (segment is BezierSegment) { var cubicBezierSegment = segment as BezierSegment; context.CubicBezierTo( PointShape.Create(cubicBezierSegment.Point1.X + dx, cubicBezierSegment.Point1.Y + dy), PointShape.Create(cubicBezierSegment.Point2.X + dx, cubicBezierSegment.Point2.Y + dy), PointShape.Create(cubicBezierSegment.Point3.X + dx, cubicBezierSegment.Point3.Y + dy), cubicBezierSegment.IsStroked, cubicBezierSegment.IsSmoothJoin); } else if (segment is LineSegment) { var lineSegment = segment as LineSegment; context.LineTo( PointShape.Create(lineSegment.Point.X + dx, lineSegment.Point.Y + dy), lineSegment.IsStroked, lineSegment.IsSmoothJoin); } else if (segment is PolyBezierSegment) { var polyCubicBezierSegment = segment as PolyBezierSegment; context.PolyCubicBezierTo( ToPointShapes(polyCubicBezierSegment.Points, dx, dy), polyCubicBezierSegment.IsStroked, polyCubicBezierSegment.IsSmoothJoin); } else if (segment is PolyLineSegment) { var polyLineSegment = segment as PolyLineSegment; context.PolyLineTo( ToPointShapes(polyLineSegment.Points, dx, dy), polyLineSegment.IsStroked, polyLineSegment.IsSmoothJoin); } else if (segment is PolyQuadraticBezierSegment) { var polyQuadraticSegment = segment as PolyQuadraticBezierSegment; context.PolyQuadraticBezierTo( ToPointShapes(polyQuadraticSegment.Points, dx, dy), polyQuadraticSegment.IsStroked, polyQuadraticSegment.IsSmoothJoin); } else if (segment is QuadraticBezierSegment) { var quadraticBezierSegment = segment as QuadraticBezierSegment; context.QuadraticBezierTo( PointShape.Create(quadraticBezierSegment.Point1.X + dx, quadraticBezierSegment.Point1.Y + dy), PointShape.Create(quadraticBezierSegment.Point2.X + dx, quadraticBezierSegment.Point2.Y + dy), quadraticBezierSegment.IsStroked, quadraticBezierSegment.IsSmoothJoin); } else { throw new NotSupportedException("Not supported segment type: " + segment.GetType()); } } } return(geometry); }
/// <summary> /// Initializes static designer context. /// </summary> /// <param name="serviceProvider">The service provider.</param> public static void InitializeContext(IServiceProvider serviceProvider) { // Editor Editor = serviceProvider.GetService <ProjectEditor>(); // Recent Projects Editor.RecentProjects = Editor.RecentProjects.Add(RecentFile.Create("Test1", "Test1.project")); Editor.RecentProjects = Editor.RecentProjects.Add(RecentFile.Create("Test2", "Test2.project")); // New Project Editor.OnNewProject(); // Transform Transform = MatrixObject.Identity; // Data var db = Database.Create("Db"); var fields = new string[] { "Column0", "Column1" }; var columns = ImmutableArray.CreateRange(fields.Select(c => Column.Create(db, c))); db.Columns = columns; var values = Enumerable.Repeat("<empty>", db.Columns.Length).Select(c => Value.Create(c)); var record = Record.Create( db, ImmutableArray.CreateRange(values)); db.Records = db.Records.Add(record); db.CurrentRecord = record; Database = db; Data = Context.Create(record); Record = record; // Project IProjectFactory factory = new ProjectFactory(); Project = factory.GetProject(); Template = PageContainer.CreateTemplate(); Page = PageContainer.CreatePage(); var layer = Page.Layers.FirstOrDefault(); layer.Shapes = layer.Shapes.Add(LineShape.Create(0, 0, null, null)); Page.CurrentLayer = layer; Page.CurrentShape = layer.Shapes.FirstOrDefault(); Page.Template = Template; Document = DocumentContainer.Create(); Layer = LayerContainer.Create(); Options = Options.Create(); // State State = ShapeState.Create(); // Style ArgbColor = ArgbColor.Create(128, 255, 0, 0); ArrowStyle = ArrowStyle.Create(); FontStyle = FontStyle.Create(); LineFixedLength = LineFixedLength.Create(); LineStyle = LineStyle.Create(); Style = ShapeStyle.Create("Default"); TextStyle = TextStyle.Create(); // Shapes Arc = ArcShape.Create(0, 0, Style, null); CubicBezier = CubicBezierShape.Create(0, 0, Style, null); Ellipse = EllipseShape.Create(0, 0, Style, null); Group = GroupShape.Create(Constants.DefaulGroupName); Image = ImageShape.Create(0, 0, Style, null, "key"); Line = LineShape.Create(0, 0, Style, null); Path = PathShape.Create(Style, null); Point = PointShape.Create(); QuadraticBezier = QuadraticBezierShape.Create(0, 0, Style, null); Rectangle = RectangleShape.Create(0, 0, Style, null); Text = TextShape.Create(0, 0, Style, null, "Text"); // Path ArcSegment = ArcSegment.Create(PointShape.Create(), PathSize.Create(), 180, true, SweepDirection.Clockwise, true, true); CubicBezierSegment = CubicBezierSegment.Create(PointShape.Create(), PointShape.Create(), PointShape.Create(), true, true); LineSegment = LineSegment.Create(PointShape.Create(), true, true); PathFigure = PathFigure.Create(PointShape.Create(), false, true); PathGeometry = PathGeometry.Create(ImmutableArray.Create <PathFigure>(), FillRule.EvenOdd); PathSize = PathSize.Create(); PolyCubicBezierSegment = PolyCubicBezierSegment.Create(ImmutableArray.Create <PointShape>(), true, true); PolyLineSegment = PolyLineSegment.Create(ImmutableArray.Create <PointShape>(), true, true); PolyQuadraticBezierSegment = PolyQuadraticBezierSegment.Create(ImmutableArray.Create <PointShape>(), true, true); QuadraticBezierSegment = QuadraticBezierSegment.Create(PointShape.Create(), PointShape.Create(), true, true); }