Ejemplo n.º 1
0
        public MainPage()
        {
            InitializeComponent();

            _manager = new ShapeManager(ThePanel);

            _num = 10;
            _dot = new Ellipse[_num];
            _x   = new double[_num];
            _y   = new double[_num];
            _dx  = new double[_num];
            _dy  = new double[_num];

            for (int i = 0; i < _num; i++)
            {
                Ellipse z = new Ellipse();
                if (i == 0 || i == _num - 1)
                {
                    z.Fill = new SolidColorBrush(Colors.Red);
                }
                else
                {
                    z.Fill = new SolidColorBrush(Colors.Green);
                }
                z.Width  = 20;
                z.Height = 20;
                _dot[i]  = z;

                double x = (i + 1) * ThePanel.Width / (_num + 2);
                double y = ThePanel.Height / 2;
                _x[i] = x;
                _y[i] = y;

                z.SetValue(Canvas.TopProperty, y);
                z.SetValue(Canvas.LeftProperty, x);

                ThePanel.Children.Add(z);
                _manager.Add(z);
            }

            _timer          = new DispatcherTimer();
            _timer.Interval = new TimeSpan(0, 0, 0, 0, 100);
            _timer.Tick    += new EventHandler(_timer_Tick);
            _timer.Start();
        }
        public MainPage()
        {
            InitializeComponent();

            _manager = new ShapeManager(ThePanel);

            _num = 10;
            _dot = new Ellipse[_num];
            _x = new double[_num];
            _y = new double[_num];
            _dx = new double[_num];
            _dy = new double[_num];

            for (int i = 0; i < _num; i++)
            {
                Ellipse z = new Ellipse();
                if( i==0 || i==_num-1 )
                    z.Fill = new SolidColorBrush(Colors.Red);
                else
                    z.Fill = new SolidColorBrush(Colors.Green);
                z.Width = 20;
                z.Height = 20;
                _dot[i] = z;

                double x = (i+1) * ThePanel.Width / (_num+2);
                double y = ThePanel.Height / 2;
                _x[i] = x;
                _y[i] = y;

                z.SetValue(Canvas.TopProperty, y);
                z.SetValue(Canvas.LeftProperty, x);

                ThePanel.Children.Add(z);
                _manager.Add(z);
            }

            _timer = new DispatcherTimer();
            _timer.Interval = new TimeSpan(0, 0, 0, 0, 100);
            _timer.Tick += new EventHandler(_timer_Tick);
            _timer.Start();
        }