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

📄 groupportraitform.cs

📁 破解的飞信源代码
💻 CS
📖 第 1 页 / 共 2 页
字号:
namespace Imps.Client.Pc
{
    using Imps.Client;
    using Imps.Client.Core;
    using Imps.Client.Pc.BizControls;
    using Imps.Client.Pc.Controls;
    using Imps.Client.Pc.Properties;
    using Imps.Client.Resource;
    using Imps.Client.Utils;
    using Imps.Utils;
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Drawing;
    using System.Drawing.Imaging;
    using System.IO;
    using System.Windows.Forms;

    public class GroupPortraitForm : XIMDialog
    {
        private List<headicon> _addPortrait;
        private string _customImagesDir;
        private string _defaultImagesDir;
        private List<headicon> _delPortrait;
        private IFrameworkWindow _iFrameworkWnd;
        private string _initDir;
        private PersonalGroup _personalGroup;
        private const string _portraitFileEx = "*.jpg";
        private Image _resultImg;
        private Imps.Client.Core.User _user;
        private XButton buttonAdd;
        private XButton buttonCancel;
        private XButton buttonDel;
        private XButton buttonOK;
        private IContainer components;
        private XLabel label1;
        private listbox_widget_t<headicon> lbPortrait;
        private headiconlist_drawer m_headiconlist_drawer = new headiconlist_drawer();
        private vscroll_widget m_headiconlist_vscroll = scroll_maker.instance.vscroll();
        private int m_index_of_customicon;
        private int m_index_of_sysicon;
        private Panel m_pane;
        protected OpenFileDialog OpenFileDialogPic;
        private DisplayPortrait pbMyPortrait;

        public GroupPortraitForm(IFrameworkWindow wnd, string DefaultImagesDir, string CustomImagesDir, PersonalGroup group)
        {
            this._personalGroup = group;
            this._defaultImagesDir = DefaultImagesDir;
            this._customImagesDir = CustomImagesDir;
            this.m_headiconlist_drawer.item_height = 0x24;
            this.lbPortrait = new listbox_widget_t<headicon>();
            this.InitializeComponent();
            this.lbPortrait.set_FormattingEnabled(true);
            this.lbPortrait.Name = "lbPortrait";
            this.lbPortrait.Location = new System.Drawing.Point(this.m_pane.Left + 5, this.buttonAdd.Location.Y);
            this.lbPortrait.Size = new Size((this.pbMyPortrait.Left - this.m_pane.Left) - 10, this.m_pane.Height - (this.buttonAdd.Location.Y * 2));
            this.lbPortrait.TabIndex = 1;
            this.lbPortrait.BorderStyle = BorderStyle.FixedSingle;
            this.lbPortrait.compare_func = new listbox_widget.compare_func_type(this.compare_func);
            this._iFrameworkWnd = wnd;
            this._user = wnd.AccountManager.CurrentUser;
            this._addPortrait = new List<headicon>();
            this._delPortrait = new List<headicon>();
            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.lbPortrait.SelectedIndexChanged += new EventHandler(this.lbPortrait_SelectedIndexChanged);
            this.lbPortrait.drawer = this.m_headiconlist_drawer;
            this.OpenFileDialogPic = new OpenFileDialog();
            this.OpenFileDialogPic.Multiselect = false;
            this.OpenFileDialogPic.Filter = "Image Files(*.BMP;*.JPG;*.GIF;*.PNG)|*.BMP;*.JPG;*.GIF;*.PNG|All files (*.*)|*.*";
            this.OpenFileDialogPic.InitialDirectory = this._initDir;
            this.m_pane.Controls.Add(this.lbPortrait);
            this.m_headiconlist_vscroll.host = this.lbPortrait;
            this.m_pane.Controls.Add(this.m_headiconlist_vscroll);
            base.ResumeLayout(false);
            base.PerformLayout();
        }

        private void buttonAdd_Click(object sender, EventArgs e)
        {
            try
            {
                if (this.OpenFileDialogPic.ShowDialog(this) == DialogResult.OK)
                {
                    string path = this.OpenFileDialogPic.FileName;
                    string text = path.Substring(path.LastIndexOf(@"\") + 1, (path.LastIndexOf(".") - path.LastIndexOf(@"\")) - 1);
                    Image icon = ImageHelper.TryGetSquareThumbnailImage(path, 0x60);
                    if (icon == null)
                    {
                        this._iFrameworkWnd.UnifiedMessageBox.ShowInfo("未能成功添加群形象:形象文件格式错误");
                    }
                    else
                    {
                        int num = 0;
                        foreach (object obj2 in this.lbPortrait.Items)
                        {
                            if (obj2 is headicon)
                            {
                                headicon headicon = (headicon) obj2;
                                if (headicon.iconpath.ToLower().CompareTo(path.ToLower()) == 0)
                                {
                                    this.lbPortrait.SelectedIndex = num;
                                    this._iFrameworkWnd.UnifiedMessageBox.ShowInfo("已经存在和当前路径相同的文件");
                                    return;
                                }
                            }
                            num++;
                        }
                        headicon headicon2 = new headicon(icon, text);
                        headicon2.iconpath = path.ToLower();
                        this.lbPortrait.Sorted = false;
                        int num2 = this.lbPortrait.add(headicon2);
                        this.lbPortrait.SelectedIndex = num2;
                        this._addPortrait.Add(headicon2);
                    }
                }
            }
            catch (ArgumentException)
            {
                this._iFrameworkWnd.UnifiedMessageBox.ShowError("无效的图片文件或者文件已损坏,请重新选择!");
            }
            catch (Exception exception)
            {
                ClientLogger.WriteException(exception);
            }
        }

        private void buttonCancel_Click(object sender, EventArgs e)
        {
            try
            {
                base.Close();
            }
            catch (Exception exception)
            {
                ClientLogger.WriteException(exception);
            }
        }

        private void buttonDel_Click(object sender, EventArgs e)
        {
            try
            {
                if (this.lbPortrait.SelectedIndex != -1)
                {
                    headicon headicon = this.lbPortrait.get_selected_item();
                    if (headicon != null)
                    {
                        this._delPortrait.Add(headicon);
                        int num = this.lbPortrait.get_selected_index();
                        if (num < this.m_index_of_customicon)
                        {
                            this.m_index_of_customicon--;
                        }
                        this.lbPortrait.Items.Remove(headicon);
                        if (num < this.lbPortrait.Items.Count)
                        {
                            this.lbPortrait.SelectedIndex = num;
                        }
                        else if (num == (this.m_index_of_customicon + 1))
                        {
                            this.lbPortrait.SelectedIndex = this.m_index_of_customicon - 1;
                        }
                        else if (0 < num)
                        {
                            this.lbPortrait.SelectedIndex = num - 1;
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                ClientLogger.WriteException(exception);
            }
        }

        private void buttonOK_Click(object sender, EventArgs e)
        {
            try
            {
                if (this._delPortrait.get_Count() > 0)
                {
                    List<headicon>.Enumerator enumerator = this._delPortrait.GetEnumerator();
                    try
                    {
                        while (enumerator.MoveNext())
                        {
                            headicon headicon = enumerator.get_Current();
                            string path = this._customImagesDir + headicon.text + ".dat";
                            if (File.Exists(path))
                            {
                                headicon.icon.Dispose();
                                File.Delete(path);
                            }
                        }
                    }
                    finally
                    {
                        enumerator.Dispose();
                    }
                }
                if (this._user.Configuration.UserSetting.SaveMyInfo && (this._addPortrait.get_Count() > 0))
                {
                    if (!Directory.Exists(this._customImagesDir))
                    {
                        Directory.CreateDirectory(this._customImagesDir);
                    }
                    List<headicon>.Enumerator enumerator2 = this._addPortrait.GetEnumerator();
                    try
                    {
                        while (enumerator2.MoveNext())
                        {
                            headicon headicon2 = enumerator2.get_Current();
                            string text2 = this._customImagesDir + headicon2.text + ".dat";
                            if (File.Exists(text2))
                            {
                                int num = 1;
                                while (true)
                                {
                                    text2 = (this._customImagesDir + headicon2.text) + num.ToString() + ".dat";
                                    if (!File.Exists(text2))
                                    {
                                        break;
                                    }
                                    num++;
                                }
                            }
                            int width = 0x60;
                            using (Bitmap bitmap = new Bitmap(width, width))
                            {
                                using (Graphics graphics = Graphics.FromImage(bitmap))
                                {
                                    graphics.FillRectangle(new SolidBrush(Color.White), 0, 0, width, width);
                                    graphics.DrawImage(headicon2.icon, 0, 0);
                                    bitmap.Save(text2, ImageHelper.GetImageCodecInfo(ImageFormat.Jpeg), ImageHelper.JpegParms());
                                }
                            }
                            headicon2.iconpath = text2;
                        }
                    }
                    finally
                    {
                        enumerator2.Dispose();
                    }
                }
                headicon headicon3 = this.lbPortrait.get_selected_item();
                Image image = new Bitmap(headicon3.icon);
                headicon3.icon.Dispose();
                this.ResultImg = image;
                base.Close();
            }
            catch (Exception exception)
            {
                ClientLogger.WriteException(exception);
                base.Close();
            }
        }

        private bool compare_func(object headicon1, object headicon2)
        {
            if (!(headicon1 is headicon) || !(headicon2 is headicon))
            {
                return false;
            }
            headicon headicon = (headicon) headicon1;
            headicon headicon3 = (headicon) headicon2;
            return (0 > headicon.text.CompareTo(headicon3.text));
        }

        protected override void Dispose(bool disposing)
        {

⌨️ 快捷键说明

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