⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xpicturebox.cs

📁 破解的飞信源代码
💻 CS
字号:
namespace Imps.Client.Pc.Controls
{
    using System;
    using System.ComponentModel;
    using System.Drawing;
    using System.Windows.Forms;

    public class XPictureBox : XControlBase
    {
        private System.Drawing.Image _image;
        private bool _showPaddingBorder;
        private PictureBoxSizeMode _sizeMode;

        private Rectangle ImageRectangleFromSizeMode(PictureBoxSizeMode mode, Rectangle rectangle)
        {
            if (this.Image != null)
            {
                switch (mode)
                {
                    case PictureBoxSizeMode.Normal:
                    case PictureBoxSizeMode.StretchImage:
                    case PictureBoxSizeMode.AutoSize:
                        return rectangle;

                    case PictureBoxSizeMode.CenterImage:
                        rectangle.X += (rectangle.Width - this.Image.Width) / 2;
                        rectangle.Y += (rectangle.Height - this.Image.Height) / 2;
                        rectangle.Size = this.Image.Size;
                        return rectangle;

                    case ((PictureBoxSizeMode) 4):
                    {
                        Size size = this.Image.Size;
                        float num = Math.Min((float) (((float) base.ClientRectangle.Width) / ((float) size.Width)), (float) (((float) base.ClientRectangle.Height) / ((float) size.Height)));
                        rectangle.Width = (int) (size.Width * num);
                        rectangle.Height = (int) (size.Height * num);
                        return rectangle;
                    }
                }
            }
            return rectangle;
        }

        protected override void OnPaintControl(PaintEventArgs e)
        {
            base.OnPaintControl(e);
            try
            {
                if (this.Image != null)
                {
                    Rectangle rectangle = XControlHelper.GetWorkRectangle(e.ClipRectangle, base.get_Padding(), this.BorderStyle);
                    Rectangle rect = this.ImageRectangleFromSizeMode(this.SizeMode, rectangle);
                    e.Graphics.DrawImage(this.Image, rect);
                    if ((this.ShowPaddingBorder && (base.get_Padding().get_All() != 0)) && (this.BorderStyle == BorderStyle.FixedSingle))
                    {
                        rectangle.Inflate(2, 2);
                        ControlPaint.DrawBorder(e.Graphics, rectangle, base.BorderColor, base.ButtonBorderStyle);
                    }
                }
            }
            catch (Exception)
            {
            }
        }

        [Category("外观"), Description("PictureBox 里显示的图片")]
        public System.Drawing.Image Image
        {
            get
            {
                return this._image;
            }
            set
            {
                if (this._image != value)
                {
                    this._image = value;
                    base.Invalidate();
                }
            }
        }

        [Description("图片如果设置了Padding 是否在Padding的内侧显示边框(BorderStyle需要设置为FixedSingle)"), Category("外观"), DefaultValue(false)]
        public bool ShowPaddingBorder
        {
            get
            {
                return this._showPaddingBorder;
            }
            set
            {
                if (this._showPaddingBorder != value)
                {
                    this._showPaddingBorder = value;
                    base.Invalidate();
                }
            }
        }

        [Description("控制PictureBox将如何显示图片的位置和控件的大小"), Category("行为")]
        public PictureBoxSizeMode SizeMode
        {
            get
            {
                return this._sizeMode;
            }
            set
            {
                if (this._sizeMode != value)
                {
                    if (value == PictureBoxSizeMode.AutoSize)
                    {
                        this.set_AutoSize(true);
                        base.SetStyle(ControlStyles.FixedHeight | ControlStyles.FixedWidth, true);
                    }
                    if (value != PictureBoxSizeMode.AutoSize)
                    {
                        this.set_AutoSize(false);
                        base.SetStyle(ControlStyles.FixedHeight | ControlStyles.FixedWidth, false);
                    }
                    this._sizeMode = value;
                    base.Invalidate();
                }
            }
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -