/// <inheritdoc/> IImageShape IShapeFactory.Image(string path, IPointShape topLeft, IPointShape bottomRight, bool isStroked, bool isFilled, string text) { var factory = _serviceProvider.GetService <IFactory>(); var editor = _serviceProvider.GetService <IProjectEditor>(); var project = editor.Project; var fileIO = editor.FileIO; byte[] bytes; using (var stream = fileIO?.Open(path)) { bytes = fileIO?.ReadBinary(stream); } if (project is IImageCache imageCache) { var key = imageCache.AddImageFromFile(path, bytes); var style = project.CurrentStyleLibrary?.Selected != null ? project.CurrentStyleLibrary.Selected : factory.CreateShapeStyle(ProjectEditorConfiguration.DefaulStyleName); var image = factory.CreateImageShape( topLeft, bottomRight, (IShapeStyle)style.Copy(null), key, isStroked, isFilled, text); project.AddShape(project.CurrentContainer.CurrentLayer, image); return(image); } return(null); }
/// <summary> /// Initialize new instance of <see cref="ToolPointSelection"/> class. /// </summary> /// <param name="layer">The selection shapes layer.</param> /// <param name="shape">The selected shape.</param> /// <param name="style">The selection shapes style.</param> /// <param name="point">The selection point shape.</param> public ToolPointSelection(ILayerContainer layer, IPointShape shape, IShapeStyle style, IBaseShape point) { _layer = layer; _shape = shape; _style = style; _point = point; }
/// <summary> /// Adds <see cref="IPointShape"/> to <see cref="IConnectableShape.Connectors"/> collection with <see cref="ShapeStateFlags.Output"/> flag set. /// </summary> /// <param name="shape">The connectable shape.</param> /// <param name="point">The point object.</param> public static void AddConnectorAsOutput(this IConnectableShape shape, IPointShape point) { point.Owner = shape; point.State.Flags |= ShapeStateFlags.Connector | ShapeStateFlags.Output; point.State.Flags &= ~ShapeStateFlags.Standalone; shape.Connectors = shape.Connectors.Add(point); }
/// <summary> /// Transfer selection state to Point4. /// </summary> public void ToStatePoint4() { _helperPoint1 = _serviceProvider.GetService <IFactory>().CreatePointShape(0, 0, _point); _layer.Shapes = _layer.Shapes.Add(_helperPoint1); _helperPoint4 = _serviceProvider.GetService <IFactory>().CreatePointShape(0, 0, _point); _layer.Shapes = _layer.Shapes.Add(_helperPoint4); }
public static void TransformPoint(ref MatrixD matrix, IPointShape point) { var transformed = MatrixD.TransformPoint(matrix, new PointD((decimal)point.X, (decimal)point.Y)); point.X = (double)transformed.X; point.Y = (double)transformed.Y; }
/// <summary> /// Remove selection. /// </summary> public void Remove() { if (_line12 != null) { _layer.Shapes = _layer.Shapes.Remove(_line12); _line12 = null; } if (_line32 != null) { _layer.Shapes = _layer.Shapes.Remove(_line32); _line32 = null; } if (_helperPoint1 != null) { _layer.Shapes = _layer.Shapes.Remove(_helperPoint1); _helperPoint1 = null; } if (_helperPoint2 != null) { _layer.Shapes = _layer.Shapes.Remove(_helperPoint2); _helperPoint2 = null; } if (_helperPoint3 != null) { _layer.Shapes = _layer.Shapes.Remove(_helperPoint3); _helperPoint3 = null; } _layer.Invalidate(); }
public PointDrawNode(IPointShape point, IShapeStyle pointStyle, double pointSize) { Style = pointStyle; Point = point; PointSize = pointSize; UpdateGeometry(); }
/// <summary> /// Calculates distance between points. /// </summary> /// <param name="point">The point instance.</param> /// <param name="other">The other point.</param> /// <returns>The distance between points.</returns> public static double DistanceTo(this IPointShape point, IPointShape other) { double dx = point.X - other.X; double dy = point.Y - other.Y; return(Sqrt(dx * dx + dy * dy)); }
public static void TransformPoint(ref Matrix2 matrix, IPointShape point) { var transformed = Matrix2.TransformPoint(matrix, new Point2(point.X, point.Y)); point.X = transformed.X; point.Y = transformed.Y; }
/// <inheritdoc/> public void LineTo(IPointShape point, bool isStroked = true) { var segment = _factory.CreateLineSegment( point, isStroked); _currentFigure.Segments = _currentFigure.Segments.Add(segment); }
/// <summary> /// Transfer selection state to End. /// </summary> public void ToStateEnd() { _startHelperPoint = _serviceProvider.GetService <IFactory>().CreatePointShape(0, 0, _point); _endHelperPoint = _serviceProvider.GetService <IFactory>().CreatePointShape(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 = _serviceProvider.GetService <IFactory>().CreateLineShape(0, 0, _style, null); _helperPoint2 = _serviceProvider.GetService <IFactory>().CreatePointShape(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() { _topLeftHelperPoint = _serviceProvider.GetService <IFactory>().CreatePointShape(0, 0, _point); _bottomRightHelperPoint = _serviceProvider.GetService <IFactory>().CreatePointShape(0, 0, _point); _layer.Shapes = _layer.Shapes.Add(_topLeftHelperPoint); _layer.Shapes = _layer.Shapes.Add(_bottomRightHelperPoint); }
public static Rect2 ToRect2(this IPointShape center, double radius) { return(Rect2.FromPoints( center.X - radius, center.Y - radius, center.X + radius, center.Y + radius)); }
internal void DrawLine(object dc, IShapeRenderer renderer, IPointShape a, IPointShape b, double dx, double dy, double scale) { _line.StyleId = _strokeStyleId; _line.StartPoint.X = a.X; _line.StartPoint.Y = a.Y; _line.Point.X = b.X; _line.Point.Y = b.Y; _line.Draw(dc, renderer, dx, dy, scale, null, null); }
internal void DrawText(object dc, IShapeRenderer renderer, string text, IPointShape a, IPointShape b, double dx, double dy, double scale) { _text.StyleId = _strokeStyleId; _text.StartPoint.X = a.X; _text.StartPoint.Y = a.Y; _text.Point.X = b.X; _text.Point.Y = b.Y; _text.Draw(dc, renderer, dx, dy, scale, null, null); }
internal void DrawEllipse(object dc, IShapeRenderer renderer, IPointShape s, double radius, double dx, double dy, double scale) { _ellipse.StyleId = _strokeStyleId; _ellipse.StartPoint.X = s.X - radius; _ellipse.StartPoint.Y = s.Y - radius; _ellipse.Point.X = s.X + radius; _ellipse.Point.Y = s.Y + radius; _ellipse.Draw(dc, renderer, dx, dy, scale, null, null); }
internal void FillRectangle(object dc, IShapeRenderer renderer, IPointShape s, double radius, double dx, double dy, double scale) { _rectangle.StyleId = _fillStyleId; _rectangle.StartPoint.X = s.X - radius; _rectangle.StartPoint.Y = s.Y - radius; _rectangle.Point.X = s.X + radius; _rectangle.Point.Y = s.Y + radius; _rectangle.Draw(dc, renderer, dx, dy, scale, null, null); }
public static SKRect CreateRect(IPointShape tl, IPointShape br) { float left = (float)Math.Min(tl.X, br.X); float top = (float)Math.Min(tl.Y, br.Y); float right = (float)Math.Max(tl.X, br.X); float bottom = (float)Math.Max(tl.Y, br.Y); return(new SKRect(left, top, right, bottom)); }
/// <inheritdoc/> public void QuadraticBezierTo(IPointShape point1, IPointShape point2, bool isStroked = true) { var segment = _factory.CreateQuadraticBezierSegment( point1, point2, isStroked); _currentFigure.Segments = _currentFigure.Segments.Add(segment); }
internal void FillRectangle(object dc, IShapeRenderer renderer, IPointShape a, IPointShape b, double dx, double dy, double scale) { _rectangle.StyleId = _fillStyleId; _rectangle.StartPoint.X = a.X; _rectangle.StartPoint.Y = a.Y; _rectangle.Point.X = b.X; _rectangle.Point.Y = b.Y; _rectangle.Draw(dc, renderer, dx, dy, scale, null, null); }
/// <summary> /// Transfer selection state to Point2. /// </summary> public void ToStatePoint2() { _line12 = _serviceProvider.GetService <IFactory>().CreateLineShape(0, 0, _style); _line12.State.Flags |= ShapeStateFlags.Thickness; _helperPoint2 = _serviceProvider.GetService <IFactory>().CreatePointShape(0, 0); _layer.Shapes = _layer.Shapes.Add(_line12); _layer.Shapes = _layer.Shapes.Add(_helperPoint2); }
/// <summary> /// Transfer selection state to BottomRight. /// </summary> public void ToStateBottomRight() { _helperRectangle = _serviceProvider.GetService <IFactory>().CreateRectangleShape(0, 0, _style, null); _topLeftHelperPoint = _serviceProvider.GetService <IFactory>().CreatePointShape(0, 0, _point); _bottomRightHelperPoint = _serviceProvider.GetService <IFactory>().CreatePointShape(0, 0, _point); _layer.Shapes = _layer.Shapes.Add(_helperRectangle); _layer.Shapes = _layer.Shapes.Add(_topLeftHelperPoint); _layer.Shapes = _layer.Shapes.Add(_bottomRightHelperPoint); }
/// <summary> /// Transfer selection state to Point3. /// </summary> public void ToStatePoint3() { _line43 = _serviceProvider.GetService <IFactory>().CreateLineShape(0, 0, _style); _line23 = _serviceProvider.GetService <IFactory>().CreateLineShape(0, 0, _style); _helperPoint3 = _serviceProvider.GetService <IFactory>().CreatePointShape(0, 0); _layer.Shapes = _layer.Shapes.Add(_line43); _layer.Shapes = _layer.Shapes.Add(_line23); _layer.Shapes = _layer.Shapes.Add(_helperPoint3); }
/// <inheritdoc/> public void CubicBezierTo(IPointShape point1, IPointShape point2, IPointShape point3, bool isStroked = true, bool isSmoothJoin = true) { var segment = _factory.CreateCubicBezierSegment( point1, point2, point3, isStroked, isSmoothJoin); _currentFigure.Segments = _currentFigure.Segments.Add(segment); }
/// <inheritdoc/> public void ArcTo(IPointShape point, IPathSize size, double rotationAngle = 0.0, bool isLargeArc = false, SweepDirection sweepDirection = SweepDirection.Clockwise, bool isStroked = true) { var segment = _factory.CreateArcSegment( point, size, rotationAngle, isLargeArc, sweepDirection, isStroked); _currentFigure.Segments = _currentFigure.Segments.Add(segment); }
/// <summary> /// Transfer selection state to BottomRight. /// </summary> public void ToStateBottomRight() { _helperRectangle = _serviceProvider.GetService <IFactory>().CreateRectangleShape(0, 0, _style); _helperRectangle.State.Flags |= ShapeStateFlags.Thickness; _topLeftHelperPoint = _serviceProvider.GetService <IFactory>().CreatePointShape(0, 0); _bottomRightHelperPoint = _serviceProvider.GetService <IFactory>().CreatePointShape(0, 0); _layer.Shapes = _layer.Shapes.Add(_helperRectangle); _layer.Shapes = _layer.Shapes.Add(_topLeftHelperPoint); _layer.Shapes = _layer.Shapes.Add(_bottomRightHelperPoint); }
/// <summary> /// Transfer selection state to Point2. /// </summary> public void ToStatePoint2() { _ellipse = _serviceProvider.GetService <IFactory>().CreateEllipseShape(0, 0, _style); _p1HelperPoint = _serviceProvider.GetService <IFactory>().CreatePointShape(0, 0); _p2HelperPoint = _serviceProvider.GetService <IFactory>().CreatePointShape(0, 0); _centerHelperPoint = _serviceProvider.GetService <IFactory>().CreatePointShape(0, 0); _layer.Shapes = _layer.Shapes.Add(_ellipse); _layer.Shapes = _layer.Shapes.Add(_p1HelperPoint); _layer.Shapes = _layer.Shapes.Add(_p2HelperPoint); _layer.Shapes = _layer.Shapes.Add(_centerHelperPoint); }
/// <summary> /// Reset selection. /// </summary> public void Reset() { if (_ellipse != null) { _layer.Shapes = _layer.Shapes.Remove(_ellipse); _ellipse = null; } if (_startLine != null) { _layer.Shapes = _layer.Shapes.Remove(_startLine); _startLine = null; } if (_endLine != null) { _layer.Shapes = _layer.Shapes.Remove(_endLine); _endLine = null; } if (_p1HelperPoint != null) { _layer.Shapes = _layer.Shapes.Remove(_p1HelperPoint); _p1HelperPoint = null; } if (_p2HelperPoint != null) { _layer.Shapes = _layer.Shapes.Remove(_p2HelperPoint); _p2HelperPoint = null; } if (_centerHelperPoint != null) { _layer.Shapes = _layer.Shapes.Remove(_centerHelperPoint); _centerHelperPoint = null; } if (_startHelperPoint != null) { _layer.Shapes = _layer.Shapes.Remove(_startHelperPoint); _startHelperPoint = null; } if (_endHelperPoint != null) { _layer.Shapes = _layer.Shapes.Remove(_endHelperPoint); _endHelperPoint = null; } _layer.Invalidate(); }
internal static SKRect ToSKRect(IPointShape p1, IPointShape p2, double dx, double dy) { double x1 = p1.X + dx; double y1 = p1.Y + dy; double x2 = p2.X + dx; double y2 = p2.Y + dy; double left = Math.Min(x1, x2); double top = Math.Min(y1, y2); double right = left + Math.Abs(Math.Max(x1, x2) - left); double bottom = top + Math.Abs(Math.Max(y1, y2) - top); return(new SKRect((float)left, (float)top, (float)right, (float)bottom)); }
public void CopyStateTo(IPointShape element) { element.Descriptor = Descriptor; }