📄 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 pnlContainer;
private Panel pnlOptions;
public OptionsForm(IFrameworkWindow host)
{
this._frameworkWnd = host;
host.AccountManager.CurrentUser.StatusChanged += new EventHandler<UserSatusChangedEventArgs>(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.btnApply = new XButton();
this.btnCancel = new XButton();
this.btnOk = new XButton();
this.pnlOptions = new Panel();
this.pnlContainer.SuspendLayout();
base.SuspendLayout();
base.menubar.Location = new Point(3, 0x17);
this.pnlContainer.BackColor = Color.Transparent;
this.pnlContainer.Controls.Add(this.btnApply);
this.pnlContainer.Controls.Add(this.btnCancel);
this.pnlContainer.Controls.Add(this.btnOk);
this.pnlContainer.Controls.Add(this.pnlOptions);
this.pnlContainer.Dock = DockStyle.Fill;
this.pnlContainer.Location = new Point(3, 3);
this.pnlContainer.Name = "pnlContainer";
this.pnlContainer.Padding = new Padding(2);
this.pnlContainer.Size = new Size(0x1fc, 0x206);
this.pnlContainer.TabIndex = 4;
this.btnApply.Anchor = AnchorStyles.None;
this.btnApply.Location = new Point(0x192, 0x1d1);
this.btnApply.Name = "btnApply";
this.btnApply.Size = new Size(0x4b, 0x17);
this.btnApply.TabIndex = 3;
this.btnApply.UseVisualStyleBackColor = true;
this.btnApply.Click += new EventHandler(this.btnApply_Click);
this.btnCancel.Anchor = AnchorStyles.None;
this.btnCancel.DialogResult = DialogResult.Cancel;
this.btnCancel.Location = new Point(0x141, 0x1d1);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new Size(0x4b, 0x17);
this.btnCancel.TabIndex = 2;
this.btnCancel.UseVisualStyleBackColor = true;
this.btnCancel.Click += new EventHandler(this.btnCancel_Click);
this.btnOk.Anchor = AnchorStyles.None;
this.btnOk.DialogResult = DialogResult.OK;
this.btnOk.Location = new Point(240, 0x1d1);
this.btnOk.Name = "btnOk";
this.btnOk.Size = new Size(0x4b, 0x17);
this.btnOk.TabIndex = 1;
this.btnOk.UseVisualStyleBackColor = true;
this.btnOk.Click += new EventHandler(this.btnOk_Click);
this.pnlOptions.Anchor = AnchorStyles.None;
this.pnlOptions.Location = new Point(130, 0x16);
this.pnlOptions.Name = "pnlOptions";
this.pnlOptions.Size = new Size(0x16b, 0x1b1);
this.pnlOptions.TabIndex = 0;
base.AcceptButton = this.btnOk;
base.AutoScaleDimensions = new SizeF(6f, 13f);
base.AutoScaleMode = AutoScaleMode.Font;
base.CancelButton = this.btnCancel;
base.ClientSize = new Size(0x202, 0x20c);
base.Controls.Add(this.pnlContainer);
base.Icon = (Icon) manager.GetObject("$this.Icon");
base.MinimizeBox = false;
base.Name = "OptionsForm";
base.Padding = new Padding(3);
base.StartPosition = FormStartPosition.CenterParent;
base.ShowInTaskbar = false;
base.Load += new EventHandler(this.OptionsForm_Load);
base.Controls.SetChildIndex(base.menubar, 0);
base.Controls.SetChildIndex(this.pnlContainer, 0);
this.pnlContainer.ResumeLayout(false);
base.ResumeLayout(false);
}
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 = 0;
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 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 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 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 Point(6, 6);
this.m_slider_pane.Size = new Size(110, base.ClientRectangle.Height - 0x11);
this.pnlContainer.Controls.Add(this.m_system_options);
this.pnlContainer.Controls.Add(this.m_personal_options);
this.pnlContainer.Controls.Add(this.m_default_options);
this.pnlContainer.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)
{
foreach (KeyValuePair<int, OptionsItem> pair in this._optionItems)
{
if (pair.Value.Name == name)
{
return pair.Key;
}
}
return -1;
}
private bool InnerUpdateOptionsControl(bool update)
{
if (update)
{
Dictionary<int, OptionsItem>.Enumerator enumerator = this._optionItems.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
OptionsItem item = enumerator.Current.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.opUpdate_ImpsError);
Dictionary<int, OptionsItem>.Enumerator enumerator2 = this._optionItems.GetEnumerator();
try
{
while (enumerator2.MoveNext())
{
OptionsItem item2 = enumerator2.Current.Value;
if (item2.ControlAvailable && item2.OptionsControl.Modified)
{
if (!item2.OptionsControl.UpdateData(update))
{
return false;
}
contextForUi.Add(item2.OptionsControl);
}
}
}
finally
{
enumerator2.Dispose();
}
foreach (ICommittable committable in this._commitableItems)
{
if (!committable.CommitChanges(op))
{
return false;
}
}
UserAccounts.SaveToLocal();
}
else
{
Dictionary<int, OptionsItem>.Enumerator enumerator4 = this._optionItems.GetEnumerator();
try
{
while (enumerator4.MoveNext())
{
OptionsItem item3 = enumerator4.Current.Value;
if (item3.ControlAvailable)
{
item3.OptionsControl.UpdateData(update);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -