コード例 #1
0
        private void UniformBezierRouteCallBack(BezierRoute bezierRoute, Point realPoint, BezierRoute.BezierStatus status)
        {
            // Draw demo panel
            lock (this)
            {
                g_demo.Clear(panel1.BackColor);
                int biasX = 0;
                int biasY = 0;
                int biasW = 0;
                int biasH = 0;
                if (bezierRoute.EnableEaseRoute())
                {
                    if (bezierRoute.Tag == 1)
                    {
                        biasX = (int)(bezierRoute.EaseRealRete * (615 - 8)) / 2;
                        biasY = (int)(bezierRoute.EaseRealRete * (10 - 8)) / 2;
                        biasW = (int)(bezierRoute.EaseRealRete * (350 - 8));
                        biasH = (int)(bezierRoute.EaseRealRete * (120 - 8));
                    }
                    else if (bezierRoute.Tag == -1)
                    {
                        biasX = (int)((1 - bezierRoute.EaseRealRete) * (615 - 8)) / 2;
                        biasY = (int)((1 - bezierRoute.EaseRealRete) * (10 - 8)) / 2;
                        biasW = (int)((1 - bezierRoute.EaseRealRete) * (350 - 8));
                        biasH = (int)((1 - bezierRoute.EaseRealRete) * (120 - 8));
                    }
                }
                g_demo.FillRectangle(new SolidBrush(Color.White), new RectangleF(realPoint.X - 4 - biasX, realPoint.Y - 4 - biasY, 8 + biasW, 8 + biasH));
            }
            if (status == BezierRoute.BezierStatus.Finished)
            {
                curvePointI = 0;
                // DrawBezierCurve();
                bezierRoute.Reverse();
                bezierRoute.Tag = -bezierRoute.Tag;

                // bezierRoute.Start = true;
                button1.BeginInvoke(new Action(() =>
                {
                    button1.Text = (string)button1.Tag;
                    button4.Text = (string)button4.Tag;
                }));

                Console.WriteLine("Finished");
            }

            // Update curve panel
            if (0 == ++curvePointI % curvePointInterval)
            {
                UpdateCurvePanel(realPoint);
            }
        }
コード例 #2
0
        private void button4_Click(object sender, EventArgs e)
        {
            if (!bezierRoute.Start)
            // Start route
            {
                // 临时测试区 Bezier ease route
                Point[] tempRoutePoints = new Point[4];
                tempRoutePoints[0] = new Point(10, 221);
                tempRoutePoints[1] = new Point(211, 221);
                tempRoutePoints[2] = new Point(311, 201);
                tempRoutePoints[3] = new Point(311, 10);
                Point[] tempEasePoints = new Point[4];
                tempEasePoints[0]       = new Point(10, 111);
                tempEasePoints[1]       = new Point(110, 21);
                tempEasePoints[2]       = new Point(21, 10);
                tempEasePoints[3]       = new Point(311, 10);
                bezierRoute.RoutePoints = tempRoutePoints;
                if (bezierRoute.Tag == -1)
                {
                    bezierRoute.Reverse();
                }
                bezierRoute.EnableEaseRoute(tempEasePoints);
                bezierRoute.FullTime = 1800;
                button1_Click(sender, e);

                // Change button text
                button4.Text = "Pause";

                // Reset other buttons' text
                button1.Text = (string)button1.Tag;
                button2.Text = (string)button2.Tag;
                button3.Text = (string)button3.Tag;
            }
            else
            // Pause or Continue
            {
                bezierRoute.Pause = !bezierRoute.Pause;

                // Change button text
                if (button4.Text.Equals("Pause"))
                {
                    button4.Text = "Continue";
                }
                else if (button4.Text.Equals("Continue"))
                {
                    button4.Text = "Pause";
                }
            }
        }