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


namespace Imps.Client.Pc 
{ 
    using Imps.Client.Core; 
    using Imps.Client.Pc.Properties; 
    using Imps.Client.Pc.WndlessControls; 
    using Imps.Client.Utils; 
    using System; 
    using System.ComponentModel; 
    using System.Drawing; 
    using System.Runtime.CompilerServices; 
    using System.Windows.Forms; 
 
    public class ContactInfoControl : UserControl 
    { 
        private Color _BorderColor = Color.FromArgb(0xa4, 170, 220); 
        private Imps.Client.Core.Contact _contact; 
        private string _fetionNo; 
        private IFrameworkWindow _framwork; 
        private System.Drawing.Image _image; 
        private int _imageHeight = 0x60; 
        private int _imagePadding = 8; 
        private int _imageWidth = 0x60; 
        private string _mobileNo; 
        private Rectangle _recPicture; 
        private WndlessScorePictureBox _scoreBox; 
        private string _toolTipText; 
        private WndlessControlCollection _wndlessControls; 
        private IContainer components; 
        private WndlessPortrait imgPortrait; 
        private WndlessPictureBox pictureBox1; 
        private WndlessPictureBox pictureBox2; 
        private TextBox txtFetionNo; 
        private TextBox txtMobileNo; 
 
        public event EventHandler PictureMouseClick; 
 
        public ContactInfoControl() 
        { 
            this.InitializeComponent(); 
            base.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.SupportsTransparentBackColor | ControlStyles.UserPaint, true); 
            this.BackColor = Color.White; 
            this.MobileNo = string.Empty; 
            this.FetionNo = string.Empty; 
            base.MouseMove += new MouseEventHandler(this.ContactInfoControl_MouseMove); 
            base.MouseClick += new MouseEventHandler(this.ContactInfoControl_MouseClick); 
            this.InitImageControl(); 
        } 
 
        private void ContactInfoControl_MouseClick(object sender, MouseEventArgs e) 
        { 
            if ((this.PictureMouseClick != null) && this._recPicture.Contains(e.Location)) 
            { 
                this.PictureMouseClick(sender, e); 
            } 
        } 
 
        private void ContactInfoControl_MouseMove(object sender, MouseEventArgs e) 
        { 
            if (this._recPicture.Contains(e.Location)) 
            { 
                this.Cursor = Cursors.Hand; 
            } 
            else 
            { 
                this.Cursor = Cursors.Default; 
            } 
        } 
 
        protected override void Dispose(bool disposing) 
        { 
            if (disposing && (this.components != null)) 
            { 
                this.components.Dispose(); 
            } 
            base.Dispose(disposing); 
        } 
 
        private void imgPortrait_PortraitClicked(object sender, EventArgs e) 
        { 
            try 
            { 
                this._framwork.ContactManager.ShowContactDetail(base.FindForm(), this.Contact.Uri.Raw); 
            } 
            catch (Exception exception) 
            { 
                ClientLogger.WriteException(exception); 
            } 
        } 
 
        private void InitContactScore() 
        { 
            if ((this._contact != null) && (this._contact.PersonalInfo.ScoreLevel != 0)) 
            { 
                try 
                { 
                    this._scoreBox.ScoreLevel = this._contact.PersonalInfo.ScoreLevel; 
                    this._scoreBox.ToolTipText = string.Empty; 
                } 
                catch (Exception exception) 
                { 
                    ClientLogger.WriteException(exception); 
                } 
            } 
        } 
 
        private void InitializeComponent() 
        { 
            this.txtMobileNo = new TextBox(); 
            this.txtFetionNo = new TextBox(); 
            base.SuspendLayout(); 
            this.txtMobileNo.BackColor = Color.FromArgb(0xec, 0xec, 0xec); 
            this.txtMobileNo.BorderStyle = BorderStyle.None; 
            this.txtMobileNo.ForeColor = Color.Gray; 
            this.txtMobileNo.Location = new System.Drawing.Point(0x1d, 0x71); 
            this.txtMobileNo.Name = "txtMobileNo"; 
            this.txtMobileNo.ReadOnly = true; 
            this.txtMobileNo.Size = new Size(0x44, 14); 
            this.txtMobileNo.TabIndex = 2; 
            this.txtMobileNo.Text = "13810261800"; 
            this.txtFetionNo.BackColor = Color.FromArgb(0xec, 0xec, 0xec); 
            this.txtFetionNo.BorderStyle = BorderStyle.None; 
            this.txtFetionNo.ForeColor = Color.Gray; 
            this.txtFetionNo.Location = new System.Drawing.Point(0x1d, 0x7f); 
            this.txtFetionNo.Name = "txtFetionNo"; 
            this.txtFetionNo.ReadOnly = true; 
            this.txtFetionNo.Size = new Size(0x44, 14); 
            this.txtFetionNo.TabIndex = 2; 
            this.txtFetionNo.Text = "123456789"; 
            base.AutoScaleDimensions = new SizeF(6f, 12f); 
            base.AutoScaleMode = AutoScaleMode.Font; 
            this.BackColor = Color.Transparent; 
            base.Controls.Add(this.txtFetionNo); 
            base.Controls.Add(this.txtMobileNo); 
            base.Margin = new Padding(0); 
            base.Name = "ContactInfoControl"; 
            base.Size = new Size(0x6f, 160); 
            base.ResumeLayout(false); 
            base.PerformLayout(); 
        } 
 
        private void InitImageControl() 
        { 
            try 
            { 
                this._wndlessControls = new WndlessControlCollection(this); 
                this.pictureBox2 = new WndlessPictureBox(); 
                this.pictureBox1 = new WndlessPictureBox(); 
                this.imgPortrait = new WndlessPortrait(); 
                this.imgPortrait.Location = new System.Drawing.Point(0, 0); 
                this.imgPortrait.PortraitSize = 0x60; 
                this.imgPortrait.Style = WndlessPortrait.PortraitStyle.DropDownAtBottomSide; 
                this.imgPortrait.Padding = new Padding(4, 4, 4, 0x35); 
                this.pictureBox2.Image = Resources.Con_Fetion; 
                this.pictureBox2.Location = new System.Drawing.Point(8, 0x7f); 
                this.pictureBox1.Image = Resources.Con_Mobile; 
                this.pictureBox1.Location = new System.Drawing.Point(8, 0x70); 
                this._scoreBox = new WndlessScorePictureBox(); 
                this._scoreBox.Location = new System.Drawing.Point(4, 0x84); 
                this._scoreBox.ToolTipText = string.Empty; 
                this._wndlessControls.Add(this._scoreBox); 
                this._wndlessControls.Add(this.pictureBox2); 
                this._wndlessControls.Add(this.pictureBox1); 
                this._wndlessControls.Add(this.imgPortrait); 
                this.imgPortrait.PortraitCursor = Cursors.Hand; 
                this.imgPortrait.PortraitClicked += new EventHandler(this.imgPortrait_PortraitClicked); 
            } 
            catch (Exception exception) 
            { 
                ClientLogger.WriteException(exception); 
            } 
        } 
 
        protected override void OnLoad(EventArgs e) 
        { 
            base.OnLoad(e); 
            base.SuspendLayout(); 
            int y = (this.imgPortrait.Bottom - this.txtFetionNo.Height) - 7; 
            int x = this.pictureBox1.Right + 3; 
            this.txtFetionNo.SetBounds(x, y, 0, 0, BoundsSpecified.Location); 
            this.pictureBox2.Top = y; 
            y = (this.txtFetionNo.Top - this.txtMobileNo.Height) - 3; 
            this.txtMobileNo.SetBounds(x, y, 0, 0, BoundsSpecified.Location); 
            this.pictureBox1.Top = y; 
            y = (y - this._scoreBox.Height) - 3; 
            this._scoreBox.Top = y; 
            base.ResumeLayout(); 
        } 
 
        public Color BorderColor 
        { 
            get 
            { 
                return this._BorderColor; 
            } 
            set 
            { 
                this._BorderColor = value; 
            } 
        } 
 
        public Imps.Client.Core.Contact Contact 
        { 
            get 
            { 
                return this._contact; 
            } 
            set 
            { 
                this._contact = value; 
                this.InitContactScore(); 
                if (this._contact != null) 
                { 
                    this.imgPortrait.ToolTipText = this._contact.DisplayName; 
                } 
            } 
        } 
 
        public ToolStripDropDown DropDown 
        { 
            get 
            { 
                return this.imgPortrait.DropDown; 
            } 
            set 
            { 
                this.imgPortrait.DropDown = value; 
            } 
        } 
 
        public string FetionNo 
        { 
            get 
            { 
                return this._fetionNo; 
            } 
            set 
            { 
                this._fetionNo = value; 
                this.txtFetionNo.Text = this._fetionNo; 
            } 
        } 
 
        public IFrameworkWindow Framwork 
        { 
            get 
            { 
                return this._framwork; 
            } 
            set 
            { 
                this._framwork = value; 
            } 
        } 
 
        public System.Drawing.Image Image 
        { 
            get 
            { 
                if (this.imgPortrait == null) 
                { 
                    return null; 
                } 
                return this.imgPortrait.Portrait; 
            } 
            set 
            { 
                if (this.imgPortrait != null) 
                { 
                    this.imgPortrait.Portrait = value; 
                } 
            } 
        } 
 
        public string MobileNo 
        { 
            get 
            { 
                return this._mobileNo; 
            } 
            set 
            { 
                this._mobileNo = value; 
                this.txtMobileNo.Text = this._mobileNo; 
            } 
        } 
 
        public string ToolTipText 
        { 
            get 
            { 
                return this._toolTipText; 
            } 
            set 
            { 
                this._toolTipText = value; 
            } 
        } 
    } 
}