void GenerateAnimation(PennerAnimationGeneratorDelegate pennerAnimator)
        {
            float startValue       = 0;
            float stopValue        = 300;
            float sec              = 0;
            float completeDuration = 10;

            _animationBoard.ClearChildren();

            List <double> calculatedValues = new List <double>();

            while (sec < completeDuration)
            {
                double currentValue = pennerAnimator(sec, startValue, stopValue, completeDuration);
                //step 0.1 sec (100 ms), until complete at 5 sec
                sec += 0.1f;
                calculatedValues.Add(currentValue);
                //System.Console.WriteLine(currentValue.ToString());
            }

            //create image box that present the results
            int j = calculatedValues.Count;

            for (int i = 0; i < j; ++i)
            {
                Box box = new Box(5, 5);
                box.SetLocation(5 * i, (int)calculatedValues[i]);
                _animationBoard.AddChild(box);
            }

            //-----
            //show animation

            Box sampleBox1 = new Box(600, 20);

            _animationBoard.AddChild(sampleBox1);
            sampleBox1.BackColor = PixelFarm.Drawing.Color.Red;
            int step = 0;

            UIPlatform.RegisterTimerTask(10, tim =>
            {
                //animate the box
                sampleBox1.SetLocation(10, (int)calculatedValues[step]);
                if (step < j - 1)
                {
                    step++;
                }
                else
                {
                    //unregister and remove the task
                    tim.Remove();
                }
            });
        }
Exemple #2
0
        public void AddPanel(IDebugPanel panel)
        {
            panel.SetClientGuiStage(_clientGuiStage);
            panel.SetClientHardware(_clientHardware);

            var button = new ToggleButton(100, 20, panel.GetName());

            button.OnClick(e => ShowPanel(panel, button));
            _buttonContainer.AddChild(button);

            panel.SetPercentualWidth(1);
            panel.SetPercentualHeight(1);
            _panelContainer.AddChild(panel);

            // if this is not the first panel it will be hidden
            if (_panelContainer.GetChildren().Count > 1)
            {
                panel.SetVisible(false);
            }
        }