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

📄 psportraitcontrol.cs

📁 飞信的收发使用csharp进行开发
💻 CS
字号:
namespace Imps.Client.Pc.Options
{
    using Imps.Client;
    using Imps.Client.Core;
    using Imps.Client.Pc;
    using Imps.Client.Pc.BizControls;
    using Imps.Client.Pc.Controls;
    using Imps.Client.Resource;
    using Imps.Utils;
    using System;
    using System.ComponentModel;
    using System.Drawing;
    using System.IO;
    using System.Windows.Forms;

    public class PsPortraitControl : OptionsControlBase
    {
        private IFrameworkWindow _iFrameworkWnd;
        private string _initDir;
        private Imps.Client.Core.User _user;
        private XButton btnAddPortrait;
        private XButton button1;
        private IContainer components;
        private OpenFileDialog fdAddPortrait;
        private XLabel lbMsgHistory;
        private listbox_widget_t<headicon> lbPortrait;
        private XLabel lbPreview;
        protected OpenFileDialog OpenFileDialogPic;
        private PictureBox pbMyPortrait;

        public PsPortraitControl(IFrameworkWindow wnd)
        {
            this.InitializeComponent();
            this.lbPortrait.drawer = new headiconlist_drawer();
            this.OpenFileDialogPic = new OpenFileDialog();
            this.OpenFileDialogPic.Multiselect = false;
            this.OpenFileDialogPic.Filter = "Image Files(*.BMP;*.JPG;*.GIF)|*.BMP;*.JPG;*.GIF|All files (*.*)|*.*";
            this._initDir = ImpsPathInfo.StartupPath;
            if (Directory.Exists(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures)))
            {
                this._initDir = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures);
            }
            else if (Directory.Exists(Environment.GetFolderPath(Environment.SpecialFolder.Personal)))
            {
                this._initDir = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            }
            this.OpenFileDialogPic.InitialDirectory = this._initDir;
            this._iFrameworkWnd = wnd;
            this._user = wnd.AccountManager.CurrentUser;
        }

        private void btnAddPortrait_Click(object sender, EventArgs e)
        {
            if (this.OpenFileDialogPic.ShowDialog(this) == DialogResult.OK)
            {
                FileStream stream = (FileStream) this.OpenFileDialogPic.OpenFile();
                Image.FromStream(stream);
            }
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void InitializeComponent()
        {
            this.lbMsgHistory = new XLabel();
            this.lbPortrait = new listbox_widget_t<headicon>();
            this.pbMyPortrait = new PictureBox();
            this.btnAddPortrait = new XButton();
            this.button1 = new XButton();
            this.lbPreview = new XLabel();
            this.fdAddPortrait = new OpenFileDialog();
            XLabel label = new XLabel();
            ((ISupportInitialize) this.pbMyPortrait).BeginInit();
            base.SuspendLayout();
            label.BorderStyle = BorderStyle.Fixed3D;
            label.Location = new Point(4, 10);
            label.Name = "lbLine";
            label.Size = new Size(350, 2);
            label.TabIndex = 8;
            this.lbMsgHistory.AutoSize = true;
            this.lbMsgHistory.Location = new Point(4, 4);
            this.lbMsgHistory.Name = "lbMsgHistory";
            this.lbMsgHistory.Size = new Size(0x37, 13);
            this.lbMsgHistory.TabIndex = 9;
            this.lbMsgHistory.Text = "修改头像";
            this.lbPortrait.FormattingEnabled = true;
            this.lbPortrait.Location = new Point(6, 0x15);
            this.lbPortrait.Name = "lbPortrait";
            this.lbPortrait.Size = new Size(0xf6, 0x18a);
            this.lbPortrait.TabIndex = 10;
            this.pbMyPortrait.Location = new Point(0x103, 0x72);
            this.pbMyPortrait.Name = "pbMyPortrait";
            this.pbMyPortrait.Size = new Size(0x60, 0x68);
            this.pbMyPortrait.TabIndex = 11;
            this.pbMyPortrait.TabStop = false;
            this.btnAddPortrait.Location = new Point(270, 0x15);
            this.btnAddPortrait.Name = "btnAddPortrait";
            this.btnAddPortrait.Size = new Size(0x4b, 0x19);
            this.btnAddPortrait.TabIndex = 12;
            this.btnAddPortrait.Text = "添加...";
            this.btnAddPortrait.UseVisualStyleBackColor = true;
            this.btnAddPortrait.Click += new EventHandler(this.btnAddPortrait_Click);
            this.button1.Location = new Point(270, 0x34);
            this.button1.Name = "button1";
            this.button1.Size = new Size(0x4b, 0x19);
            this.button1.TabIndex = 13;
            this.button1.Text = "删除";
            this.button1.UseVisualStyleBackColor = true;
            this.lbPreview.AutoSize = true;
            this.lbPreview.Location = new Point(0x103, 0x5e);
            this.lbPreview.Name = "lbPreview";
            this.lbPreview.Size = new Size(0x1f, 13);
            this.lbPreview.TabIndex = 14;
            this.lbPreview.Text = "预览";
            this.fdAddPortrait.FileName = "openFileDialog1";
            base.AutoScaleDimensions = new SizeF(6f, 13f);
            base.AutoScaleMode = AutoScaleMode.Font;
            base.Controls.Add(this.lbPreview);
            base.Controls.Add(this.button1);
            base.Controls.Add(this.btnAddPortrait);
            base.Controls.Add(this.pbMyPortrait);
            base.Controls.Add(this.lbPortrait);
            base.Controls.Add(this.lbMsgHistory);
            base.Controls.Add(label);
            base.Name = "PsPortraitControl";
            base.Size = new Size(0x16b, 0x1b1);
            ((ISupportInitialize) this.pbMyPortrait).EndInit();
            base.ResumeLayout(false);
            base.PerformLayout();
            base.Load += new EventHandler(this.PsPortraitControl_Load);
        }

        private void PsPortraitControl_Load(object sender, EventArgs e)
        {
            Imps.Client.Resource.Portrait[] defaultPortraits = ImpsPortrait.GetDefaultPortraits();
            if (defaultPortraits != null)
            {
                foreach (Imps.Client.Resource.Portrait portrait in defaultPortraits)
                {
                    this.lbPortrait.add(new headicon(portrait.Image, portrait.Description));
                }
            }
            string baseDirForPortrait = this._user.PersistentManager.BaseDirForPortrait;
            if (Directory.Exists(baseDirForPortrait))
            {
                DirectoryInfo info = new DirectoryInfo(baseDirForPortrait);
                foreach (FileInfo info2 in info.GetFiles("*.dat"))
                {
                    Image input = ImpsResources.LoadImage(info2.FullName);
                    if (input != null)
                    {
                        Image icon = ImageHelper.Image2Jpg(input);
                        this.lbPortrait.add(new headicon(icon, info2.Name));
                    }
                }
            }
        }
    }
}

⌨️ 快捷键说明

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