Beispiel #1
0
        protected IList<Rectangle> CalculateCells(int width, int height, GridOptions options)
        {
            List<Rectangle> cells = new List<Rectangle>();

            int cellCount = options.Rows * options.Columns;

            int cellWidth = (Width - ((options.Rows + 1) * options.PaddingX)) / options.Rows;
            int cellHeight = (Height - ((options.Columns + 1) * options.PaddingY)) / options.Columns;

            int pX = options.PaddingX;
            int pY = options.PaddingY;

            for (int v = 0; v < options.Columns; v++)
            {
                for (int u = 0; u < options.Rows; u++)
                {
                    Rectangle cell = new Rectangle(pX, pY, cellWidth, cellHeight);
                    cells.Add(cell);
                    pX += cellWidth + options.PaddingX;
                }
                pX = options.PaddingX;
                pY += cellHeight + options.PaddingY;
            }
            return cells;
        }
Beispiel #2
0
        protected IList <Rectangle> CalculateCells(int width, int height, GridOptions options)
        {
            List <Rectangle> cells = new List <Rectangle>();

            int cellCount = options.Rows * options.Columns;

            int cellWidth  = (Width - ((options.Rows + 1) * options.PaddingX)) / options.Rows;
            int cellHeight = (Height - ((options.Columns + 1) * options.PaddingY)) / options.Columns;

            int pX = options.PaddingX;
            int pY = options.PaddingY;

            for (int v = 0; v < options.Columns; v++)
            {
                for (int u = 0; u < options.Rows; u++)
                {
                    Rectangle cell = new Rectangle(pX, pY, cellWidth, cellHeight);
                    cells.Add(cell);
                    pX += cellWidth + options.PaddingX;
                }
                pX  = options.PaddingX;
                pY += cellHeight + options.PaddingY;
            }
            return(cells);
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            GridOptions options = new GridOptions()
            {
                Columns  = 5,
                Rows     = 6,
                PaddingX = 10,
                PaddingY = 25
            };

            Grid grid = new Grid(20, 20, 1000, 1000, options);

            grid.Add(new SimpleFrame());
            grid.Add(new SimpleFrame());
            grid.Add(new SimpleFrame());
            grid.Add(new SimpleFrame());
            grid.Add(new SimpleFrame());
            grid.Add(new SimpleFrame());
            grid.Add(new SimpleFrame());
            grid.Add(new SimpleFrame());
            grid.Add(new SimpleFrame());
            grid.Add(new SimpleFrame());
            grid.Add(new SimpleFrame());
            grid.Add(new SimpleFrame());
            grid.Add(new SimpleFrame());
            grid.Add(new SimpleFrame());

            foreach (var c in grid.Cells)
            {
                Console.WriteLine(c.ToString());
            }

            Page p = new Page(1500, 1500, savingPath);

            p.Elements.Add(grid);
            p.Elements.Last().Move(100, 100);
            p.Create();
            Console.WriteLine("finished...");
        }
Beispiel #4
0
        static void Main(string[] args)
        {
            GridOptions options = new GridOptions()
            {
                Columns = 5,
                Rows = 6,
                PaddingX = 10,
                PaddingY = 25
            };

            Grid grid = new Grid(20, 20, 1000, 1000, options);
            grid.Add(new SimpleFrame());
            grid.Add(new SimpleFrame());
            grid.Add(new SimpleFrame());
            grid.Add(new SimpleFrame());
            grid.Add(new SimpleFrame());
            grid.Add(new SimpleFrame());
            grid.Add(new SimpleFrame());
            grid.Add(new SimpleFrame());
            grid.Add(new SimpleFrame());
            grid.Add(new SimpleFrame());
            grid.Add(new SimpleFrame());
            grid.Add(new SimpleFrame());
            grid.Add(new SimpleFrame());
            grid.Add(new SimpleFrame());

            foreach(var c in grid.Cells)
            {
                Console.WriteLine(c.ToString());
            }

            Page p = new Page(1500, 1500, savingPath);
            p.Elements.Add(grid);
            p.Elements.Last().Move(100, 100);
            p.Create();
            Console.WriteLine("finished...");
        }
Beispiel #5
0
 public Grid(int x, int y, int width, int height, GridOptions options)
     : base(x, y, width, height)
 {
     _options = options;
     _cells = CalculateCells(width, height, _options);
 }
Beispiel #6
0
 public Grid(int x, int y, int width, int height, GridOptions options)
     : base(x, y, width, height)
 {
     _options = options;
     _cells   = CalculateCells(width, height, _options);
 }