Example #1
0
        protected virtual Bitmap GenerateTile(Screen s, ColumnGroup cg, Group g, Tile t)
        {
            var szTile = new Size()
            {
                Width  = (cg.TileSize + cg.HorizontalSpacing) * t.ColSpan - cg.HorizontalSpacing,
                Height = (cg.TileSize + cg.VerticalSpacing) * t.RowSpan - cg.VerticalSpacing
            };

            var b = new Bitmap(szTile.Width, szTile.Height);

            var gr = Graphics.FromImage(b);

            //var clT = Color.FromArgb(128, Color.Red);
            //var pgb = new LinearGradientBrush(new Point(0, 0), new Point(iTileWidth, iTileHeight), t.BackColor, clT);
            //gr.FillRectangle(pgb, 0, 0, iTileWidth, iTileHeight);

            // Draw background
            Drawer.DrawBackground(gr, szTile, t);

            // Draw title
            Drawer.DrawTitle(gr, szTile, t);

            // Draw icon
            Drawer.DrawIcon(gr, szTile, t);

            // Draw border
            Drawer.DrawBorder(gr, b.Size, t);

            return(b);
        }
Example #2
0
        protected virtual Bitmap GenerateGroup(Screen s, ColumnGroup cg, Group g)
        {
            g.Populate(cg);

            var b = new Bitmap(g.RenderingSize.Width, g.RenderingSize.Height);

            var gr = Graphics.FromImage(b);

            Drawer.DrawBackground(gr, g.RenderingSize, g);

            //gr.FillRectangle(Brushes.Transparent, 0, 0, g.RenderingSize.Width, g.RenderingSize.Height);

            for (int iR = 0; iR < g.Cells.GetLength(0); iR++)
            {
                for (int iC = 0; iC < g.Cells.GetLength(1); iC++)
                {
                    ScreenCell cell = g.Cells[iR, iC];
                    if (cell != null)
                    {
                        if (cell.Anchor)
                        {
                            int iX = iC * (cg.TileSize + cg.HorizontalSpacing);
                            int iY = iR * (cg.TileSize + cg.VerticalSpacing);
                            gr.DrawImage(GenerateTile(s, cg, g, cell.Tile), iX, iY);
                        }
                    }
                }
            }

            // Draw border
            Drawer.DrawBorder(gr, b.Size, g);

            return(b);
        }
Example #3
0
        protected virtual Bitmap GenerateColumnGroup(Screen s, ColumnGroup cg)
        {
            var b = new Bitmap(cg.RenderingSize.Width, cg.RenderingSize.Height);

            var gr = Graphics.FromImage(b);

            Drawer.DrawBackground(gr, cg.RenderingSize, cg);

            int iTop = cg.Padding.Top;

            foreach (var g in cg.Groups)
            {
                // Draw title
                var bT  = new Bitmap(cg.RenderingSize.Width, Math.Max(1, cg.VerticalGroupSpacing));
                var grT = Graphics.FromImage(bT);

                grT.FillRectangle(Brushes.Transparent, 0, 0, bT.Width, bT.Height);
                Drawer.DrawTitle(grT, bT.Size, g);

                gr.DrawImage(bT, cg.Padding.Left, iTop);
                iTop += cg.VerticalGroupSpacing;

                // Draw group
                gr.DrawImage(GenerateGroup(s, cg, g), cg.Padding.Left, iTop);

                // Draw border
                Drawer.DrawBorder(gr, cg.RenderingSize, cg);

                iTop += g.RenderingSize.Height;
            }

            return(b);
        }
 public Screen()
 {
     BackColor                = Color.Black;
     BackColorOpacity         = 255;
     BackgroundImageAlign     = System.Drawing.ContentAlignment.MiddleCenter;
     BackgroundImageLayout    = ImageLayout.None;
     BackgroundImageOffset    = new Point();
     BackgroundImageOpacity   = 255;
     BackgroundImageZoom      = 1;
     BackgroundOverlayColor   = Color.White;
     BackgroundOverlayOpacity = 0;
     HeaderContentAlign       = System.Drawing.ContentAlignment.MiddleCenter;
     HeaderLocation           = Position.Top;
     HeaderMargins            = new Margins(0, 0, 0, 0);
     HeaderOffset             = new Point();
     HeaderThickness          = 0;
     TitleAlign               = System.Drawing.ContentAlignment.MiddleCenter;
     TitleColor               = Color.Black;
     TitleOffset              = new Point();
     TitleBarColor            = Color.Black;
     TitleBarHeight           = 0;
     TitleBarOpacity          = 0;
     Size = new Size()
     {
         Width = 1920, Height = 1080
     };
     ContentMargins = new Margins(0, 0, 0, 0);
     ContentAlign   = System.Drawing.ContentAlignment.TopCenter;
     ColumnGroups   = new List <ColumnGroup>();
     Header         = new ColumnGroup();
 }
        public virtual void Populate(ColumnGroup cg)
        {
            // Count maximum possible rows
            // Sum number of cells, which is sum of tile sizes, then add tallest tile size
            var iMaxRows = 1;

            if (Tiles.Count > 0)
            {
                iMaxRows = Tiles.Sum(x => x.ColSpan * x.RowSpan) / cg.WidthInColumns + Tiles.Max(x => x.RowSpan);
            }

            // Populate table of cells
            Cells = new ScreenCell[iMaxRows, cg.WidthInColumns];
            var cc = new CellCoordinates()
            {
                Columns = cg.WidthInColumns
            };

            foreach (var tile in Tiles)
            {
                // Skip tiles that are larger than the column group
                if (tile.ColSpan <= cg.WidthInColumns)
                {
                    // Find next available cell
                    bool bFound = false;
                    while (!bFound && cc.Row < iMaxRows)
                    {
                        bFound = true;
                        for (int iR = 0; iR < tile.RowSpan; iR++)
                        {
                            for (int iC = 0; iC < tile.ColSpan; iC++)
                            {
                                bFound &= EmptyCell(Cells, cc.Row + iR, cc.Col + iC);
                            }
                        }
                        if (!bFound)
                        {
                            cc.Next();
                        }
                    }

                    // If available cell found, set tile in cell(s)
                    if (bFound)
                    {
                        for (int iR = 0; iR < tile.RowSpan; iR++)
                        {
                            for (int iC = 0; iC < tile.ColSpan; iC++)
                            {
                                Cells[cc.Row + iR, cc.Col + iC] = new ScreenCell()
                                {
                                    Tile = tile, Anchor = (iR == 0 && iC == 0)
                                };
                            }
                        }
                    }
                }
            }
        }
        public virtual void Calculate(ColumnGroup cg) //, int TileSize, int VerticalSpacing)
        {
            Populate(cg);

            // Count used rows
            int i = Cells.GetLength(0);

            while (i > 0)
            {
                bool bUsed = false;
                for (int j = 0; j < Cells.GetLength(1); j++)
                {
                    if (Cells[i - 1, j] != null)
                    {
                        bUsed = true;
                    }
                }

                if (!bUsed)
                {
                    i--;
                }
                else
                {
                    break;
                }
            }

            int iHeight = 1;

            if (i > 0)
            {
                iHeight = (cg.TileSize + cg.VerticalSpacing) * i - cg.VerticalSpacing;
            }

            RenderingSize = new Size(cg.RenderingSize.Width, iHeight);
        }