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


namespace Imps.Client.Pc.IPI.UI 
{ 
    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 RegisterIPIDialog : XIMDialog 
    { 
        private XButton btnCancel; 
        private XButton btnRegister; 
        private CheckBox chkAgreeLicence; 
        private IContainer components; 
        internal Imps.Client.Core.Configuration config; 
        internal IFrameworkWindow frmWnd; 
        private XLabel label1; 
        private XLabel lbLicence; 
        private XLabel lblSeperate; 
        private XLabel lbTip; 
        private PictureBox pbProvision; 
        private Panel pnlContainer; 
        private Panel pnlPage; 
        private ProvsionData provsionData = new ProvsionData(); 
        private const string serverId = "VodafoneFederation"; 
        private XTextBox txtLicence; 
        private Imps.Client.Core.User user; 
 
        public RegisterIPIDialog(IFrameworkWindow wnd) 
        { 
            base.DialogResult = DialogResult.No; 
            this.InitializeComponent(); 
            this.Init(wnd); 
            this.AttachEventHandler(); 
            this.LoadResource(); 
            this.LoadControl(); 
        } 
 
        private void AttachEventHandler() 
        { 
            Imps.Client.Core.Provisioning.OnAgreementRecived += new EventHandler(this.Provsioning_OnAgreementRecived); 
        } 
 
        private void chkAgreeLicence_CheckedChanged(object sender, EventArgs e) 
        { 
            this.btnRegister.Enabled = this.chkAgreeLicence.Checked; 
        } 
 
        protected override void Dispose(bool disposing) 
        { 
            if (disposing && (this.components != null)) 
            { 
                this.components.Dispose(); 
            } 
            base.Dispose(disposing); 
        } 
 
        private void Init(IFrameworkWindow wnd) 
        { 
            this.frmWnd = wnd; 
            this.user = wnd.AccountManager.CurrentUser; 
            this.config = wnd.AccountManager.CurrentUser.Configuration; 
            this.provsionData.AgreementName = "VodafoneFederation"; 
        } 
 
        private void InitializeComponent() 
        { 
            this.pnlContainer = new Panel(); 
            this.lbTip = new XLabel(); 
            this.label1 = new XLabel(); 
            this.btnRegister = new XButton(); 
            this.btnCancel = new XButton(); 
            this.pnlPage = new Panel(); 
            this.lblSeperate = new XLabel(); 
            this.lbLicence = new XLabel(); 
            this.chkAgreeLicence = new CheckBox(); 
            this.txtLicence = new XTextBox(); 
            this.pbProvision = new PictureBox(); 
            this.pnlContainer.SuspendLayout(); 
            this.pnlPage.SuspendLayout(); 
            ((ISupportInitialize) this.pbProvision).BeginInit(); 
            base.SuspendLayout(); 
            this.pnlContainer.BackColor = Color.Transparent; 
            this.pnlContainer.Controls.Add(this.lbTip); 
            this.pnlContainer.Controls.Add(this.label1); 
            this.pnlContainer.Controls.Add(this.btnRegister); 
            this.pnlContainer.Controls.Add(this.btnCancel); 
            this.pnlContainer.Controls.Add(this.pnlPage); 
            this.pnlContainer.Controls.Add(this.pbProvision); 
            this.pnlContainer.Dock = DockStyle.Fill; 
            this.pnlContainer.Location = new System.Drawing.Point(6, 0x1f); 
            this.pnlContainer.Name = "pnlContainer"; 
            this.pnlContainer.Padding = new Padding(2); 
            this.pnlContainer.Size = new Size(0x1f7, 0x18f); 
            this.pnlContainer.TabIndex = 1; 
            this.lbTip.AutoSize = true; 
            this.lbTip.Location = new System.Drawing.Point(5, 0x169); 
            this.lbTip.Name = "lbTip"; 
            this.lbTip.Size = new Size(0, 13); 
            this.lbTip.TabIndex = 0x1a; 
            this.label1.BorderStyle = BorderStyle.Fixed3D; 
            this.label1.Location = new System.Drawing.Point(1, 350); 
            this.label1.Name = "label1"; 
            this.label1.Size = new Size(500, 2); 
            this.label1.TabIndex = 0x19; 
            this.btnRegister.Enabled = false; 
            this.btnRegister.Location = new System.Drawing.Point(0x150, 0x163); 
            this.btnRegister.Name = "btnRegister"; 
            this.btnRegister.Size = new Size(0x4b, 0x19); 
            this.btnRegister.TabIndex = 3; 
            this.btnRegister.Text = "开通"; 
            this.btnRegister.UseVisualStyleBackColor = true; 
            this.btnRegister.DialogResult = DialogResult.OK; 
            this.btnCancel.DialogResult = DialogResult.Cancel; 
            this.btnCancel.Location = new System.Drawing.Point(0x1a1, 0x163); 
            this.btnCancel.Name = "btnCancel"; 
            this.btnCancel.Size = new Size(0x4b, 0x19); 
            this.btnCancel.TabIndex = 4; 
            this.btnCancel.Text = "取消"; 
            this.btnCancel.UseVisualStyleBackColor = true; 
            this.pnlPage.Controls.Add(this.lblSeperate); 
            this.pnlPage.Controls.Add(this.lbLicence); 
            this.pnlPage.Controls.Add(this.chkAgreeLicence); 
            this.pnlPage.Controls.Add(this.txtLicence); 
            this.pnlPage.Location = new System.Drawing.Point(0x84, 5); 
            this.pnlPage.Name = "pnlPage"; 
            this.pnlPage.Size = new Size(360, 340); 
            this.pnlPage.TabIndex = 0; 
            this.lblSeperate.BorderStyle = BorderStyle.Fixed3D; 
            this.lblSeperate.Location = new System.Drawing.Point(60, 11); 
            this.lblSeperate.Name = "lblSeperate"; 
            this.lblSeperate.Size = new Size(0x128, 2); 
            this.lblSeperate.TabIndex = 10; 
            this.lbLicence.AutoSize = true; 
            this.lbLicence.Location = new System.Drawing.Point(5, 5); 
            this.lbLicence.Name = "lbLicence"; 
            this.lbLicence.Size = new Size(0x37, 13); 
            this.lbLicence.TabIndex = 9; 
            this.lbLicence.Text = "用户协议"; 
            this.chkAgreeLicence.AutoSize = true; 
            this.chkAgreeLicence.Location = new System.Drawing.Point(3, 320); 
            this.chkAgreeLicence.Name = "chkAgreeLicence"; 
            this.chkAgreeLicence.Size = new Size(0xda, 0x11); 
            this.chkAgreeLicence.TabIndex = 5; 
            this.chkAgreeLicence.Text = "我已经阅读并且接受上面的用户协议"; 
            this.chkAgreeLicence.UseVisualStyleBackColor = true; 
            this.chkAgreeLicence.CheckedChanged += new EventHandler(this.chkAgreeLicence_CheckedChanged); 
            this.txtLicence.BackColor = Color.FromArgb(240, 240, 240); 
            this.txtLicence.BorderStyle = BorderStyle.FixedSingle; 
            this.txtLicence.ImeMode = ImeMode.Disable; 
            this.txtLicence.Location = new System.Drawing.Point(4, 0x15); 
            this.txtLicence.Multiline = true; 
            this.txtLicence.Name = "txtLicence"; 
            this.txtLicence.ReadOnly = true; 
            this.txtLicence.ScrollBars = ScrollBars.Vertical; 
            this.txtLicence.Size = new Size(0x160, 0x125); 
            this.txtLicence.TabIndex = 4; 
            this.pbProvision.BorderStyle = BorderStyle.FixedSingle; 
            this.pbProvision.ErrorImage = null; 
            this.pbProvision.InitialImage = null; 
            this.pbProvision.Location = new System.Drawing.Point(6, 5); 
            this.pbProvision.Name = "pbProvision"; 
            this.pbProvision.Size = new Size(120, 340); 
            this.pbProvision.TabIndex = 0; 
            this.pbProvision.TabStop = false; 
            base.AcceptButton = this.btnRegister; 
            base.AutoScaleDimensions = new SizeF(6f, 13f); 
            base.AutoScaleMode = AutoScaleMode.Font; 
            base.CancelButton = this.btnCancel; 
            base.ClientSize = new Size(0x210, 0x1b6); 
            base.Controls.Add(this.pnlContainer); 
            base.FormBorderStyle = FormBorderStyle.FixedDialog; 
            base.MinimizeBox = false; 
            base.Name = "RegisterIPIDialog"; 
            base.Padding = new Padding(6, 0x1f, 0x13, 8); 
            base.ShowInTaskbar = false; 
            base.StartPosition = FormStartPosition.CenterScreen; 
            base.Text = "开通与Vodafone互通业务 "; 
            this.pnlContainer.ResumeLayout(false); 
            this.pnlContainer.PerformLayout(); 
            this.pnlPage.ResumeLayout(false); 
            this.pnlPage.PerformLayout(); 
            ((ISupportInitialize) this.pbProvision).EndInit(); 
            base.ResumeLayout(false); 
        } 
 
        private void InitSvrUrl(ProvsionData pdata, ServerUriSetting SvrUri) 
        { 
            pdata.ProvsionUrl.UriGetPic = SvrUri.UriGetPicCode; 
            pdata.ProvsionUrl.UriGetSms = SvrUri.UriApplySubSvc; 
            pdata.ProvsionUrl.UriSubSvc = SvrUri.UriSubSvc; 
            pdata.ProvsionUrl.UriSsiLogin = SvrUri.UriSsiAppSignIn; 
            pdata.ProvsionUrl.UriSetProfile = SvrUri.UriInitProfile; 
            pdata.ProvsionUrl.UriGetGeneralInfo = SvrUri.UriGetGeneralInfo; 
            pdata.ProvsionUrl.UriGetProfile = SvrUri.UriGetPersonalInfo; 
        } 
 
        private void LoadControl() 
        { 
            if (this.provsionData.Agreement.Length > 0) 
            { 
                this.txtLicence.Text = this.provsionData.Agreement; 
            } 
            if (this.provsionData.Flag.SmsRequestSended) 
            { 
                this.chkAgreeLicence.Checked = true; 
            } 
            if (!this.provsionData.Flag.SysCfgInited) 
            { 
                ServerUriSetting serverUriSetting = this.config.SystemSetting.ServerUriSetting; 
                if ((serverUriSetting.UriGetPicCode.Length <= 0) || (serverUriSetting.UriGetGeneralInfo.Length <= 0)) 
                { 
                    this.LoadSysCfg(); 
                } 
                else 
                { 
                    this.provsionData.Flag.SysCfgInited = true; 
                    this.InitSvrUrl(this.provsionData, serverUriSetting); 
                    if (this.provsionData.Agreement.Length == 0) 
                    { 
                        Imps.Client.Core.Provisioning.GetAgreement(this.provsionData); 
                    } 
                } 
            } 
            else 
            { 
                Imps.Client.Core.Provisioning.GetCertPic(this.provsionData); 
                if (this.provsionData.Agreement.Length == 0) 
                { 
                    Imps.Client.Core.Provisioning.GetAgreement(this.provsionData); 
                } 
            } 
        } 
 
        private void LoadResource() 
        { 
            base.Icon = ImpsIcons.Logo; 
            this.pbProvision.Image = ImpsResources.GetImage("Images.provsion.png"); 
            base.Text = string.Format(StringTable.Framework.MI_SubscribeVodafoneFormTitle, StringTable.Services.ServiceName_Vodafone); 
        } 
 
        internal void LoadSysCfg() 
        { 
            Imps.Client.Core.Provisioning.GetSysCfg(this.provsionData); 
        } 
 
        protected override void OnClosing(CancelEventArgs e) 
        { 
            if ((base.DialogResult == DialogResult.OK) && !this.chkAgreeLicence.Checked) 
            { 
            } 
        } 
 
        protected override void OnFormClosed(FormClosedEventArgs e) 
        { 
            Imps.Client.Core.Provisioning.OnAgreementRecived -= new EventHandler(this.Provsioning_OnAgreementRecived); 
            base.OnFormClosed(e); 
        } 
 
        private void Provsioning_OnAgreementRecived(object sender, AgreementEventArgs e) 
        { 
            if (e.ErrorMessage.Length == 0) 
            { 
                if (e.Agreement.Length > 0) 
                { 
                    this.provsionData.Agreement = e.Agreement; 
                    this.provsionData.Flag.AgreementRecived = true; 
                    this.txtLicence.Text = e.Agreement; 
                } 
                else 
                { 
                    this.ShowLoadError(); 
                } 
            } 
            else 
            { 
                this.ShowLoadError(); 
            } 
        } 
 
        private void ShowLoadError() 
        { 
        } 
    } 
}