Esempio n. 1
0
        public void Draw(RaphaelPaper _context)
        {
            string strokeStyle = Selected ? "#FAFAFA" : (Glow ? "gold" : "black");
            int    lineWidth   = Selected ? 18 : (Glow ? 16 : 14);

            var currentColor = GetCurrentColor();

            if (currentColor == null)
            {
                if (Element != null)
                {
                    Element.Remove();
                }

                Element = null;
                return;
            }

            string fillStyle = currentColor;

            if (Element == null)
            {
                if (PointUp)
                {
                    var x = (X) / 2.0f;
                    var y = Y;

                    var xxx = x * TriangleLength + x * spacing - spacing / 2.0f + TriangleGame.Offset.X;
                    var yyy = y * TriangleLength + y * (spacing - 3) / 2 + TriangleGame.Offset.Y;


                    Element = _context.Path("M" + xxx + " " + yyy + "L" + (xxx + TriangleLength / 2) + " " + (yyy + TriangleLength) + "L" + (xxx - TriangleLength / 2) + " " + (yyy + TriangleLength) + "L" + (xxx) + " " + (yyy));
                }
                else
                {
                    var x = (X - 1) / 2.0f;
                    var y = Y;

                    var xxx = x * TriangleLength + x * spacing + TriangleGame.Offset.X;
                    var yyy = y * TriangleLength + y * (spacing - 3) / 2 + TriangleGame.Offset.Y;


                    Element = _context.Path("M" + xxx + " " + yyy + "L" + (xxx + TriangleLength) + " " + (yyy) + "L" + (xxx + TriangleLength / 2) + " " + (yyy + TriangleLength) + "L" + (xxx) + " " + (yyy));
                }

                Element.Attribute(new RaphaelElementAttributes()
                {
                    StrokeLineCap = RaphaelLineCap.Round, StrokeLineJoin = RaphaelLineJoin.Round
                });
                Element.MouseDown((e) =>
                {
                    var pointer = Help.GetCursorPosition(e);

                    TriangleGame.Instance.mouseDown(pointer, this);
                });
                Element.MouseOver((e) =>
                {
                    TriangleGame.Instance.mouseOver(this);
                });
                bool touched;
                Element.TouchStart((e) =>
                {
                    var pointer = Help.GetCursorPosition(e);
                    touched     = true;

                    Window.SetTimeout(() =>
                    {
                        if (touched)
                        {
                            pointer.Right = true;
                            TriangleGame.Instance.mouseDown(pointer, this);
                        }
                    },
                                      500);//right click
                    TriangleGame.Instance.mouseDown(pointer, this);
                    e.PreventDefault();
                });
                Element.TouchEnd((e) =>
                {
                    touched = false;
                    e.PreventDefault();
                });

                Element.TouchMove((e) =>
                {
                    TriangleGame.Instance.mouseOver(this);
                    e.PreventDefault();
                });
            }
            Element.Attribute(new RaphaelElementAttributes()
            {
                Fill = fillStyle, StrokeWidth = lineWidth, Stroke = strokeStyle
            });
        }
Esempio n. 2
0
 public RaphaelElement InsertAfter(RaphaelElement element)
 {
     return(default(RaphaelElement));
 }
Esempio n. 3
0
 public RaphaelElement InsertBefore(RaphaelElement element)
 {
     return(default(RaphaelElement));
 }
Esempio n. 4
0
 public void Exclude(RaphaelElement element)
 {
 }