www.pudn.com > Fetion.rar > CreatePersonalGroup.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.Resource; 
    using Imps.Client.Utils; 
    using System; 
    using System.ComponentModel; 
    using System.Drawing; 
    using System.Windows.Forms; 
 
    public class CreatePersonalGroup : XIMDialog 
    { 
        private IFrameworkWindow _framework; 
        private IContainer components; 
        private PGAgreementControl m_ucAgreement; 
        private PGCreateGroupControl m_ucCreateDetail; 
        private Panel pnlContent; 
        private XButton xbtnCancel; 
        private XButton xbtnOK; 
 
        public CreatePersonalGroup(IFrameworkWindow framework) 
        { 
            this._framework = framework; 
            this.InitializeComponent(); 
            base.Controls.SetChildIndex(this.pnlContent, 0); 
            this.m_ucAgreement = new PGAgreementControl(this._framework); 
            this.m_ucAgreement.Dock = DockStyle.Fill; 
            this.pnlContent.Controls.Add(this.m_ucAgreement); 
            this.CurrentUser.StatusChanged += new EventHandler(this.CurrentUser_StatusChanged); 
        } 
 
        public bool CreatePG() 
        { 
            try 
            { 
                PersonalGroupInfo info = new PersonalGroupInfo(null); 
                if (this.m_ucCreateDetail.CollectData(info)) 
                { 
                    AsyncBizOperation op = new AsyncBizOperation(); 
                    op.Successed += new EventHandler(this.op_Successed); 
                    op.ImpsError += new EventHandler(this.op_ImpsError); 
                    this.CurrentUser.PersonalGroupManager.AsyncCreatePersonalGroup(op, info); 
                } 
                else 
                { 
                    return false; 
                } 
            } 
            catch (Exception exception) 
            { 
                ClientLogger.WriteException(exception); 
                return false; 
            } 
            return true; 
        } 
 
        private void CurrentUser_StatusChanged(object sender, UserSatusChangedEventArgs e) 
        { 
            try 
            { 
                if (e.NewStatus != UserAccountStatus.Logon) 
                { 
                    base.Close(); 
                } 
            } 
            catch (Exception exception) 
            { 
                ClientLogger.WriteException(exception); 
            } 
        } 
 
        protected override void Dispose(bool disposing) 
        { 
            if (disposing && (this.components != null)) 
            { 
                this.components.Dispose(); 
            } 
            base.Dispose(disposing); 
        } 
 
        private void InitializeComponent() 
        { 
            ComponentResourceManager manager = new ComponentResourceManager(typeof(Imps.Client.Pc.CreatePersonalGroup)); 
            this.pnlContent = new Panel(); 
            this.xbtnCancel = new XButton(); 
            this.xbtnOK = new XButton(); 
            base.SuspendLayout(); 
            this.pnlContent.BackColor = Color.Transparent; 
            this.pnlContent.Location = new System.Drawing.Point(15, 8); 
            this.pnlContent.Name = "pnlContent"; 
            this.pnlContent.Padding = new Padding(3); 
            this.pnlContent.Size = new Size(0x18e, 380); 
            this.pnlContent.TabIndex = 8; 
            this.xbtnCancel.Anchor = AnchorStyles.Right | AnchorStyles.Bottom; 
            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(0x13d, 0x18a); 
            this.xbtnCancel.Name = "xbtnCancel"; 
            this.xbtnCancel.Size = new Size(0x4b, 0x17); 
            this.xbtnCancel.TabIndex = 10; 
            this.xbtnCancel.Text = "拒绝"; 
            this.xbtnCancel.UseVisualStyleBackColor = false; 
            this.xbtnCancel.Click += new EventHandler(this.xbtnCancel_Click); 
            this.xbtnOK.Anchor = AnchorStyles.Right | AnchorStyles.Bottom; 
            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(0xec, 0x18a); 
            this.xbtnOK.Name = "xbtnOK"; 
            this.xbtnOK.Size = new Size(0x4b, 0x17); 
            this.xbtnOK.TabIndex = 9; 
            this.xbtnOK.Text = "接受"; 
            this.xbtnOK.UseVisualStyleBackColor = false; 
            this.xbtnOK.Click += new EventHandler(this.xbtnOK_Click_1); 
            base.AutoScaleDimensions = new SizeF(6f, 13f); 
            base.AutoScaleMode = AutoScaleMode.Font; 
            base.BaseHeight = 0x1c6; 
            base.BaseWidth = 0x1b9; 
            base.CancelButton = this.xbtnCancel; 
            base.ClientSize = new Size(0x1b3, 0x1ac); 
            base.Controls.Add(this.xbtnCancel); 
            base.Controls.Add(this.pnlContent); 
            base.Controls.Add(this.xbtnOK); 
            base.DisplayLocation = new System.Drawing.Point(0x12, 20); 
            base.Icon = (Icon) manager.GetObject("$this.Icon"); 
            base.Name = "CreatePersonalGroup"; 
            base.Text = "创建群"; 
            base.ResumeLayout(false); 
        } 
 
        protected override void OnClosed(EventArgs e) 
        { 
            try 
            { 
                this.CurrentUser.StatusChanged += new EventHandler(this.CurrentUser_StatusChanged); 
            } 
            catch (Exception exception) 
            { 
                ClientLogger.WriteException(exception); 
            } 
            base.OnClosed(e); 
        } 
 
        private void op_ImpsError(object sender, ImpsErrorEventArgs e) 
        { 
            this._framework.UnifiedMessageBox.ShowError(e.Summary); 
            this.xbtnCancel.Enabled = true; 
            this.xbtnOK.Enabled = true; 
        } 
 
        private void op_Successed(object sender, EventArgs e) 
        { 
            PersonalGroupInfo contextForBiz = (sender as AsyncBizOperation).ContextForBiz as PersonalGroupInfo; 
            this._framework.UnifiedMessageBox.ShowInfo(string.Format(StringTable.CreatePersonalGroup.MsgCreateSuccess, contextForBiz.Name.Value, contextForBiz.Id)); 
            base.Close(); 
        } 
 
        private void xbtnCancel_Click(object sender, EventArgs e) 
        { 
            base.Close(); 
        } 
 
        private void xbtnOK_Click_1(object sender, EventArgs e) 
        { 
            try 
            { 
                if (this.pnlContent.Controls.Contains(this.m_ucAgreement)) 
                { 
                    this.pnlContent.Controls.Clear(); 
                    this.m_ucCreateDetail = new PGCreateGroupControl(this._framework); 
                    this.pnlContent.Controls.Add(this.m_ucCreateDetail); 
                    this.m_ucCreateDetail.Focus(); 
                    this.xbtnOK.Text = "确定"; 
                    this.xbtnCancel.Text = "取消"; 
                } 
                else if (this.CreatePG()) 
                { 
                    this.xbtnOK.Enabled = false; 
                    this.xbtnCancel.Enabled = false; 
                } 
            } 
            catch (Exception exception) 
            { 
                ClientLogger.WriteException(exception); 
            } 
        } 
 
        private Imps.Client.Core.User CurrentUser 
        { 
            get 
            { 
                return this._framework.AccountManager.CurrentUser; 
            } 
        } 
    } 
}