Example #1
0
        //public ZImageButton() : base()
        //{

        //}

        protected override void OnPaint(ZPaintContext context)
        {
            base.OnPaint(context);
            Image image = null;

            if (this.isDown && this.PressImage != null)
            {
                image = this.PressImage;
            }
            else if (this.isHover && this.HoverImage != null)
            {
                image = this.HoverImage;
            }
            else if (this.NormalImage != null)
            {
                image = this.NormalImage;
            }
            else
            {
                return;
            }
            if (this.ImageEdgeInset != Padding.Empty)
            {
                image = ImageApi.ImageStretch(image, this.ImageEdgeInset, this.Size, context.ClipRectangle);
            }

            context.Graphics.DrawImage(image, context.ClipRectangle, new RectangleF(Point.Empty, image.Size), GraphicsUnit.Pixel);
        }
Example #2
0
        protected override void OnPaint(PaintEventArgs e)
        {
            //base.OnPaint(e);
            if (this.BackgroundImage == null || this.BackgroundImageLayout != ImageLayout.Stretch || this.ClientRectangle == Rectangle.Empty)
            {
                base.OnPaint(e);
                return;
            }

            var image = ImageApi.ImageStretch(this.BackgroundImage, this.BackgroundEdgeInset, this.ClientSize, e.ClipRectangle);

            e.Graphics.DrawImage(image, e.ClipRectangle);
            this.PaintChildren(e);
        }