Пример #1
0
 /// <summary>
 /// 
 /// </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<ShapeBinding>(),
             Properties = ImmutableArray.Create<ShapeProperty>()
         },
         Point1 = XPoint.Create(x1, y1, point),
         Point2 = XPoint.Create(x2, y2, point),
         Point3 = XPoint.Create(x3, y3, point)
     };
 }
Пример #2
0
 /// <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="path"></param>
 /// <param name="isStroked"></param>
 /// <param name="isFilled"></param>
 /// <param name="text"></param>
 /// <param name="name"></param>
 /// <returns></returns>
 public static XImage Create(
     double x1, double y1,
     double x2, double y2,
     ShapeStyle style,
     BaseShape point,
     string path,
     bool isStroked = false,
     bool isFilled = false,
     string text = null,
     string name = "")
 {
     return new XImage()
     {
         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),
         Path = path,
         Text = text
     };
 }
Пример #3
0
 /// <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 XQBezier 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, style, point, isStroked, isFilled, name));
 }
Пример #4
0
 /// <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);
 }
Пример #5
0
 /// <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));
 }
Пример #6
0
 /// <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));
 }
Пример #7
0
 /// <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);
 }
Пример #8
0
 /// <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);
 }
Пример #9
0
        /// <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);
        }
Пример #10
0
        /// <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;
        }
Пример #11
0
        /// <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);
        }
Пример #12
0
        /// <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;
        }
Пример #13
0
        /// <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);
        }
Пример #14
0
 /// <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,
         Bindings = ImmutableArray.Create<ShapeBinding>(),
         Properties = ImmutableArray.Create<ShapeProperty>(),
         Geometry = geometry
     };
 }
Пример #15
0
        /// <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);
        }
Пример #16
0
        /// <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);
        }
Пример #17
0
 /// <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,
         Bindings = ImmutableArray.Create<ShapeBinding>(),
         Properties = ImmutableArray.Create<ShapeProperty>(),
         Start = start,
         End = end
     };
 }
Пример #18
0
 /// <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
     });
 }
Пример #19
0
 /// <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,
         Bindings = ImmutableArray.Create<ShapeBinding>(),
         Properties = ImmutableArray.Create<ShapeProperty>(),
         TopLeft = XPoint.Create(x1, y1, point),
         BottomRight = XPoint.Create(x2, y2, point),
         Text = text
     };
 }
Пример #20
0
 /// <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)
     });
 }
Пример #21
0
 /// <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
     });
 }
Пример #22
0
 /// <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
     });
 }
Пример #23
0
 /// <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
     });
 }
Пример #24
0
 /// <summary>
 /// 
 /// </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,
         Bindings = ImmutableArray.Create<ShapeBinding>(),
         Properties = ImmutableArray.Create<ShapeProperty>(),
         Point1 = point1,
         Point2 = point2,
         Point3 = point3,
         Point4 = point4
     };
 }
Пример #25
0
 /// <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 XRectangle 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 XRectangle()
     {
         Name = name,
         Style = style,
         IsStroked = isStroked,
         IsFilled = isFilled,
         Bindings = ImmutableArray.Create<ShapeBinding>(),
         Properties = ImmutableArray.Create<ShapeProperty>(),
         TopLeft = XPoint.Create(x1, y1, point),
         BottomRight = XPoint.Create(x2, y2, point),
         Text = text,
         IsGrid = false,
         OffsetX = 30.0,
         OffsetY = 30.0,
         CellWidth = 30.0,
         CellHeight = 30.0
     };
 }
Пример #26
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="topLeft"></param>
 /// <param name="bottomRight"></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(
     XPoint topLeft,
     XPoint bottomRight,
     ShapeStyle style,
     BaseShape point,
     bool isStroked = true,
     bool isFilled = false,
     string text = null,
     string name = "")
 {
     return new XRectangle()
     {
         Name = name,
         Style = style,
         IsStroked = isStroked,
         IsFilled = isFilled,
         Data = new Data()
         {
             Bindings = ImmutableArray.Create<ShapeBinding>(),
             Properties = ImmutableArray.Create<ShapeProperty>()
         },
         TopLeft = topLeft,
         BottomRight = bottomRight,
         Text = text,
         IsGrid = false,
         OffsetX = 30.0,
         OffsetY = 30.0,
         CellWidth = 30.0,
         CellHeight = 30.0
     };
 }
