Ejemplo n.º 1
0
        private bool YOut(DiscGame d)
        {
            bool result = false;

            Dispatcher.Invoke(() =>
            {
                result = d.Y > gamePicture.ActualHeight - ((DISC_SIZE + HEIGHT_MARGIN) * board_state[d.Column]) + BOTTOM_MARGIN || d.Y < 0;
            });
            return(result);
        }
Ejemplo n.º 2
0
        private void DisplayDisc(object disc)
        {
            DiscGame b = disc as DiscGame;

            while (true)
            {
                if (YOut(b))
                {
                    break;
                }
                Thread.Sleep(2);
                b.Y += 1;
                Dispatcher.Invoke(() =>
                {
                    Canvas.SetTop(b.Circle, b.Y);
                    Canvas.SetLeft(b.Circle, b.X);
                });
            }
        }
Ejemplo n.º 3
0
        private void draw(System.Windows.Point p, int col, SolidColorBrush color)
        {
            Ellipse el = new Ellipse
            {
                Fill   = color,
                Height = DISC_SIZE,
                Width  = DISC_SIZE
            };
            DiscGame newDisc = new DiscGame
            {
                Circle = el,
                Y      = p.Y - el.Height / 2,
                Column = col,
                X      = (col + WIDTH_MARGIN) / COL * gamePicture.ActualWidth
            };

            board_state[newDisc.Column]++;

            Canvas.SetTop(el, newDisc.Y);
            Canvas.SetLeft(el, newDisc.X);
            gamePicture.Children.Add(el);
            ThreadPool.QueueUserWorkItem(DisplayDisc, newDisc);
        }