Example #1
0
        private void DrawFormBackground(Graphics g, Rectangle rect, int radius, RoundStyle style)
        {
            using (AntiAliasGraphics antiGraphics = new AntiAliasGraphics(g))
            {
                Image formImage = ColorTable.CaptionBackground;
                if (formImage == null)
                {
                    return;
                }
                g.SmoothingMode = SmoothingMode.AntiAlias;
                //g.CompositingQuality = CompositingQuality.HighQuality;
                //g.DrawImage(formImage, rect );


                using (Brush brush = new TextureBrush(formImage, WrapMode.Clamp))
                {
                    rect.X      -= 1;
                    rect.Y      -= 1;
                    rect.Width  += 1;
                    rect.Height += 1;
                    using (GraphicsPath path = GraphicsPathHelper.CreatePath(
                               rect, radius, style, false))
                    {
                        g.FillPath(brush, path);
                    }
                }
            }
        }
        protected override void OnRenderSkinFormCaption(
            SkinFormCaptionRenderEventArgs e)
        {
            Graphics  g        = e.Graphics;
            Rectangle rect     = e.ClipRectangle;
            SkinForm  form     = e.SkinForm;
            Rectangle iconRect = form.IconRect;
            Rectangle textRect = Rectangle.Empty;

            bool closeBox    = form.ControlBox;
            bool minimizeBox = form.ControlBox && form.MinimizeBox;
            bool maximizeBox = form.ControlBox && form.MaximizeBox;

            int textWidthDec = 0;

            if (closeBox)
            {
                textWidthDec += form.CloseBoxSize.Width + form.ControlBoxOffset.X;
            }

            if (maximizeBox)
            {
                textWidthDec += form.MaximizeBoxSize.Width + form.ControlBoxSpace;
            }

            if (minimizeBox)
            {
                textWidthDec += form.MinimizeBoxSize.Width + form.ControlBoxSpace;
            }

            textRect = new Rectangle(
                iconRect.Right + 3,
                form.BorderWidth,
                rect.Width - iconRect.Right - textWidthDec - 6,
                rect.Height - form.BorderWidth);

            using (AntiAliasGraphics antiGraphics = new AntiAliasGraphics(g))
            {
                DrawCaptionBackground(
                    g,
                    rect,
                    e.Active);

                if (form.ShowIcon && form.Icon != null)
                {
                    DrawIcon(g, iconRect, form.Icon);
                }

                if (!string.IsNullOrEmpty(form.Text))
                {
                    DrawCaptionText(
                        g,
                        textRect,
                        form.Text,
                        form.CaptionFont);
                }
            }
        }
        private void RenderSkinFormCloseBoxInternal(
            Graphics g,
            Rectangle rect,
            ControlBoxState state,
            bool active,
            bool minimizeBox,
            bool maximizeBox)
        {
            Color baseColor = ColorTable.ControlBoxActive;

            if (state == ControlBoxState.Pressed)
            {
                baseColor = ColorTable.ControlCloseBoxPressed;
            }
            else if (state == ControlBoxState.Hover)
            {
                baseColor = ColorTable.ControlCloseBoxHover;
            }
            else
            {
                baseColor = active ?
                            ColorTable.ControlBoxActive :
                            ColorTable.ControlBoxDeactive;
            }

            RoundStyle roundStyle = minimizeBox || maximizeBox ?
                                    RoundStyle.BottomRight : RoundStyle.Bottom;

            using (AntiAliasGraphics antiGraphics = new AntiAliasGraphics(g))
            {
                RenderHelper.RenderBackgroundInternal(
                    g,
                    rect,
                    baseColor,
                    baseColor,
                    ColorTable.ControlBoxInnerBorder,
                    roundStyle,
                    6,
                    .38F,
                    true,
                    false,
                    LinearGradientMode.Vertical);

                using (Pen pen = new Pen(ColorTable.Border))
                {
                    g.DrawLine(pen, rect.X, rect.Y, rect.Right, rect.Y);
                }

                using (GraphicsPath path = DrawUtil.CreateCloseFlagPath(rect))
                {
                    g.FillPath(Brushes.White, path);
                    using (Pen pen = new Pen(baseColor))
                    {
                        g.DrawPath(pen, path);
                    }
                }
            }
        }
Example #4
0
        protected override void OnRenderSkinFormBorder(SkinFormBorderRenderEventArgs e)
        {
            Graphics g = e.Graphics;

            using (AntiAliasGraphics antiGraphics = new AntiAliasGraphics(g))
            {
                DrawBorder(
                    g,
                    e.ClipRectangle,
                    e.SkinForm.RoundStyle,
                    e.SkinForm.Radius);
            }
        }
        protected override void OnRenderSkinFormBackground(
            SkinFormBackgroundRenderEventArgs e)
        {
            Graphics  g    = e.Graphics;
            Rectangle rect = e.ClipRectangle;
            SkinForm  form = e.SkinForm;

            using (AntiAliasGraphics antiGraphics = new AntiAliasGraphics(g))
            {
                using (Brush brush = new SolidBrush(ColorTable.Back))
                {
                    using (GraphicsPath path = GraphicsPathHelper.CreatePath(
                               rect, form.Radius, form.RoundStyle, false))
                    {
                        g.FillPath(brush, path);
                    }
                }
            }
        }
Example #6
0
        private void RenderSkinFormMaximizeBoxInternal(
            Graphics g,
            Rectangle rect,
            ControlBoxState state,
            bool active,
            bool minimizeBox,
            bool maximize,
            SkinForm form)
        {
            Bitmap          image     = null;
            SkinPictureForm imageForm = (SkinPictureForm)form;
            Color           baseColor = ColorTable.ControlBoxActive;

            if (state == ControlBoxState.Pressed)
            {
                image     = maximize ? (Bitmap)imageForm.MaxDownBack : (Bitmap)imageForm.RestoreDownBack;
                baseColor = ColorTable.ControlBoxPressed;
            }
            else if (state == ControlBoxState.Hover)
            {
                image     = maximize ? (Bitmap)imageForm.MaxMouseBack : (Bitmap)imageForm.RestoreMouseBack;
                baseColor = ColorTable.ControlBoxHover;
            }
            else
            {
                image     = maximize ? (Bitmap)imageForm.MaxNormlBack : (Bitmap)imageForm.RestoreNormlBack;
                baseColor = active ? ColorTable.ControlBoxActive : ColorTable.ControlBoxDeactive;
            }

            if (image != null)
            {
                g.DrawImage(image, rect);
            }
            else
            {
                RoundStyle roundStyle = minimizeBox ?
                                        RoundStyle.None : RoundStyle.BottomLeft;

                using (AntiAliasGraphics antiGraphics = new AntiAliasGraphics(g))
                {
                    RenderHelper.RenderBackgroundInternal(
                        g,
                        rect,
                        baseColor,
                        baseColor,
                        ColorTable.ControlBoxInnerBorder,
                        roundStyle,
                        6,
                        .38F,
                        true,
                        false,
                        LinearGradientMode.Vertical);

                    using (Pen pen = new Pen(ColorTable.Border))
                    {
                        g.DrawLine(pen, rect.X, rect.Y, rect.Right, rect.Y);
                    }

                    using (GraphicsPath path = DrawUtil.CreateMaximizeFlafPath(rect, maximize))
                    {
                        g.FillPath(Brushes.White, path);
                        using (Pen pen = new Pen(baseColor))
                        {
                            g.DrawPath(pen, path);
                        }
                    }
                }
            }
        }