📄 optionsmanagerimp.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<System.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;
UserAccountStatus status = (currentUser == null) ? UserAccountStatus.None : currentUser.Status;
if (status == UserAccountStatus.Logon)
{
this._categories = new OptionsCategory[2];
OptionsItem[] items = new OptionsItem[8];
OptionsItem[] itemArray2 = new OptionsItem[7];
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, "PsExInfo", StringTable.Options.PsExInfo, typeof(PsExControl));
items[2] = new OptionsItem(this, "PsPrivacy", StringTable.Options.PsPrivacy, typeof(PsPrivacyControl));
items[3] = new OptionsItem(this, "PsBlackList", StringTable.Options.PsBlakList, typeof(PsBlackList));
items[4] = new OptionsItem(this, "PsPass", StringTable.Options.PsPassword, typeof(PsPassControl));
items[5] = new OptionsItem(this, "SsHis", StringTable.Options.SsHistory, typeof(PsHistroyControl));
items[6] = new OptionsItem(this, "SsLongSms", StringTable.Options.SsLongSmsSetting, typeof(PsLongSmsSetting));
items[7] = new OptionsItem(this, "PsPermission", StringTable.Options.PsPermission, typeof(PsPermissionControl));
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, "SsFile", StringTable.Options.SsFile, typeof(SsFileShareControl));
itemArray2[5] = new OptionsItem(this, "SsNet", StringTable.Options.SsNetwork, typeof(SsNetworkControl));
itemArray2[6] = new OptionsItem(this, "SsPresence", StringTable.Options.SsPresence, typeof(SsStatusReplayControl));
}
else
{
this._categories = new OptionsCategory[1];
OptionsItem[] itemArray3 = new OptionsItem[6];
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, "SsApearance", StringTable.Options.SsApearance, typeof(SsThemeControl));
itemArray3[2] = new OptionsItem(this, "SsHotkey", StringTable.Options.SsHotkey, typeof(SsHotKeyControl));
itemArray3[3] = new OptionsItem(this, "SsSound", StringTable.Options.SsSound, typeof(SsSoundControl));
itemArray3[4] = new OptionsItem(this, "SsFile", StringTable.Options.SsFile, typeof(SsFileShareControl));
itemArray3[5] = new OptionsItem(this, "SsNet", StringTable.Options.SsNetwork, typeof(SsNetworkControl));
}
}
public IOptionsControl CreateOptionsControl(OptionsItem oi)
{
IOptionsControl control = null;
if (this.CachedOptionsControls.ContainsKey(oi.ControlType))
{
control = this.CachedOptionsControls[oi.ControlType];
}
else
{
ConstructorInfo constructor = oi.ControlType.GetConstructor(new System.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);
}
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);
ControlHelper.ShowDialogCenterOnParent(form, (IWin32Window) wnd);
if (form.DialogResult == DialogResult.OK)
{
NetworkDetectForm form2 = new NetworkDetectForm();
ControlHelper.ShowDialogCenterOnParent(form2, (IWin32Window) wnd);
}
}
private static void InitOptionsControl(Control ctrl)
{
ctrl.Location = new Point(0, 0);
ctrl.Anchor = AnchorStyles.Left | AnchorStyles.Top;
ctrl.BackColor = Color.Transparent;
ctrl.Visible = true;
}
private Dictionary<System.Type, IOptionsControl> CachedOptionsControls
{
get
{
if (this._cachedOptionsControls == null)
{
this._cachedOptionsControls = new Dictionary<System.Type, IOptionsControl>(15);
IOptionsControl control = new PsExControl(this._frameworkWnd);
InitOptionsControl(control.Control);
this._cachedOptionsControls.Add(typeof(PsExControl), control);
}
return this._cachedOptionsControls;
}
}
public OptionsCategory[] Categories
{
get
{
this.BuildOptionsCategory();
return this._categories;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -