Exemplo n.º 1
0
        private GamePixel[,] InitializeBoardValues(int widthElementsNumber, int heightElementsNumber,
                                                   int randomElementsNumber, string initialSetting, List <Tuple <int, int, Color> > toDrawValues)
        {
            GamePixel[,] readyBoard = null;
            switch (initialSetting)
            {
            case "Random":
                readyBoard = InitialValuesGenerator.RandomValues(randomElementsNumber, widthElementsNumber,
                                                                 heightElementsNumber);
                break;

            case "Clicks":
                readyBoard = InitialValuesGenerator.ValuesFromClicks(toDrawValues, widthElementsNumber,
                                                                     heightElementsNumber);
                break;

            case "Circle area":
                readyBoard = InitialValuesGenerator.CircleValues(randomElementsNumber, widthElementsNumber,
                                                                 heightElementsNumber);
                break;

            case "Evenly":
                readyBoard = InitialValuesGenerator.EvenlyValues(randomElementsNumber, widthElementsNumber,
                                                                 heightElementsNumber);
                break;

            default:
                throw new ArgumentException("Impossible value");
            }

            return(readyBoard);
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
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);
            }
        }
Exemplo n.º 4
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (ToDrawValues == null)
            {
                return;
            }
            ToDrawValues.Clear();

            var width  = int.Parse(WidthInput.Text);
            var height = int.Parse(HeightInput.Text);

            Grid.BoardValues = null;
            Grid.BoardValues = InitialValuesGenerator.InitializeEmpty(width, height);
            Draw(null, width, height);
        }