Example #1
0
        protected void LayoutElements(Graphics Graphics)
        {
            // Layout the alert message
            int BodyHeight = Height;

            if (Alert != null)
            {
                AlertDividerY = Height - Font.Height - 16;
                Alert.Layout(Graphics, Point.Empty, Resources);
                Alert.Layout(Graphics, new Point((Width - Alert.Bounds.Width) / 2, (Height + AlertDividerY) / 2), Resources);
                BodyHeight = AlertDividerY;
            }

            // Get the logo size
            Image DrawProjectLogo = ProjectLogo ?? Properties.Resources.DefaultProjectLogo;
            float LogoScale       = Math.Min((float)BodyHeight - ((Caption != null)? Font.Height : 0) / DrawProjectLogo.Height, 1.0f);
            int   LogoWidth       = (int)(DrawProjectLogo.Width * LogoScale);
            int   LogoHeight      = (int)(DrawProjectLogo.Height * LogoScale);

            // Figure out where the split between content and the logo is going to be
            int DividerX = ((Width - LogoWidth - ContentWidth) / 2) + LogoWidth;

            // Get the logo position
            int LogoX = DividerX - LogoWidth;
            int LogoY = (BodyHeight - LogoHeight) / 2;

            // Layout the caption. We may move the logo to make room for this.
            LogoY -= Font.Height / 2;
            if (Caption != null)
            {
                Caption.Layout(Graphics, Point.Empty, Resources);
                int CaptionWidth = Caption.Bounds.Width;
                Caption.Layout(Graphics, new Point(Math.Min(LogoX + (LogoWidth / 2) - (CaptionWidth / 2), DividerX - CaptionWidth), LogoY + LogoHeight), Resources);
            }

            // Set the logo rectangle
            ProjectLogoBounds = new Rectangle(LogoX, LogoY, LogoWidth, LogoHeight);

            // Measure up all the line height
            float TotalLineHeight = Lines.Sum(x => x.LineHeight);

            // Space out all the lines
            float LineY = (BodyHeight - TotalLineHeight * (int)(Font.Height * LineSpacing)) / 2;

            foreach (StatusLine Line in Lines)
            {
                LineY += (int)(Font.Height * LineSpacing * Line.LineHeight * 0.5f);
                Line.Layout(Graphics, new Point(DividerX + 5, (int)LineY), Resources);
                LineY += (int)(Font.Height * LineSpacing * Line.LineHeight * 0.5f);
            }
        }
        public override void Layout(Graphics Graphics, Rectangle Bounds)
        {
            this.Bounds = Bounds;

            int OffsetY = Bounds.Y + Bounds.Height / 2;

            Line.Layout(Graphics, new Point(Bounds.X, OffsetY), Resources);

            if (HorizontalAlignment == HorizontalAlignment.Center)
            {
                int OffsetX = Bounds.X + (Bounds.Width - Line.Bounds.Width) / 2;
                Line.Layout(Graphics, new Point(OffsetX, OffsetY), Resources);
            }
            else if (HorizontalAlignment == HorizontalAlignment.Right)
            {
                int OffsetX = Bounds.Right - Line.Bounds.Width;
                Line.Layout(Graphics, new Point(OffsetX, OffsetY), Resources);
            }
        }