/// <summary> /// Initialize new instance of <see cref="PointSelection"/> 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 PointSelection(XLayer layer, XPoint shape, ShapeStyle style, BaseShape point) { _layer = layer; _shape = shape; _style = style; _point = point; }
/// <summary> /// Initialize new instance of <see cref="TextSelection"/> 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 TextSelection(XLayer layer, XText shape, ShapeStyle style, BaseShape point) { _layer = layer; _text = shape; _style = style; _point = point; }
/// <summary> /// Initialize new instance of <see cref="PathSelection"/> 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 PathSelection(XLayer layer, XPath shape, ShapeStyle style, BaseShape point) { _layer = layer; _path = shape; _style = style; _point = point; }
/// <summary> /// Initialize new instance of <see cref="ImageSelection"/> 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 ImageSelection(XLayer layer, XImage shape, ShapeStyle style, BaseShape point) { _layer = layer; _image = shape; _style = style; _point = point; }
/// <summary> /// Initialize new instance of <see cref="RectangleSelection"/> 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 RectangleSelection(XLayer layer, XRectangle shape, ShapeStyle style, BaseShape point) { _layer = layer; _rectangle = shape; _style = style; _point = point; }
/// <summary> /// Initialize new instance of <see cref="QuadraticBezierSelection"/> 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 QuadraticBezierSelection(XLayer layer, IQuadraticBezier shape, ShapeStyle style, BaseShape point) { _layer = layer; _quadraticBezier = shape; _style = style; _point = point; }
private A.Point GetTextOrigin(ShapeStyle style, ref Rect2 rect, ref A.Size size) { double ox, oy; switch (style.TextStyle.TextHAlignment) { case TextHAlignment.Left: ox = rect.X; break; case TextHAlignment.Right: ox = rect.Right - size.Width; break; case TextHAlignment.Center: default: ox = (rect.Left + rect.Width / 2.0) - (size.Width / 2.0); break; } switch (style.TextStyle.TextVAlignment) { case TextVAlignment.Top: oy = rect.Y; break; case TextVAlignment.Bottom: oy = rect.Bottom - size.Height; break; case TextVAlignment.Center: default: oy = (rect.Bottom - rect.Height / 2f) - (size.Height / 2f); break; } return new A.Point(ox, oy); }
/// <summary> /// Initialize new instance of <see cref="LineSelection"/> 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 LineSelection(XLayer layer, ILine shape, ShapeStyle style, BaseShape point) { _layer = layer; _line = shape; _style = style; _point = point; }
private static Point GetTextOrigin(ShapeStyle style, ref Rect rect, FormattedText ft) { double ox, oy; switch (style.TextStyle.TextHAlignment) { case TextHAlignment.Left: ox = rect.TopLeft.X; break; case TextHAlignment.Right: ox = rect.Right - ft.Width; break; case TextHAlignment.Center: default: ox = (rect.Left + rect.Width / 2.0) - (ft.Width / 2.0); break; } switch (style.TextStyle.TextVAlignment) { case TextVAlignment.Top: oy = rect.TopLeft.Y; break; case TextVAlignment.Bottom: oy = rect.Bottom - ft.Height; break; case TextVAlignment.Center: default: oy = (rect.Bottom - rect.Height / 2.0) - (ft.Height / 2.0); break; } return new Point(ox, oy); }
/// <summary> /// Initialize new instance of <see cref="ArcSelection"/> 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 ArcSelection(XLayer layer, IArc shape, ShapeStyle style, BaseShape point) { _layer = layer; _arc = shape; _style = style; _point = point; }
/// <summary> /// Initialize new instance of <see cref="EllipseSelection"/> 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 EllipseSelection(XLayer layer, XEllipse shape, ShapeStyle style, BaseShape point) { _layer = layer; _ellipse = shape; _style = style; _point = point; }
/// <summary> /// Initialize new instance of <see cref="CubicBezierSelection"/> 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 CubicBezierSelection(XLayer layer, ICubicBezier shape, ShapeStyle style, BaseShape point) { _layer = layer; _cubicBezier = shape; _style = style; _point = point; }
/// <summary> /// Creates a new <see cref="XEllipse"/> instance. /// </summary> /// <param name="x1">The X coordinate of <see cref="XText.TopLeft"/> corner point.</param> /// <param name="y1">The Y coordinate of <see cref="XText.TopLeft"/> corner point.</param> /// <param name="x2">The X coordinate of <see cref="XText.BottomRight"/> corner point.</param> /// <param name="y2">The Y coordinate of <see cref="XText.BottomRight"/> corner point.</param> /// <param name="style">The shape style.</param> /// <param name="point">The point template.</param> /// <param name="isStroked">The flag indicating whether shape is stroked.</param> /// <param name="isFilled">The flag indicating whether shape is filled.</param> /// <param name="text">The text string.</param> /// <param name="name">The shape name.</param> /// <returns>The new instance of the <see cref="XEllipse"/> class.</returns> public static XEllipse Create(double x1, double y1, double x2, double y2, ShapeStyle style, BaseShape point, bool isStroked = true, bool isFilled = false, string text = null, string name = "") { return new XEllipse() { Name = name, Style = style, IsStroked = isStroked, IsFilled = isFilled, TopLeft = XPoint.Create(x1, y1, point), BottomRight = XPoint.Create(x2, y2, point), Text = text, }; }
/// <summary> /// Creates a new <see cref="XEllipse"/> instance. /// </summary> /// <param name="topLeft">The <see cref="XText.TopLeft"/> corner point.</param> /// <param name="bottomRight">The <see cref="XText.BottomRight"/> corner point.</param> /// <param name="style">The shape style.</param> /// <param name="point">The point template.</param> /// <param name="isStroked">The flag indicating whether shape is stroked.</param> /// <param name="isFilled">The flag indicating whether shape is filled.</param> /// <param name="text">The text string.</param> /// <param name="name">The shape name.</param> /// <returns>The new instance of the <see cref="XEllipse"/> class.</returns> public static XEllipse Create(XPoint topLeft, XPoint bottomRight, ShapeStyle style, BaseShape point, bool isStroked = true, bool isFilled = false, string text = null, string name = "") { return new XEllipse() { Name = name, Style = style, IsStroked = isStroked, IsFilled = isFilled, TopLeft = topLeft, BottomRight = bottomRight, Text = text, }; }
private SKPoint GetTextOrigin(ShapeStyle style, ref SKRect rect, ref SKRect size) { double rwidth = Math.Abs(rect.Right - rect.Left); double rheight = Math.Abs(rect.Bottom - rect.Top); double swidth = Math.Abs(size.Right - size.Left); double sheight = Math.Abs(size.Bottom - size.Top); double ox, oy; switch (style.TextStyle.TextHAlignment) { case TextHAlignment.Left: ox = rect.Left; break; case TextHAlignment.Right: ox = rect.Right - swidth; break; case TextHAlignment.Center: default: ox = (rect.Left + rwidth / 2f) - (swidth / 2f); break; } switch (style.TextStyle.TextVAlignment) { case TextVAlignment.Top: oy = rect.Top; break; case TextVAlignment.Bottom: oy = rect.Bottom - sheight; break; case TextVAlignment.Center: default: oy = (rect.Bottom - rheight / 2f) - (sheight / 2f); break; } return new SKPoint((float)ox, (float)oy); }
/// <summary> /// Creates a new <see cref="XLine"/> instance. /// </summary> /// <param name="x1">The X coordinate of <see cref="XLine.Start"/> point.</param> /// <param name="y1">The Y coordinate of <see cref="XLine.Start"/> point.</param> /// <param name="x2">The X coordinate of <see cref="XLine.End"/> point.</param> /// <param name="y2">The Y coordinate of <see cref="XLine.End"/> point.</param> /// <param name="style">The shape style.</param> /// <param name="point">The point template.</param> /// <param name="isStroked">The flag indicating whether shape is stroked.</param> /// <param name="name">The shape name.</param> /// <returns>The new instance of the <see cref="XLine"/> class.</returns> public static XLine Create(double x1, double y1, double x2, double y2, ShapeStyle style, BaseShape point, bool isStroked = true, string name = "") { return new XLine() { Name = name, Style = style, IsStroked = isStroked, IsFilled = false, Start = XPoint.Create(x1, y1, point), End = XPoint.Create(x2, y2, point) }; }
private void DrawLineArrowsInternal(DrawingContext dc, XLine line, ShapeStyle style, double halfStart, double halfEnd, double thicknessStart, double thicknessEnd, double dx, double dy, out Point pt1, out Point pt2) { // Start arrow style. Tuple<Brush, Pen> startArrowCache = _arrowStyleCache.Get(style.StartArrowStyle); Brush fillStartArrow; Pen strokeStartArrow; if (startArrowCache != null) { fillStartArrow = startArrowCache.Item1; strokeStartArrow = startArrowCache.Item2; } else { fillStartArrow = CreateBrush(style.StartArrowStyle.Fill); strokeStartArrow = CreatePen(style.StartArrowStyle, thicknessStart); _arrowStyleCache.Set(style.StartArrowStyle, Tuple.Create(fillStartArrow, strokeStartArrow)); } // End arrow style. Tuple<Brush, Pen> endArrowCache = _arrowStyleCache.Get(style.EndArrowStyle); Brush fillEndArrow; Pen strokeEndArrow; if (endArrowCache != null) { fillEndArrow = endArrowCache.Item1; strokeEndArrow = endArrowCache.Item2; } else { fillEndArrow = CreateBrush(style.EndArrowStyle.Fill); strokeEndArrow = CreatePen(style.EndArrowStyle, thicknessEnd); _arrowStyleCache.Set(style.EndArrowStyle, Tuple.Create(fillEndArrow, strokeEndArrow)); } // Line max length. double x1 = line.Start.X + dx; double y1 = line.Start.Y + dy; double x2 = line.End.X + dx; double y2 = line.End.Y + dy; line.GetMaxLength(ref x1, ref y1, ref x2, ref y2); // Arrow transforms. var sas = style.StartArrowStyle; var eas = style.EndArrowStyle; double a1 = Math.Atan2(y1 - y2, x1 - x2) * 180.0 / Math.PI; double a2 = Math.Atan2(y2 - y1, x2 - x1) * 180.0 / Math.PI; // Draw start arrow. pt1 = DrawLineArrowInternal(dc, halfStart, strokeStartArrow, fillStartArrow, x1, y1, a1, sas); // Draw end arrow. pt2 = DrawLineArrowInternal(dc, halfEnd, strokeEndArrow, fillEndArrow, x2, y2, a2, eas); }
private void Remove(ShapeStyle style) { if (style == null) return; style.PropertyChanged -= ObserveStyle; if (style.Stroke != null) { style.Stroke.PropertyChanged -= ObserveStyle; } if (style.Fill != null) { style.Fill.PropertyChanged -= ObserveStyle; } if (style.LineStyle != null) { style.LineStyle.PropertyChanged -= ObserveStyle; if (style.LineStyle.FixedLength != null) { style.LineStyle.FixedLength.PropertyChanged -= ObserveStyle; } } if (style.StartArrowStyle != null) { style.StartArrowStyle.PropertyChanged -= ObserveStyle; if (style.StartArrowStyle.Stroke != null) { style.StartArrowStyle.Stroke.PropertyChanged -= ObserveStyle; } if (style.StartArrowStyle.Fill != null) { style.StartArrowStyle.Fill.PropertyChanged -= ObserveStyle; } } if (style.EndArrowStyle != null) { style.EndArrowStyle.PropertyChanged -= ObserveStyle; if (style.EndArrowStyle.Stroke != null) { style.EndArrowStyle.Stroke.PropertyChanged -= ObserveStyle; } if (style.EndArrowStyle.Fill != null) { style.EndArrowStyle.Fill.PropertyChanged -= ObserveStyle; } } if (style.TextStyle != null) { style.TextStyle.PropertyChanged -= ObserveStyle; if (style.TextStyle.FontStyle != null) { style.TextStyle.FontStyle.PropertyChanged -= ObserveStyle; } } }
public void Inherits_From_ObservableObject() { var target = new ShapeStyle(); Assert.True(target is ObservableObject); }
/// <summary> /// Creates a new <see cref="XCubicBezier"/> instance. /// </summary> /// <param name="point1">The <see cref="XCubicBezier.Point1"/> point.</param> /// <param name="point2">The <see cref="XCubicBezier.Point2"/> point.</param> /// <param name="point3">The <see cref="XCubicBezier.Point3"/> point.</param> /// <param name="point4">The <see cref="XCubicBezier.Point4"/> point.</param> /// <param name="style">The shape style.</param> /// <param name="point">The point template.</param> /// <param name="isStroked">The flag indicating whether shape is stroked.</param> /// <param name="isFilled">The flag indicating whether shape is filled.</param> /// <param name="name">The shape name.</param> /// <returns>The new instance of the <see cref="XCubicBezier"/> class.</returns> public static XCubicBezier Create(XPoint point1, XPoint point2, XPoint point3, XPoint point4, ShapeStyle style, BaseShape point, bool isStroked = true, bool isFilled = false, string name = "") { return new XCubicBezier() { Name = name, Style = style, IsStroked = isStroked, IsFilled = isFilled, Point1 = point1, Point2 = point2, Point3 = point3, Point4 = point4 }; }
/// <summary> /// Creates a new <see cref="BaseShape"/> instance. /// </summary> /// <param name="pss">The point shape <see cref="ShapeStyle"/>.</param> /// <returns>The new instance of the <see cref="BaseShape"/> class.</returns> public static BaseShape FilledRectanglePointShape(ShapeStyle pss) { return XRectangle.Create(-3, -3, 3, 3, pss, null, true, true); }
/// <summary> /// Creates a new <see cref="XCubicBezier"/> instance. /// </summary> /// <param name="x1">The X coordinate of <see cref="XCubicBezier.Point1"/> point.</param> /// <param name="y1">The Y coordinate of <see cref="XCubicBezier.Point1"/> point.</param> /// <param name="x2">The X coordinate of <see cref="XCubicBezier.Point2"/> point.</param> /// <param name="y2">The Y coordinate of <see cref="XCubicBezier.Point2"/> point.</param> /// <param name="x3">The X coordinate of <see cref="XCubicBezier.Point3"/> point.</param> /// <param name="y3">The Y coordinate of <see cref="XCubicBezier.Point3"/> point.</param> /// <param name="x4">The X coordinate of <see cref="XCubicBezier.Point4"/> point.</param> /// <param name="y4">The Y coordinate of <see cref="XCubicBezier.Point4"/> point.</param> /// <param name="style">The shape style.</param> /// <param name="point">The point template.</param> /// <param name="isStroked">The flag indicating whether shape is stroked.</param> /// <param name="isFilled">The flag indicating whether shape is filled.</param> /// <param name="name">The shape name.</param> /// <returns>The new instance of the <see cref="XCubicBezier"/> class.</returns> public static XCubicBezier Create(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4, ShapeStyle style, BaseShape point, bool isStroked = true, bool isFilled = false, string name = "") { return new XCubicBezier() { Name = name, Style = style, IsStroked = isStroked, IsFilled = isFilled, Point1 = XPoint.Create(x1, y1, point), Point2 = XPoint.Create(x2, y2, point), Point3 = XPoint.Create(x3, y3, point), Point4 = XPoint.Create(x4, y4, point) }; }
/// <summary> /// Creates a new <see cref="XLine"/> instance. /// </summary> /// <param name="x">The X coordinate of <see cref="XLine.Start"/> and <see cref="XLine.End"/> points.</param> /// <param name="y">The Y coordinate of <see cref="XLine.Start"/> and <see cref="XLine.End"/> points.</param> /// <param name="style">The shape style.</param> /// <param name="point">The point template.</param> /// <param name="isStroked">The flag indicating whether shape is stroked.</param> /// <param name="name">The shape name.</param> /// <returns>The new instance of the <see cref="XLine"/> class.</returns> public static XLine Create(double x, double y, ShapeStyle style, BaseShape point, bool isStroked = true, string name = "") { return Create(x, y, x, y, style, point, isStroked, name); }
/// <summary> /// Creates a new <see cref="BaseShape"/> instance. /// </summary> /// <param name="pss">The point shape <see cref="ShapeStyle"/>.</param> /// <returns>The new instance of the <see cref="BaseShape"/> class.</returns> public static BaseShape EllipsePointShape(ShapeStyle pss) { return XEllipse.Create(-4, -4, 4, 4, pss, null, true, false); }
/// <summary> /// Creates a new <see cref="BaseShape"/> instance. /// </summary> /// <param name="pss">The point shape <see cref="ShapeStyle"/>.</param> /// <returns>The new instance of the <see cref="BaseShape"/> class.</returns> public static BaseShape FilledEllipsePointShape(ShapeStyle pss) { return XEllipse.Create(-3, -3, 3, 3, pss, null, true, true); }
/// <summary> /// Creates a new <see cref="BaseShape"/> instance. /// </summary> /// <param name="pss">The point shape <see cref="ShapeStyle"/>.</param> /// <returns>The new instance of the <see cref="BaseShape"/> class.</returns> public static BaseShape RectanglePointShape(ShapeStyle pss) { return XRectangle.Create(-4, -4, 4, 4, pss, null, true, false); }
/// <summary> /// Creates a new <see cref="XLine"/> instance. /// </summary> /// <param name="start">The <see cref="XLine.Start"/> point.</param> /// <param name="end">The <see cref="XLine.End"/> point.</param> /// <param name="style">The shape style.</param> /// <param name="point">The point template.</param> /// <param name="isStroked">The flag indicating whether shape is stroked.</param> /// <param name="name">The shape name.</param> /// <returns>The new instance of the <see cref="XLine"/> class.</returns> public static XLine Create(XPoint start, XPoint end, ShapeStyle style, BaseShape point, bool isStroked = true, string name = "") { return new XLine() { Name = name, Style = style, IsStroked = isStroked, IsFilled = false, Start = start, End = end }; }
/// <summary> /// Creates a new <see cref="XCubicBezier"/> instance. /// </summary> /// <param name="x">The X coordinate of <see cref="XCubicBezier.Point1"/>, <see cref="XCubicBezier.Point2"/>, <see cref="XCubicBezier.Point3"/> and <see cref="XCubicBezier.Point4"/> points.</param> /// <param name="y">The Y coordinate of <see cref="XCubicBezier.Point1"/>, <see cref="XCubicBezier.Point2"/>, <see cref="XCubicBezier.Point3"/> and <see cref="XCubicBezier.Point4"/> points.</param> /// <param name="style">The shape style.</param> /// <param name="point">The point template.</param> /// <param name="isStroked">The flag indicating whether shape is stroked.</param> /// <param name="isFilled">The flag indicating whether shape is filled.</param> /// <param name="name">The shape name.</param> /// <returns>The new instance of the <see cref="XCubicBezier"/> class.</returns> public static XCubicBezier Create(double x, double y, ShapeStyle style, BaseShape point, bool isStroked = true, bool isFilled = false, string name = "") { return Create(x, y, x, y, x, y, x, y, style, point, isStroked, isFilled, name); }
/// <summary> /// Creates a new <see cref="XPath"/> instance. /// </summary> /// <param name="name">The shape name.</param> /// <param name="style">The shape style.</param> /// <param name="geometry">The path geometry.</param> /// <param name="isStroked">The flag indicating whether shape is stroked.</param> /// <param name="isFilled">The flag indicating whether shape is filled.</param> /// <returns>The new instance of the <see cref="XPath"/> class.</returns> public static XPath Create(string name, ShapeStyle style, XPathGeometry geometry, bool isStroked = true, bool isFilled = true) { return new XPath() { Name = name, Style = style, IsStroked = isStroked, IsFilled = isFilled, Geometry = geometry }; }
/// <summary> /// Creates a new <see cref="BaseShape"/> instance. /// </summary> /// <param name="pss">The point shape <see cref="ShapeStyle"/>.</param> /// <returns>The new instance of the <see cref="BaseShape"/> class.</returns> public static BaseShape CrossPointShape(ShapeStyle pss) { var g = XGroup.Create("PointShape"); var builder = g.Shapes.ToBuilder(); builder.Add(XLine.Create(-4, 0, 4, 0, pss, null)); builder.Add(XLine.Create(0, -4, 0, 4, pss, null)); g.Shapes = builder.ToImmutable(); return g; }