📄 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.Pc.Utils;
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 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 chkAutoOffline;
private CheckBox chkAutoReply;
private CheckBox chkFullScreen;
private CheckBox chkLock;
private CheckBox chkNoAction;
private IContainer components;
private XComboBox dlReply;
private XLabel label1;
private XLabel label2;
private XLabel label4;
private XLabel label5;
private XLabel label7;
private XLabel label8;
private XLabel label9;
private XLabel lbMainPresence;
private ListBox lstCustomizedPresence;
private ListBox lstMainPresences;
private XNumericUpDown nudAway;
private XNumericUpDown numAutoOffline;
private XTextBox tbCustomTo;
private XTextBox txtReply;
public SsStatusReplayControl(IFrameworkWindow iFrameworkWnd)
{
this._frameworkWnd = iFrameworkWnd;
this.InitializeComponent();
base.Controls.Add(this._vscroll1);
this._vscroll1.host = this.lstCustomizedPresence;
base.Controls.Add(this._vscroll2);
this._vscroll2.host = this.lstMainPresences;
this.initAutoReplies();
this.InitPresences();
this.tbCustomTo.MaxLength = 0x40;
this.handleUIEvent();
this.SetLimitation();
}
private void btnAdd_Click(object sender, EventArgs e)
{
UiErrorHelper.HandEventSafely(this._frameworkWnd, delegate {
if (this.lstCustomizedPresence.Items.Count >= 5)
{
BalloonHelper.ShowInputErrorBallon(this.lstCustomizedPresence, "只能设置5个自定义状态!");
}
else
{
string desc = this.tbCustomTo.Text.Trim();
if ((str.Length > 0) && (this.lstMainPresences.SelectedIndex >= 0))
{
MainPresence selectedValue = (MainPresence) this.lstMainPresences.SelectedValue;
if (this.ContainsCustomizedPresence(str))
{
BalloonHelper.ShowInputErrorBallon(this.tbCustomTo, "不能定义同名的自定义状态!");
}
else
{
ValueNameDesc<MainPresence> item = new ValueNameDesc<MainPresence>(selectedValue, str);
int num = this.lstCustomizedPresence.Items.Add(item);
this.lstCustomizedPresence.SelectedIndex = num;
this.tbCustomTo.Text = string.Empty;
base.Modified = true;
this._customizedPresencesChanged = true;
this.tbCustomTo.Focus();
}
}
}
});
}
private void btnDel_Click(object sender, EventArgs e)
{
UiErrorHelper.HandEventSafely(this._frameworkWnd, delegate {
if (this.lstCustomizedPresence.SelectedIndex >= 0)
{
this.lstCustomizedPresence.Items.RemoveAt(this.lstCustomizedPresence.SelectedIndex);
this.lstCustomizedPresence.ClearSelected();
this.lstMainPresences.SelectedValue = MainPresence.Away;
base.Modified = true;
this._customizedPresencesChanged = true;
this.lstCustomizedPresence.Focus();
}
});
}
private void btnModify_Click(object sender, EventArgs e)
{
UiErrorHelper.HandEventSafely(this._frameworkWnd, delegate {
string desc = this.tbCustomTo.Text.Trim();
if ((str.Length > 0) && (this.lstCustomizedPresence.SelectedIndex >= 0))
{
ValueNameDesc<MainPresence> selectedItem = (ValueNameDesc<MainPresence>) this.lstCustomizedPresence.SelectedItem;
MainPresence selectedValue = (MainPresence) this.lstMainPresences.SelectedValue;
if ((str != selectedItem.Name) || (selectedValue != ((MainPresence) selectedItem.Value)))
{
int num = this.IndexOfCustomizedPresence(str);
if ((num >= 0) && (num != this.lstCustomizedPresence.SelectedIndex))
{
BalloonHelper.ShowInputErrorBallon(this.tbCustomTo, "不能定义同名的自定义状态!");
}
else
{
int index = this.lstCustomizedPresence.SelectedIndex;
this.lstCustomizedPresence.SuspendLayout();
this.lstCustomizedPresence.Items.RemoveAt(selectedIndex);
this.lstCustomizedPresence.Items.Insert(selectedIndex, new ValueNameDesc<MainPresence>(selectedValue, str));
this.lstCustomizedPresence.SelectedIndex = selectedIndex;
this.lstCustomizedPresence.ResumeLayout();
base.Modified = true;
this._customizedPresencesChanged = true;
this.tbCustomTo.Focus();
}
}
}
});
}
public override bool CheckUserInput()
{
if (this.chkAutoReply.Checked && (this.txtReply.Text.Trim().Length == 0))
{
this._frameworkWnd.UnifiedMessageBox.ShowWarning(StringTable.Configuration.AutoReplyEmpty);
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;
}
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 void dlReply_SelectedIndexChanged(object sender, EventArgs e)
{
int selectedIndex = this.dlReply.SelectedIndex;
this.txtReply.Text = ((this._autoReply[selectedIndex] != null) ? this._autoReply[selectedIndex] : string.Empty).ToString();
}
private void EnableControls()
{
ValueNameDesc<MainPresence> selectedItem = (ValueNameDesc<MainPresence>) this.lstCustomizedPresence.SelectedItem;
string str = (selectedItem == null) ? string.Empty : selectedItem.Name;
MainPresence presence = (selectedItem == null) ? MainPresence.Unknown : selectedItem.Value;
string str2 = this.tbCustomTo.Text.Trim();
this.btnAdd.Enabled = ((str2.Length > 0) && (this.lstMainPresences.SelectedIndex >= 0)) && !str2.Equals(str);
this.btnModify.Enabled = (((str2.Length > 0) && (this.lstMainPresences.SelectedIndex >= 0)) && (this.lstCustomizedPresence.SelectedIndex >= 0)) && (!str2.Equals(str) || (presence != ((MainPresence) this.lstMainPresences.SelectedValue)));
this.btnDel.Enabled = this.lstCustomizedPresence.SelectedIndex >= 0;
}
private void FillCustomizedPresences(CustomPresenceCollection col)
{
this.lstCustomizedPresence.Items.Clear();
foreach (CustomPresence presence in col)
{
this.lstCustomizedPresence.Items.Add(new ValueNameDesc<MainPresence>(presence.BasicPresence, presence.Desccription));
}
}
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.numAutoOffline.ValueChanged += new EventHandler(this.uiData_Changed);
this.numAutoOffline.KeyPress += new KeyPressEventHandler(this.uiData_Changed);
this.chkAutoOffline.CheckedChanged += new EventHandler(this.uiData_Changed);
this.tbCustomTo.TextChanged += new EventHandler(this.uiCustomizedPresence_DataChanged);
this.lstMainPresences.SelectedIndexChanged += new EventHandler(this.uiCustomizedPresence_DataChanged);
this.lstCustomizedPresence.SelectedIndexChanged += new EventHandler(this.lstCustomizedPresence_SelectedIndexChanged);
}
private int IndexOfCustomizedPresence(string desc)
{
for (int i = 0; i < this.lstCustomizedPresence.Items.Count; i++)
{
ValueNameDesc<MainPresence> desc2 = (ValueNameDesc<MainPresence>) this.lstCustomizedPresence.Items[i];
if (desc2.Name == desc)
{
return i;
}
}
return -1;
}
private void initAutoReplies()
{
this._autoReply = new Dictionary<int, string>();
this._autoReply.Add(0, (this.CurrentUser.Configuration.UserSetting.AutoReplies[0] != null) ? this.CurrentUser.Configuration.UserSetting.AutoReplies[0] : string.Empty);
this._autoReply.Add(1, (this.CurrentUser.Configuration.UserSetting.AutoReplies[1] != null) ? this.CurrentUser.Configuration.UserSetting.AutoReplies[1] : string.Empty);
this._autoReply.Add(2, (this.CurrentUser.Configuration.UserSetting.AutoReplies[2] != null) ? this.CurrentUser.Configuration.UserSetting.AutoReplies[2] : string.Empty);
this._autoReply.Add(3, (this.CurrentUser.Configuration.UserSetting.AutoReplies[3] != null) ? this.CurrentUser.Configuration.UserSetting.AutoReplies[3] : string.Empty);
this._autoReply.Add(4, (this.CurrentUser.Configuration.UserSetting.AutoReplies[4] != null) ? this.CurrentUser.Configuration.UserSetting.AutoReplies[4] : string.Empty);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -