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

📄 extendprofilecontrol.cs

📁 飞信的收发使用csharp进行开发
💻 CS
📖 第 1 页 / 共 3 页
字号:
namespace Imps.Client.Pc.UIContactList
{
    using Imps.Client.Core;
    using Imps.Client.Pc;
    using Imps.Client.Pc.BizControls;
    using Imps.Client.Pc.Controls;
    using Imps.Client.Resource;
    using Imps.Common;
    using Imps.Utils;
    using System;
    using System.ComponentModel;
    using System.Drawing;
    using System.Windows.Forms;

    public class ExtendProfileControl : ProfileControlBase
    {
        private Imps.Client.Core.Contact _contact;
        private IFrameworkWindow _iFrameworkWindow;
        private XComboBox cboBloodType;
        private XComboBox cboPrimaryEmail;
        private IContainer components;
        private DateTimeSelectControl ctlDateTime;
        private XLabel label1;
        private XLabel label4;
        private XLabel lblHomePhone_Nav;
        private XLabel lblOtherEmail;
        private XLabel lblOtherPhone_Nav;
        private XLabel lblPersonalEmail_Nav;
        private XLabel lblWorkEmail_Nav;
        private XLabel lblWorkPhone_Nav;
        private Panel panel1;
        private XTextBox txtHomePhone;
        private XTextBox txtHoroscope;
        private XTextBox txtLunarAnimal;
        private XTextBox txtOtherEmail;
        private XTextBox txtOtherPhone;
        private XTextBox txtPersonalEmail;
        private XTextBox txtWorkEmail;
        private XTextBox txtWorkPhone;

        public ExtendProfileControl(IFrameworkWindow frameworkWnd, Imps.Client.Core.Contact contact)
        {
            this._iFrameworkWindow = frameworkWnd;
            this._contact = contact;
            this.InitializeComponent();
            this.InitListBoxes();
        }

        private void AddStar()
        {
            UiErrorHelper.HandEventSafely(this._iFrameworkWindow, delegate {
                ProfileManager.StarConfirmHandler callBack = null;
                ProfileManager.StarConfirmHandler handler2 = null;
                ProfileManager.StarConfirmHandler handler3 = null;
                ProfileManager.StarConfirmHandler handler4 = null;
                ProfileManager.StarConfirmHandler handler5 = null;
                ProfileManager.StarConfirmHandler handler6 = null;
                ProfileManager.StarConfirmHandler handler7 = null;
                ProfileManager.StarConfirmHandler handler8 = null;
                ProfileManager.StarConfirmHandler handler9 = null;
                if (this._contact.PersonalInfo.BirthDate.ShouldPrompt)
                {
                    if (callBack == null)
                    {
                        callBack = delegate {
                            this.ctlDateTime.SelectedDateTime = new DateTime?(this._contact.PersonalInfo.BirthDate.ContactSetData);
                        };
                    }
                    ProfileManager.AddStar<DateTime>(this, new Point(this.ctlDateTime.Location.X - 20, this.ctlDateTime.Location.Y), this._contact.PersonalInfo.BirthDate, callBack);
                }
                if (this._contact.PersonalInfo.BloodType.ShouldPrompt)
                {
                    if (handler2 == null)
                    {
                        handler2 = delegate {
                            this.cboBloodType.SelectedValue = this._contact.PersonalInfo.BloodType.ContactSetData;
                        };
                    }
                    ProfileManager.AddStar<BloodType>(this, new Point(this.cboBloodType.Location.X - 20, this.cboBloodType.Location.Y), this._contact.PersonalInfo.BloodType, handler2);
                }
                if (this._contact.PersonalInfo.HomePhone.ShouldPrompt)
                {
                    if (handler3 == null)
                    {
                        handler3 = delegate {
                            this.txtHomePhone.Text = this._contact.PersonalInfo.HomePhone.ContactSetData;
                        };
                    }
                    ProfileManager.AddStar<string>(this, new Point(this.txtHomePhone.Location.X - 20, this.txtHomePhone.Location.Y), this._contact.PersonalInfo.HomePhone, handler3);
                }
                if (this._contact.PersonalInfo.OtherEmail.ShouldPrompt)
                {
                    if (handler4 == null)
                    {
                        handler4 = delegate {
                            this.txtOtherEmail.Text = this._contact.PersonalInfo.OtherEmail.ContactSetData;
                        };
                    }
                    ProfileManager.AddStar<string>(this, new Point(this.txtOtherEmail.Location.X - 20, this.txtOtherEmail.Location.Y), this._contact.PersonalInfo.OtherEmail, handler4);
                }
                if (this._contact.PersonalInfo.OtherPhone.ShouldPrompt)
                {
                    if (handler5 == null)
                    {
                        handler5 = delegate {
                            this.txtOtherPhone.Text = this._contact.PersonalInfo.OtherPhone.ContactSetData;
                        };
                    }
                    ProfileManager.AddStar<string>(this, new Point(this.txtOtherPhone.Location.X - 20, this.txtOtherPhone.Location.Y), this._contact.PersonalInfo.OtherPhone, handler5);
                }
                if (this._contact.PersonalInfo.PersonalEmail.ShouldPrompt)
                {
                    if (handler6 == null)
                    {
                        handler6 = delegate {
                            this.txtPersonalEmail.Text = this._contact.PersonalInfo.PersonalEmail.ContactSetData;
                        };
                    }
                    ProfileManager.AddStar<string>(this, new Point(this.txtPersonalEmail.Location.X - 20, this.txtPersonalEmail.Location.Y), this._contact.PersonalInfo.PersonalEmail, handler6);
                }
                if (this._contact.PersonalInfo.WorkEmail.ShouldPrompt)
                {
                    if (handler7 == null)
                    {
                        handler7 = delegate {
                            this.txtWorkEmail.Text = this._contact.PersonalInfo.WorkEmail.ContactSetData;
                        };
                    }
                    ProfileManager.AddStar<string>(this, new Point(this.txtWorkEmail.Location.X - 20, this.txtWorkEmail.Location.Y), this._contact.PersonalInfo.WorkEmail, handler7);
                }
                if (this._contact.PersonalInfo.WorkPhone.ShouldPrompt)
                {
                    if (handler8 == null)
                    {
                        handler8 = delegate {
                            this.txtWorkPhone.Text = this._contact.PersonalInfo.WorkPhone.ContactSetData;
                        };
                    }
                    ProfileManager.AddStar<string>(this, new Point(this.txtWorkPhone.Location.X - 20, this.txtWorkPhone.Location.Y), this._contact.PersonalInfo.WorkPhone, handler8);
                }
                if (this._contact.PersonalInfo.PrimaryEmail.ShouldPrompt)
                {
                    if (handler9 == null)
                    {
                        handler9 = delegate {
                            this.cboPrimaryEmail.SelectedValue = EnumHelper.Int32ToEnum<EmailUseType>(this._contact.PersonalInfo.PrimaryEmail.ContactSetData, EmailUseType.PersonalEmail);
                        };
                    }
                    ProfileManager.AddStar<short>(this, new Point(this.cboPrimaryEmail.Location.X - 20, this.cboPrimaryEmail.Location.Y), this._contact.PersonalInfo.PrimaryEmail, handler9);
                }
            });
        }

