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

📄 businessprofilecontrol.cs

📁 飞信的收发使用csharp进行开发
💻 CS
字号:
namespace Imps.Client.Pc.UIContactList
{
    using Imps.Client.Core;
    using Imps.Client.Pc;
    using Imps.Client.Pc.Controls;
    using System;
    using System.ComponentModel;
    using System.Drawing;
    using System.Windows.Forms;

    public class BusinessProfileControl : ProfileControlBase
    {
        private Contact _contact;
        private IFrameworkWindow _iFrameworkWindow;
        private IContainer components;
        private XLabel lblCompany;
        private XLabel lblCompanyWebsite;
        private XLabel lblJobTitle;
        private XTextBox txtCompany;
        private XTextBox txtCompanyWebsite;
        private XTextBox txtJobTitle;

        public BusinessProfileControl(IFrameworkWindow frameworkWnd, Contact contact)
        {
            this.InitializeComponent();
            this._iFrameworkWindow = frameworkWnd;
            this._contact = contact;
            this.HandleUiChanged();
            this.AddStar();
        }

        private void AddStar()
        {
            UiErrorHelper.HandEventSafely(this._iFrameworkWindow, delegate {
                ProfileManager.StarConfirmHandler callBack = null;
                ProfileManager.StarConfirmHandler handler2 = null;
                ProfileManager.StarConfirmHandler handler3 = null;
                if (this._contact.PersonalInfo.Company.ShouldPrompt)
                {
                    if (callBack == null)
                    {
                        callBack = delegate {
                            this.txtCompany.Text = this._contact.PersonalInfo.Company.ContactSetData;
                        };
                    }
                    ProfileManager.AddStar<string>(this, new Point(this.txtCompany.Location.X - 20, this.txtCompany.Location.Y), this._contact.PersonalInfo.Company, callBack);
                }
                if (this._contact.PersonalInfo.CompanyWebsite.ShouldPrompt)
                {
                    if (handler2 == null)
                    {
                        handler2 = delegate {
                            this.txtCompanyWebsite.Text = this._contact.PersonalInfo.CompanyWebsite.ContactSetData;
                        };
                    }
                    ProfileManager.AddStar<string>(this, new Point(this.txtCompanyWebsite.Location.X - 20, this.txtCompanyWebsite.Location.Y), this._contact.PersonalInfo.CompanyWebsite, handler2);
                }
                if (this._contact.PersonalInfo.JobTitle.ShouldPrompt)
                {
                    if (handler3 == null)
                    {
                        handler3 = delegate {
                            this.txtJobTitle.Text = this._contact.PersonalInfo.JobTitle.ContactSetData;
                        };
                    }
                    ProfileManager.AddStar<string>(this, new Point(this.txtJobTitle.Location.X - 20, this.txtJobTitle.Location.Y), this._contact.PersonalInfo.JobTitle, handler3);
                }
            });
        }

        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 displayContactInfo()
        {
            UiErrorHelper.HandEventSafely(this._iFrameworkWindow, delegate {
                this.txtCompany.Text = this._contact.PersonalInfo.Company.Value;
                this.txtCompanyWebsite.Text = this._contact.PersonalInfo.CompanyWebsite.Value;
                this.txtJobTitle.Text = this._contact.PersonalInfo.JobTitle.Value;
            });
        }

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

        protected override void HandleUiChanged()
        {
            base.HandleUiChanged();
            this.txtCompany.TextChanged += new EventHandler(this.UIData_Changed);
            this.txtCompanyWebsite.TextChanged += new EventHandler(this.UIData_Changed);
            this.txtJobTitle.TextChanged += new EventHandler(this.UIData_Changed);
        }