Пример #27
0
 /// <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 XQBezier 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, style, point, isStroked, isFilled, name);
 }
Пример #28
0
 /// <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));
 }
Пример #29
0
        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;
        }
Пример #30
0
 /// <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,
         Bindings = ImmutableArray.Create<ShapeBinding>(),
         Properties = ImmutableArray.Create<ShapeProperty>(),
         Start = XPoint.Create(x1, y1, point),
         End = XPoint.Create(x2, y2, point)
     };
 }
Пример #31
0
 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);
 }
Пример #32
0
 /// <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);
 }
Пример #33
0
 /// <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);
 }
Пример #34
0
        /// <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;
        }
Пример #35
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="name"></param>
        /// <param name="sa"></param>
        /// <param name="sr"></param>
        /// <param name="sg"></param>
        /// <param name="sb"></param>
        /// <param name="fa"></param>
        /// <param name="fr"></param>
        /// <param name="fg"></param>
        /// <param name="fb"></param>
        /// <param name="thickness"></param>
        /// <param name="textStyle"></param>
        /// <param name="lineStyle"></param>
        /// <param name="startArrowStyle"></param>
        /// <param name="endArrowStyle"></param>
        /// <param name="lineCap"></param>
        /// <param name="dashes"></param>
        /// <param name="dashOffset"></param>
        /// <returns></returns>
        public static ShapeStyle Create(
            string name = "",
            byte sa = 0xFF, byte sr = 0x00, byte sg = 0x00, byte sb = 0x00,
            byte fa = 0xFF, byte fr = 0x00, byte fg = 0x00, byte fb = 0x00,
            double thickness = 2.0,
            TextStyle textStyle = null,
            LineStyle lineStyle = null,
            ArrowStyle startArrowStyle = null,
            ArrowStyle endArrowStyle = null,
            LineCap lineCap = LineCap.Round,
            double[] dashes = default(double[]),
            double dashOffset = 0.0)
        {
            var style = new ShapeStyle()
            {
                Name = name,
                Stroke = ArgbColor.Create(sa, sr, sg, sb),
                Fill = ArgbColor.Create(fa, fr, fg, fb),
                Thickness = thickness,
                LineCap = lineCap,
                Dashes = dashes,
                DashOffset = dashOffset,
                LineStyle = lineStyle ?? LineStyle.Create("Line"),
                TextStyle = textStyle ?? TextStyle.Create("Text")
            };

            style.StartArrowStyle = startArrowStyle ?? ArrowStyle.Create("Start", style);
            style.EndArrowStyle = endArrowStyle ?? ArrowStyle.Create("End", style);

            return style;
        }
Пример #36
0
        /// <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.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;
            }

            Verbose("Add Style: " + style.Name);
        }
Пример #37
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="x"></param>
 /// <param name="y"></param>
 /// <param name="style"></param>
 /// <param name="point"></param>
 /// <param name="isStroked"></param>
 /// <param name="name"></param>
 /// <returns></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);
 }
Пример #38
0
 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);
 }
Пример #39
0
 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);
 }
Пример #40
0
        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;
        }
Пример #41
0
 /// <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));
 }
Пример #42
0
 /// <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));
 }
Пример #43
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="topLeft"></param>
 /// <param name="bottomRight"></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(
     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,
         Data = new Data()
         {
             Bindings = ImmutableArray.Create<ShapeBinding>(),
             Properties = ImmutableArray.Create<ShapeProperty>()
         },
         TopLeft = topLeft,
         BottomRight = bottomRight,
         Text = text,
     };
 }
Пример #44
0
 /// <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));
 }
Пример #45
0
        /// <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);
        }
Пример #46
0
 /// <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);
         }
     }
 }
Пример #47
0
        /// <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;
        }
Пример #48
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="point1"></param>
 /// <param name="point2"></param>
 /// <param name="point3"></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(
     XPoint point1,
     XPoint point2,
     XPoint point3,
     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<ShapeBinding>(),
             Properties = ImmutableArray.Create<ShapeProperty>()
         },
         Point1 = point1,
         Point2 = point2,
         Point3 = point3
     };
 }
Пример #49
0
 /// <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,
         Bindings = ImmutableArray.Create<ShapeBinding>(),
         Properties = ImmutableArray.Create<ShapeProperty>(),
         TopLeft = topLeft,
         BottomRight = bottomRight,
         Text = text
     };
 }
Пример #50
0
        /// <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);
        }
Пример #51
0
 /// <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);
 }