📄 receiverequestbymobilenoform.cs
字号:
namespace Imps.Client.Pc.UIContactList.AddBuddy
{
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.WndlessControls;
using Imps.Client.Resource;
using Imps.Common;
using Imps.Utils;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
public class ReceiveRequestByMobileNoForm : XIMDialog
{
private Imps.Client.Core.Contact _contact;
private WndlessControlCollection _controlCollection;
private string _desc;
private bool _hasHandleRequest;
private IFrameworkWindow _iFarmeworkWindow;
private int? _initTargetGroupId;
private WndlessPortrait _pictureBoxPortrait;
private Imps.Client.Core.User _user;
private XButton buttonCancel;
private XButton buttonOK;
private CheckBox checkBoxBlock;
private XComboBox comboBoxGroup;
private IContainer components;
private Label label2;
private Label label3;
private XLabel labelHello;
private XLabel labelRemind;
private LinkLabel linkLabelDetail;
private Panel panel1;
private Panel panelInfo;
private Panel panelMain;
private RadioButton radioButtonAgree;
private RadioButton radioButtonReject;
private TextBox tbDisplayName;
private UButton uButton1;
public ReceiveRequestByMobileNoForm(IFrameworkWindow iFrameworkWindow, Imps.Client.Core.Contact contact, string desc)
{
this.InitializeComponent();
this.InitializeWndlessControl();
base.Controls.SetChildIndex(this.panelMain, 0);
this._iFarmeworkWindow = iFrameworkWindow;
this._user = iFrameworkWindow.AccountManager.CurrentUser;
this._contact = contact;
this._desc = desc;
this._user.StatusChanged += new EventHandler<UserSatusChangedEventArgs>(this, (IntPtr) this._user_StatusChanged);
this._user.ContactList.ContactGroupChanged += new EventHandler<ContactGroupChangedEventArgs>(this, (IntPtr) this.ContactList_ContactGroupChanged);
}
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 buttonCancel_Click(object sender, EventArgs e)
{
try
{
base.Close();
}
catch
{
}
}
private void buttonOK_Click(object sender, EventArgs e)
{
try
{
if (!this.radioButtonAgree.Checked && !this.radioButtonReject.Checked)
{
this._iFarmeworkWindow.UnifiedMessageBox.ShowInfo(StringTable.FormAddBuddy.MustCheckOne);
}
else
{
int? targetGroupId = null;
if (this.radioButtonAgree.Checked && (this.comboBoxGroup.Items.Count > 0))
{
if ((this.comboBoxGroup.SelectedIndex == -1) || (this.comboBoxGroup.SelectedItem == null))
{
this._iFarmeworkWindow.UnifiedMessageBox.ShowInfo(StringTable.FormAddBuddy.MustSelectGroup);
return;
}
ComboBoxItem selectedItem = (ComboBoxItem) this.comboBoxGroup.SelectedItem;
targetGroupId = new int?((int) selectedItem.Value);
if (((int) selectedItem.Value) <= 0)
{
this._iFarmeworkWindow.UnifiedMessageBox.ShowInfo(StringTable.FormAddBuddy.MustSelectGroup);
return;
}
if (Encoding.GetEncoding(0x3a8).GetByteCount(this.tbDisplayName.Text) > 10)
{
this._iFarmeworkWindow.UnifiedMessageBox.ShowInfo(this, StringTable.Contact.AddBuddy_MyNameTooLong);
this.tbDisplayName.Focus();
return;
}
}
int result = this.radioButtonAgree.Checked ? 1 : 0;
this._hasHandleRequest = true;
bool? isBlock = null;
if (result == 0)
{
isBlock = new bool?(this.checkBoxBlock.Checked);
}
AsyncBizOperation op = new AsyncBizOperation();
this._user.ContactList.AsyncHandleContactRequest(this._contact.Uri.ToString(), result, isBlock, targetGroupId, true, this.tbDisplayName.Text, op);
if (this.checkBoxBlock.Checked)
{
this._user.ContactList.AsyncAddToBlackList(this._contact.Uri, op);
}
base.Close();
}
}
catch
{
}
}
private void ContactList_ContactGroupChanged(object sender, ContactGroupChangedEventArgs e)
{
if (e.Type == ContactGroupEventType.Added)
{
this._initTargetGroupId = new int?(e.ContactGroup.Id);
}
else if (e.Type == ContactGroupEventType.Deleted)
{
int? nullable = this._initTargetGroupId;
if ((e.ContactGroup.Id == nullable.GetValueOrDefault()) && nullable.get_HasValue())
{
this._initTargetGroupId = null;
}
}
this.InitGroup();
}
protected override void Dispose(bool disposing)
{
if (disposing && (this.components != null))
{
this.components.Dispose();
}
base.Dispose(disposing);
}
private void InitGroup()
{
this.comboBoxGroup.DropDownStyle = ComboBoxStyle.DropDownList;
this.comboBoxGroup.Items.Clear();
lock (this._user.ContactList.Groups.SyncRoot)
{
using (IEnumerator<ContactGroupBase> enumerator = this._user.ContactList.Groups.GetEnumerator())
{
while (enumerator.MoveNext())
{
Imps.Client.Core.ContactGroup group = (Imps.Client.Core.ContactGroup) enumerator.get_Current();
if (group.Id != -1)
{
ComboBoxItem item = new ComboBoxItem(group.Name, group.Id);
this.comboBoxGroup.Items.Add(item);
if (this._initTargetGroupId.get_HasValue())
{
int? nullable = this._initTargetGroupId;
if ((nullable.GetValueOrDefault() == group.Id) && nullable.get_HasValue())
{
this.comboBoxGroup.SelectedItem = item;
}
}
}
}
}
}
if (this._initTargetGroupId.get_HasValue())
{
int? nullable2 = this._initTargetGroupId;
if (!((nullable2.GetValueOrDefault() == -1) && nullable2.get_HasValue()))
{
return;
}
}
if (this.comboBoxGroup.Items.Count > 0)
{
this.comboBoxGroup.SelectedIndex = 0;
}
}
private void InitializeComponent()
{
ComponentResourceManager manager = new ComponentResourceManager(typeof(ReceiveRequestByMobileNoForm));
this.buttonCancel = new XButton();
this.buttonOK = new XButton();
this.checkBoxBlock = new CheckBox();
this.radioButtonReject = new RadioButton();
this.radioButtonAgree = new RadioButton();
this.labelRemind = new XLabel();
this.panel1 = new Panel();
this.linkLabelDetail = new LinkLabel();
this.labelHello = new XLabel();
this.panelInfo = new Panel();
this.comboBoxGroup = new XComboBox();
this.panelMain = new Panel();
this.tbDisplayName = new TextBox();
this.label2 = new Label();
this.label3 = new Label();
this.uButton1 = new UButton();
XLabel label = new XLabel();
XLabel label2 = new XLabel();
this.panel1.SuspendLayout();
this.panelInfo.SuspendLayout();
this.panelMain.SuspendLayout();
base.SuspendLayout();
label.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top;
label.BorderColor = Color.Empty;
label.BorderStyle = BorderStyle.Fixed3D;
label.ButtonBorderStyle = ButtonBorderStyle.None;
label.Location = new System.Drawing.Point(40, 0x5f);
label.Name = "label4";
label.Size = new Size(0x159, 2);
label.TabIndex = 2;
label.Text = "label4";
label.UseMnemonic = false;
label2.set_AutoSize(true);
label2.BackColor = Color.Transparent;
label2.BorderColor = Color.Empty;
label2.ButtonBorderStyle = ButtonBorderStyle.None;
label2.Font = new Font("Microsoft Sans Serif", 9f, FontStyle.Bold, GraphicsUnit.Point, 0);
label2.ForeColor = Color.RoyalBlue;
label2.Location = new System.Drawing.Point(2, 0x56);
label2.Name = "label6";
label2.Size = new Size(0x21, 15);
label2.TabIndex = 1;
label2.Text = "回应";
label2.UseMnemonic = false;
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(0x13b, 0x124);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new Size(0x4b, 0x17);
this.buttonCancel.TabIndex = 8;
this.buttonCancel.Text = "取消";
this.buttonCancel.set_UseVisualStyleBackColor(false);
this.buttonCancel.Click += new EventHandler(this.buttonCancel_Click);
this.buttonOK.AutoArrangementX = false;
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.Location = new System.Drawing.Point(0xea, 0x124);
this.buttonOK.Name = "buttonOK";
this.buttonOK.Size = new Size(0x4b, 0x17);
this.buttonOK.TabIndex = 7;
this.buttonOK.Text = "确定";
this.buttonOK.set_UseVisualStyleBackColor(false);
this.buttonOK.Click += new EventHandler(this.buttonOK_Click);
this.checkBoxBlock.set_AutoSize(true);
this.checkBoxBlock.BackColor = Color.Transparent;
this.checkBoxBlock.Location = new System.Drawing.Point(0x20, 0xf8);
this.checkBoxBlock.Name = "checkBoxBlock";
this.checkBoxBlock.Size = new Size(0x86, 0x11);
this.checkBoxBlock.TabIndex = 6;
this.checkBoxBlock.Text = "拒绝此人再和我联系";
this.checkBoxBlock.set_UseVisualStyleBackColor(false);
this.radioButtonReject.set_AutoSize(true);
this.radioButtonReject.BackColor = Color.Transparent;
this.radioButtonReject.Location = new System.Drawing.Point(14, 0xdd);
this.radioButtonReject.Name = "radioButtonReject";
this.radioButtonReject.Size = new Size(0x3d, 0x11);
this.radioButtonReject.TabIndex = 5;
this.radioButtonReject.TabStop = true;
this.radioButtonReject.Text = "不同意";
this.radioButtonReject.set_UseVisualStyleBackColor(false);
this.radioButtonReject.CheckedChanged += new EventHandler(this.radioButtonReject_CheckedChanged);
this.radioButtonAgree.set_AutoSize(true);
this.radioButtonAgree.BackColor = Color.Transparent;
this.radioButtonAgree.Location = new System.Drawing.Point(14, 0x95);
this.radioButtonAgree.Name = "radioButtonAgree";
this.radioButtonAgree.Size = new Size(0x85, 0x11);
this.radioButtonAgree.TabIndex = 1;
this.radioButtonAgree.TabStop = true;
this.radioButtonAgree.Text = "同意,设置屏显名称";
this.radioButtonAgree.set_UseVisualStyleBackColor(false);
this.radioButtonAgree.CheckedChanged += new EventHandler(this.radioButtonAgree_CheckedChanged);
this.labelRemind.BorderColor = Color.Empty;
this.labelRemind.ButtonBorderStyle = ButtonBorderStyle.None;
this.labelRemind.Font = new Font("Microsoft Sans Serif", 8.25f, FontStyle.Regular, GraphicsUnit.Point, 0);
this.labelRemind.ForeColor = Color.FromArgb(0xc0, 0, 0);
this.labelRemind.Location = new System.Drawing.Point(7, 4);
this.labelRemind.Name = "labelRemind";
this.labelRemind.Size = new Size(0x165, 0x21);
this.labelRemind.TabIndex = 0;
this.labelRemind.Text = "提醒:";
this.labelRemind.UseMnemonic = false;
this.panel1.BackColor = Color.Transparent;
this.panel1.Controls.Add(this.linkLabelDetail);
this.panel1.Controls.Add(this.labelHello);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -