Esempio n. 1
0
        private void boardPictureBox_Click(object sender, EventArgs e)
        {
            var me          = (MouseEventArgs)e;
            var x           = me.X;
            var y           = me.Y;
            var screen      = Screen.FromControl(this);
            var workingArea = screen.WorkingArea;

            var workingWidth  = workingArea.Height - 40;
            var workingHeight = workingWidth;

            var elementWidth  = workingWidth / GlobalWidth;
            var elementHeight = workingHeight / GlobalHeight;

            var finalX = x / elementWidth;
            var finalY = y / elementHeight;

            var pixel = Grid.ChangeOnePixelColor(finalX, finalY);

            if (pixel.IsAlive())
            {
                ActualView.Add(new GamePixel(finalX, finalY, true));
            }
            else
            {
                var element = ActualView.First(u => u.X == pixel.X && u.Y == pixel.Y);
                ActualView.Remove(element);
            }

            Draw(ActualView, GlobalWidth, GlobalHeight);
        }