📄 ssstatusreplaycontrol.cs
字号:
namespace Imps.Client.Pc.Options
{
using Imps.Client;
using Imps.Client.Core;
using Imps.Client.Pc;
using Imps.Client.Pc.BizControls;
using Imps.Client.Pc.Controls;
using Imps.Client.Resource;
using Imps.Client.Utils;
using Imps.Common;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
public class SsStatusReplayControl : OptionsControlBase
{
private Dictionary<int, string> _autoReply;
private bool _customizedPresencesChanged;
private IFrameworkWindow _frameworkWnd;
private StatusEditForm _statusEditForm;
private vscroll_widget _vscroll1 = scroll_maker.instance.vscroll();
private vscroll_widget _vscroll2 = scroll_maker.instance.vscroll();
private XButton btnAdd;
private XButton btnDel;
private XButton btnModify;
private CheckBox cbMessageToSMS;
private CheckBox chkAutoOffline;
private CheckBox chkAutoReply;
private CheckBox chkFullScreen;
private CheckBox chkLock;
private CheckBox chkNoAction;
private ColumnHeader columnHeader1;
private IContainer components;
private XComboBox dlReply;
private GroupBox groupBox1;
private GroupBox groupBox2;
private GroupBox groupBox3;
private ImageList imageList;
private XLabel label4;
private XLabel label8;
private XLabel label9;
private ListView lstCustomizedPresence;
private XNumericUpDown nudAway;
private XNumericUpDown numAutoOffline;
private XTextBox txtReply;
public SsStatusReplayControl(IFrameworkWindow iFrameworkWnd)
{
this._frameworkWnd = iFrameworkWnd;
this.InitializeComponent();
base.Controls.Add(this._vscroll1);
this._vscroll1.host = this.lstCustomizedPresence;
this.initAutoReplies();
this.InitPresences();
this.handleUIEvent();
this.SetLimitation();
this._statusEditForm = new StatusEditForm(this.lstCustomizedPresence);
this.imageList.Images.Add("Online", ImpsResources.GetIcon("TrayIcons.tray_online.ico"));
this.imageList.Images.Add("Busy", ImpsResources.GetIcon("TrayIcons.tray_busy.ico"));
this.imageList.Images.Add("Leave", ImpsResources.GetIcon("TrayIcons.tray_away.ico"));
}
private void btnAdd_Click(object sender, EventArgs e)
{
if ((this.lstCustomizedPresence.Items.Count < 5) && (this._statusEditForm.ShowDialog(false) == DialogResult.OK))
{
base.Modified = true;
this._customizedPresencesChanged = true;
this.PressencesChanged();
}
}
private void btnDel_Click(object sender, EventArgs e)
{
UiErrorHelper.HandEventSafely(this._frameworkWnd, delegate {
if (((this.lstCustomizedPresence.SelectedIndices.Count > 0) && (this.lstCustomizedPresence.SelectedIndices[0] >= 0)) && (this._frameworkWnd.UnifiedMessageBox.ShowConfirmation("是否要删除自定义状态?") == DialogResult.Yes))
{
this.lstCustomizedPresence.Items.RemoveAt(this.lstCustomizedPresence.SelectedIndices[0]);
base.Modified = true;
this._customizedPresencesChanged = true;
this.lstCustomizedPresence.Focus();
}
});
}
private void btnModify_Click(object sender, EventArgs e)
{
if (this._statusEditForm.ShowDialog(true) == DialogResult.OK)
{
base.Modified = true;
this._customizedPresencesChanged = true;
this.PressencesChanged();
}
}
public override bool CheckUserInput()
{
if (this.chkAutoReply.Checked && (this.txtReply.Text.Trim().Length == 0))
{
this._frameworkWnd.UnifiedMessageBox.ShowWarning(base.FindForm(), StringTable.Configuration.AutoReplyEmpty);
return false;
}
if (this.chkNoAction.Checked && (this.nudAway.Text.Trim().Length == 0))
{
this._frameworkWnd.UnifiedMessageBox.ShowWarning(base.FindForm(), StringTable.Configuration.NoActionEmpty);
this.nudAway.Focus();
return false;
}
return true;
}
private void chkAutoOffline_CheckedChanged(object sender, EventArgs e)
{
this.numAutoOffline.Enabled = this.chkAutoOffline.Checked;
}
private void chkAutoReply_CheckedChanged(object sender, EventArgs e)
{
this.dlReply.Enabled = this.chkAutoReply.Checked;
this.txtReply.Enabled = this.chkAutoReply.Checked;
}
private void chkNoAction_CheckedChanged(object sender, EventArgs e)
{
this.nudAway.Enabled = this.chkNoAction.Checked;
}
protected override void Dispose(bool disposing)
{
if (this._statusEditForm != null)
{
this._statusEditForm.Dispose();
this._statusEditForm = null;
}
if (disposing && (this.components != null))
{
this.components.Dispose();
}
base.Dispose(disposing);
}
private void dlReply_SelectedIndexChanged(object sender, EventArgs e)
{
int selectedIndex = this.dlReply.SelectedIndex;
this.txtReply.Text = ((this._autoReply.get_Item(selectedIndex) != null) ? this._autoReply.get_Item(selectedIndex) : string.Empty).ToString();
}
private void EnableControls()
{
this.PressencesChanged();
this.btnModify.Enabled = this.lstCustomizedPresence.SelectedIndices.Count > 0;
this.btnDel.Enabled = this.lstCustomizedPresence.SelectedIndices.Count > 0;
}
private void FillCustomizedPresences(CustomPresenceCollection col)
{
this.lstCustomizedPresence.Items.Clear();
using (IEnumerator<CustomPresence> enumerator = col.GetEnumerator())
{
while (enumerator.MoveNext())
{
CustomPresence presence = enumerator.get_Current();
string text = "Online";
switch (presence.BasicPresence)
{
case MainPresence.BeRightBack:
case MainPresence.Away:
case MainPresence.OutToLunch:
text = "Leave";
break;
case MainPresence.Online:
text = "Online";
break;
case MainPresence.OnThePhone:
case MainPresence.Busy:
case MainPresence.DoNotDisturb:
case MainPresence.InTheMeeting:
text = "Busy";
break;
}
ListViewItem item = new ListViewItem(presence.Desccription, text);
item.Tag = new ValueNameDesc<MainPresence>(presence.BasicPresence, presence.Desccription);
this.lstCustomizedPresence.Items.Add(item);
}
}
}
private void handleUIEvent()
{
this.chkAutoReply.CheckedChanged += new EventHandler(this.uiData_Changed);
this.chkFullScreen.CheckedChanged += new EventHandler(this.uiData_Changed);
this.chkLock.CheckedChanged += new EventHandler(this.uiData_Changed);
this.chkNoAction.CheckedChanged += new EventHandler(this.uiData_Changed);
this.txtReply.TextChanged += new EventHandler(this.uiData_Changed);
this.dlReply.SelectedIndexChanged += new EventHandler(this.uiData_Changed);
this.nudAway.ValueChanged += new EventHandler(this.uiData_Changed);
this.nudAway.KeyPress += new KeyPressEventHandler(this.uiData_Changed);
this.nudAway.TextChanged += new EventHandler(this.uiData_Changed);
this.numAutoOffline.ValueChanged += new EventHandler(this.uiData_Changed);
this.numAutoOffline.KeyPress += new KeyPressEventHandler(this.uiData_Changed);
this.chkAutoOffline.CheckedChanged += new EventHandler(this.uiData_Changed);
this.cbMessageToSMS.CheckedChanged += new EventHandler(this.uiData_Changed);
this.lstCustomizedPresence.SelectedIndexChanged += new EventHandler(this.lstCustomizedPresence_SelectedIndexChanged);
}
private void initAutoReplies()
{
this._autoReply = new Dictionary<int, string>();
this._autoReply.Add(0, this.CurrentUser.Configuration.UserSetting.AutoReplies[0] ?? string.Empty);
this._autoReply.Add(1, this.CurrentUser.Configuration.UserSetting.AutoReplies[1] ?? string.Empty);
this._autoReply.Add(2, this.CurrentUser.Configuration.UserSetting.AutoReplies[2] ?? string.Empty);
this._autoReply.Add(3, this.CurrentUser.Configuration.UserSetting.AutoReplies[3] ?? string.Empty);
this._autoReply.Add(4, this.CurrentUser.Configuration.UserSetting.AutoReplies[4] ?? string.Empty);
this.dlReply.Items.Clear();
for (int i = 0; i < this._autoReply.get_Count(); i++)
{
int num2 = i + 1;
this.dlReply.Items.Add(num2.ToString());
}
this.chkAutoReply.Enabled = this.CurrentUser.Status == UserAccountStatus.Logon;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -