📄 blacklistaddform.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.Pc.WndlessControls;
using Imps.Client.Resource;
using Imps.Client.Utils;
using Imps.Common;
using Imps.Utils;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Text.RegularExpressions;
using System.Windows.Forms;
public class BlackListAddForm : XIMDialog
{
private WndlessControlCollection _controlCollection;
private IFrameworkWindow _frameworkWindow;
private Imps.Client.Core.Contact _lastContact;
private Imps.Client.Core.User _user;
private IContainer components;
private GroupBox groupBox1;
private GroupBox groupBox2;
private LinkLabel linkLabelDetail;
private Label lNickName;
private Panel panel1;
private WndlessPortrait pictureBoxPortrait;
private RadioButton rbMobile;
private RadioButton rbSID;
private XTextBox tbMobile;
private XTextBox tbSid;
private XButton xbCancel;
private XButton xbOK;
public BlackListAddForm(IFrameworkWindow frameworkWindow)
{
this.InitializeComponent();
this.InitializeWndlessControl();
this._frameworkWindow = frameworkWindow;
this._user = this._frameworkWindow.AccountManager.CurrentUser;
this._user.StatusChanged += new EventHandler<UserSatusChangedEventArgs>(this, (IntPtr) this._user_StatusChanged);
this.clearContactInfo();
}
private void _user_StatusChanged(object sender, UserSatusChangedEventArgs e)
{
if (((e.NewStatus == UserAccountStatus.Disconnected) || (e.NewStatus == UserAccountStatus.Logoff)) || (e.NewStatus == UserAccountStatus.Logouting))
{
base.Close();
}
}
private void clearContactInfo()
{
this.lNickName.Text = string.Empty;
this.pictureBoxPortrait.Visible = false;
this.pictureBoxPortrait.Image = ImpsPortrait.GetDefaultPortrait(0x18, 0x18);
this.linkLabelDetail.Visible = false;
}
private void contactInfo_PropertiesChanged(object sender, PropertiesChangedEventArgs e)
{
if (e.ContainsProperty("nickname"))
{
this.showContactInfo(((Imps.Client.Core.ContactInfo) sender).Owner.PersonalInfo);
}
else if (e.ContainsProperty("Provision"))
{
this.showContactInfo(((Imps.Client.Core.ContactInfo) sender).Owner.PersonalInfo);
}
}
protected override void Dispose(bool disposing)
{
if (disposing && (this.components != null))
{
this.components.Dispose();
}
base.Dispose(disposing);
}
private void findContactByMobileOrSid(bool isMobileNo)
{
IicUri uri;
Imps.Client.Core.Contact contact;
this.LastContact = null;
AsyncBizOperation op = new AsyncBizOperation();
op.IsImpsErrorHandled = true;
if (isMobileNo)
{
if (!ImpsHelper.IsCmccMobileNo(this.tbMobile.Text))
{
return;
}
if (this.tbMobile.Text.Trim() == this._user.MobileNo)
{
BalloonHelper.ShowInputErrorBallon(this.tbMobile, "不能添加自己!");
return;
}
uri = IicUri.CreateTelUri(this.tbMobile.Text.Trim());
contact = this._user.ContactList.FindContactByMsisdnEx(uri.MobileNo);
if (contact == null)
{
contact = this._user.ContactList.FindOrCreateContact(uri.Raw, op);
}
}
else
{
if (this.tbSid.Text.Length < 7)
{
return;
}
if (this.tbSid.Text.Trim() == this._user.Uri.Sid.ToString())
{
BalloonHelper.ShowInputErrorBallon(this.tbSid, "不能添加自己!");
return;
}
long sid = Convert.ToInt64(this.tbSid.Text.Trim());
uri = IicUri.CreateSidUri(sid);
contact = this._user.ContactList.FindContact(uri.Raw);
if (contact == null)
{
contact = this._user.ContactList.FindOrCreateContact(sid, op);
}
}
if (contact != null)
{
lock (this._user.BlackList.SyncRoot)
{
using (IEnumerator<IicUri> enumerator = this._user.BlackList.GetEnumerator())
{
while (enumerator.MoveNext())
{
IicUri uri2 = enumerator.get_Current();
if (contact.Uri.Raw == uri2.Raw)
{
if (isMobileNo)
{
BalloonHelper.ShowInputErrorBallon(this.tbMobile, "此联系人已经在黑名单中,无法再次添加联系人!");
}
else
{
BalloonHelper.ShowInputErrorBallon(this.tbSid, "此联系人已经在黑名单中,无法再次添加联系人!");
}
return;
}
}
}
}
this.LastContact = contact;
}
}
private void InitializeComponent()
{
ComponentResourceManager manager = new ComponentResourceManager(typeof(BlackListAddForm));
this.panel1 = new Panel();
this.groupBox1 = new GroupBox();
this.groupBox2 = new GroupBox();
this.lNickName = new Label();
this.linkLabelDetail = new LinkLabel();
this.tbSid = new XTextBox();
this.tbMobile = new XTextBox();
this.rbSID = new RadioButton();
this.rbMobile = new RadioButton();
this.xbOK = new XButton();
this.xbCancel = new XButton();
this.panel1.SuspendLayout();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
base.SuspendLayout();
this.panel1.BackColor = Color.Transparent;
this.panel1.Controls.Add(this.groupBox1);
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new Size(0x123, 0xc5);
this.panel1.TabIndex = 0;
this.groupBox1.BackColor = Color.Transparent;
this.groupBox1.Controls.Add(this.groupBox2);
this.groupBox1.Controls.Add(this.tbSid);
this.groupBox1.Controls.Add(this.tbMobile);
this.groupBox1.Controls.Add(this.rbSID);
this.groupBox1.Controls.Add(this.rbMobile);
this.groupBox1.Location = new System.Drawing.Point(3, 3);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new Size(0x11d, 0xb3);
this.groupBox1.TabIndex = 0;
this.groupBox1.TabStop = false;
this.groupBox2.BackColor = Color.Transparent;
this.groupBox2.Controls.Add(this.lNickName);
this.groupBox2.Controls.Add(this.linkLabelDetail);
this.groupBox2.Location = new System.Drawing.Point(0, 0x65);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new Size(0x11d, 0x4e);
this.groupBox2.TabIndex = 5;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "联系人信息";
this.lNickName.set_AutoEllipsis(true);
this.lNickName.Location = new System.Drawing.Point(0x51, 0x17);
this.lNickName.Name = "lNickName";
this.lNickName.Size = new Size(0xb8, 13);
this.lNickName.TabIndex = 0x1f;
this.lNickName.Text = "昵称:";
this.linkLabelDetail.set_AutoSize(true);
this.linkLabelDetail.LinkColor = Color.Green;
this.linkLabelDetail.Location = new System.Drawing.Point(0x51, 0x31);
this.linkLabelDetail.Name = "linkLabelDetail";
this.linkLabelDetail.Size = new Size(0x37, 13);
this.linkLabelDetail.TabIndex = 30;
this.linkLabelDetail.TabStop = true;
this.linkLabelDetail.Text = "查看资料";
this.linkLabelDetail.LinkClicked += new LinkLabelLinkClickedEventHandler(this.linkLabelDetail_LinkClicked);
this.tbSid.BackColor = Color.White;
this.tbSid.BorderStyle = BorderStyle.FixedSingle;
this.tbSid.EmptyTextTip = "请输入飞信号";
this.tbSid.EmptyTextTipColor = Color.DarkGray;
this.tbSid.Enabled = false;
this.tbSid.ImeMode = ImeMode.Off;
this.tbSid.Location = new System.Drawing.Point(0x53, 0x37);
this.tbSid.MaxLength = 9;
this.tbSid.Name = "tbSid";
this.tbSid.Size = new Size(0xa7, 20);
this.tbSid.TabIndex = 4;
this.tbSid.TextChanged += new EventHandler(this.tbSid_TextChanged);
this.tbMobile.BackColor = Color.White;
this.tbMobile.BorderStyle = BorderStyle.FixedSingle;
this.tbMobile.EmptyTextTip = "请输入手机号";
this.tbMobile.EmptyTextTipColor = Color.DarkGray;
this.tbMobile.ImeMode = ImeMode.Off;
this.tbMobile.Location = new System.Drawing.Point(0x53, 0x16);
this.tbMobile.MaxLength = 11;
this.tbMobile.Name = "tbMobile";
this.tbMobile.Size = new Size(0xa7, 20);
this.tbMobile.TabIndex = 3;
this.tbMobile.TextChanged += new EventHandler(this.tbMobile_TextChanged);
this.rbSID.set_AutoSize(true);
this.rbSID.Location = new System.Drawing.Point(6, 0x37);
this.rbSID.Name = "rbSID";
this.rbSID.Size = new Size(0x49, 0x11);
this.rbSID.TabIndex = 1;
this.rbSID.Text = "飞信号:";
this.rbSID.set_UseVisualStyleBackColor(true);
this.rbSID.CheckedChanged += new EventHandler(this.rbSID_CheckedChanged);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -