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

📄 psexcontrol.cs

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

    internal class PsExControl : OptionsControlBase
    {
        private bool _duringAgeOrBirthdayChanging;
        private IFrameworkWindow _iFrameworkWindow;
        private XComboBox comboBoxBloodType;
        private XComboBox comboBoxEmail;
        private IContainer components;
        private DateTimeSelectControl ctlBirthdate;
        private XLabel label1;
        private XLabel label3;
        private XLabel labelBirthday;
        private XLabel lbBloodType;
        private XLabel lbHoroscope;
        private XLabel lbLunarAnimal;
        private XLabel lbOtherEmail;
        private XLabel lbPersonalEmail;
        private XLabel lbPrimaryEmail;
        private XLabel lbWorkEmail;
        private XNumericUpDown numericUpDownAge;
        private XTextBox textBoxHoroscope;
        private XTextBox textBoxLunarAnimal;
        private XTextBox textBoxOtherEmail;
        private XTextBox textBoxPersonalEmail;
        private XTextBox textBoxWorkEmail;
        private XComboBox xcbPerBirthday;
        private XComboBox xcbPerEmail;
        private GroupBox xgbEmail;
        private GroupBox xGroupBox1;
        private GroupBox xGroupBox2;

        public PsExControl(IFrameworkWindow iFrameworkWindow)
        {
            this._iFrameworkWindow = iFrameworkWindow;
            this.InitializeComponent();
            this.SetLimitation();
            this.ctlBirthdate.MinDateTime = new DateTime(0x76c, 1, 1);
            this.ctlBirthdate.MaxDateTime = Imps.Client.Core.User.ServerTime;
            this.InitSelectEmail();
            this.InitBloodType();
            this.InitPermissions();
            this.handleUiEvent();
            this.numericUpDownAge.MaxLength = 2;
            this.numericUpDownAge.SetAcceptDigitOnly();
            this.numericUpDownAge.TextChanged += new EventHandler(this.PsExControl_TextChanged);
            this.ctlBirthdate.YearTextChange += new EventHandler(this.ctlBirthdate_YearTextChange);
        }

        private static Horoscope calHoroscope(DateTime date)
        {
            string str;
            if (date.Year == PersonalInfoBase.NullBirthDate.Year)
            {
                return Horoscope.Unknown;
            }
            ChineseCalendar calendar = new ChineseCalendar(date);
            return (Horoscope) calendar.FormatHoroscope(out str);
        }

        private static LunarAnimal calLunarAnimal(DateTime date)
        {
            ChineseCalendar calendar = new ChineseCalendar(date);
            if ((date >= calendar.MinSupportedDateTime) && (date <= calendar.MaxSupportedDateTime))
            {
                return IMPSEnums.GetEnumByDescription<LunarAnimal>(calendar.LunarAnimal);
            }
            return LunarAnimal.Unknown;
        }

        public override bool CheckUserInput()
        {
            DateTime? selectedDateTime = this.ctlBirthdate.SelectedDateTime;
            if (this.ctlBirthdate.SelectedYearText == "1900")
            {
                BalloonHelper.ShowInputErrorBallon(this.ctlBirthdate, StringTable.PersonalInfo.MsgInvalidAge, StringTable.Options.TitleInvalidInput);
                return false;
            }
            if (!selectedDateTime.HasValue)
            {
                BalloonHelper.ShowInputErrorBallon(this.ctlBirthdate, StringTable.PersonalInfo.MsgInvalidAge, StringTable.Options.TitleInvalidInput);
                return false;
            }
            if ((selectedDateTime.Value.Year != 0x76c) && !ImpsHelper.IsBirthdayValid(selectedDateTime.Value, 1, 0x63, Imps.Client.Core.User.ServerTime))
            {
                BalloonHelper.ShowInputErrorBallon(this.ctlBirthdate, StringTable.PersonalInfo.MsgInvalidAge, StringTable.Options.TitleInvalidInput);
                return false;
            }
            if (!this.DoCheckEmail(this.textBoxPersonalEmail))
            {
                return false;
            }
            if (!this.DoCheckEmail(this.textBoxWorkEmail))
            {
                return false;
            }
            return this.DoCheckEmail(this.textBoxOtherEmail);
        }

        private void ctlBirthdate_SelectedDateTimeChange(object sender, EventArgs e)
        {
            UiErrorHelper.HandEventSafely(this._iFrameworkWindow, delegate {
                DateTime? birthday = this.ctlBirthdate.SelectedDateTime;
                this.SetBirthDate(selectedDateTime);
            });
        }

        private void ctlBirthdate_YearTextChange(object sender, EventArgs e)
        {
            this.SetBirthDate(this.ctlBirthdate.SelectedDateTime);
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private bool DoCheckEmail(TextBox txtControl)
        {
            if ((txtControl.Text.Trim() != "") && !StringHelper.IsEmail(txtControl.Text))
            {
                txtControl.Focus();
                txtControl.SelectAll();
                BalloonHelper.ShowInputErrorBallon(txtControl, "电子邮件地址不正确!", "错误!", 0x5dc);
                return false;
            }
            return true;
        }

        private void handleUiEvent()
        {
            this.numericUpDownAge.ValueChanged += new EventHandler(this.uiData_Changed);
            this.comboBoxBloodType.SelectedIndexChanged += new EventHandler(this.uiData_Changed);
            this.xcbPerEmail.SelectedIndexChanged += new EventHandler(this.uiData_Changed);
            this.textBoxOtherEmail.TextChanged += new EventHandler(this.uiData_Changed);
            this.textBoxPersonalEmail.TextChanged += new EventHandler(this.uiData_Changed);
            this.textBoxWorkEmail.TextChanged += new EventHandler(this.uiData_Changed);
            this.comboBoxEmail.SelectedIndexChanged += new EventHandler(this.uiData_Changed);
            this.xcbPerBirthday.SelectedIndexChanged += new EventHandler(this.uiData_Changed);
            this.xcbPerBirthday.MouseHover += new EventHandler(this.xcbPerBirthday_MouseHover);
            this.ctlBirthdate.SelectedDateTimeChange += new EventHandler(this.uiData_Changed);
            this.ctlBirthdate.YearTextChange += new EventHandler(this.uiData_Changed);
        }

        private void InitBloodType()
        {
            this.comboBoxBloodType.DataSource = IMPSEnums.GetEnumDescriptionList<BloodType>();
            this.comboBoxBloodType.DisplayMember = "Description";
            this.comboBoxBloodType.ValueMember = "Value";
        }

        private void InitializeComponent()
        {
            this.lbLunarAnimal = new XLabel();
            this.textBoxLunarAnimal = new XTextBox();
            this.lbBloodType = new XLabel();
            this.comboBoxBloodType = new XComboBox();
            this.lbHoroscope = new XLabel();
            this.textBoxHoroscope = new XTextBox();
            this.textBoxPersonalEmail = new XTextBox();
            this.lbPersonalEmail = new XLabel();
            this.textBoxWorkEmail = new XTextBox();
            this.lbWorkEmail = new XLabel();
            this.textBoxOtherEmail = new XTextBox();
            this.lbOtherEmail = new XLabel();
            this.lbPrimaryEmail = new XLabel();
            this.comboBoxEmail = new XComboBox();
            this.xGroupBox1 = new GroupBox();
            this.label3 = new XLabel();
            this.numericUpDownAge = new XNumericUpDown();
            this.label1 = new XLabel();
            this.xGroupBox2 = new GroupBox();
            this.ctlBirthdate = new DateTimeSelectControl();
            this.xcbPerBirthday = new XComboBox();
            this.labelBirthday = new XLabel();
            this.xgbEmail = new GroupBox();
            this.xcbPerEmail = new XComboBox();
            this.xGroupBox1.SuspendLayout();
            this.numericUpDownAge.BeginInit();
            this.xGroupBox2.SuspendLayout();
            this.xgbEmail.SuspendLayout();
            base.SuspendLayout();
            this.lbLunarAnimal.AutoSize = true;
            this.lbLunarAnimal.Location = new Point(15, 0x53);
            this.lbLunarAnimal.Name = "lbLunarAnimal";
            this.lbLunarAnimal.Size = new Size(0x1f, 13);
            this.lbLunarAnimal.TabIndex = 5;
            this.lbLunarAnimal.Text = "生肖";
            this.textBoxLunarAnimal.BackColor = Color.FromArgb(240, 240, 240);
            this.textBoxLunarAnimal.BorderStyle = BorderStyle.FixedSingle;
            this.textBoxLunarAnimal.Location = new Point(0x41, 80);
            this.textBoxLunarAnimal.Name = "textBoxLunarAnimal";
            this.textBoxLunarAnimal.ReadOnly = true;
            this.textBoxLunarAnimal.Size = new Size(140, 20);
            this.textBoxLunarAnimal.TabIndex = 6;
            this.lbBloodType.AutoSize = true;
            this.lbBloodType.Location = new Point(15, 0x37);
            this.lbBloodType.Name = "lbBloodType";
            this.lbBloodType.Size = new Size(0x1f, 13);
            this.lbBloodType.TabIndex = 3;

⌨️ 快捷键说明

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