📄 optionsform.cs
字号:
namespace Imps.Client.Pc
{
using Imps.Client;
using Imps.Client.Core;
using Imps.Client.Pc.BizControls;
using Imps.Client.Pc.Controls;
using Imps.Client.Resource;
using Imps.Client.Utils;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
internal class OptionsForm : XIMDialog
{
private List<ICommittable> _commitableItems;
private IFrameworkWindow _frameworkWnd;
private Dictionary<int, OptionsItem> _optionItems;
private XButton btnApply;
private XButton btnCancel;
private XButton btnOk;
private IContainer components;
private listbox_widget_t<headicon> m_default_options = new listbox_widget_t<headicon>();
private headiconlist_drawer m_headicon_list_drawer = new headiconlist_drawer();
private listbox_widget_t<headicon> m_personal_options = new listbox_widget_t<headicon>();
private slider_pane m_slider_pane = new slider_pane();
private listbox_widget_t<headicon> m_system_options = new listbox_widget_t<headicon>();
private Panel pNavigation;
private Panel pnlContainer;
private Panel pnlOptions;
public OptionsForm(IFrameworkWindow host)
{
this._frameworkWnd = host;
host.AccountManager.CurrentUser.StatusChanged += new EventHandler<UserSatusChangedEventArgs>(this, (IntPtr) this.CurrentUser_StatusChanged);
this.InitOptionList(host);
this.initComponentRegion();
}
private void btnApply_Click(object sender, EventArgs e)
{
try
{
this.InnerUpdateOptionsControl(true);
}
catch (Exception exception)
{
this._frameworkWnd.UnifiedMessageBox.ShowError(this, exception.Message);
}
}
private void btnCancel_Click(object sender, EventArgs e)
{
base.Close();
}
private void btnHelp_Click(object sender, EventArgs e)
{
try
{
ImpsHelp.LoadHelp(ImpsHelpSrc.Unspcified);
}
catch (Exception exception)
{
UiErrorHelper.HandExceptionSafely(this._frameworkWnd, exception);
}
}
private void btnOk_Click(object sender, EventArgs e)
{
try
{
if (this.InnerUpdateOptionsControl(true))
{
base.Close();
}
}
catch (Exception exception)
{
this._frameworkWnd.UnifiedMessageBox.ShowError(this, exception.Message);
}
}
private void CurrentUser_StatusChanged(object sender, UserSatusChangedEventArgs e)
{
try
{
switch (e.NewStatus)
{
case UserAccountStatus.Loginning:
case UserAccountStatus.Logouting:
case UserAccountStatus.Logoff:
case UserAccountStatus.Disconnected:
base.Close();
return;
case UserAccountStatus.Logon:
return;
}
}
catch
{
}
}
protected override void Dispose(bool disposing)
{
if (disposing && (this.components != null))
{
this.components.Dispose();
}
base.Dispose(disposing);
}
private void InitializeComponent()
{
this.components = new Container();
ComponentResourceManager manager = new ComponentResourceManager(typeof(OptionsForm));
this.pnlContainer = new Panel();
this.pNavigation = new Panel();
this.pnlOptions = new Panel();
this.btnApply = new XButton();
this.btnCancel = new XButton();
this.btnOk = new XButton();
this.pnlContainer.SuspendLayout();
base.SuspendLayout();
this.pnlContainer.BackColor = Color.Transparent;
this.pnlContainer.Controls.Add(this.pNavigation);
this.pnlContainer.Controls.Add(this.pnlOptions);
this.pnlContainer.Location = new System.Drawing.Point(0, 0);
this.pnlContainer.Name = "pnlContainer";
this.pnlContainer.Size = new Size(0x220, 500);
this.pnlContainer.TabIndex = 4;
this.pNavigation.Location = new System.Drawing.Point(7, 8);
this.pNavigation.Name = "pNavigation";
this.pNavigation.Size = new Size(0x75, 480);
this.pNavigation.TabIndex = 1;
this.pnlOptions.Anchor = AnchorStyles.None;
this.pnlOptions.Location = new System.Drawing.Point(0x7c, 8);
this.pnlOptions.Name = "pnlOptions";
this.pnlOptions.Size = new Size(420, 480);
this.pnlOptions.TabIndex = 0;
this.btnApply.AutoSizeToImage = false;
this.btnApply.BackColor = Color.Transparent;
this.btnApply.BackgroundImageDisable = null;
this.btnApply.BackgroundImageDown = null;
this.btnApply.BackgroundImageHover = null;
this.btnApply.ChangeSkin = true;
this.btnApply.Location = new System.Drawing.Point(0x1c6, 0x1fa);
this.btnApply.Name = "btnApply";
this.btnApply.Size = new Size(0x4b, 0x1b);
this.btnApply.TabIndex = 0x20;
this.btnApply.set_UseVisualStyleBackColor(false);
this.btnApply.Click += new EventHandler(this.btnApply_Click);
this.btnCancel.AutoSizeToImage = false;
this.btnCancel.BackColor = Color.Transparent;
this.btnCancel.BackgroundImageDisable = null;
this.btnCancel.BackgroundImageDown = null;
this.btnCancel.BackgroundImageHover = null;
this.btnCancel.ChangeSkin = true;
this.btnCancel.DialogResult = DialogResult.Cancel;
this.btnCancel.Location = new System.Drawing.Point(0x175, 0x1fa);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new Size(0x4b, 0x1b);
this.btnCancel.TabIndex = 0x1f;
this.btnCancel.set_UseVisualStyleBackColor(false);
this.btnCancel.Click += new EventHandler(this.btnCancel_Click);
this.btnOk.AutoSizeToImage = false;
this.btnOk.BackColor = Color.Transparent;
this.btnOk.BackgroundImageDisable = null;
this.btnOk.BackgroundImageDown = null;
this.btnOk.BackgroundImageHover = null;
this.btnOk.ChangeSkin = true;
this.btnOk.DialogResult = DialogResult.OK;
this.btnOk.Location = new System.Drawing.Point(0x124, 0x1fa);
this.btnOk.Name = "btnOk";
this.btnOk.Size = new Size(0x4b, 0x1b);
this.btnOk.TabIndex = 30;
this.btnOk.set_UseVisualStyleBackColor(false);
this.btnOk.Click += new EventHandler(this.btnOk_Click);
base.set_AutoScaleDimensions(new SizeF(6f, 13f));
base.set_AutoScaleMode(1);
base.ClientSize = new Size(0x236, 0x219);
base.Controls.Add(this.pnlContainer);
base.Controls.Add(this.btnApply);
base.Controls.Add(this.btnCancel);
base.Controls.Add(this.btnOk);
base.DisplayLocation = new System.Drawing.Point(0x12, 12);
base.DisplaySize = new Size(0x22d, 0x219);
base.Icon = (Icon) manager.GetObject("$this.Icon");
base.MinimizeBox = false;
base.Name = "OptionsForm";
base.set_Padding(new Padding(1, 0x16, 13, 4));
base.StartPosition = FormStartPosition.CenterParent;
base.Load += new EventHandler(this.OptionsForm_Load);
this.pnlContainer.ResumeLayout(false);
base.ResumeLayout(false);
base.KeyPreview = true;
}
private void InitOptionList(IFrameworkWindow host)
{
this.m_headicon_list_drawer.show_focus = false;
this.m_slider_pane.Name = "m_slider_pane";
this.m_slider_pane.is_qqstyle = true;
this.m_slider_pane.TabIndex = 0x63;
this.m_slider_pane.items_dock_pos = false;
this.m_slider_pane.Anchor = AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Top;
this.m_slider_pane.selected_index_changed += new slider_pane.selected_index_changed_handler(this.OnSliderPaneSelectedIndexChanged);
this.m_slider_pane.selected_index_changing += new slider_pane.selected_index_changing_handler(this.m_slider_pane_selected_index_changing);
this.m_system_options.Location = new System.Drawing.Point(0, 0);
this.m_system_options.Name = "m_system_options";
this.m_system_options.Size = new Size(1, 1);
this.m_system_options.TabIndex = 0;
this.m_system_options.drawer = this.m_headicon_list_drawer;
this.m_system_options.BorderStyle = BorderStyle.None;
this.m_system_options.Visible = false;
this.m_personal_options.Location = new System.Drawing.Point(0, 0);
this.m_personal_options.Name = "m_personal_options";
this.m_personal_options.Size = new Size(1, 1);
this.m_personal_options.TabIndex = 0;
this.m_personal_options.drawer = this.m_headicon_list_drawer;
this.m_personal_options.BorderStyle = BorderStyle.None;
this.m_personal_options.Visible = false;
this.m_default_options.Location = new System.Drawing.Point(0, 0);
this.m_default_options.Name = "m_default_options";
this.m_default_options.Size = new Size(1, 1);
this.m_default_options.TabIndex = 0;
this.m_default_options.drawer = this.m_headicon_list_drawer;
this.m_default_options.BorderStyle = BorderStyle.None;
this.m_default_options.Visible = false;
this.InitializeComponent();
this.m_slider_pane.Location = new System.Drawing.Point(0, 0);
this.m_slider_pane.Size = new Size(0x75, 0x1de);
this.pNavigation.Controls.Add(this.m_system_options);
this.pNavigation.Controls.Add(this.m_personal_options);
this.pNavigation.Controls.Add(this.m_default_options);
this.pNavigation.Controls.Add(this.m_slider_pane);
this._commitableItems = new List<ICommittable>();
this._commitableItems.Add(host.AccountManager.CurrentUser.PersonalInfo);
this._commitableItems.Add(host.AccountManager.CurrentUser.PermissionManager);
this._commitableItems.Add(host.AccountManager.CurrentUser.Configuration);
this.m_system_options.SelectedIndexChanged += new EventHandler(this.lbOptionItems_SelectedIndexChanged);
this.m_personal_options.SelectedIndexChanged += new EventHandler(this.lbOptionItems_SelectedIndexChanged);
this.m_default_options.SelectedIndexChanged += new EventHandler(this.lbOptionItems_SelectedIndexChanged);
this.m_system_options.SelectedIndexChanging += new listbox_widget.cancel_select_event_handler(this.OnSelectingOptionItem);
this.m_personal_options.SelectedIndexChanging += new listbox_widget.cancel_select_event_handler(this.OnSelectingOptionItem);
this.m_default_options.SelectedIndexChanging += new listbox_widget.cancel_select_event_handler(this.OnSelectingOptionItem);
}
private int InnerFindOcpByName(string name)
{
Dictionary<int, OptionsItem>.Enumerator enumerator = this._optionItems.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
KeyValuePair<int, OptionsItem> pair = enumerator.get_Current();
if (pair.get_Value().Name == name)
{
return pair.get_Key();
}
}
}
finally
{
enumerator.Dispose();
}
return -1;
}
private bool InnerUpdateOptionsControl(bool update)
{
if (update)
{
Dictionary<int, OptionsItem>.Enumerator enumerator = this._optionItems.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
OptionsItem item = enumerator.get_Current().get_Value();
if ((item.ControlAvailable && item.OptionsControl.Modified) && !item.OptionsControl.CheckUserInput())
{
return false;
}
}
}
finally
{
enumerator.Dispose();
}
List<IOptionsControl> contextForUi = new List<IOptionsControl>();
AsyncBizOperation op = new AsyncBizOperation(contextForUi);
op.ImpsError += new EventHandler<ImpsErrorEventArgs>(this, (IntPtr) this.opUpdate_ImpsError);
Dictionary<int, OptionsItem>.Enumerator enumerator2 = this._optionItems.GetEnumerator();
try
{
while (enumerator2.MoveNext())
{
OptionsItem item2 = enumerator2.get_Current().get_Value();
if (item2.ControlAvailable && item2.OptionsControl.Modified)
{
if (!item2.OptionsControl.UpdateData(update))
{
return false;
}
contextForUi.Add(item2.OptionsControl);
}
}
}
finally
{
enumerator2.Dispose();
}
List<ICommittable>.Enumerator enumerator3 = this._commitableItems.GetEnumerator();
try
{
while (enumerator3.MoveNext())
{
if (!enumerator3.get_Current().CommitChanges(op))
{
return false;
}
}
}
finally
{
enumerator3.Dispose();
}
UserAccounts.SaveToLocal();
}
else
{
Dictionary<int, OptionsItem>.Enumerator enumerator4 = this._optionItems.GetEnumerator();
try
{
while (enumerator4.MoveNext())
{
OptionsItem item3 = enumerator4.get_Current().get_Value();
if (item3.ControlAvailable)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -