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

📄 displayportrait.cs

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

    public class DisplayPortrait : BControl
    {
        private bool _showSecondBorder;
        private bool _useHandCursor;
        protected Color borderColor;
        protected System.Drawing.Image image;
        private PortraitSizeMode sizeMode;

        public event EventHandler Click;

        public DisplayPortrait()
        {
            this.borderColor = Color.FromArgb(0xa4, 170, 220);
            this.sizeMode = PortraitSizeMode.Size_96;
            this._showSecondBorder = true;
            this._useHandCursor = true;
            base.SetStyle(0x20802, true);
            this.BackColor = Color.White;
            this.SetSize();
        }

        public DisplayPortrait(System.Drawing.Image image) : this()
        {
            this.image = image;
        }

        public void OnClick(EventArgs e)
        {
            if (this.Click != null)
            {
                this.Click(this, e);
            }
        }

        protected override void OnMouseClick(MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                this.OnClick(new EventArgs());
            }
        }

        protected override void OnMouseEnter(EventArgs e)
        {
            if (this.UseHandCursor)
            {
                this.Cursor = Cursors.Hand;
            }
        }

        protected override void OnMouseLeave(EventArgs e)
        {
            if (this.UseHandCursor)
            {
                this.Cursor = Cursors.Default;
            }
        }

        protected override void OnPaint(PaintEventArgs e)
        {
            this.SetSize();
            if (this.image == null)
            {
                this.image = ImpsPortrait.GetDefaultPortrait(0x60, 0x60);
            }
            if (this.image != null)
            {
                using (Bitmap image = new Bitmap(base.Width, base.Height))
                {
                    using (Graphics graphics = Graphics.FromImage(image))
                    {
                        graphics.Clear(Color.Transparent);
                        if (this.SizeMode == PortraitSizeMode.Size_96)
                        {
                            if (this.ShowSecondBorder)
                            {
                                using (Pen pen = new Pen(this.borderColor, 1f))
                                {
                                    graphics.DrawRectangle(pen, 0, 0, 0x75, 0x75);
                                    graphics.DrawRectangle(pen, 8, 8, 0x65, 0x65);
                                }
                                graphics.DrawImage(this.image, 11, 11, 0x60, 0x60);
                            }
                            else
                            {
                                using (Pen pen2 = new Pen(this.borderColor, 1f))
                                {
                                    graphics.DrawRectangle(pen2, 0, 0, 0x65, 0x65);
                                }
                                graphics.DrawImage(this.image, 3, 3, 0x60, 0x60);
                            }
                        }
                        else if (this.SizeMode == PortraitSizeMode.Size_48)
                        {
                            using (Pen pen3 = new Pen(this.borderColor, 1f))
                            {
                                graphics.DrawRectangle(pen3, 0, 0, 0x35, 0x35);
                            }
                            graphics.DrawImage(this.image, 3, 3, 0x30, 0x30);
                        }
                        else if (this.SizeMode == PortraitSizeMode.Size_64)
                        {
                            using (Pen pen4 = new Pen(this.borderColor, 1f))
                            {
                                graphics.DrawRectangle(pen4, 0, 0, 0x45, 0x45);
                            }
                            graphics.DrawImage(this.image, 3, 3, 0x40, 0x40);
                        }
                    }
                    e.Graphics.DrawImage(image, 0, 0);
                }
            }
        }

        private void SetSize()
        {
            if (this.SizeMode == PortraitSizeMode.Size_48)
            {
                base.Size = new Size(0x36, 0x36);
            }
            if (this.SizeMode == PortraitSizeMode.Size_64)
            {
                base.Size = new Size(70, 70);
            }
            else if (this.ShowSecondBorder)
            {
                base.Size = new Size(0x76, 0x76);
            }
            else
            {
                base.Size = new Size(0x66, 0x66);
            }
        }

        [Category("IMPS"), Browsable(true), Description("Set the border color of the portrait!")]
        public Color BorderColor
        {
            get
            {
                return this.borderColor;
            }
            set
            {
                this.borderColor = value;
                this.Refresh();
            }
        }

        [Description("Set the portrait image to be displayed!"), Category("IMPS"), DefaultValue((string) null), Browsable(true)]
        public System.Drawing.Image Image
        {
            get
            {
                return this.image;
            }
            set
            {
                this.image = value;
                this.Refresh();
            }
        }

        [Category("IMPS"), Browsable(true), Description("Set whether display the second border outside the image when the image sizemode set to Size_96"), DefaultValue(true)]
        public bool ShowSecondBorder
        {
            get
            {
                return this._showSecondBorder;
            }
            set
            {
                this._showSecondBorder = value;
            }
        }

        [DefaultValue(2), Category("IMPS"), Browsable(true), Description("Set the portrait size mode")]
        public PortraitSizeMode SizeMode
        {
            get
            {
                return this.sizeMode;
            }
            set
            {
                this.sizeMode = value;
            }
        }

        [Category("IMPS"), DefaultValue(true), Browsable(true), Description("Set the cursor while hover on this control")]
        public bool UseHandCursor
        {
            get
            {
                return this._useHandCursor;
            }
            set
            {
                this._useHandCursor = value;
            }
        }
    }
}

⌨️ 快捷键说明

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