private static void GenerateGridLayout(Grid gameGrid, GameColorViewModel[] gameColors)
        {
            gameGrid.RowDefinitions.Clear();
            gameGrid.ColumnDefinitions.Clear();

            var triangleSize = PositionHelper.GetMaxTriangleSize(gameColors.Length);

            var newRows = Enumerable.Range(0, triangleSize).Select(i => CreateNewRow()).ToArray();

            foreach (var row in newRows)
            {
                gameGrid.RowDefinitions.Add(row);
            }

            var newColumns = Enumerable.Range(0, triangleSize * 2).Select(i => CreateNewColumn()).ToArray();

            foreach (var column in newColumns)
            {
                gameGrid.ColumnDefinitions.Add(column);
            }

            var width = gameGrid.ColumnDefinitions.Count * 10;
            var height = gameGrid.RowDefinitions.Count * 20;

            gameGrid.MaxWidth = width;
            gameGrid.MinWidth = width;
            gameGrid.MaxHeight = height;
            gameGrid.MinHeight = height;
        }
 public DragAndDropManager([NotNull] GridGenerator gridGenerator, [NotNull] GameColorViewModel colorsModel)
 {
     _gridGenerator = gridGenerator;
     _colorsModel = colorsModel;
 }
 private void UpdateView(Ellipse circle, GameColorViewModel targetModel)
 {
     circle.Fill = new SolidColorBrush(targetModel.Color.GetColor());
 }
        private void GenerateGridBalls(GameColorViewModel[] gameColors, Style style, GridGenerator gridGenerator)
        {
            var triangleSize = PositionHelper.GetMaxTriangleSize(gameColors.Length);

            var colorsCount = gameColors.Length;
            var size = gridGenerator.EllipseSize;

            for (var index = 0; index < colorsCount; index++)
            {
                var circle = new Ellipse();

                var targetModel = gameColors[index];

                circle.DataContext = targetModel;
                circle.Style = style;
                circle.Margin = new Thickness(0, 0, 0, -.75);
                circle.Width = size.Width;
                circle.Height = size.Height;

                targetModel.PropertyChanged += (_, __) => UpdateView(circle, targetModel);

                var trianglePosition = PositionHelper.GetTrianglePosition(index, triangleSize);
                var position = gridGenerator.GetCenterOfCell(trianglePosition);

                ConfigureAndAddElement(GameCanvas, circle, position);

                UpdateView(circle, targetModel);
            }
        }
        private void BuildTriangle(Grid gameGrid, GameColorViewModel[] gameColors)
        {
            /*enerateGridLayout(gameGrid, gameColors);

            var style = (Style)Resources["CellStyle"];

            GenerateGridBalls(gameGrid, gameColors, style);

            GenerateGridGrid(gameGrid, gameColors);*/
        }
        private void BuildGrid(GameColorViewModel[] gameColors)
        {
            GameCanvas.Children.Clear();

            var pointsGenerator = new GridGenerator(gameColors.Length, RootContainer.RenderSize.ToSize());

            var path = new Path();

            path.Data = new PathGeometry()
            {
                Figures = CreatePathFigure(pointsGenerator),
            };

            path.Stroke = new SolidColorBrush(Colors.White);
            path.Fill = new SolidColorBrush(Colors.Green);

            GameCanvas.Children.Add(path);

            GameCanvas.Width = pointsGenerator.Size.Width;
            GameCanvas.Height = pointsGenerator.Size.Height;

            GenerateGridBalls(gameColors, (Style) Resources["CellStyle"], pointsGenerator);
        }