Example #1
0
        private void GenerateRendering(Graphics g)
        {
            Rectangle clientRectangle = base.ClientRectangle;
            Brush brush = new SolidBrush(this._page.BackColor);
            g.FillRectangle(brush, clientRectangle);
            brush.Dispose();
            Watermark watermark = this._page.Watermark;
            if (watermark.Image != null)
            {
                Image image = watermark.Image;
                Size size = image.Size;
                Point empty = Point.Empty;
                switch (watermark.Placement)
                {
                    case WatermarkPlacement.TopRight:
                        empty = new Point(clientRectangle.Width - size.Width, 0);
                        break;

                    case WatermarkPlacement.BottomLeft:
                        empty = new Point(0, clientRectangle.Height - size.Height);
                        break;

                    case WatermarkPlacement.BottomRight:
                        empty = new Point(clientRectangle.Width - size.Width, clientRectangle.Height - size.Height);
                        break;

                    case WatermarkPlacement.Center:
                        empty = new Point((clientRectangle.Width - size.Width) / 2, (clientRectangle.Height - size.Height) / 2);
                        break;
                }
                g.DrawImageUnscaled(image, empty);
            }
            Point autoScrollPosition = base.AutoScrollPosition;
            ElementRenderData renderData = null;
            g.TranslateTransform((float) autoScrollPosition.X, (float) autoScrollPosition.Y);
            try
            {
                if (this._page.AntiAliasedText)
                {
                    g.TextRenderingHint = TextRenderingHint.AntiAlias;
                    g.SmoothingMode = SmoothingMode.AntiAlias;
                }
                renderData = new ElementRenderData(g, autoScrollPosition, base.ContainsFocus, this._page.AntiAliasedText);
                renderData.SetLinkColor(this._page.LinkColor);
                if (renderData.LinkColor.IsEmpty)
                {
                    renderData.SetLinkColor(this.ForeColor);
                }
                renderData.SetHoverColor(this._page.HoverColor);
                if (renderData.HoverColor.IsEmpty)
                {
                    renderData.SetHoverColor(this._page.LinkColor);
                }
                if (renderData.HoverColor.IsEmpty)
                {
                    renderData.SetHoverColor(this.ForeColor);
                }
                this._page.CreateRendering(renderData, autoScrollPosition, new Point(0, base.ClientSize.Height));
                if (renderData.ShowFocus && (this._focusIndex != -1))
                {
                    VisualElement element = (VisualElement) this._focusableElements[this._focusIndex];
                    Rectangle bounds = element.Bounds;
                    if (!bounds.IsEmpty)
                    {
                        bounds.Offset(autoScrollPosition);
                        if ((bounds.Bottom >= 0) && (bounds.Top <= base.ClientSize.Height))
                        {
                            element.RenderFocusCues(renderData);
                        }
                    }
                }
            }
            finally
            {
                if (renderData != null)
                {
                    renderData.Dispose();
                    renderData = null;
                }
                g.TranslateTransform((float) -autoScrollPosition.X, (float) -autoScrollPosition.Y);
            }
        }
Example #2
0
 protected override void RenderForeground(ElementRenderData renderData)
 {
     if (base.Text.Length != 0)
     {
         bool flag = this._active && !this._hoverColor.IsEmpty;
         bool flag2 = !this._active && !this._linkColor.IsEmpty;
         Color empty = Color.Empty;
         if (flag)
         {
             empty = renderData.HoverColor;
             renderData.SetHoverColor(this._hoverColor);
         }
         else if (flag2)
         {
             empty = renderData.LinkColor;
             renderData.SetLinkColor(this._linkColor);
         }
         try
         {
             if (renderData.AntiAliasedText)
             {
                 Brush textBrush = null;
                 if (this._active)
                 {
                     textBrush = renderData.HoverColorBrush;
                 }
                 else if (this.ForeColor.IsEmpty)
                 {
                     textBrush = renderData.LinkColorBrush;
                 }
                 else
                 {
                     textBrush = renderData.ForeColorBrush;
                 }
                 base.RenderText(renderData, textBrush);
             }
             else
             {
                 Color linkColor = renderData.LinkColor;
                 if (this._active)
                 {
                     linkColor = renderData.HoverColor;
                 }
                 else if (!this.ForeColor.IsEmpty)
                 {
                     linkColor = this.ForeColor;
                 }
                 base.RenderText(renderData, linkColor);
             }
         }
         finally
         {
             if (flag)
             {
                 renderData.SetHoverColor(empty);
             }
             else if (flag2)
             {
                 renderData.SetLinkColor(empty);
             }
         }
     }
 }