private void DrawClusters(Graphics painter, IMazeView maze, MazeClusters clusters)
        {
            int clustersNumber = clusters.Count();

            Brush[] brushes = new Brush[clustersNumber];
            for (int i = 0; i < brushes.Length; i++)
            {
                brushes[i] = new SolidBrush(Palette.GetColor(i + 1));
            }

            for (int row = 0; row < maze.RowCount; row++)
            {
                for (int col = 0; col < maze.ColCount; col++)
                {
                    int BaseX = col * cellSize;
                    int BaseY = row * cellSize;

                    if (!clusters.IsNonclustered(row, col))
                    {
                        int circleShift = cellSize / 2 - circleSize / 2;
                        int brushIndex  = clusters.GetClusterIndex(row, col) - 1;
                        painter.FillEllipse(brushes[brushIndex],
                                            BaseX + circleShift,
                                            BaseY + circleShift,
                                            circleSize, circleSize);
                    }
                }
            }
        }
Exemple #2
0
        protected virtual void DrawClusters(Graphics graphics, MazeClusters clusters)
        {
            int clustersNumber = clusters.Count();

            Brush[] brushes = new Brush[clustersNumber];
            for (int i = 0; i < brushes.Length; i++)
            {
                brushes[i] = new SolidBrush(Palette.GetColor(i + 1));
            }

            int cellWidth  = drawingSettings.CellWidth;
            int cellHeight = drawingSettings.CellHeight;

            for (int row = 0; row < rowCount; row++)
            {
                for (int col = 0; col < colCount; col++)
                {
                    int index = clusters.GetClusterIndex(row, col);
                    if (index > 0)
                    {
                        Rectangle cellRect = new Rectangle(col * cellWidth, row * cellHeight,
                                                           cellWidth, cellHeight);

                        graphics.FillRectangle(brushes[index - 1], cellRect);
                    }
                }
            }
        }
Exemple #3
0
        private void DrawClusters(Graphics painter, IMazeView maze, MazeClusters clusters)
        {
            CreateClusterBrushes(clusters);
            for (int row = 0; row < rowCount; row++)
            {
                for (int col = 0; col < colCount; col++)
                {
                    int index = clusters.GetClusterIndex(row, col);

                    if (index != 0)
                    {
                        int drawRow = row * 2 + 1;
                        int drawCol = col * 2 + 1;

                        DrawCell(painter, clustersBrushes[index - 1],
                                 drawRow, drawCol);

                        MazeSide cell = maze.GetCell(row, col);

                        if (!cell.HasFlag(MazeSide.Bottom))
                        {
                            DrawCell(painter, clustersBrushes[index - 1],
                                     drawRow + 1, drawCol);
                        }

                        if (!cell.HasFlag(MazeSide.Right))
                        {
                            DrawCell(painter, clustersBrushes[index - 1],
                                     drawRow, drawCol + 1);
                        }

                        if (!cell.HasFlag(MazeSide.Bottom) && !cell.HasFlag(MazeSide.Right))
                        {
                            DrawCell(painter, clustersBrushes[index - 1],
                                     drawRow + 1, drawCol + 1);
                        }
                    }
                }
            }
        }