/// <summary> /// Creates a new <see cref="XQBezier"/> instance. /// </summary> /// <param name="x1"></param> /// <param name="y1"></param> /// <param name="x2"></param> /// <param name="y2"></param> /// <param name="x3"></param> /// <param name="y3"></param> /// <param name="style"></param> /// <param name="point"></param> /// <param name="isStroked"></param> /// <param name="isFilled"></param> /// <param name="name"></param> /// <returns></returns> public static XQBezier Create( double x1, double y1, double x2, double y2, double x3, double y3, ShapeStyle style, BaseShape point, bool isStroked = true, bool isFilled = false, string name = "") { return new XQBezier() { Name = name, Style = style, IsStroked = isStroked, IsFilled = isFilled, Data = new Data() { Bindings = ImmutableArray.Create<Binding>(), Properties = ImmutableArray.Create<Property>() }, Point1 = XPoint.Create(x1, y1, point), Point2 = XPoint.Create(x2, y2, point), Point3 = XPoint.Create(x3, y3, point) }; }
/// <summary> /// /// </summary> /// <param name="x1"></param> /// <param name="y1"></param> /// <param name="x2"></param> /// <param name="y2"></param> /// <param name="style"></param> /// <param name="point"></param> /// <param name="isStroked"></param> /// <param name="isFilled"></param> /// <param name="text"></param> /// <param name="name"></param> /// <returns></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, Data = new Data() { Bindings = ImmutableArray.Create<ShapeBinding>(), Properties = ImmutableArray.Create<ShapeProperty>() }, TopLeft = XPoint.Create(x1, y1, point), BottomRight = XPoint.Create(x2, y2, point), Text = text, }; }
/// <summary> /// /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <param name="style"></param> /// <param name="point"></param> /// <param name="isStroked"></param> /// <param name="isFilled"></param> /// <param name="name"></param> /// <returns></returns> public static XArc 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> /// /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <param name="style"></param> /// <param name="point"></param> /// <param name="text"></param> /// <param name="isStroked"></param> /// <param name="name"></param> /// <returns></returns> public static XText Create( double x, double y, ShapeStyle style, BaseShape point, string text, bool isStroked = true, string name = "") { return(Create(x, y, x, y, style, point, text, isStroked, name)); }
/// <summary> /// /// </summary> public override void ToStateTwo() { _style = _editor.Project.Options.HelperStyle; _line12 = XLine.Create(0, 0, _style, null); _editor.Project.CurrentContainer.HelperLayer.Shapes = _editor.Project.CurrentContainer.HelperLayer.Shapes.Add(_line12); _line32 = XLine.Create(0, 0, _style, null); _editor.Project.CurrentContainer.HelperLayer.Shapes = _editor.Project.CurrentContainer.HelperLayer.Shapes.Add(_line32); _helperPoint2 = XPoint.Create(0, 0, _editor.Project.Options.PointShape); _editor.Project.CurrentContainer.HelperLayer.Shapes = _editor.Project.CurrentContainer.HelperLayer.Shapes.Add(_helperPoint2); }
/// <summary> /// /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <param name="style"></param> /// <param name="point"></param> /// <param name="isStroked"></param> /// <param name="isFilled"></param> /// <param name="text"></param> /// <param name="name"></param> /// <returns></returns> public static XRectangle Create( double x, double y, ShapeStyle style, BaseShape point, bool isStroked = true, bool isFilled = false, string text = null, string name = "") { return(Create(x, y, x, y, style, point, isStroked, isFilled, text, name)); }
/// <summary> /// /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <param name="style"></param> /// <param name="point"></param> /// <param name="isStroked"></param> /// <param name="isFilled"></param> /// <param name="text"></param> /// <param name="name"></param> /// <returns></returns> public static XEllipse Create( double x, double y, ShapeStyle style, BaseShape point, bool isStroked = true, bool isFilled = false, string text = null, string name = "") { return Create(x, y, x, y, style, point, isStroked, isFilled, text, name); }
/// <summary> /// /// </summary> public override void ToStateOne() { _style = _editor.Project.Options.HelperStyle; _ellipse = XEllipse.Create(0, 0, _style, null); _editor.Project.CurrentContainer.HelperLayer.Shapes = _editor.Project.CurrentContainer.HelperLayer.Shapes.Add(_ellipse); _p1HelperPoint = XPoint.Create(0, 0, _editor.Project.Options.PointShape); _editor.Project.CurrentContainer.HelperLayer.Shapes = _editor.Project.CurrentContainer.HelperLayer.Shapes.Add(_p1HelperPoint); _p2HelperPoint = XPoint.Create(0, 0, _editor.Project.Options.PointShape); _editor.Project.CurrentContainer.HelperLayer.Shapes = _editor.Project.CurrentContainer.HelperLayer.Shapes.Add(_p2HelperPoint); _centerHelperPoint = XPoint.Create(0, 0, _editor.Project.Options.PointShape); _editor.Project.CurrentContainer.HelperLayer.Shapes = _editor.Project.CurrentContainer.HelperLayer.Shapes.Add(_centerHelperPoint); }
/// <summary> /// /// </summary> /// <param name="pss"></param> /// <returns></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); }
/// <summary> /// /// </summary> public override void Remove() { if (_ellipse != null) { _editor.Project.CurrentContainer.HelperLayer.Shapes = _editor.Project.CurrentContainer.HelperLayer.Shapes.Remove(_ellipse); _ellipse = null; } if (_startLine != null) { _editor.Project.CurrentContainer.HelperLayer.Shapes = _editor.Project.CurrentContainer.HelperLayer.Shapes.Remove(_startLine); _startLine = null; } if (_endLine != null) { _editor.Project.CurrentContainer.HelperLayer.Shapes = _editor.Project.CurrentContainer.HelperLayer.Shapes.Remove(_endLine); _endLine = null; } if (_p1HelperPoint != null) { _editor.Project.CurrentContainer.HelperLayer.Shapes = _editor.Project.CurrentContainer.HelperLayer.Shapes.Remove(_p1HelperPoint); _p1HelperPoint = null; } if (_p2HelperPoint != null) { _editor.Project.CurrentContainer.HelperLayer.Shapes = _editor.Project.CurrentContainer.HelperLayer.Shapes.Remove(_p2HelperPoint); _p2HelperPoint = null; } if (_centerHelperPoint != null) { _editor.Project.CurrentContainer.HelperLayer.Shapes = _editor.Project.CurrentContainer.HelperLayer.Shapes.Remove(_centerHelperPoint); _centerHelperPoint = null; } if (_startHelperPoint != null) { _editor.Project.CurrentContainer.HelperLayer.Shapes = _editor.Project.CurrentContainer.HelperLayer.Shapes.Remove(_startHelperPoint); _startHelperPoint = null; } if (_endHelperPoint != null) { _editor.Project.CurrentContainer.HelperLayer.Shapes = _editor.Project.CurrentContainer.HelperLayer.Shapes.Remove(_endHelperPoint); _endHelperPoint = null; } _style = null; }
/// <summary> /// /// </summary> /// <returns></returns> public static StyleLibrary TemplateStyleLibrary() { var sgt = StyleLibrary.Create("Template"); var gs = ShapeStyle.Create("Grid", 255, 222, 222, 222, 255, 222, 222, 222, 1.0); var builder = sgt.Styles.ToBuilder(); builder.Add(gs); sgt.Styles = builder.ToImmutable(); sgt.CurrentStyle = sgt.Styles.FirstOrDefault(); return(sgt); }
/// <summary> /// /// </summary> public override void Remove() { if (_line12 != null) { _editor.Project.CurrentContainer.HelperLayer.Shapes = _editor.Project.CurrentContainer.HelperLayer.Shapes.Remove(_line12); _line12 = null; } if (_line43 != null) { _editor.Project.CurrentContainer.HelperLayer.Shapes = _editor.Project.CurrentContainer.HelperLayer.Shapes.Remove(_line43); _line43 = null; } if (_line23 != null) { _editor.Project.CurrentContainer.HelperLayer.Shapes = _editor.Project.CurrentContainer.HelperLayer.Shapes.Remove(_line23); _line23 = null; } if (_helperPoint1 != null) { _editor.Project.CurrentContainer.HelperLayer.Shapes = _editor.Project.CurrentContainer.HelperLayer.Shapes.Remove(_helperPoint1); _helperPoint1 = null; } if (_helperPoint2 != null) { _editor.Project.CurrentContainer.HelperLayer.Shapes = _editor.Project.CurrentContainer.HelperLayer.Shapes.Remove(_helperPoint2); _helperPoint2 = null; } if (_helperPoint3 != null) { _editor.Project.CurrentContainer.HelperLayer.Shapes = _editor.Project.CurrentContainer.HelperLayer.Shapes.Remove(_helperPoint3); _helperPoint3 = null; } if (_helperPoint4 != null) { _editor.Project.CurrentContainer.HelperLayer.Shapes = _editor.Project.CurrentContainer.HelperLayer.Shapes.Remove(_helperPoint4); _helperPoint4 = null; } _style = null; }
/// <summary> /// /// </summary> /// <returns></returns> public static StyleLibrary DefaultStyleLibrary() { var sgd = StyleLibrary.Create("Default"); var builder = sgd.Styles.ToBuilder(); builder.Add(ShapeStyle.Create("Black", 255, 0, 0, 0, 80, 0, 0, 0, 2.0)); builder.Add(ShapeStyle.Create("Yellow", 255, 255, 255, 0, 80, 255, 255, 0, 2.0)); builder.Add(ShapeStyle.Create("Red", 255, 255, 0, 0, 80, 255, 0, 0, 2.0)); builder.Add(ShapeStyle.Create("Green", 255, 0, 255, 0, 80, 0, 255, 0, 2.0)); builder.Add(ShapeStyle.Create("Blue", 255, 0, 0, 255, 80, 0, 0, 255, 2.0)); sgd.Styles = builder.ToImmutable(); sgd.CurrentStyle = sgd.Styles.FirstOrDefault(); return(sgd); }
/// <summary> /// /// </summary> /// <returns></returns> public static Options Create() { var options = new Options() { SnapToGrid = true, SnapX = 15.0, SnapY = 15.0, HitTreshold = 7.0, MoveMode = MoveMode.Point, DefaultIsStroked = true, DefaultIsFilled = false, DefaultIsClosed = true, DefaultIsSmoothJoin = true, DefaultFillRule = XFillRule.EvenOdd, TryToConnect = false }; options.SelectionStyle = ShapeStyle.Create( "Selection", 0x7F, 0x33, 0x33, 0xFF, 0x4F, 0x33, 0x33, 0xFF, 1.0); options.HelperStyle = ShapeStyle.Create( "Helper", 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 1.0); options.PointStyle = ShapeStyle.Create( "Point", 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 1.0); options.PointShape = RectanglePointShape(options.PointStyle); return(options); }
/// <summary> /// /// </summary> /// <returns></returns> public static StyleLibrary LinesStyleLibrary() { var sgdl = StyleLibrary.Create("Lines"); var solid = ShapeStyle.Create("Solid", 255, 0, 0, 0, 80, 0, 0, 0, 2.0); solid.Dashes = default(double[]); solid.DashOffset = 0.0; var dash = ShapeStyle.Create("Dash", 255, 0, 0, 0, 80, 0, 0, 0, 2.0); dash.Dashes = new double[] { 2, 2 }; dash.DashOffset = 1.0; var dot = ShapeStyle.Create("Dot", 255, 0, 0, 0, 80, 0, 0, 0, 2.0); dot.Dashes = new double[] { 0, 2 }; dot.DashOffset = 0.0; var dashDot = ShapeStyle.Create("DashDot", 255, 0, 0, 0, 80, 0, 0, 0, 2.0); dashDot.Dashes = new double[] { 2, 2, 0, 2 }; dashDot.DashOffset = 1.0; var dashDotDot = ShapeStyle.Create("DashDotDot", 255, 0, 0, 0, 80, 0, 0, 0, 2.0); dashDotDot.Dashes = new double[] { 2, 2, 0, 2, 0, 2 }; dashDotDot.DashOffset = 1.0; var builder = sgdl.Styles.ToBuilder(); builder.Add(solid); builder.Add(dash); builder.Add(dot); builder.Add(dashDot); builder.Add(dashDotDot); sgdl.Styles = builder.ToImmutable(); sgdl.CurrentStyle = sgdl.Styles.FirstOrDefault(); return(sgdl); }
/// <summary> /// /// </summary> /// <param name="name"></param> /// <param name="style"></param> /// <param name="geometry"></param> /// <param name="isStroked"></param> /// <param name="isFilled"></param> /// <returns></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, Data = new Data() { Bindings = ImmutableArray.Create <ShapeBinding>(), Properties = ImmutableArray.Create <ShapeProperty>() }, Geometry = geometry }); }
/// <summary> /// /// </summary> /// <param name="name"></param> /// <param name="style"></param> /// <param name="geometry"></param> /// <param name="isStroked"></param> /// <param name="isFilled"></param> /// <returns></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, Data = new Data() { Bindings = ImmutableArray.Create<ShapeBinding>(), Properties = ImmutableArray.Create<ShapeProperty>() }, Geometry = geometry }; }
/// <summary> /// /// </summary> /// <param name="start"></param> /// <param name="end"></param> /// <param name="style"></param> /// <param name="point"></param> /// <param name="isStroked"></param> /// <param name="name"></param> /// <returns></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, Data = new Data() { Bindings = ImmutableArray.Create <ShapeBinding>(), Properties = ImmutableArray.Create <ShapeProperty>() }, Start = start, End = end }); }
/// <summary> /// /// </summary> /// <param name="start"></param> /// <param name="end"></param> /// <param name="style"></param> /// <param name="point"></param> /// <param name="isStroked"></param> /// <param name="name"></param> /// <returns></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, Data = new Data() { Bindings = ImmutableArray.Create<ShapeBinding>(), Properties = ImmutableArray.Create<ShapeProperty>() }, Start = start, End = end }; }
/// <summary> /// /// </summary> /// <param name="x1"></param> /// <param name="y1"></param> /// <param name="x2"></param> /// <param name="y2"></param> /// <param name="style"></param> /// <param name="point"></param> /// <param name="isStroked"></param> /// <param name="name"></param> /// <returns></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, Data = new Data() { Bindings = ImmutableArray.Create <ShapeBinding>(), Properties = ImmutableArray.Create <ShapeProperty>() }, Start = XPoint.Create(x1, y1, point), End = XPoint.Create(x2, y2, point) }); }
/// <summary> /// /// </summary> /// <param name="x1"></param> /// <param name="y1"></param> /// <param name="x2"></param> /// <param name="y2"></param> /// <param name="style"></param> /// <param name="point"></param> /// <param name="text"></param> /// <param name="isStroked"></param> /// <param name="name"></param> /// <returns></returns> public static XText Create( double x1, double y1, double x2, double y2, ShapeStyle style, BaseShape point, string text, bool isStroked = true, string name = "") { return(new XText() { Name = name, Style = style, IsStroked = isStroked, Data = new Data() { Bindings = ImmutableArray.Create <ShapeBinding>(), Properties = ImmutableArray.Create <ShapeProperty>() }, TopLeft = XPoint.Create(x1, y1, point), BottomRight = XPoint.Create(x2, y2, point), Text = text }); }
/// <summary> /// /// </summary> /// <param name="topLeft"></param> /// <param name="bottomRight"></param> /// <param name="style"></param> /// <param name="point"></param> /// <param name="text"></param> /// <param name="isStroked"></param> /// <param name="name"></param> /// <returns></returns> public static XText Create( XPoint topLeft, XPoint bottomRight, ShapeStyle style, BaseShape point, string text, bool isStroked = true, string name = "") { return(new XText() { Name = name, Style = style, IsStroked = isStroked, Data = new Data() { Bindings = ImmutableArray.Create <ShapeBinding>(), Properties = ImmutableArray.Create <ShapeProperty>() }, TopLeft = topLeft, BottomRight = bottomRight, Text = text }); }
/// <summary> /// /// </summary> /// <param name="pss"></param> /// <returns></returns> public static BaseShape FilledRectanglePointShape(ShapeStyle pss) { return(XRectangle.Create(-3, -3, 3, 3, pss, null, true, true)); }
/// <summary> /// Creates a new <see cref="XArc"/> instance. /// </summary> /// <param name="point1"></param> /// <param name="point2"></param> /// <param name="point3"></param> /// <param name="point4"></param> /// <param name="style"></param> /// <param name="point"></param> /// <param name="isStroked"></param> /// <param name="isFilled"></param> /// <param name="name"></param> /// <returns></returns> public static XArc Create( XPoint point1, XPoint point2, XPoint point3, XPoint point4, ShapeStyle style, BaseShape point, bool isStroked = true, bool isFilled = false, string name = "") { return new XArc() { Name = name, Style = style, IsStroked = isStroked, IsFilled = isFilled, Data = new Data() { Bindings = ImmutableArray.Create<Binding>(), Properties = ImmutableArray.Create<Property>() }, Point1 = point1, Point2 = point2, Point3 = point3, Point4 = point4 }; }
/// <summary> /// /// </summary> /// <param name="topLeft"></param> /// <param name="bottomRight"></param> /// <param name="style"></param> /// <param name="point"></param> /// <param name="text"></param> /// <param name="isStroked"></param> /// <param name="name"></param> /// <returns></returns> public static XText Create( XPoint topLeft, XPoint bottomRight, ShapeStyle style, BaseShape point, string text, bool isStroked = true, string name = "") { return new XText() { Name = name, Style = style, IsStroked = isStroked, Data = new Data() { Bindings = ImmutableArray.Create<ShapeBinding>(), Properties = ImmutableArray.Create<ShapeProperty>() }, TopLeft = topLeft, BottomRight = bottomRight, Text = text }; }
/// <summary> /// /// </summary> /// <param name="pss"></param> /// <returns></returns> public static BaseShape RectanglePointShape(ShapeStyle pss) { return XRectangle.Create(-4, -4, 4, 4, pss, null, true, false); }
/// <summary> /// /// </summary> /// <param name="pss"></param> /// <returns></returns> public static BaseShape FilledEllipsePointShape(ShapeStyle pss) { return XEllipse.Create(-3, -3, 3, 3, pss, null, true, true); }
/// <summary> /// /// </summary> /// <param name="pss"></param> /// <returns></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; }
/// <summary> /// /// </summary> public override void ToStateOne() { _style = _editor.Project.Options.HelperStyle; _helperPoint1 = XPoint.Create(0, 0, _editor.Project.Options.PointShape); _editor.Project.CurrentContainer.HelperLayer.Shapes = _editor.Project.CurrentContainer.HelperLayer.Shapes.Add(_helperPoint1); _helperPoint4 = XPoint.Create(0, 0, _editor.Project.Options.PointShape); _editor.Project.CurrentContainer.HelperLayer.Shapes = _editor.Project.CurrentContainer.HelperLayer.Shapes.Add(_helperPoint4); }
/// <summary> /// /// </summary> /// <param name="style"></param> /// <param name="rect"></param> /// <param name="ft"></param> /// <returns></returns> 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> /// /// </summary> /// <param name="style"></param> /// <param name="x"></param> /// <param name="y"></param> public void Drop(ShapeStyle style, double x, double y) { try { if (_editor.Renderers[0].State.SelectedShape != null || (_editor.Renderers[0].State.SelectedShapes != null && _editor.Renderers[0].State.SelectedShapes.Count > 0)) { _editor.ApplyStyle(style); } else { _editor.ApplyStyle(style, x, y); } } catch (Exception ex) { if (_editor.Log != null) { _editor.Log.LogError("{0}{1}{2}", ex.Message, Environment.NewLine, ex.StackTrace); } } }
/// <summary> /// /// </summary> /// <param name="style"></param> public void Add(ShapeStyle style) { if (style == null) return; style.PropertyChanged += StyleObserver; if (style.Stroke != null) { style.Stroke.PropertyChanged += StyleObserver; } if (style.Fill != null) { style.Fill.PropertyChanged += StyleObserver; } if (style.LineStyle != null) { style.LineStyle.PropertyChanged += StyleObserver; if (style.LineStyle.FixedLength != null) { style.LineStyle.FixedLength.PropertyChanged += StyleObserver; } } if (style.StartArrowStyle != null) { style.StartArrowStyle.PropertyChanged += StyleObserver; if (style.StartArrowStyle.Stroke != null) { style.StartArrowStyle.Stroke.PropertyChanged += StyleObserver; } if (style.StartArrowStyle.Fill != null) { style.StartArrowStyle.Fill.PropertyChanged += StyleObserver; } } if (style.EndArrowStyle != null) { style.EndArrowStyle.PropertyChanged += StyleObserver; if (style.EndArrowStyle.Stroke != null) { style.EndArrowStyle.Stroke.PropertyChanged += StyleObserver; } if (style.EndArrowStyle.Fill != null) { style.EndArrowStyle.Fill.PropertyChanged += StyleObserver; } } if (style.TextStyle != null) { style.TextStyle.PropertyChanged += StyleObserver; if (style.TextStyle.FontStyle != null) { style.TextStyle.FontStyle.PropertyChanged += StyleObserver; } } Verbose("Add Style: " + style.Name); }
/// <summary> /// /// </summary> /// <param name="pss"></param> /// <returns></returns> public static BaseShape EllipsePointShape(ShapeStyle pss) { return(XEllipse.Create(-4, -4, 4, 4, pss, null, true, false)); }
/// <summary> /// /// </summary> /// <param name="pss"></param> /// <returns></returns> public static BaseShape FilledEllipsePointShape(ShapeStyle pss) { return(XEllipse.Create(-3, -3, 3, 3, pss, null, true, true)); }
/// <summary> /// /// </summary> /// <param name="x1"></param> /// <param name="y1"></param> /// <param name="x2"></param> /// <param name="y2"></param> /// <param name="style"></param> /// <param name="point"></param> /// <param name="isStroked"></param> /// <param name="name"></param> /// <returns></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, Data = new Data() { Bindings = ImmutableArray.Create<ShapeBinding>(), Properties = ImmutableArray.Create<ShapeProperty>() }, Start = XPoint.Create(x1, y1, point), End = XPoint.Create(x2, y2, point) }; }
/// <summary> /// /// </summary> public override void ToStateTwo() { _style = _editor.Project.Options.HelperStyle; _line12 = XLine.Create(0, 0, _style, null); _editor.Project.CurrentContainer.HelperLayer.Shapes = _editor.Project.CurrentContainer.HelperLayer.Shapes.Add(_line12); _helperPoint2 = XPoint.Create(0, 0, _editor.Project.Options.PointShape); _editor.Project.CurrentContainer.HelperLayer.Shapes = _editor.Project.CurrentContainer.HelperLayer.Shapes.Add(_helperPoint2); }
/// <summary> /// /// </summary> /// <param name="style"></param> /// <param name="x"></param> /// <param name="y"></param> public void Drop(ShapeStyle style, double x, double y) { try { if (_editor.Renderers[0].State.SelectedShape != null) { // TODO: Add history snapshot. _editor.Renderers[0].State.SelectedShape.Style = style; } else if (_editor.Renderers[0].State.SelectedShapes != null && _editor.Renderers[0].State.SelectedShapes.Count > 0) { // TODO: Add history snapshot. foreach (var shape in _editor.Renderers[0].State.SelectedShapes) { shape.Style = style; } } else { var container = _editor.Project.CurrentContainer; if (container != null) { var result = ShapeBounds.HitTest(container, new Vector2(x, y), _editor.Project.Options.HitTreshold); if (result != null) { // Add history snapshot. result.Style = style; } } } } catch (Exception ex) { if (_editor.Log != null) { _editor.Log.LogError("{0}{1}{2}", ex.Message, Environment.NewLine, ex.StackTrace); } } }
private void RemoveLineHelpers() { if (_lineStartHelperPoint != null) { _editor.Project.CurrentContainer.HelperLayer.Shapes = _editor.Project.CurrentContainer.HelperLayer.Shapes.Remove(_lineStartHelperPoint); _lineStartHelperPoint = null; } if (_lineEndHelperPoint != null) { _editor.Project.CurrentContainer.HelperLayer.Shapes = _editor.Project.CurrentContainer.HelperLayer.Shapes.Remove(_lineEndHelperPoint); _lineEndHelperPoint = null; } _style = null; }
/// <summary> /// /// </summary> /// <param name="pss"></param> /// <returns></returns> public static BaseShape EllipsePointShape(ShapeStyle pss) { return XEllipse.Create(-4, -4, 4, 4, pss, null, true, false); }
private void RemoveQBezierHelpers() { if (_qbezierLine12 != null) { _editor.Project.CurrentContainer.HelperLayer.Shapes = _editor.Project.CurrentContainer.HelperLayer.Shapes.Remove(_qbezierLine12); _qbezierLine12 = null; } if (_qbezierLine32 != null) { _editor.Project.CurrentContainer.HelperLayer.Shapes = _editor.Project.CurrentContainer.HelperLayer.Shapes.Remove(_qbezierLine32); _qbezierLine32 = null; } if (_qbezierHelperPoint1 != null) { _editor.Project.CurrentContainer.HelperLayer.Shapes = _editor.Project.CurrentContainer.HelperLayer.Shapes.Remove(_qbezierHelperPoint1); _qbezierHelperPoint1 = null; } if (_qbezierHelperPoint2 != null) { _editor.Project.CurrentContainer.HelperLayer.Shapes = _editor.Project.CurrentContainer.HelperLayer.Shapes.Remove(_qbezierHelperPoint2); _qbezierHelperPoint2 = null; } if (_qbezierHelperPoint3 != null) { _editor.Project.CurrentContainer.HelperLayer.Shapes = _editor.Project.CurrentContainer.HelperLayer.Shapes.Remove(_qbezierHelperPoint3); _qbezierHelperPoint3 = null; } _style = null; }
/// <summary> /// /// </summary> /// <param name="pss"></param> /// <returns></returns> public static BaseShape FilledRectanglePointShape(ShapeStyle pss) { return XRectangle.Create(-3, -3, 3, 3, pss, null, true, true); }
private void ToStateOneLine() { _style = _editor.Project.Options.HelperStyle; _lineStartHelperPoint = XPoint.Create(0, 0, _editor.Project.Options.PointShape); _editor.Project.CurrentContainer.HelperLayer.Shapes = _editor.Project.CurrentContainer.HelperLayer.Shapes.Add(_lineStartHelperPoint); _lineEndHelperPoint = XPoint.Create(0, 0, _editor.Project.Options.PointShape); _editor.Project.CurrentContainer.HelperLayer.Shapes = _editor.Project.CurrentContainer.HelperLayer.Shapes.Add(_lineEndHelperPoint); }
/// <summary> /// /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <param name="style"></param> /// <param name="point"></param> /// <param name="text"></param> /// <param name="isStroked"></param> /// <param name="name"></param> /// <returns></returns> public static XText Create( double x, double y, ShapeStyle style, BaseShape point, string text, bool isStroked = true, string name = "") { return Create(x, y, x, y, style, point, text, isStroked, name); }
private void ToStateOneQBezier() { _style = _editor.Project.Options.HelperStyle; _qbezierHelperPoint1 = XPoint.Create(0, 0, _editor.Project.Options.PointShape); _editor.Project.CurrentContainer.HelperLayer.Shapes = _editor.Project.CurrentContainer.HelperLayer.Shapes.Add(_qbezierHelperPoint1); _qbezierHelperPoint3 = XPoint.Create(0, 0, _editor.Project.Options.PointShape); _editor.Project.CurrentContainer.HelperLayer.Shapes = _editor.Project.CurrentContainer.HelperLayer.Shapes.Add(_qbezierHelperPoint3); }
/// <summary> /// /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <param name="style"></param> /// <param name="point"></param> /// <param name="isStroked"></param> /// <param name="isFilled"></param> /// <param name="name"></param> /// <returns></returns> public static XBezier 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); }
private void ToStateTwoQBezier() { _style = _editor.Project.Options.HelperStyle; _qbezierLine12 = XLine.Create(0, 0, _style, null); _editor.Project.CurrentContainer.HelperLayer.Shapes = _editor.Project.CurrentContainer.HelperLayer.Shapes.Add(_qbezierLine12); _qbezierLine32 = XLine.Create(0, 0, _style, null); _editor.Project.CurrentContainer.HelperLayer.Shapes = _editor.Project.CurrentContainer.HelperLayer.Shapes.Add(_qbezierLine32); _qbezierHelperPoint2 = XPoint.Create(0, 0, _editor.Project.Options.PointShape); _editor.Project.CurrentContainer.HelperLayer.Shapes = _editor.Project.CurrentContainer.HelperLayer.Shapes.Add(_qbezierHelperPoint2); }
/// <summary> /// /// </summary> /// <param name="style"></param> /// <param name="rect"></param> /// <param name="size"></param> /// <returns></returns> private PointF GetTextOrigin(ShapeStyle style, ref RectangleF rect, ref SizeF size) { float 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 / 2f) - (size.Width / 2f); break; } switch (style.TextStyle.TextVAlignment) { case TextVAlignment.Top: oy = rect.TopLeft.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 PointF(ox, oy); }
/// <summary> /// /// </summary> /// <param name="pss"></param> /// <returns></returns> public static BaseShape RectanglePointShape(ShapeStyle pss) { return(XRectangle.Create(-4, -4, 4, 4, pss, null, true, false)); }