        private void InitializeComponent()
        {
            this.lblCompany = new XLabel();
            this.txtCompany = new XTextBox();
            this.lblCompanyWebsite = new XLabel();
            this.txtCompanyWebsite = new XTextBox();
            this.lblJobTitle = new XLabel();
            this.txtJobTitle = new XTextBox();
            XLabel label = new XLabel();
            XLabel label2 = new XLabel();
            base.SuspendLayout();
            label.AutoSize = true;
            label.BorderColor = Color.Empty;
            label.ButtonBorderStyle = ButtonBorderStyle.None;
            label.Location = new Point(3, 11);
            label.Name = "lblBasicInfo";
            label.Size = new Size(0x37, 13);
            label.TabIndex = 0x15;
            label.Text = "商务信息";
            label.UseMnemonic = false;
            label2.BorderColor = Color.Empty;
            label2.BorderStyle = BorderStyle.Fixed3D;
            label2.ButtonBorderStyle = ButtonBorderStyle.None;
            label2.Location = new Point(0x3a, 0x11);
            label2.Name = "lblSeperate";
            label2.Size = new Size(300, 2);
            label2.TabIndex = 0x16;
            label2.UseMnemonic = false;
            this.lblCompany.AutoSize = true;
            this.lblCompany.BorderColor = Color.Empty;
            this.lblCompany.ButtonBorderStyle = ButtonBorderStyle.None;
            this.lblCompany.Location = new Point(0x11, 0x23);
            this.lblCompany.Name = "lblCompany";
            this.lblCompany.Size = new Size(0x37, 13);
            this.lblCompany.TabIndex = 0x17;
            this.lblCompany.Text = "公司名称";
            this.lblCompany.UseMnemonic = false;
            this.txtCompany.BackColor = Color.FromArgb(240, 240, 240);
            this.txtCompany.BorderStyle = BorderStyle.FixedSingle;
            this.txtCompany.Location = new Point(20, 0x37);
            this.txtCompany.MaxLength = 0x80;
            this.txtCompany.Name = "txtCompany";
            this.txtCompany.ReadOnly = true;
            this.txtCompany.Size = new Size(320, 20);
            this.txtCompany.TabIndex = 1;
            this.lblCompanyWebsite.AutoSize = true;
            this.lblCompanyWebsite.BorderColor = Color.Empty;
            this.lblCompanyWebsite.ButtonBorderStyle = ButtonBorderStyle.None;
            this.lblCompanyWebsite.Location = new Point(0x11, 0x56);
            this.lblCompanyWebsite.Name = "lblCompanyWebsite";
            this.lblCompanyWebsite.Size = new Size(0x37, 13);
            this.lblCompanyWebsite.TabIndex = 0x17;
            this.lblCompanyWebsite.Text = "公司主页";
            this.lblCompanyWebsite.UseMnemonic = false;
            this.txtCompanyWebsite.BackColor = Color.FromArgb(240, 240, 240);
            this.txtCompanyWebsite.BorderStyle = BorderStyle.FixedSingle;
            this.txtCompanyWebsite.Location = new Point(20, 0x6a);
            this.txtCompanyWebsite.MaxLength = 0x80;
            this.txtCompanyWebsite.Name = "txtCompanyWebsite";
            this.txtCompanyWebsite.ReadOnly = true;
            this.txtCompanyWebsite.Size = new Size(320, 20);
            this.txtCompanyWebsite.TabIndex = 2;
            this.lblJobTitle.AutoSize = true;
            this.lblJobTitle.BorderColor = Color.Empty;
            this.lblJobTitle.ButtonBorderStyle = ButtonBorderStyle.None;
            this.lblJobTitle.Location = new Point(0x11, 0x89);
            this.lblJobTitle.Name = "lblJobTitle";
            this.lblJobTitle.Size = new Size(0x37, 13);
            this.lblJobTitle.TabIndex = 0x17;
            this.lblJobTitle.Text = "职  位";
            this.lblJobTitle.UseMnemonic = false;
            this.txtJobTitle.BackColor = Color.FromArgb(240, 240, 240);
            this.txtJobTitle.BorderStyle = BorderStyle.FixedSingle;
            this.txtJobTitle.Location = new Point(20, 0x9d);
            this.txtJobTitle.MaxLength = 0x100;
            this.txtJobTitle.Name = "txtJobTitle";
            this.txtJobTitle.ReadOnly = true;
            this.txtJobTitle.Size = new Size(320, 20);
            this.txtJobTitle.TabIndex = 3;
            base.AutoScaleDimensions = new SizeF(6f, 13f);
            base.AutoScaleMode = AutoScaleMode.Font;
            this.BackColor = Color.Transparent;
            base.Controls.Add(label);
            base.Controls.Add(this.txtJobTitle);
            base.Controls.Add(this.txtCompanyWebsite);
            base.Controls.Add(this.txtCompany);
            base.Controls.Add(this.lblJobTitle);
            base.Controls.Add(this.lblCompanyWebsite);
            base.Controls.Add(this.lblCompany);
            base.Controls.Add(label2);
            base.Name = "BusinessProfileControl";
            base.Size = new Size(370, 400);
            base.ResumeLayout(false);
            base.PerformLayout();
        }

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            if (!this._iFrameworkWindow.AccountManager.CurrentUser.ContactList.Contacts.Contains(this._contact))
            {
                this.txtCompany.ReadOnly = true;
                this.txtCompanyWebsite.ReadOnly = true;
                this.txtJobTitle.ReadOnly = true;
            }
        }

        private void PersonalInfo_PropertiesChanged(object sender, PropertiesChangedEventArgs e)
        {
            if (e.ContainsAnyOfProperties(new string[] { "company", "company-website", "job-title" }))
            {
                this.displayContactInfo();
            }
        }

        protected override void UIData_Changed(object sender, EventArgs e)
        {
            UiErrorHelper.HandEventSafely(this._iFrameworkWindow, delegate {
                base.Modified = true;
            });
        }

        public override bool UpdateData(bool update)
        {
            SimpleEventHandler handler = null;
            if (update)
            {
                if (!this.CheckUserInput())
                {
                    return false;
                }
                if (handler == null)
                {
                    handler = delegate {
                        if (this.txtCompany.Text != this._contact.PersonalInfo.Company.Value)
                        {
                            this._contact.PersonalInfo.Company.UserSetDataProposedValue = this.txtCompany.Text;
                        }
                        if (this.txtCompanyWebsite.Text != this._contact.PersonalInfo.CompanyWebsite.Value)
                        {
                            this._contact.PersonalInfo.CompanyWebsite.UserSetDataProposedValue = this.txtCompanyWebsite.Text;
                        }
                        if (this.txtJobTitle.Text != this._contact.PersonalInfo.JobTitle.Value)
                        {
                            this._contact.PersonalInfo.JobTitle.UserSetDataProposedValue = this.txtJobTitle.Text;
                        }
                    };
                }
                UiErrorHelper.HandEventSafely(this._iFrameworkWindow, handler);
                base.Modified = false;
            }
            else
            {
                this.displayContactInfo();
            }
            return true;
        }
    }
}

⌨️ 快捷键说明

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