Beispiel #1
0
        public int AddValue(int x, int y, bool showMessage = true)
        {
            if (x > BoardValues.GetLength(0) || y > BoardValues.GetLength(1))
            {
                return(0);
            }
            if (BoardValues[x, y].IsGrain())
            {
                if (showMessage)
                {
                    MessageBox.Show("This pixel is already grained", "Error", MessageBoxButtons.OK);
                }
                return(0);
            }

            var randomColor = InitialValuesGenerator.RandomColor();

            BoardValues[x, y].GrainValue = true;
            BoardValues[x, y].Color      = randomColor;
            Grained.Add(new GamePixelWithCoordinates
            {
                Color      = randomColor,
                GrainValue = true,
                Id         = BoardValues[x, y].Id,
                X          = x,
                Y          = y
            });

            return(1);
        }
Beispiel #2
0
        private void boardPictureBox_Click(object sender, EventArgs e)
        {
            if (_elementSize == 0)
            {
                return;
            }
            var me = (MouseEventArgs)e;
            var x  = me.X;
            var y  = me.Y;
            var xx = x / _elementSize;
            var yy = y / _elementSize;

            if (Timer == null)
            {
                var color = InitialValuesGenerator.RandomColor();
                ToDrawValues.Add(new Tuple <int, int, Color>(xx, yy, color));
                DrawOnePixel(xx, yy, color);
            }
            else
            {
                var added = Grid.AddValue(xx, yy);
                _grainedElementsNumber = _grainedElementsNumber + added;
                var pixel = Grid.BoardValues[xx, yy];
                DrawOnePixel(xx, yy, pixel.Color);
            }
        }