        private bool CheckMail(TextBox txtControl)
        {
            if ((txtControl.Text.Trim() != "") && !StringHelper.IsEmail(txtControl.Text))
            {
                this._iFrameworkWindow.UnifiedMessageBox.ShowInfo(base.FindForm(), StringTable.PersonalInfo.MsgEmailInvalid);
                txtControl.Focus();
                return false;
            }
            return true;
        }

        public override bool CheckUserInput()
        {
            if ((!this.CheckMail(this.txtPersonalEmail) || !this.CheckMail(this.txtWorkEmail)) || !this.CheckMail(this.txtOtherEmail))
            {
                return false;
            }
            if ((this.ctlDateTime.SelectedYearText.Length > 0) && !this.ctlDateTime.SelectedDateTime.HasValue)
            {
                this.ctlDateTime.Focus();
                this._iFrameworkWindow.UnifiedMessageBox.ShowInfo(base.FindForm(), StringTable.PersonalInfo.MsgDateTimeError);
                return false;
            }
            return true;
        }

        public override bool ControlLoad()
        {
            this._contact.PersonalInfo.PropertiesChanged += new EventHandler<PropertiesChangedEventArgs>(this.PersonalInfo_PropertiesChanged);
            return base.ControlLoad();
        }

        public override bool ControlUnload()
        {
            this._contact.PersonalInfo.PropertiesChanged -= new EventHandler<PropertiesChangedEventArgs>(this.PersonalInfo_PropertiesChanged);
            return base.ControlUnload();
        }

        private void ctlDateTime_DateTimeChange(object sender, EventArgs e)
        {
            this.FormatHoroscopeAndLunarAnimal();
        }

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

        private void FormatHoroscopeAndLunarAnimal()
        {
            UiErrorHelper.HandEventSafely(this._iFrameworkWindow, delegate {
                DateTime? selectedDateTime = this.ctlDateTime.SelectedDateTime;
                if (selectedDateTime.HasValue)
                {
                    string str;
                    ChineseCalendar calendar = new ChineseCalendar(selectedDateTime.Value);
                    if ((selectedDateTime.Value < calendar.MaxSupportedDateTime) && (selectedDateTime.Value > calendar.MinSupportedDateTime))
                    {
                        this.txtLunarAnimal.Text = calendar.LunarAnimal;
                    }
                    calendar.FormatHoroscope(out str);
                    this.txtHoroscope.Text = str;
                }
                else
                {
                    this.txtHoroscope.Text = IMPSEnums.GetEnumDescription<Horoscope>(this._contact.PersonalInfo.Horoscope);
                    this.txtLunarAnimal.Text = IMPSEnums.GetEnumDescription<LunarAnimal>(this._contact.PersonalInfo.LunarAnimal);
                }
            });
        }

        protected override void HandleUiChanged()

⌨️ 快捷键说明

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