📄 receiverequestbysidform.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 ReceiveRequestBySIDForm : 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 LinkLabel linkLabelDetail;
private Panel panel1;
private Panel panelMain;
private RadioButton radioButtonAgree;
private RadioButton radioButtonReject;
private TextBox tbDisplayName;
private UButton uButton1;
public ReceiveRequestBySIDForm(IFrameworkWindow iFrameworkWindow, Imps.Client.Core.Contact contact, string desc)
{
this.InitializeComponent();
this.InitializeWndlessControl();
this.initComponentRegion();
this._iFarmeworkWindow = iFrameworkWindow;
this._contact = contact;
this._desc = desc;
this._user = iFrameworkWindow.AccountManager.CurrentUser;
this._user.StatusChanged += new EventHandler<UserSatusChangedEventArgs>(this, (IntPtr) this._user_StatusChanged);
this._contact.PersonalInfo.PropertiesChanged += new EventHandler<PropertiesChangedEventArgs>(this, (IntPtr) this.contactPersonalInfo_PropertiesChanged);
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;
}
}
this._hasHandleRequest = true;
int result = this.radioButtonAgree.Checked ? 1 : 0;
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, false, 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();
}
private void contactPersonalInfo_PropertiesChanged(object sender, PropertiesChangedEventArgs e)
{
if (e.ContainsProperty("Portrait"))
{
this._pictureBoxPortrait.Image = this._contact.PersonalInfo.PortraitMedium;
}
if (e.ContainsProperty("nickname"))
{
string paddingStringEndEllipsis = StringHelper.GetPaddingStringEndEllipsis(this._contact.PersonalInfo.Nickname.Value, 15);
base.Text = string.Format(StringTable.FormAddBuddy.RequestReceivedFormText, paddingStringEndEllipsis);
if ((this._desc == this._contact.PersonalInfo.Nickname.Value) || (this._contact.PersonalInfo.Nickname.Value.Length == 0))
{
this.labelHello.Text = string.Format(StringTable.FormAddBuddy.RequestReceivedLetterContentSID_NoNickname, this._desc);
}
else
{
this.labelHello.Text = string.Format(StringTable.FormAddBuddy.RequestReceivedLetterContentSID, this._desc, this._contact.PersonalInfo.Nickname.Value);
}
}
}
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(ReceiveRequestBySIDForm));
this.linkLabelDetail = new LinkLabel();
this.comboBoxGroup = new XComboBox();
this.labelHello = new XLabel();
this.buttonCancel = new XButton();
this.buttonOK = new XButton();
this.checkBoxBlock = new CheckBox();
this.radioButtonReject = new RadioButton();
this.radioButtonAgree = new RadioButton();
this.panel1 = new Panel();
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.panelMain.SuspendLayout();
base.SuspendLayout();
label.set_AutoSize(true);
label.BackColor = Color.Transparent;
label.BorderColor = Color.Empty;
label.ButtonBorderStyle = ButtonBorderStyle.None;
label.Font = new Font("Microsoft Sans Serif", 9f, FontStyle.Bold, GraphicsUnit.Point, 0);
label.ForeColor = Color.RoyalBlue;
label.Location = new System.Drawing.Point(1, 0x57);
label.Name = "label6";
label.Size = new Size(0x21, 15);
label.TabIndex = 1;
label.Text = "回应";
label.UseMnemonic = false;
label2.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top;
label2.BorderColor = Color.Empty;
label2.BorderStyle = BorderStyle.Fixed3D;
label2.ButtonBorderStyle = ButtonBorderStyle.None;
label2.Location = new System.Drawing.Point(0x24, 0x5f);
label2.Name = "label4";
label2.Size = new Size(0x164, 2);
label2.TabIndex = 2;
label2.UseMnemonic = false;
this.linkLabelDetail.set_AutoSize(true);
this.linkLabelDetail.LinkColor = Color.Green;
this.linkLabelDetail.Location = new System.Drawing.Point(14, 70);
this.linkLabelDetail.Name = "linkLabelDetail";
this.linkLabelDetail.Size = new Size(0x37, 13);
this.linkLabelDetail.TabIndex = 1;
this.linkLabelDetail.TabStop = true;
this.linkLabelDetail.Text = "查看资料";
this.linkLabelDetail.LinkClicked += new LinkLabelLinkClickedEventHandler(this.linkLabelDetail_LinkClicked);
this.comboBoxGroup.BackColor = Color.White;
this.comboBoxGroup.DropDownStyle = ComboBoxStyle.DropDownList;
this.comboBoxGroup.EmptyTextTip = "";
this.comboBoxGroup.EmptyTextTipColor = Color.DarkGray;
this.comboBoxGroup.set_FormattingEnabled(true);
this.comboBoxGroup.Location = new System.Drawing.Point(0x93, 0x8b);
this.comboBoxGroup.Name = "comboBoxGroup";
this.comboBoxGroup.Size = new Size(0x8e, 0x15);
this.comboBoxGroup.TabIndex = 5;
this.labelHello.set_AutoEllipsis(true);
this.labelHello.BorderColor = Color.Empty;
this.labelHello.ButtonBorderStyle = ButtonBorderStyle.None;
this.labelHello.Font = new Font("Microsoft Sans Serif", 8.25f, FontStyle.Regular, GraphicsUnit.Point, 0x86);
this.labelHello.Location = new System.Drawing.Point(0x4d, 0x13);
this.labelHello.Name = "labelHello";
this.labelHello.Size = new Size(0x131, 0x40);
this.labelHello.TabIndex = 2;
this.labelHello.Text = "我的自我介绍:";
this.labelHello.UseMnemonic = false;
this.buttonCancel.AutoArrangementX = false;
this.buttonCancel.AutoSizeToImage = false;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -