예제 #1
0
        public override void Decorate(ImageDecoratorContext context)
        {
            DropShadowBorderDecoratorSettings settings = new DropShadowBorderDecoratorSettings(context);

            Rectangle adjustment = AdjustImagePositionAndSize(context);
            Bitmap    bitmap     = new Bitmap(
                context.Image.Width + adjustment.Width,
                context.Image.Height + adjustment.Height,
                PixelFormat.Format32bppArgb);

            using (Graphics g = Graphics.FromImage(bitmap))
            {
                using (Brush b = new SolidBrush(settings.BackgroundColor))
                    g.FillRectangle(b, 0, 0, bitmap.Width, bitmap.Height);

                int[]       sliceLines = SliceLines;
                BorderPaint bp         = new BorderPaint(BorderImage, false, BorderPaintMode.Default, sliceLines[0], sliceLines[1], sliceLines[2], sliceLines[3]);
                if (DiscardColors)
                {
                    using (ImageAttributes ia = new ImageAttributes())
                    {
                        ia.SetColorMatrix(ImageHelper.GetColorOverrideImageMatrix(settings.ShadowColor));
                        bp.ImageAttributes = ia;
                        bp.DrawBorder(g, new Rectangle(0, 0, bitmap.Width, bitmap.Height));
                    }
                }
                else
                {
                    bp.DrawBorder(g, new Rectangle(0, 0, bitmap.Width, bitmap.Height));
                }

                g.DrawImage(context.Image,
                            adjustment.Left,
                            adjustment.Top,
                            context.Image.Width,
                            context.Image.Height);

                OnBorderDecorationComplete(g, context);
            }

            context.Image        = bitmap;
            context.BorderMargin =
                new ImageBorderMargin(adjustment.Width, adjustment.Height,
                                      new BorderCalculation(adjustment.Width, adjustment.Height));
            HideHtmlBorder(context);
        }
예제 #2
0
        protected override void OnPaint(PaintEventArgs e)
        {
            BidiGraphics g = new BidiGraphics(e.Graphics, ClientRectangle);

            if (IsHovered || (SystemInformation.HighContrast && Focused))
            {
                BorderPaint borderPaint = new BorderPaint(ResourceHelper.LoadAssemblyResourceBitmap("Images.ChoiceOptionHover.png"), true, BorderPaintMode.StretchToFill | BorderPaintMode.PaintMiddleCenter, 3, 4, 3, 71);
                borderPaint.DrawBorder(e.Graphics, ClientRectangle);
            }
            else if (Focused)
            {
                BorderPaint borderPaint = new BorderPaint(ResourceHelper.LoadAssemblyResourceBitmap("Images.ChoiceOptionFocus.png"), true, BorderPaintMode.StretchToFill | BorderPaintMode.PaintMiddleCenter, 3, 4, 3, 71);
                borderPaint.DrawBorder(e.Graphics, ClientRectangle);
            }

            // Draw everything else
            Render(g, ClientRectangle.Width, ClientRectangle.Height);
        }