📄 statuseditform.cs
字号:
namespace Imps.Client.Pc.Options
{
using Imps.Client.Pc;
using Imps.Client.Pc.BizControls;
using Imps.Client.Pc.Controls;
using Imps.Client.Pc.Utils;
using Imps.Common;
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
public class StatusEditForm : XIMDialog
{
private MainPresence _baseStatus;
private ListView _lstCustomizedPresence;
private bool _modified;
private string _statusName;
private XButton btnCancel;
private XButton btnOk;
private IContainer components;
private Label label1;
private Label label2;
private Panel panel1;
private RadioButton rbBusy;
private RadioButton rbLeave;
private RadioButton rbOnline;
private XTextBox tbCustomTo;
public StatusEditForm(ListView lstCustomizedPresence)
{
this.InitializeComponent();
this._lstCustomizedPresence = lstCustomizedPresence;
this.tbCustomTo.MaxLength = 0x40;
}
private void btnCancel_Click(object sender, EventArgs e)
{
base.DialogResult = DialogResult.Cancel;
base.Close();
}
private void btnOk_Click(object sender, EventArgs e)
{
this._statusName = this.tbCustomTo.Text;
if (string.IsNullOrEmpty(this._statusName.Trim()))
{
BalloonHelper.ShowInputErrorBallon(this.tbCustomTo, "必须输入状态名称!");
}
else
{
string text = "Online";
if (this.rbOnline.Checked)
{
this._baseStatus = MainPresence.Online;
text = "Online";
}
else if (this.rbBusy.Checked)
{
this._baseStatus = MainPresence.Busy;
text = "Busy";
}
else if (this.rbLeave.Checked)
{
this._baseStatus = MainPresence.Away;
text = "Leave";
}
else
{
BalloonHelper.ShowInputErrorBallon(this.rbOnline, "必须选择一个系统状态!");
return;
}
if (this._modified)
{
int num = this.IndexOfCustomizedPresence(this._statusName);
if ((num >= 0) && (num != this._lstCustomizedPresence.SelectedIndices[0]))
{
BalloonHelper.ShowInputErrorBallon(this.tbCustomTo, "不能定义同名的自定义状态!");
return;
}
int index = this._lstCustomizedPresence.SelectedIndices[0];
this._lstCustomizedPresence.SuspendLayout();
this._lstCustomizedPresence.Items.RemoveAt(index);
ListViewItem item = new ListViewItem(this._statusName, text);
item.Tag = new ValueNameDesc<MainPresence>(this._baseStatus, this._statusName);
this._lstCustomizedPresence.Items.Insert(index, item);
this._lstCustomizedPresence.SelectedIndices.Clear();
this._lstCustomizedPresence.SelectedIndices.Add(index);
this._lstCustomizedPresence.ResumeLayout();
}
else
{
if (this.ContainsCustomizedPresence(this._statusName))
{
BalloonHelper.ShowInputErrorBallon(this.tbCustomTo, "不能定义同名的自定义状态!");
return;
}
this._lstCustomizedPresence.SelectedIndices.Clear();
ListViewItem item2 = new ListViewItem(this._statusName, text);
item2.Tag = new ValueNameDesc<MainPresence>(this._baseStatus, this._statusName);
item2.Selected = true;
this._lstCustomizedPresence.Items.Add(item2);
this.tbCustomTo.Text = string.Empty;
}
base.DialogResult = DialogResult.OK;
base.Close();
}
}
private bool ContainsCustomizedPresence(string desc)
{
return (this.IndexOfCustomizedPresence(desc) >= 0);
}
protected override void Dispose(bool disposing)
{
if (disposing && (this.components != null))
{
this.components.Dispose();
}
base.Dispose(disposing);
}
private int IndexOfCustomizedPresence(string desc)
{
for (int i = 0; i < this._lstCustomizedPresence.Items.Count; i++)
{
ValueNameDesc<MainPresence> tag = (ValueNameDesc<MainPresence>) this._lstCustomizedPresence.Items[i].Tag;
if (tag.Name == desc)
{
return i;
}
}
return -1;
}
private void InitializeComponent()
{
ComponentResourceManager manager = new ComponentResourceManager(typeof(StatusEditForm));
this.panel1 = new Panel();
this.rbLeave = new RadioButton();
this.rbBusy = new RadioButton();
this.rbOnline = new RadioButton();
this.tbCustomTo = new XTextBox();
this.label2 = new Label();
this.label1 = new Label();
this.btnCancel = new XButton();
this.btnOk = new XButton();
this.panel1.SuspendLayout();
base.SuspendLayout();
this.panel1.BackColor = Color.Transparent;
this.panel1.Controls.Add(this.rbLeave);
this.panel1.Controls.Add(this.rbBusy);
this.panel1.Controls.Add(this.rbOnline);
this.panel1.Controls.Add(this.tbCustomTo);
this.panel1.Controls.Add(this.label2);
this.panel1.Controls.Add(this.label1);
this.panel1.Location = new System.Drawing.Point(12, 13);
this.panel1.Name = "panel1";
this.panel1.Size = new Size(260, 0x7f);
this.panel1.TabIndex = 0;
this.rbLeave.set_AutoSize(true);
this.rbLeave.Location = new System.Drawing.Point(0x56, 0x62);
this.rbLeave.Name = "rbLeave";
this.rbLeave.Size = new Size(0x31, 0x11);
this.rbLeave.TabIndex = 5;
this.rbLeave.TabStop = true;
this.rbLeave.Text = "离开";
this.rbLeave.set_UseVisualStyleBackColor(true);
this.rbBusy.set_AutoSize(true);
this.rbBusy.Location = new System.Drawing.Point(0x56, 0x4a);
this.rbBusy.Name = "rbBusy";
this.rbBusy.Size = new Size(0x31, 0x11);
this.rbBusy.TabIndex = 4;
this.rbBusy.TabStop = true;
this.rbBusy.Text = "忙碌";
this.rbBusy.set_UseVisualStyleBackColor(true);
this.rbOnline.set_AutoSize(true);
this.rbOnline.Location = new System.Drawing.Point(0x56, 50);
this.rbOnline.Name = "rbOnline";
this.rbOnline.Size = new Size(0x31, 0x11);
this.rbOnline.TabIndex = 3;
this.rbOnline.TabStop = true;
this.rbOnline.Text = "在线";
this.rbOnline.set_UseVisualStyleBackColor(true);
this.tbCustomTo.BackColor = Color.White;
this.tbCustomTo.BorderStyle = BorderStyle.FixedSingle;
this.tbCustomTo.EmptyTextTip = "请输入状态名称";
this.tbCustomTo.EmptyTextTipColor = Color.DarkGray;
this.tbCustomTo.Location = new System.Drawing.Point(0x56, 0x12);
this.tbCustomTo.Name = "tbCustomTo";
this.tbCustomTo.Size = new Size(0xa7, 20);
this.tbCustomTo.TabIndex = 2;
this.label2.set_AutoSize(true);
this.label2.Location = new System.Drawing.Point(15, 0x34);
this.label2.Name = "label2";
this.label2.Size = new Size(0x43, 13);
this.label2.TabIndex = 1;
this.label2.Text = "系统状态:";
this.label1.set_AutoSize(true);
this.label1.Location = new System.Drawing.Point(15, 0x16);
this.label1.Name = "label1";
this.label1.Size = new Size(0x43, 13);
this.label1.TabIndex = 0;
this.label1.Text = "状态名称:";
this.btnCancel.AutoArrangementX = true;
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(0xc5, 0x92);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new Size(0x4b, 0x19);
this.btnCancel.TabIndex = 7;
this.btnCancel.Text = "取消";
this.btnCancel.set_UseVisualStyleBackColor(false);
this.btnCancel.Click += new EventHandler(this.btnCancel_Click);
this.btnOk.AutoArrangementX = true;
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.Location = new System.Drawing.Point(0x74, 0x92);
this.btnOk.Name = "btnOk";
this.btnOk.Size = new Size(0x4b, 0x19);
this.btnOk.TabIndex = 6;
this.btnOk.Text = "确定";
this.btnOk.set_UseVisualStyleBackColor(false);
this.btnOk.Click += new EventHandler(this.btnOk_Click);
base.AcceptButton = this.btnOk;
base.set_AutoScaleDimensions(new SizeF(6f, 13f));
base.set_AutoScaleMode(1);
base.BaseHeight = 0x138;
base.BaseWidth = 0x119;
base.CancelButton = this.btnCancel;
base.ClientSize = new Size(0x119, 0x138);
base.Controls.Add(this.panel1);
base.Controls.Add(this.btnOk);
base.Controls.Add(this.btnCancel);
base.DisplayLocation = new System.Drawing.Point(0x12, 0x26);
base.DisplaySize = new Size(0x119, 0x138);
base.Icon = (Icon) manager.GetObject("$this.Icon");
base.MinimizeBox = false;
base.Name = "StatusEditForm";
base.set_Padding(new Padding(1, 0x18, 13, 4));
base.ShowInTaskbar = false;
base.StartPosition = FormStartPosition.CenterParent;
base.Text = "设置状态";
this.panel1.ResumeLayout(false);
this.panel1.PerformLayout();
base.ResumeLayout(false);
}
public DialogResult ShowDialog(bool modified)
{
this._modified = modified;
if (modified && (this._lstCustomizedPresence.SelectedItems.Count > 0))
{
ValueNameDesc<MainPresence> tag = (ValueNameDesc<MainPresence>) this._lstCustomizedPresence.SelectedItems[0].Tag;
this.tbCustomTo.Text = tag.Name;
switch (tag.Value)
{
case MainPresence.BeRightBack:
case MainPresence.Away:
case MainPresence.OutToLunch:
this.rbBusy.Checked = false;
this.rbOnline.Checked = false;
this.rbLeave.Checked = true;
goto Label_0169;
case MainPresence.Online:
this.rbLeave.Checked = false;
this.rbBusy.Checked = false;
this.rbOnline.Checked = true;
goto Label_0169;
case MainPresence.OnThePhone:
case MainPresence.Busy:
case MainPresence.DoNotDisturb:
case MainPresence.InTheMeeting:
this.rbLeave.Checked = false;
this.rbOnline.Checked = false;
this.rbBusy.Checked = true;
goto Label_0169;
}
}
else
{
this.tbCustomTo.Text = string.Empty;
this.rbLeave.Checked = false;
this.rbOnline.Checked = false;
this.rbBusy.Checked = false;
}
Label_0169:
return base.ShowDialog();
}
public MainPresence BaseStatus
{
get
{
return this._baseStatus;
}
set
{
this._baseStatus = value;
}
}
public string StatusName
{
get
{
return this._statusName;
}
set
{
this._statusName = value;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -