?? receiverequestvodafoneform.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.Resource;
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
public class ReceiveRequestVodafoneForm : XIMDialog
{
private Imps.Client.Core.Contact _contact;
private bool _hasHandleRequest;
private IFrameworkWindow _iFarmeworkWindow;
private int? _initTargetGroupId;
private bool _isServiceSubscribed;
private Imps.Client.Core.User _user;
private XButton buttonCancel;
private XButton buttonOK;
private CheckBox checkBoxBlock;
private XComboBox comboBoxGroup;
private IContainer components;
private XLabel label1;
private XLabel labelAlert;
private XLabel labelHello;
private XLabel labelNickname;
private LinkLabel linkLabelDetail;
private LinkLabel linkLabelNewGroup;
private Panel panel2;
private Panel panelAlert;
private Panel panelButton;
private Panel panelContact;
private Panel panelLine;
private Panel panelReject;
private Panel panelRequest;
private DisplayPortrait pictureBoxPortrait;
private RadioButton radioButtonAgree;
private RadioButton radioButtonReject;
private RadioButton radioButtonServiceAccept;
private RadioButton radioButtonServiceReject;
public ReceiveRequestVodafoneForm(IFrameworkWindow iFrameworkWnd, Imps.Client.Core.Contact contact)
{
this.InitializeComponent();
this._iFarmeworkWindow = iFrameworkWnd;
this._user = this._iFarmeworkWindow.AccountManager.CurrentUser;
this._contact = contact;
this._user.StatusChanged += new EventHandler<UserSatusChangedEventArgs>(this._user_StatusChanged);
this._contact.PersonalInfo.PropertiesChanged += new EventHandler<PropertiesChangedEventArgs>(this.contactPersonalInfo_PropertiesChanged);
this._user.ContactList.ContactGroupChanged += new EventHandler<ContactGroupChangedEventArgs>(this.ContactList_ContactGroupChanged);
this._isServiceSubscribed = this._user.IsServiceSubscribed("VodafoneFederation");
}
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._isServiceSubscribed)
{
if (this.radioButtonServiceAccept.Checked)
{
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;
if (((int) selectedItem.Value) <= 0)
{
this._iFarmeworkWindow.UnifiedMessageBox.ShowInfo(StringTable.FormAddBuddy.MustSelectGroup);
return;
}
}
AsyncBizOperation op = new AsyncBizOperation();
op.Successed += new EventHandler(this.vodafoneServiceSubscribe_Successed);
this._user.AsyncSubscribeService("VodafoneFederation", op);
}
else
{
base.Close();
}
}
else 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 item2 = (ComboBoxItem) this.comboBoxGroup.SelectedItem;
targetGroupId = new int?((int) item2.Value);
if (((int) item2.Value) <= 0)
{
this._iFarmeworkWindow.UnifiedMessageBox.ShowInfo(StringTable.FormAddBuddy.MustSelectGroup);
return;
}
}
int result = this.radioButtonAgree.Checked ? 1 : 0;
this._hasHandleRequest = true;
bool? isBlock = null;
if (result == 0)
{
isBlock = new bool?(this.checkBoxBlock.Checked);
}
AsyncBizOperation operation2 = new AsyncBizOperation();
this._user.ContactList.AsyncHandleContactRequest(this._contact.Uri.ToString(), result, isBlock, targetGroupId, true, string.Empty, operation2);
if (this.checkBoxBlock.Checked)
{
this._user.ContactList.AsyncAddToBlackList(this._contact.Uri, operation2);
}
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) && (e.ContactGroup.Id == this._initTargetGroupId))
{
this._initTargetGroupId = null;
}
this.InitGroup();
}
private void contactPersonalInfo_PropertiesChanged(object sender, PropertiesChangedEventArgs e)
{
if (e.ContainsAnyOfProperties(new string[] { "Portrait", "nickname" }))
{
this.setUI();
}
}
protected override void Dispose(bool disposing)
{
if (disposing && (this.components != null))
{
this.components.Dispose();
}
base.Dispose(disposing);
}
private void InitGroup()
{
this.comboBoxGroup.Items.Clear();
lock (this._user.ContactList.Groups.SyncRoot)
{
foreach (Imps.Client.Core.ContactGroup group in this._user.ContactList.Groups)
{
if (group.Id != -1)
{
ComboBoxItem item = new ComboBoxItem(group.Name, group.Id);
this.comboBoxGroup.Items.Add(item);
if (this._initTargetGroupId.HasValue && (this._initTargetGroupId == group.Id))
{
this.comboBoxGroup.SelectedItem = item;
}
}
}
}
if ((!this._initTargetGroupId.HasValue || (this._initTargetGroupId == -1)) && (this.comboBoxGroup.Items.Count > 0))
{
this.comboBoxGroup.SelectedIndex = 0;
}
}
private void InitializeComponent()
{
this.components = new Container();
ComponentResourceManager manager = new ComponentResourceManager(typeof(ReceiveRequestVodafoneForm));
this.panelContact = new Panel();
this.label1 = new XLabel();
this.panel2 = new Panel();
this.pictureBoxPortrait = new DisplayPortrait();
this.labelNickname = new XLabel();
this.linkLabelDetail = new LinkLabel();
this.labelHello = new XLabel();
this.comboBoxGroup = new XComboBox();
this.checkBoxBlock = new CheckBox();
this.radioButtonAgree = new RadioButton();
this.radioButtonReject = new RadioButton();
this.linkLabelNewGroup = new LinkLabel();
this.panelLine = new Panel();
this.panelAlert = new Panel();
this.radioButtonServiceAccept = new RadioButton();
this.labelAlert = new XLabel();
this.panelRequest = new Panel();
this.panelReject = new Panel();
this.radioButtonServiceReject = new RadioButton();
this.buttonCancel = new XButton();
this.buttonOK = new XButton();
this.panelButton = new Panel();
XLabel label = new XLabel();
XLabel label2 = new XLabel();
this.panelContact.SuspendLayout();
this.panel2.SuspendLayout();
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -