public override void Initialize()
        {
            PLayer layer        = Canvas.Layer;
            PNode  animatedNode = PPath.CreateRectangle(0, 0, 100, 80);

            layer.AddChild(animatedNode);

            // create node to display animation path
            PPath ppath = new PPath();

            // create animation path
            ppath.AddLine(0, 0, 300, 300);
            ppath.AddLine(300, 300, 300, 0);
            ppath.AddArc(0, 0, 300, 300, -90, 90);
            ppath.CloseFigure();

            // add the path to the scene graph
            layer.AddChild(ppath);

            PPositionPathActivity positionPathActivity = new PPositionPathActivity(5000, 0, new PositionPathTarget(animatedNode));

            positionPathActivity.PositionPath = (XnaGraphicsPath)ppath.PathReference.Clone();
            positionPathActivity.LoopCount    = int.MaxValue;

            // add the activity
            animatedNode.AddActivity(positionPathActivity);
        }
Пример #2
0
        public override void Initialize()
        {
            PPath n1 = PPath.CreateRectangle(0, 0, 100, 80);
            PPath n2 = PPath.CreateEllipse(100, 100, 200, 34);
            PPath n3 = new PPath();

            n3.AddLine(0, 0, 20, 40);
            n3.AddLine(20, 40, 10, 200);
            n3.AddLine(10, 200, 155.444f, 33.232f);
            n3.CloseFigure();
            n3.Brush = Color.Yellow;

            n1.Pen = new System.Drawing.Pen(System.Drawing.Brushes.Red, 5);
            n2.Pen = new System.Drawing.Pen(System.Drawing.Brushes.Black, 0); //Fixed width stroke
            n3.Pen = new System.Drawing.Pen(System.Drawing.Brushes.Black, 0); //Fixed width stroke

            Canvas.Layer.AddChild(n1);
            Canvas.Layer.AddChild(n2);
            Canvas.Layer.AddChild(n3);

            // create a set of bounds handles for reshaping n3, and make them
            // sticky relative to the getCanvas().getCamera().
            PStickyHandleManager sm = new PStickyHandleManager(Canvas.Camera, n3);

            Canvas.RemoveInputEventListener(Canvas.PanEventHandler);
            Canvas.AddInputEventListener(new PDragEventHandler());
        }
Пример #3
0
        public void UpdateLink()
        {
            PointFx p1 = PUtil.CenterOfRectangle(node1.FullBounds);
            PointFx p2 = PUtil.CenterOfRectangle(node2.FullBounds);

            link.Reset();
            link.AddLine(p1.X, p1.Y, p2.X, p2.Y);
        }
Пример #4
0
            protected void UpdateSquiggle(PInputEventArgs e)
            {
                PointF p = e.Position;

                if (p.X != lastPoint.X || p.Y != lastPoint.Y)
                {
                    squiggle.AddLine(lastPoint.X, lastPoint.Y, p.X, p.Y);
                }
                lastPoint = p;
            }
Пример #5
0
            public void UpdateSquiggle(PInputEventArgs e)
            {
                PointFx p2 = e.Position;

                if (p.X != p2.X || p.Y != p2.Y)
                {
                    squiggle.AddLine(p.X, p.Y, p2.X, p2.Y);
                }
                p = p2;
            }
Пример #6
0
        protected void BuildLine(PointF endpoint)
        {
            PPath.Reset();

            Points[0] = Start.GlobalMiddle;
            Points[Points.Count - 1] = endpoint;

            for (int i = 0; i < Points.Count - 1; i++)
            {
                PPath.AddLine(Points[i].X, Points[i].Y, Points[i + 1].X, Points[i + 1].Y);
            }
        }
Пример #7
0
        //! Создает линии - связи между узлами на графе диалогов
        public static void updateEdge(PPath edge)
        {
            // Note that the node's "FullBounds" must be used (instead of just the "Bound")
            // because the nodes have non-identity transforms which must be included when
            // determining their position.
            ArrayList nodes = (ArrayList)edge.Tag;
            PNode     node1 = (PNode)nodes[0];
            PNode     node2 = (PNode)nodes[1];
            PointF    start = PUtil.CenterOfRectangle(node1.FullBounds);
            PointF    end   = PUtil.CenterOfRectangle(node2.FullBounds);

            edge.Reset();
            edge.AddLine(start.X, start.Y, end.X, end.Y);
        }
Пример #8
0
        /// <summary>
        /// Creates straight edged lines, from the center of the node.
        /// </summary>
        /// <param name="edge"></param>
        public static void UpdateEdgeStraight(PPath edge)
        {
            // Note that the node's "FullBounds" must be used (instead of just the "Bound")
            // because the nodes have non-identity transforms which must be included when
            // determining their position.

            ArrayList nodes = (ArrayList)edge.Tag;
            PNode     node1 = (PNode)nodes[0];
            PNode     node2 = (PNode)nodes[1];
            PointF    start = node1.GlobalBounds.Location;
            PointF    end   = node2.GlobalBounds.Location;


            //float h1x, h1y, h2x;
            //if (nodes.Count > 2 && (int)nodes[2] == -1) //var link
            //{
            //    start.X += node1.GlobalBounds.Width * 0.5f;
            //    start.Y += node1.GlobalBounds.Height;
            //    h1x = h2x = 0;
            //    h1y = end.Y > start.Y ? 200 * (float)Math.Log10((end.Y - start.Y) / 200 + 1) : 200 * (float)Math.Log10((start.Y - end.Y) / 100 + 1);
            //    if (h1y < 15)
            //    {
            //        h1y = 15;
            //    }
            //    end.X += node2.GlobalBounds.Width / 2;
            //    end.Y += node2.GlobalBounds.Height / 2;
            //}
            //else
            //{
            //    start.X += node1.GlobalBounds.Width;
            //    start.Y += node1.GlobalBounds.Height * 0.5f;
            //    end.Y += node2.GlobalBounds.Height * 0.5f;
            //    h1x = h2x = end.X > start.X ? 200 * (float)Math.Log10((end.X - start.X) / 200 + 1) : 200 * (float)Math.Log10((start.X - end.X) / 100 + 1);
            //    if (h1x < 15)
            //    {
            //        h1x = h2x = 15;
            //    }
            //    h1y = 0;
            //}

            edge.Reset();
            edge.AddLine(start.X + node1.GlobalBounds.Width * 0.5f, start.Y + node1.GlobalBounds.Height * 0.5f, end.X + node2.GlobalBounds.Width * 0.5f, end.Y + node2.GlobalBounds.Height * 0.5f);
        }
Пример #9
0
        protected void Rebuild()
        {
            if (IsClosed)            //solid
            {
                if (FPoints.Count > 2)
                {
                    PPath.Reset();
                    PPath.AddPolygon(FPoints.ToArray());
                }
            }
            else             //line strip
            {
                if (FPoints.Count > 1)
                {
                    PPath.Reset();

                    for (int i = 0; i < FPoints.Count - 1; i++)
                    {
                        PPath.AddLine(FPoints[i].X, FPoints[i].Y, FPoints[i + 1].X, FPoints[i + 1].Y);
                    }
                }
            }
        }
Пример #10
0
        public SectorBoundsSprite(PLayer layer, float x_min, float y_min, float x_max, float y_max)
        {
            float width  = (x_max - x_min) / 100;
            float height = (y_max - y_min) / 100;
            float x      = -(width / 2);
            float y      = -(height / 2);

            Pen boundsPen = new Pen(Color.Red, 10.0F);

            boundsPen.DashStyle = DashStyle.DashDotDot;
            Pen xEdgePen = new Pen(Color.White, 2.5F);

            xEdgePen.DashStyle = DashStyle.Solid;
            Pen yEdgePen = new Pen(Color.White, 2.5F);

            yEdgePen.DashStyle = DashStyle.Solid;

            PPath boundsRectangle = PPath.CreateRectangle(x, y, width, height);

            boundsRectangle.Brush = Brushes.Transparent;
            boundsRectangle.Pen   = boundsPen;

            PPath xEdge = new PPath();

            xEdge.AddLine(-50, 0, 50, 0);
            xEdge.Pen = xEdgePen;

            PPath yEdge = new PPath();

            yEdge.AddLine(0, -50, 0, 50);
            yEdge.Pen = xEdgePen;

            PText xy = new PText();

            xy.TextBrush     = Brushes.White;
            xy.TextAlignment = StringAlignment.Center;
            xy.Text          = "0,0";
            xy.X             = 5;
            xy.Y             = 5;

            PText posX = new PText();

            posX.TextBrush     = Brushes.White;
            posX.TextAlignment = StringAlignment.Center;
            posX.Text          = "+X";
            posX.X             = 52;
            posX.Y             = -9;

            PText posY = new PText();

            posY.TextBrush     = Brushes.White;
            posY.TextAlignment = StringAlignment.Center;
            posY.Text          = "+Y";
            posY.X             = -12;
            posY.Y             = 52;

            boundsRectangle.AddChild(xy);
            boundsRectangle.AddChild(posX);
            boundsRectangle.AddChild(posY);
            boundsRectangle.AddChild(xEdge);
            boundsRectangle.AddChild(yEdge);
            boundsRectangle.Pickable = false;

            layer.AddChild(boundsRectangle);
        }