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


namespace Imps.Client.Pc 
{ 
    using Imps.Client; 
    using Imps.Client.Core; 
    using Imps.Client.Pc.BizControls; 
    using Imps.Client.Resource; 
    using Imps.Utils; 
    using System; 
    using System.ComponentModel; 
    using System.Drawing; 
    using System.Windows.Forms; 
 
    public class BUserInfoControl : Control 
    { 
        private UserAccountManager _manager; 
        private menu_widget cmMoodPhrases; 
        private menu_widget cmStatus; 
        private IContainer components; 
 
        public BUserInfoControl(UserAccountManager manager) 
        { 
            this._manager = manager; 
            this.InitializeComponent(); 
            this.DoLocalize(); 
        } 
 
        private void cmMoodPhrases_Opening(object sender, CancelEventArgs e) 
        { 
            UiErrorHelper.HandEventSafely(this._manager.FrameworkWnd, delegate { 
                string b = this._manager.CurrentUser.Presence.MoodPhrase.Value; 
                this.cmMoodPhrases.Items.Clear(); 
                MoodPhraseCollection moodPhrases = this._manager.CurrentUser.Configuration.UserSetting.MoodPhrases; 
                for (int j = 0; i < moodPhrases.Count; i++) 
                { 
                    menu_radioitem _radioitem = new menu_radioitem(StringHelper.GetPaddingStringEndEllipsis(StringHelper.ReplaceCrLfToSpace(moodPhrases[i]), 0x10)); 
                    this.cmMoodPhrases.Items.Add(_radioitem); 
                    _radioitem.ToolTipText = moodPhrases[i]; 
                    if (string.Equals(moodPhrases[i], b)) 
                    { 
                        _radioitem.Radioed = true; 
                    } 
                    else 
                    { 
                        _radioitem.Click += new EventHandler(this.tiMoodPhrase_Click); 
                    } 
                } 
                if (moodPhrases.Count > 0) 
                { 
                    ToolStripSeparator separator = new ToolStripSeparator { 
                        Enabled = false 
                    }; 
                    this.cmMoodPhrases.Items.Add(separator); 
                } 
                ToolStripItem item = this.cmMoodPhrases.Items.Add(StringTable.User.UI_EraseMoodPhrase); 
                item.ToolTipText = string.Empty; 
                item.Enabled = !string.IsNullOrEmpty(b); 
                item.Click += new EventHandler(this.tiMoodPhrase_Click); 
            }); 
        } 
 
        private void cmStatus_Opening(object sender, CancelEventArgs e) 
        { 
            UiErrorHelper.HandEventSafely(this._manager.FrameworkWnd, delegate { 
                this._manager.DoPresenceMenuItemsOpening(this.cmStatus.Items); 
            }); 
        } 
 
        protected override void Dispose(bool disposing) 
        { 
            if (disposing && (this.components != null)) 
            { 
                this.components.Dispose(); 
            } 
            base.Dispose(disposing); 
        } 
 
        private void DoLocalize() 
        { 
            this.cmStatus.Items.AddRange(this._manager.GetPresenceMenuItems(false, false)); 
            this.cmStatus.Opening += new CancelEventHandler(this._manager.OnStatusMenuOpening); 
        } 
 
        private void InitializeComponent() 
        { 
            this.components = new Container(); 
            this.cmMoodPhrases = new menu_widget(this.components); 
            this.cmStatus = new menu_widget(this.components); 
            this.cmMoodPhrases.UseMnemonic = false; 
            this.cmMoodPhrases.Name = "cmMoodPhrases"; 
            this.cmMoodPhrases.Size = new Size(0x3d, 4); 
            this.cmMoodPhrases.Opening += new CancelEventHandler(this.cmMoodPhrases_Opening); 
            this.cmStatus.Name = "cmStatus"; 
            this.cmStatus.Size = new Size(0x3d, 4); 
            this.cmStatus.Opening += new CancelEventHandler(this.cmStatus_Opening); 
        } 
 
        private void tiMoodPhrase_Click(object sender, EventArgs e) 
        { 
            if (sender is ToolStripItem) 
            { 
                this.TryChangeMoodPhrase(((ToolStripItem) sender).ToolTipText); 
            } 
        } 
 
        public void toolIm_Click(object sender, EventArgs e) 
        { 
            UiErrorHelper.HandEventSafely(this._manager.FrameworkWnd, delegate { 
                this._manager.FrameworkWnd.ConversationManager.StartConversation(this._manager.FrameworkWnd.MainWindow, ConversationOperation.ImChat, null); 
            }); 
        } 
 
        public void toolIVR_Click(object sender, EventArgs e) 
        { 
            UiErrorHelper.HandEventSafely(this._manager.FrameworkWnd, delegate { 
                this._manager.FrameworkWnd.IVRManager.StartIVR(this._manager.FrameworkWnd.MainWindow, null); 
            }); 
        } 
 
        public void toolSms_Click(object sender, EventArgs e) 
        { 
            UiErrorHelper.HandEventSafely(this._manager.FrameworkWnd, delegate { 
                this._manager.FrameworkWnd.ConversationManager.StartConversation(this._manager.FrameworkWnd.MainWindow, ConversationOperation.SmsChat, null); 
            }); 
        } 
 
        private void TryChangeMoodPhrase(string phrase) 
        { 
            try 
            { 
                phrase = phrase.Trim(); 
                AsyncBizOperation op = new AsyncBizOperation(); 
                this._manager.CurrentUser.Presence.AsyncChangeMoodPhrase(phrase, op); 
            } 
            catch 
            { 
            } 
        } 
 
        public menu_widget MoodPhraseMenu 
        { 
            get 
            { 
                return this.cmMoodPhrases; 
            } 
        } 
 
        public menu_widget StatusMenu 
        { 
            get 
            { 
                return this.cmStatus; 
            } 
        } 
    } 
}