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

📄 sendrequestform.cs

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

    public class SendRequestForm : XIMDialog
    {
        private bool _allowSendRequestAgain;
        private Imps.Common.ContactType _contactType;
        private IFrameworkWindow _frameworkWindow;
        private string _initDesc;
        private string _initMobileNo;
        private long? _initSid;
        private int? _initTargetGroupId;
        private int? _initTargetGroupIdV;
        private Imps.Client.Core.Contact _lastContact;
        private string _lastContactNickname;
        private Imps.Client.Core.Contact _lastContactVodafone;
        private Imps.Client.Core.User _user;
        private XButton buttonCancel;
        private XButton buttonOK;
        private XComboBox comboBoxGroup;
        private XComboBox comboBoxGroupV;
        private IContainer components;
        private GroupBox groupBoxPreview;
        private Label label1;
        private XLabel label15;
        private XLabel label3;
        private XLabel label5;
        private XLabel labelAlert;
        private XLabel labelPreview;
        private XLabel labelSetNickname;
        private XLabel lbIAm;
        private LinkLabel linkLabelDetail;
        private LinkLabel linkLabelMobileNoHint;
        private LinkLabel linkLabelNewGroup;
        private LinkLabel linkLabelNewGroupV;
        private LinkLabel linkLabelNicknameMobileNoV;
        private LinkLabel linkLabelNicknameSIDV;
        private Panel panel1;
        private Panel panelAddBuddy;
        private Panel panelTop;
        private DisplayPortrait pictureBoxPortrait;
        private RadioButton radioButtonMobileNo;
        private RadioButton radioButtonMobileNoV;
        private RadioButton radioButtonSID;
        private RadioButton radioButtonSIDV;
        private XTabControl tabControlAddBuddy;
        private XTabPage tabPageImps;
        private XTabPage tabPageVodafone;
        private XTextBox textBoxMobileNo;
        private XTextBox textBoxMyName;
        private XTextBox textBoxSID;
        private XTextBox xTextBoxMobileNoV;
        private XTextBox xTextBoxNickname;
        private XTextBox xTextBoxNicknameV;
        private XTextBox xTextBoxSIDV;

        public SendRequestForm(IFrameworkWindow frameworkWindow) : this(frameworkWindow, null, null, string.Empty, null, Imps.Common.ContactType.ImpsContact)
        {
        }

        public SendRequestForm(IFrameworkWindow frameworkWindow, string mobileNo, long? sid, string desc, int? targetGroupId, Imps.Common.ContactType contactType)
        {
            this.InitializeComponent();
            this._frameworkWindow = frameworkWindow;
            this._user = this._frameworkWindow.AccountManager.CurrentUser;
            this._user.StatusChanged += new EventHandler<UserSatusChangedEventArgs>(this._user_StatusChanged);
            this._user.ContactList.ContactGroupChanged += new EventHandler<ContactGroupChangedEventArgs>(this.ContactList_ContactGroupChanged);
            this._initMobileNo = mobileNo;
            this._initDesc = desc;
            this._initSid = sid;
            this._initTargetGroupId = targetGroupId;
            this._initTargetGroupIdV = targetGroupId;
            this._contactType = contactType;
            ControlHelper.ForceControlImeHangul(this.textBoxMyName);
        }

        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
            {
                int? nullable = null;
                if (this.comboBoxGroup.Items.Count > 0)
                {
                    ComboBoxItem selectedItem = (ComboBoxItem) this.comboBoxGroup.SelectedItem;
                    if (selectedItem == null)
                    {
                        this._frameworkWindow.UnifiedMessageBox.ShowWarning(this, StringTable.Contact.PlsSelectGroup);
                        return;
                    }
                    if (Convert.ToInt32(selectedItem.Value) == -1)
                    {
                        this._frameworkWindow.UnifiedMessageBox.ShowWarning(this, StringTable.Contact.PlsSelectGroup);
                        return;
                    }
                    nullable = new int?(Convert.ToInt32(selectedItem.Value));
                }
                bool isByMobileNo = false;
                string id = string.Empty;
                string domain = string.Empty;
                int? targetGroupId = null;
                string localName = string.Empty;
                Imps.Client.Core.ContactList.AddBuddyExtraData extraData = new Imps.Client.Core.ContactList.AddBuddyExtraData();
                bool sendRequestAgain = false;
                bool copyWhenExist = false;
                bool? invite = null;
                AsyncBizOperation op = new AsyncBizOperation();
                if (this.tabControlAddBuddy.SelectedIndex == 0)
                {
                    domain = "fetion";
                    if (this.radioButtonMobileNo.Checked)
                    {
                        if (this.textBoxMobileNo.Text.Trim().Length == 0)
                        {
                            this._frameworkWindow.UnifiedMessageBox.ShowWarning(this, StringTable.Contact.AddBuddy_MobileNoEmpty);
                            this.textBoxMobileNo.Focus();
                            return;
                        }
                        if (this.textBoxMobileNo.Text.Trim().Length != 11)
                        {
                            this._frameworkWindow.UnifiedMessageBox.ShowWarning(this, StringTable.Contact.InvalidMobileNo);
                            this.textBoxMobileNo.Focus();
                            return;
                        }
                        if (this.textBoxMyName.Text.Trim().Length == 0)
                        {
                            BalloonHelper.ShowBallon(this.textBoxMyName, StringTable.Contact.AddBuddy_MyNameEmptyMobileNo, "请注意!", ToolTipIcon.Info, 0xbb8);
                            this.textBoxMyName.Focus();
                            return;
                        }
                        if (Encoding.GetEncoding(0x3a8).GetByteCount(this.textBoxMyName.Text) > 10)
                        {
                            BalloonHelper.ShowBallon(this.textBoxMyName, StringTable.Contact.AddBuddy_MyNameTooLong, "请注意!", ToolTipIcon.Info, 0xbb8);
                            this.textBoxMyName.Focus();
                            return;
                        }
                        string mobileNo = this.textBoxMobileNo.Text.Trim();
                        if (mobileNo == this._user.PersonalInfo.MobileNo)
                        {
                            this._frameworkWindow.UnifiedMessageBox.ShowWarning(this, StringTable.Contact.CannotAddYouself);
                            return;
                        }
                        if (ImpsHelper.IsUnicomMobileNo(mobileNo))
                        {
                            this._frameworkWindow.UnifiedMessageBox.ShowWarning(this, StringTable.Contact.UnicomMobileNo);
                            return;
                        }
                        IicUri uri = IicUri.CreateTelUri(mobileNo);
                        Imps.Client.Core.Contact contact = this._user.ContactList.FindContactByMsisdnEx(uri.MobileNo);
                        if ((contact != null) && (contact.RelationStatus == 1))
                        {
                            string str6;
                            string name = string.Empty;
                            foreach (int num in contact.BelongToGroups)
                            {
                                Imps.Client.Core.ContactGroup group = this._user.ContactList.Groups[new int?(num)] as Imps.Client.Core.ContactGroup;
                                if (group != null)
                                {
                                    name = group.Name;
                                    if (name.Length > 20)
                                    {
                                        name = name.Substring(0, 20) + "...";
                                    }
                                    break;
                                }
                            }
                            if (name.Length > 0)
                            {
                                str6 = string.Format(StringTable.Contact.ContactAlreadyExistInBuddy_WithGroup, contact.DisplayName.Replace("&", "&&"), name);
                            }
                            else
                            {
                                str6 = string.Format(StringTable.Contact.ContactAlreadyExistInBuddy, contact.DisplayName.Replace("&", "&&"));
                            }
                            this._frameworkWindow.UnifiedMessageBox.ShowWarning(this, str6);
                            return;
                        }
                        isByMobileNo = true;
                        id = uri.MobileNo;
                    }
                    else if (this.radioButtonSID.Checked)
                    {
                        long num2;
                        if (this.textBoxSID.Text.Trim().Length == 0)
                        {
                            this._frameworkWindow.UnifiedMessageBox.ShowWarning(this, StringTable.Contact.PlsInputSID);
                            this.textBoxSID.Focus();
                            return;
                        }
                        if (this.textBoxMyName.Text.Trim().Length == 0)
                        {
                            BalloonHelper.ShowBallon(this.textBoxMyName, StringTable.Contact.AddBuddy_MyNameEmptySID, "请注意!", ToolTipIcon.Info, 0xbb8);
                            this.textBoxMyName.Focus();
                            return;
                        }
                        if (Encoding.GetEncoding(0x3a8).GetByteCount(this.textBoxMyName.Text) > 10)
                        {
                            BalloonHelper.ShowBallon(this.textBoxMyName, StringTable.Contact.AddBuddy_MyNameTooLong, "请注意!", ToolTipIcon.Info, 0xbb8);
                            this.textBoxMyName.Focus();
                            return;
                        }
                        long.TryParse(this.textBoxSID.Text, out num2);
                        this.textBoxSID.Text = num2.ToString();
                        if (num2 == this._user.Sid)
                        {
                            this._frameworkWindow.UnifiedMessageBox.ShowWarning(this, StringTable.Contact.CannotAddYouself);
                            return;
                        }
                        IicUri uri2 = IicUri.CreateSidUri(num2);
                        Imps.Client.Core.Contact contact2 = this._user.ContactList.Contacts[uri2.Raw];
                        if ((contact2 != null) && (contact2.RelationStatus == 1))
                        {
                            string str8;

⌨️ 快捷键说明

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