📄 contactgroupform.cs
字号:
namespace Imps.Client.Pc.UIContactList
{
using Imps.Client.Core;
using Imps.Client.Pc;
using Imps.Client.Pc.BizControls;
using Imps.Client.Pc.Controls;
using Imps.Client.Resource;
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
public class ContactGroupForm : XIMDialog
{
private bool _canClose;
private int? _groupId;
private IFrameworkWindow _iFrameworkWindow;
private bool _isFrist = true;
private AsyncBizOperation _op;
private Imps.Client.Core.User _user;
private XButton buttonCancel;
private XButton buttonOK;
private IContainer components;
private XLabel labelName;
private Panel panel1;
private XTextBox textBoxName;
public ContactGroupForm(IFrameworkWindow iFrameworkWindow, int? groupId, AsyncBizOperation op)
{
this.InitializeComponent();
this.initComponentRegion();
this._iFrameworkWindow = iFrameworkWindow;
this._user = this._iFrameworkWindow.AccountManager.CurrentUser;
this._groupId = groupId;
if (op == null)
{
op = new AsyncBizOperation();
}
this._op = op;
this.textBoxName.MaxLength = 0x40;
}
private void buttonCancel_Click(object sender, EventArgs e)
{
base.Close();
}
private void buttonOK_Click(object sender, EventArgs e)
{
string newName = this.textBoxName.Text.Trim();
if (newName.Length == 0)
{
this._iFrameworkWindow.UnifiedMessageBox.ShowError(this, StringTable.ContactGroup.MsgAddGroupNameEmpty);
this._canClose = false;
}
else if (newName.Length > 0x40)
{
this._iFrameworkWindow.UnifiedMessageBox.ShowError(this, StringTable.ContactGroup.MsgAddGroupNameTooLong);
this._canClose = false;
}
else if (this._groupId.get_HasValue())
{
Imps.Client.Core.ContactGroup group = this._user.ContactList.Groups.FindContactGroup(this._groupId) as Imps.Client.Core.ContactGroup;
if (group == null)
{
this._iFrameworkWindow.UnifiedMessageBox.ShowError(this, StringTable.ContactGroup.MsgNotExist);
}
else
{
this._canClose = group.AsyncUpdate(newName, this._op);
}
}
else if (newName == StringTable.ContactGroup.ChatFriendGroup)
{
this._iFrameworkWindow.UnifiedMessageBox.ShowError(this, StringTable.ContactGroup.NotAllowFixedGroupName);
}
else
{
this._canClose = this._user.ContactList.AsyncAddGroup(newName, this._op);
}
}
private void ContactGroupForm_Load(object sender, EventArgs e)
{
this.labelName.Text = StringTable.ContactGroup.InputGroupName;
this._isFrist = true;
if (!this._groupId.get_HasValue())
{
base.Text = StringTable.ContactGroup.TitleText_New;
this.textBoxName.Text = "";
}
else
{
base.Text = StringTable.ContactGroup.TitleText_Rename;
Imps.Client.Core.ContactGroup group = this._user.ContactList.Groups.FindContactGroup(this._groupId) as Imps.Client.Core.ContactGroup;
if (group == null)
{
this._iFrameworkWindow.UnifiedMessageBox.ShowError(StringTable.ContactGroup.MsgNotExist);
}
else
{
this.textBoxName.Text = group.Name;
}
}
}
protected override void Dispose(bool disposing)
{
if (disposing && (this.components != null))
{
this.components.Dispose();
}
base.Dispose(disposing);
}
private void InitializeComponent()
{
this.textBoxName = new XTextBox();
this.buttonCancel = new XButton();
this.buttonOK = new XButton();
this.labelName = new XLabel();
this.panel1 = new Panel();
this.panel1.SuspendLayout();
base.SuspendLayout();
this.textBoxName.BackColor = Color.White;
this.textBoxName.BorderStyle = BorderStyle.FixedSingle;
this.textBoxName.EmptyTextTip = "";
this.textBoxName.EmptyTextTipColor = Color.DarkGray;
this.textBoxName.Location = new System.Drawing.Point(0x42, 0x2b);
this.textBoxName.MaxLength = 0x40;
this.textBoxName.Name = "textBoxName";
this.textBoxName.Size = new Size(0xc1, 20);
this.textBoxName.TabIndex = 5;
this.buttonCancel.AutoArrangementX = false;
this.buttonCancel.AutoSizeToImage = false;
this.buttonCancel.BackColor = Color.Transparent;
this.buttonCancel.BackgroundImageDisable = null;
this.buttonCancel.BackgroundImageDown = null;
this.buttonCancel.BackgroundImageHover = null;
this.buttonCancel.ChangeSkin = true;
this.buttonCancel.DialogResult = DialogResult.Cancel;
this.buttonCancel.Location = new System.Drawing.Point(190, 0x76);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new Size(0x4b, 0x17);
this.buttonCancel.TabIndex = 15;
this.buttonCancel.Text = "取消";
this.buttonCancel.set_UseVisualStyleBackColor(false);
this.buttonCancel.Click += new EventHandler(this.buttonCancel_Click);
this.buttonOK.AutoArrangementX = false;
this.buttonOK.set_AutoEllipsis(true);
this.buttonOK.AutoSizeToImage = false;
this.buttonOK.BackColor = Color.Transparent;
this.buttonOK.BackgroundImageDisable = null;
this.buttonOK.BackgroundImageDown = null;
this.buttonOK.BackgroundImageHover = null;
this.buttonOK.ChangeSkin = true;
this.buttonOK.DialogResult = DialogResult.OK;
this.buttonOK.Location = new System.Drawing.Point(0x6d, 0x76);
this.buttonOK.Name = "buttonOK";
this.buttonOK.Size = new Size(0x4b, 0x17);
this.buttonOK.TabIndex = 10;
this.buttonOK.Text = "确定";
this.buttonOK.set_UseVisualStyleBackColor(false);
this.buttonOK.Click += new EventHandler(this.buttonOK_Click);
this.labelName.set_AutoSize(true);
this.labelName.BackColor = Color.Transparent;
this.labelName.BorderColor = Color.Empty;
this.labelName.ButtonBorderStyle = ButtonBorderStyle.None;
this.labelName.Location = new System.Drawing.Point(15, 0x2d);
this.labelName.Name = "labelName";
this.labelName.Size = new Size(0x37, 13);
this.labelName.TabIndex = 0x27;
this.labelName.Text = "组名称:";
this.panel1.BackColor = Color.Transparent;
this.panel1.Controls.Add(this.textBoxName);
this.panel1.Controls.Add(this.labelName);
this.panel1.Location = new System.Drawing.Point(8, 8);
this.panel1.Name = "panel1";
this.panel1.Size = new Size(0x11b, 0x68);
this.panel1.TabIndex = 40;
base.AcceptButton = this.buttonOK;
base.set_AutoScaleDimensions(new SizeF(6f, 13f));
base.set_AutoScaleMode(1);
base.BaseHeight = 0xae;
base.BaseWidth = 0x12e;
base.CancelButton = this.buttonCancel;
base.ClientSize = new Size(0x128, 0x94);
base.Controls.Add(this.panel1);
base.Controls.Add(this.buttonCancel);
base.Controls.Add(this.buttonOK);
base.DisplayLocation = new System.Drawing.Point(0x12, 0x26);
base.MinimizeBox = false;
base.Name = "ContactGroupForm";
base.set_Padding(new Padding(8));
base.ShowInTaskbar = false;
base.StartPosition = FormStartPosition.Manual;
base.Text = "管理组";
base.Load += new EventHandler(this.ContactGroupForm_Load);
this.panel1.ResumeLayout(false);
this.panel1.PerformLayout();
base.ResumeLayout(false);
}
protected override void OnActivated(EventArgs e)
{
base.OnActivated(e);
if (this._isFrist)
{
this.textBoxName.Focus();
this._isFrist = false;
}
}
protected override void OnClosing(CancelEventArgs e)
{
if ((base.DialogResult == DialogResult.OK) && !this._canClose)
{
e.Cancel = true;
}
}
public int? GroupId
{
get
{
return this._groupId;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -