www.pudn.com > Fetion.rar > ApplyJoinGroupForm.cs


namespace Imps.Client.Pc 
{ 
    using Imps.Client; 
    using Imps.Client.Core; 
    using Imps.Client.Pc.BizControls; 
    using Imps.Client.Pc.Controls; 
    using Imps.Client.Utils; 
    using Imps.Common; 
    using Imps.Utils; 
    using System; 
    using System.ComponentModel; 
    using System.Drawing; 
    using System.Windows.Forms; 
 
    public class ApplyJoinGroupForm : XIMDialog 
    { 
        private Contact _contact; 
        private string _description; 
        private IFrameworkWindow _framework; 
        private PersonalGroup _group; 
        private IContainer components; 
        private GroupBox gbReply; 
        private AsyncBizOperation op; 
        private PictureBox pbPortrait; 
        private Panel pnlContent; 
        private RadioButton rbAgree; 
        private RadioButton rbReject; 
        private XButton xbtnCancel; 
        private XButton xbtnOK; 
        private HtmlLabel xlblAnouce; 
        private XLabel xlblUserName; 
        private XLinkLabel xlblUserNameText; 
        private XTextBox xtbApplyNote; 
 
        public ApplyJoinGroupForm(IFrameworkWindow wnd, Contact contact, string contactNickname, PersonalGroup group, string description) 
        { 
            string str; 
            this._framework = wnd; 
            this._contact = contact; 
            this._description = description; 
            this._group = group; 
            this.InitializeComponent(); 
            this.pbPortrait.Image = this._contact.PersonalInfo.Portrait; 
            this.xtbApplyNote.Text = this._description; 
            if (contact is Stranger) 
            { 
                str = StringHelper.GetPaddingStringEndEllipsis(contactNickname, 11); 
                this.xlblUserNameText.Text = contactNickname; 
            } 
            else 
            { 
                str = StringHelper.GetPaddingStringEndEllipsis(this._contact.PersonalInfo.DisplayName, 11); 
                this.xlblUserNameText.Text = this._contact.DisplayName; 
            } 
            string paddingStringEndEllipsis = StringHelper.GetPaddingStringEndEllipsis(this._group.GroupInfo.Name.Value, 11); 
            str = StringHelper.EncodString(str); 
            paddingStringEndEllipsis = StringHelper.EncodString(paddingStringEndEllipsis); 
            string str3 = string.Format("{1}({2})", this._contact.Uri.Raw, str, this._contact.Uri.Id); 
            string str4 = string.Format("{1}({2})", this._group.Uri.Raw, paddingStringEndEllipsis, this._group.Uri.Id); 
            this.xlblAnouce.Text = string.Format("飞信用户{0}申请加入群{1},请求您通过身份验证。", str3, str4); 
            this.xlblAnouce.LabelLinkClick += new EventHandler(this.xlblAnouce_LabelLinkClick); 
            this.initComponentRegion(); 
        } 
 
        private void ApplyJoinGroupForm_FormClosing(object sender, FormClosingEventArgs e) 
        { 
            this._contact.PersonalInfo.PropertiesChanged -= new EventHandler(this.PersonalInfo_PropertiesChanged); 
            this.xlblAnouce.LabelLinkClick -= new EventHandler(this.xlblAnouce_LabelLinkClick); 
        } 
 
        private void ApplyJoinGroupForm_Load(object sender, EventArgs e) 
        { 
            this._contact.PersonalInfo.PropertiesChanged += new EventHandler(this.PersonalInfo_PropertiesChanged); 
        } 
 
        protected override void Dispose(bool disposing) 
        { 
            if (disposing && (this.components != null)) 
            { 
                this.components.Dispose(); 
            } 
            base.Dispose(disposing); 
        } 
 
        private void InitializeComponent() 
        { 
            this.xbtnCancel = new XButton(); 
            this.xbtnOK = new XButton(); 
            this.pnlContent = new Panel(); 
            this.xlblAnouce = new HtmlLabel(); 
            this.gbReply = new GroupBox(); 
            this.rbReject = new RadioButton(); 
            this.rbAgree = new RadioButton(); 
            this.xtbApplyNote = new XTextBox(); 
            this.xlblUserNameText = new XLinkLabel(); 
            this.xlblUserName = new XLabel(); 
            this.pbPortrait = new PictureBox(); 
            this.pnlContent.SuspendLayout(); 
            this.gbReply.SuspendLayout(); 
            ((ISupportInitialize) this.pbPortrait).BeginInit(); 
            base.SuspendLayout(); 
            this.xbtnCancel.AutoArrangementX = false; 
            this.xbtnCancel.AutoSizeToImage = false; 
            this.xbtnCancel.BackColor = Color.Transparent; 
            this.xbtnCancel.BackgroundImageDisable = null; 
            this.xbtnCancel.BackgroundImageDown = null; 
            this.xbtnCancel.BackgroundImageHover = null; 
            this.xbtnCancel.ChangeSkin = true; 
            this.xbtnCancel.DialogResult = DialogResult.Cancel; 
            this.xbtnCancel.Location = new System.Drawing.Point(0x106, 0xfd); 
            this.xbtnCancel.Name = "xbtnCancel"; 
            this.xbtnCancel.Size = new Size(0x4b, 0x19); 
            this.xbtnCancel.TabIndex = 1; 
            this.xbtnCancel.Text = "取消"; 
            this.xbtnCancel.UseVisualStyleBackColor = false; 
            this.xbtnCancel.Click += new EventHandler(this.xbtnCancel_Click); 
            this.xbtnOK.AutoArrangementX = false; 
            this.xbtnOK.AutoSizeToImage = false; 
            this.xbtnOK.BackColor = Color.Transparent; 
            this.xbtnOK.BackgroundImageDisable = null; 
            this.xbtnOK.BackgroundImageDown = null; 
            this.xbtnOK.BackgroundImageHover = null; 
            this.xbtnOK.ChangeSkin = true; 
            this.xbtnOK.Location = new System.Drawing.Point(0xb5, 0xfd); 
            this.xbtnOK.Name = "xbtnOK"; 
            this.xbtnOK.Size = new Size(0x4b, 0x19); 
            this.xbtnOK.TabIndex = 0; 
            this.xbtnOK.Text = "确定"; 
            this.xbtnOK.UseVisualStyleBackColor = false; 
            this.xbtnOK.Click += new EventHandler(this.xbtnOK_Click); 
            this.pnlContent.BackColor = Color.Transparent; 
            this.pnlContent.Controls.Add(this.xlblAnouce); 
            this.pnlContent.Controls.Add(this.gbReply); 
            this.pnlContent.Controls.Add(this.xtbApplyNote); 
            this.pnlContent.Controls.Add(this.xlblUserNameText); 
            this.pnlContent.Controls.Add(this.xlblUserName); 
            this.pnlContent.Controls.Add(this.pbPortrait); 
            this.pnlContent.ForeColor = SystemColors.ControlText; 
            this.pnlContent.Location = new System.Drawing.Point(0x12, 11); 
            this.pnlContent.Name = "pnlContent"; 
            this.pnlContent.Size = new Size(0x14d, 0xde); 
            this.pnlContent.TabIndex = 2; 
            this.xlblAnouce.AutoEllipsis = true; 
            this.xlblAnouce.LinkColor = Color.Blue; 
            this.xlblAnouce.Location = new System.Drawing.Point(9, 6); 
            this.xlblAnouce.Name = "xlblAnouce"; 
            this.xlblAnouce.ShowBackgroundImage = false; 
            this.xlblAnouce.Size = new Size(0x133, 0x27); 
            this.xlblAnouce.SpaceDistance = 5; 
            this.xlblAnouce.TabIndex = 11; 
            this.xlblAnouce.Text = "飞信用户xxxx昵称(12345678)申请加入群xxxx群名(12345678),请求您通过身份验证。"; 
            this.xlblAnouce.TextAlign = ContentAlignment.MiddleLeft; 
            this.gbReply.Controls.Add(this.rbReject); 
            this.gbReply.Controls.Add(this.rbAgree); 
            this.gbReply.Location = new System.Drawing.Point(12, 140); 
            this.gbReply.Name = "gbReply"; 
            this.gbReply.Size = new Size(0x133, 0x45); 
            this.gbReply.TabIndex = 10; 
            this.gbReply.TabStop = false; 
            this.gbReply.Text = "回应"; 
            this.rbReject.AutoSize = true; 
            this.rbReject.Location = new System.Drawing.Point(0x10, 0x2a); 
            this.rbReject.Name = "rbReject"; 
            this.rbReject.Size = new Size(0x31, 0x11); 
            this.rbReject.TabIndex = 1; 
            this.rbReject.Text = "拒绝"; 
            this.rbReject.UseVisualStyleBackColor = true; 
            this.rbAgree.AutoSize = true; 
            this.rbAgree.Checked = true; 
            this.rbAgree.Location = new System.Drawing.Point(0x10, 0x13); 
            this.rbAgree.Name = "rbAgree"; 
            this.rbAgree.Size = new Size(0x31, 0x11); 
            this.rbAgree.TabIndex = 0; 
            this.rbAgree.TabStop = true; 
            this.rbAgree.Text = "同意"; 
            this.rbAgree.UseVisualStyleBackColor = true; 
            this.xtbApplyNote.BackColor = Color.FromArgb(240, 240, 240); 
            this.xtbApplyNote.BorderStyle = BorderStyle.None; 
            this.xtbApplyNote.EmptyTextTip = ""; 
            this.xtbApplyNote.EmptyTextTipColor = Color.LightGray; 
            this.xtbApplyNote.Location = new System.Drawing.Point(0x6c, 0x4c); 
            this.xtbApplyNote.Multiline = true; 
            this.xtbApplyNote.Name = "xtbApplyNote"; 
            this.xtbApplyNote.ReadOnly = true; 
            this.xtbApplyNote.ScrollBars = ScrollBars.Vertical; 
            this.xtbApplyNote.Size = new Size(0xd3, 0x39); 
            this.xtbApplyNote.TabIndex = 9; 
            this.xlblUserNameText.AutoEllipsis = true; 
            this.xlblUserNameText.BorderColor = Color.Empty; 
            this.xlblUserNameText.BorderStyle = BorderStyle.None; 
            this.xlblUserNameText.ButtonBorderStyle = ButtonBorderStyle.None; 
            this.xlblUserNameText.Cursor = Cursors.Hand; 
            this.xlblUserNameText.Font = new Font("Microsoft Sans Serif", 8.25f, FontStyle.Underline); 
            this.xlblUserNameText.ForeColor = Color.Blue; 
            this.xlblUserNameText.LinkBehavior = LinkBehavior.AlwaysUnderline; 
            this.xlblUserNameText.LinkColor = Color.Blue; 
            this.xlblUserNameText.Location = new System.Drawing.Point(0x8d, 0x36); 
            this.xlblUserNameText.Name = "xlblUserNameText"; 
            this.xlblUserNameText.Size = new Size(0xa7, 13); 
            this.xlblUserNameText.TabIndex = 7; 
            this.xlblUserNameText.Text = "user"; 
            this.xlblUserNameText.TextAlign = ContentAlignment.TopLeft; 
            this.xlblUserNameText.UseMnemonic = false; 
            this.xlblUserNameText.LinkClicked += new LinkLabelLinkClickedEventHandler(this.xlblUserNameText_LinkClicked); 
            this.xlblUserName.AutoSize = true; 
            this.xlblUserName.BorderColor = Color.Empty; 
            this.xlblUserName.ButtonBorderStyle = ButtonBorderStyle.None; 
            this.xlblUserName.Location = new System.Drawing.Point(0x69, 0x36); 
            this.xlblUserName.Name = "xlblUserName"; 
            this.xlblUserName.Size = new Size(0x2b, 13); 
            this.xlblUserName.TabIndex = 6; 
            this.xlblUserName.Text = "昵称:"; 
            this.pbPortrait.BackColor = Color.Silver; 
            this.pbPortrait.Location = new System.Drawing.Point(12, 0x36); 
            this.pbPortrait.Name = "pbPortrait"; 
            this.pbPortrait.Padding = new Padding(1); 
            this.pbPortrait.Size = new Size(80, 0x4f); 
            this.pbPortrait.SizeMode = PictureBoxSizeMode.StretchImage; 
            this.pbPortrait.TabIndex = 5; 
            this.pbPortrait.TabStop = false; 
            base.AutoScaleDimensions = new SizeF(6f, 13f); 
            base.BaseHeight = 0x15b; 
            base.BaseWidth = 0x17b; 
            base.CancelButton = this.xbtnCancel; 
            base.ClientSize = new Size(0x17b, 0x15b); 
            base.Controls.Add(this.pnlContent); 
            base.Controls.Add(this.xbtnCancel); 
            base.Controls.Add(this.xbtnOK); 
            base.DisplayLocation = new System.Drawing.Point(0x12, 0x26); 
            base.DisplaySize = new Size(0x17b, 0x15b); 
            base.Name = "ApplyJoinGroupForm"; 
            base.Padding = new Padding(1, 0x16, 13, 4); 
            base.Text = "申请加入群"; 
            base.FormClosing += new FormClosingEventHandler(this.ApplyJoinGroupForm_FormClosing); 
            base.Load += new EventHandler(this.ApplyJoinGroupForm_Load); 
            this.pnlContent.ResumeLayout(false); 
            this.pnlContent.PerformLayout(); 
            this.gbReply.ResumeLayout(false); 
            this.gbReply.PerformLayout(); 
            ((ISupportInitialize) this.pbPortrait).EndInit(); 
            base.ResumeLayout(false); 
        } 
 
        private void op_ImpsError(object sender, ImpsErrorEventArgs e) 
        { 
            try 
            { 
                if (e.ErrorCode != 0x199) 
                { 
                    base.Close(); 
                } 
                this._framework.UnifiedMessageBox.ShowInfo(e.Summary); 
                (sender as AsyncBizOperation).IsImpsErrorHandled = true; 
                this.op = null; 
                this.xbtnOK.Enabled = true; 
                this.xbtnCancel.Enabled = true; 
            } 
            catch (Exception exception) 
            { 
                ClientLogger.WriteException(exception); 
            } 
        } 
 
        private void op_Successed(object sender, EventArgs e) 
        { 
            base.Close(); 
        } 
 
        private void PersonalInfo_PropertiesChanged(object sender, PropertiesChangedEventArgs e) 
        { 
            try 
            { 
                if (e.ContainsProperty("Portrait")) 
                { 
                    this.pbPortrait.Image = this._contact.PersonalInfo.Portrait; 
                } 
            } 
            catch (Exception exception) 
            { 
                ClientLogger.WriteException(exception); 
            } 
        } 
 
        private void xbtnCancel_Click(object sender, EventArgs e) 
        { 
            base.Close(); 
        } 
 
        private void xbtnOK_Click(object sender, EventArgs e) 
        { 
            try 
            { 
                if (this.op == null) 
                { 
                    string str; 
                    if (this.rbAgree.Checked) 
                    { 
                        str = "1"; 
                    } 
                    else 
                    { 
                        str = "2"; 
                    } 
                    PersonalGroupMember member = new PersonalGroupMember(this.CurrentUser, this._contact.Uri.Raw, this._group); 
                    this.op = new AsyncBizOperation(); 
                    this.op.Successed += new EventHandler(this.op_Successed); 
                    this.op.ImpsError += new EventHandler(this.op_ImpsError); 
                    this.CurrentUser.PersonalGroupManager.AsyncHandleGroupJoin(member, str, "", this.op); 
                    this.xbtnOK.Enabled = false; 
                    this.xbtnCancel.Enabled = false; 
                } 
            } 
            catch (Exception exception) 
            { 
                ClientLogger.WriteException(exception); 
            } 
        } 
 
        private void xlblAnouce_LabelLinkClick(object sender, LabelLinkClickEventArgs e) 
        { 
            try 
            { 
                if (!string.IsNullOrEmpty(e.Url)) 
                { 
                    IicUri uri = new IicUri(e.Url); 
                    if (uri.IsContact) 
                    { 
                        this._framework.ContactManager.ShowContactDetail(this, uri.Raw); 
                    } 
                    else if (uri.Type == IicUriType.PersonalGroup) 
                    { 
                        PersonalGroup group = this.CurrentUser.PersonalGroups[uri]; 
                        if (group != null) 
                        { 
                            this._framework.PersonalGroupManager.ShowGroupSetting(this, group, GroupOption.Normal); 
                        } 
                    } 
                } 
            } 
            catch (Exception exception) 
            { 
                ClientLogger.WriteException(exception); 
            } 
        } 
 
        private void xlblUserNameText_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) 
        { 
            try 
            { 
                this._framework.ContactManager.ShowContactDetail(this, this._contact.Uri.Raw); 
            } 
            catch (Exception exception) 
            { 
                ClientLogger.WriteException(exception); 
            } 
        } 
 
        private void xllSeeUserDetails_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) 
        { 
            try 
            { 
                this._framework.ContactManager.ShowContactDetail(this, this._contact.Uri.Raw); 
            } 
            catch (Exception exception) 
            { 
                ClientLogger.WriteException(exception); 
            } 
        } 
 
        private User CurrentUser 
        { 
            get 
            { 
                return this._framework.AccountManager.CurrentUser; 
            } 
        } 
    } 
}