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

📄 optionsmanagerimp.cs

📁 破解的飞信源代码
💻 CS
字号:
namespace Imps.Client.Pc
{
    using Imps.Client;
    using Imps.Client.Core;
    using Imps.Client.Pc.Options;
    using Imps.Client.Pc.UserAccount;
    using Imps.Client.Resource;
    using Imps.Client.Utils;
    using System;
    using System.Collections.Generic;
    using System.Drawing;
    using System.Reflection;
    using System.Windows.Forms;

    public class OptionsManagerImp : IOptionsManager
    {
        private Dictionary<Type, IOptionsControl> _cachedOptionsControls;
        private OptionsCategory[] _categories;
        private IFrameworkWindow _frameworkWnd;

        public OptionsManagerImp(IFrameworkWindow framework)
        {
            this._frameworkWnd = framework;
        }

        private void BuildOptionsCategory()
        {
            Imps.Client.Core.User currentUser = this._frameworkWnd.AccountManager.CurrentUser;
            switch (((currentUser == null) ? UserAccountStatus.None : currentUser.Status))
            {
                case UserAccountStatus.Logon:
                case UserAccountStatus.OfflineLogon:
                {
                    this._categories = new OptionsCategory[2];
                    OptionsItem[] items = new OptionsItem[6];
                    OptionsItem[] itemArray2 = new OptionsItem[5];
                    this._categories[0] = new OptionsCategory(StringTable.Options.PersonalSetting, items);
                    this._categories[1] = new OptionsCategory(StringTable.Options.SystemSetting, itemArray2);
                    items[0] = new OptionsItem(this, "PsGeneral", StringTable.Options.PsGeneral, typeof(PsGeneralControl));
                    items[1] = new OptionsItem(this, "PsPrivacy", StringTable.Options.PsExInfo, typeof(PsPrivacyControl));
                    items[2] = new OptionsItem(this, "PsBlackList", StringTable.Options.PsBlakList, typeof(PsBlackList));
                    items[3] = new OptionsItem(this, "PsPass", StringTable.Options.PsPassword, typeof(PsPassControl));
                    items[4] = new OptionsItem(this, "SsHis", StringTable.Options.SsHistory, typeof(PsHistroyControl));
                    items[5] = new OptionsItem(this, "SsPresence", StringTable.Options.SsPresence, typeof(SsStatusReplayControl));
                    itemArray2[0] = new OptionsItem(this, "SsGeneral", StringTable.Options.SsGeneral, typeof(SsGeneralControl));
                    itemArray2[1] = new OptionsItem(this, "SsApearance", StringTable.Options.SsApearance, typeof(SsThemeControl));
                    itemArray2[2] = new OptionsItem(this, "SsHotkey", StringTable.Options.SsHotkey, typeof(SsHotKeyControl));
                    itemArray2[3] = new OptionsItem(this, "SsSound", StringTable.Options.SsSound, typeof(SsSoundControl));
                    itemArray2[4] = new OptionsItem(this, "SsNet", StringTable.Options.SsNetwork, typeof(SsNetworkControl));
                    return;
                }
            }
            this._categories = new OptionsCategory[1];
            OptionsItem[] itemArray3 = new OptionsItem[3];
            this._categories[0] = new OptionsCategory(StringTable.Options.SystemSetting, itemArray3);
            itemArray3[0] = new OptionsItem(this, "SsGeneral", StringTable.Options.SsGeneral, typeof(SsGeneralControl));
            itemArray3[1] = new OptionsItem(this, "SsHotkey", StringTable.Options.SsHotkey, typeof(SsHotKeyControl));
            itemArray3[2] = new OptionsItem(this, "SsNet", StringTable.Options.SsNetwork, typeof(SsNetworkControl));
        }

        public IOptionsControl CreateOptionsControl(OptionsItem oi)
        {
            Predicate<OptionsItem> predicate = null;
            IOptionsControl control = null;
            if (this.CachedOptionsControls.ContainsKey(oi.ControlType))
            {
                control = this.CachedOptionsControls.get_Item(oi.ControlType);
            }
            else
            {
                ConstructorInfo constructor = oi.ControlType.GetConstructor(new Type[] { typeof(IFrameworkWindow) });
                if (constructor == null)
                {
                    control = (IOptionsControl) Activator.CreateInstance(oi.ControlType);
                }
                else
                {
                    control = (IOptionsControl) constructor.Invoke(new object[] { this._frameworkWnd });
                }
                InitOptionsControl(control.Control);
                this.CachedOptionsControls.Add(oi.ControlType, control);
            }
            if (this._frameworkWnd.AccountManager.CurrentUser.Status == UserAccountStatus.OfflineLogon)
            {
                if (predicate == null)
                {
                    <>c__DisplayClass2 class2;
                    predicate = new Predicate<OptionsItem>(class2, (IntPtr) this.<CreateOptionsControl>b__0);
                }
                if (Array.Exists<OptionsItem>(this._categories[0].Items, predicate))
                {
                    foreach (Control control2 in control.Control.Controls)
                    {
                        control2.Enabled = false;
                    }
                    if (this.CachedOptionsControls.ContainsKey(oi.ControlType))
                    {
                        this.CachedOptionsControls.Remove(oi.ControlType);
                    }
                }
            }
            control.ControlLoad();
            control.UpdateData(false);
            return control;
        }

        public void HandleConnectionFailed(IFrameworkWindow wnd, int ErrorCode)
        {
            Imps.Client.Core.User currentUser = this._frameworkWnd.AccountManager.CurrentUser;
            LoginFailedForm form = new LoginFailedForm(ErrorCode, currentUser);
            if (ControlHelper.ShowDialogCenterOnParent(form, wnd.MainWindow, true) == DialogResult.OK)
            {
                NetworkDetectForm form2 = new NetworkDetectForm();
                ControlHelper.ShowDialogCenterOnParent(form2, wnd.MainWindow, true);
            }
        }

        private static void InitOptionsControl(Control ctrl)
        {
            ctrl.Location = new System.Drawing.Point(0, 0);
            ctrl.Anchor = AnchorStyles.Left | AnchorStyles.Top;
            ctrl.BackColor = Color.Transparent;
            ctrl.Visible = true;
        }

        private Dictionary<Type, IOptionsControl> CachedOptionsControls
        {
            get
            {
                if (this._cachedOptionsControls == null)
                {
                    this._cachedOptionsControls = new Dictionary<Type, IOptionsControl>(15);
                }
                return this._cachedOptionsControls;
            }
        }

        public OptionsCategory[] Categories
        {
            get
            {
                this.BuildOptionsCategory();
                return this._categories;
            }
        }
    }
}

⌨️ 快捷键说明

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