⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 receiverequestbysidform.cs

📁 飞信的收发使用csharp进行开发
💻 CS
📖 第 1 页 / 共 2 页
字号:
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 Imps.Common;
    using System;
    using System.ComponentModel;
    using System.Drawing;
    using System.Windows.Forms;

    public class ReceiveRequestBySIDForm : XIMDialog
    {
        private Imps.Client.Core.Contact _contact;
        private string _desc;
        private bool _hasHandleRequest;
        private IFrameworkWindow _iFarmeworkWindow;
        private int? _initTargetGroupId;
        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 labelHello;
        private XLabel labelNickname;
        private LinkLabel linkLabelDetail;
        private LinkLabel linkLabelNewGroup;
        private Panel panel1;
        private Panel panel2;
        private Panel panel3;
        private DisplayPortrait pictureBoxPortrait;
        private RadioButton radioButtonAgree;
        private RadioButton radioButtonReject;

        public ReceiveRequestBySIDForm(IFrameworkWindow iFrameworkWindow, Imps.Client.Core.Contact contact, string desc)
        {
            this.InitializeComponent();
            this.initComponentRegion();
            this._iFarmeworkWindow = iFrameworkWindow;
            this._contact = contact;
            this._desc = desc;
            this._user = iFrameworkWindow.AccountManager.CurrentUser;
            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);
        }

        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;
                        }
                    }
                    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, string.Empty, 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) && (e.ContactGroup.Id == this._initTargetGroupId))
            {
                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 str = this._contact.PersonalInfo.Nickname.Value.Replace("&", "&&");
                if (str.Length > 15)
                {
                    str = str.Substring(0, 15) + "...";
                }
                base.Text = string.Format(StringTable.FormAddBuddy.RequestReceivedFormText, str);
                this.labelNickname.Text = this._contact.PersonalInfo.Nickname.Value.Replace("&", "&&");
            }
        }

        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)
            {
                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(ReceiveRequestBySIDForm));
            this.linkLabelDetail = new LinkLabel();
            this.panel2 = new Panel();
            this.pictureBoxPortrait = new DisplayPortrait();
            this.labelNickname = new XLabel();
            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.label1 = new XLabel();
            this.panel3 = new Panel();
            this.linkLabelNewGroup = new LinkLabel();
            XLabel label = new XLabel();
            XLabel label2 = new XLabel();
            this.panel2.SuspendLayout();
            this.panel1.SuspendLayout();
            this.panel3.SuspendLayout();
            base.SuspendLayout();
            base.menubar.Location = new Point(3, 0x19);
            label.AutoEllipsis = false;
            label.AutoSize = true;
            label.BackColor = Color.Transparent;
            label.BorderColor = Color.Black;
            label.BorderStyle = BorderStyle.None;
            label.ButtonBorderStyle = ButtonBorderStyle.Solid;
            label.Font = new Font("Microsoft Sans Serif", 9f, FontStyle.Bold, GraphicsUnit.Point, 0);
            label.ForeColor = Color.RoyalBlue;
            label.Location = new Point(3, 0x8f);
            label.Name = "label6";
            label.Size = new Size(0x21, 15);
            label.TabIndex = 1;
            label.Text = "回应";
            label.TextAlign = ContentAlignment.TopLeft;
            label.UseMnemonic = false;
            label2.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top;
            label2.AutoEllipsis = false;
            label2.BorderColor = Color.Black;
            label2.BorderStyle = BorderStyle.Fixed3D;
            label2.ButtonBorderStyle = ButtonBorderStyle.Solid;
            label2.Location = new Point(0x26, 0x97);
            label2.Name = "label4";
            label2.Size = new Size(0x181, 2);
            label2.TabIndex = 2;
            label2.TextAlign = ContentAlignment.TopLeft;
            label2.UseMnemonic = false;
            this.linkLabelDetail.AutoSize = true;
            this.linkLabelDetail.Location = new Point(0x4c, 0x35);
            this.linkLabelDetail.Name = "linkLabelDetail";
            this.linkLabelDetail.Size = new Size(0x4f, 13);
            this.linkLabelDetail.TabIndex = 1;
            this.linkLabelDetail.TabStop = true;
            this.linkLabelDetail.Text = "查看详细信息";
            this.linkLabelDetail.LinkClicked += new LinkLabelLinkClickedEventHandler(this.linkLabelDetail_LinkClicked);
            this.panel2.Controls.Add(this.pictureBoxPortrait);
            this.panel2.Controls.Add(this.labelNickname);
            this.panel2.Controls.Add(this.linkLabelDetail);
            this.panel2.Location = new Point(0xb1, 0x45);
            this.panel2.Name = "panel2";
            this.panel2.Size = new Size(220, 0x4b);
            this.panel2.TabIndex = 3;
            this.pictureBoxPortrait.BackColor = Color.White;
            this.pictureBoxPortrait.BorderColor = Color.FromArgb(0xa4, 170, 220);
            this.pictureBoxPortrait.Image = (Image) manager.GetObject("pictureBoxPortrait.Image");
            this.pictureBoxPortrait.Location = new Point(4, 4);
            this.pictureBoxPortrait.Name = "pictureBoxPortrait";
            this.pictureBoxPortrait.Size = new Size(70, 70);
            this.pictureBoxPortrait.SizeMode = PortraitSizeMode.Size_64;
            this.pictureBoxPortrait.TabIndex = 2;
            this.pictureBoxPortrait.Text = "displayPortrait1";
            this.pictureBoxPortrait.ToolTipText = "";
            this.labelNickname.AutoEllipsis = true;
            this.labelNickname.BorderColor = Color.Black;
            this.labelNickname.BorderStyle = BorderStyle.None;
            this.labelNickname.ButtonBorderStyle = ButtonBorderStyle.Solid;
            this.labelNickname.Location = new Point(0x4c, 0x16);
            this.labelNickname.Name = "labelNickname";

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -