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

📄 contactnotifywindowmanager.cs

📁 破解的飞信源代码
💻 CS
📖 第 1 页 / 共 2 页
字号:
namespace Imps.Client.Pc.UIContactList
{
    using Imps.Client;
    using Imps.Client.Core;
    using Imps.Client.Pc;
    using Imps.Client.Pc.BizControls.NotifyWindows;
    using Imps.Client.Pc.BizControls.NotifyWindows.Templates;
    using Imps.Client.Pc.UIContactList.AddBuddy;
    using Imps.Client.Utils;
    using Imps.Common;
    using Imps.Utils;
    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Media;
    using System.Windows.Forms;

    public class ContactNotifyWindowManager
    {
        private List<AddBuddyRequest> _addBuddyRequestCol;
        private List<Contact> _addBuddyRequestProposerCol;
        private List<AddBuddyResultEventArgs> _addBuddyResultEventArgsCol;
        private List<AddBuddyResultEventArgs> _agreeMobileBuddyEventArgsCol;
        private int _currentDisplayAgreeMobileBuddy;
        private IFrameworkWindow _iFrameworkWindow;
        private User _owner;
        private const int MaxDisplayAgreeMobileBuddy = 5;

        public ContactNotifyWindowManager(User owner, IFrameworkWindow iFrameworkWnd)
        {
            this._owner = owner;
            this._iFrameworkWindow = iFrameworkWnd;
            owner.ContactList.AddBuddyRequest += new EventHandler<AddBuddyApplicationEventArgs>(this, (IntPtr) this.AddBuddyRequestReceived);
        }

        private void addBuddyApplication_onTick(object sender, EventArgs e)
        {
            bool flag = true;
            try
            {
                if (this._owner.Status != UserAccountStatus.Logon)
                {
                    this._addBuddyRequestCol = null;
                    this._addBuddyResultEventArgsCol = null;
                }
                else if (this._addBuddyRequestCol != null)
                {
                    List<AddBuddyRequest>.Enumerator enumerator = this.AddBuddyRequestCol.GetEnumerator();
                    try
                    {
                        while (enumerator.MoveNext())
                        {
                            AddBuddyRequest request = enumerator.get_Current();
                            if (request.Contact.PersonalInfo["nickname"] != null)
                            {
                                this.showWindows_AddBuddy(request.Contact, request.Desc, request.IsByMobileNo);
                                this.AddBuddyRequestCol.Remove(request);
                                return;
                            }
                        }
                    }
                    finally
                    {
                        enumerator.Dispose();
                    }
                    if (this.AddBuddyRequestCol.get_Count() > 0)
                    {
                        flag = false;
                    }
                }
            }
            catch (Exception exception)
            {
                ClientLogger.WriteException(exception);
            }
            finally
            {
                if (flag)
                {
                    GlobalTimer.Unregister(new EventHandler(this.addBuddyApplication_onTick));
                }
            }
        }

        public void AddBuddyRequestReceived(object sender, AddBuddyApplicationEventArgs e)
        {
            AsyncBizOperation op = new AsyncBizOperation();
            op.IsImpsErrorHandled = true;
            Contact c = this._owner.ContactList.FindOrCreateContact(e.Uri, op);
            if ((c.Type != ContactType.Buddy) && !this.AddBuddyRequestProposerCol.Contains(c))
            {
                this.AddBuddyRequestProposerCol.Add(c);
            }
            else
            {
                return;
            }
            this.AddBuddyRequestCol.Add(new AddBuddyRequest(c, e.Desc, e.IsByMobileNo));
            this.ShowWindow();
        }

        public void AddNotifyWnd_AddBuddyResult(AddBuddyResultEventArgs e)
        {
            this.AddBuddyResultEventArgsCol.Add(e);
            this.ShowWindow();
        }

        public bool AllowPlaySound(Contact c)
        {
            if (c.IsBlocked)
            {
                return false;
            }
            if (this._owner.Configuration.UserSetting.SoundSetting.OnlineEnabled == null)
            {
                return false;
            }
            return true;
        }

        public bool AllowPresenceChangedNotifyWindow(Contact c)
        {
            if ((this._owner.Presence.IsOffline || (this._owner.Presence.MainPresence == MainPresence.DoNotDisturb)) || (this._owner.Presence.MainPresence == MainPresence.Busy))
            {
                return false;
            }
            int? relationStatus = c.RelationStatus;
            if (((relationStatus.GetValueOrDefault() != 1) || !relationStatus.get_HasValue()) || c.IsBlocked)
            {
                return false;
            }
            if (this._owner.Configuration.UserSetting.NotifyWinodwSetting.OnlineNotify.OriginalValue == 1)
            {
                return false;
            }
            if ((this._owner.Configuration.UserSetting.NotifyWinodwSetting.OnlineNotify.OriginalValue == 2) && !c.OnlineNotify.Value)
            {
                return false;
            }
            return true;
        }

        public void Clear()
        {
            this._addBuddyRequestProposerCol = null;
            this._addBuddyRequestCol = null;
            this._addBuddyResultEventArgsCol = null;
            this._agreeMobileBuddyEventArgsCol = null;
            this._currentDisplayAgreeMobileBuddy = 0;
        }

        public void ContactPresenceChanged_NotifyWnd(Contact c, PropertiesChangedEventArgs e)
        {
            try
            {
                if ((!c.Presence.IsLogonPresence && c.Presence.IsOnline) && e.ContainsProperty("value"))
                {
                    ChangedValuePair<int> pair = e["value"] as ChangedValuePair<int>;
                    int oldValue = pair.OldValue;
                    int newValue = pair.NewValue;
                    if (!MainPresenceHelper.IsOnline((MainPresence) oldValue) && (newValue != oldValue))
                    {
                        if (this.AllowPresenceChangedNotifyWindow(c))
                        {
                            ContactOnlineStatusChangedNotify wnd = new ContactOnlineStatusChangedNotify(c);
                            NotifyWindowManager.Add(wnd);
                            wnd.ContentClick += delegate {
                                this._iFrameworkWindow.ConversationManager.StartConversation(this._iFrameworkWindow.MainWindow, ConversationOperation.ImChat, new string[] { c.Uri.Raw });
                                wnd.Close();
                            };
                        }
                        if (this.AllowPlaySound(c))
                        {
                            this.playOnlineNotifySound();
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                ClientLogger.WriteException(exception);
            }
        }

        private void handleArgeeMobileBuddy()
        {
            if ((this.AgreeMobileBuddyEventArgsCol.get_Count() > 0) && (this._currentDisplayAgreeMobileBuddy <= 5))
            {
                AddBuddyResultEventArgs e = this.AgreeMobileBuddyEventArgsCol.get_Item(0);
                this.AgreeMobileBuddyEventArgsCol.RemoveAt(0);
                this._currentDisplayAgreeMobileBuddy++;
                NotifyWindowAddBuddyResult wnd = new NotifyWindowAddBuddyResult(e.Contact, e.IsByMobileNo, null);
                wnd.ContentClick += delegate {
                    this._iFrameworkWindow.ConversationManager.StartConversation(this._iFrameworkWindow.MainWindow, ConversationOperation.ImChat, new string[] { e.Contact.Uri.Raw });
                    wnd.Close();
                };
                NotifyWindowManager.Add(wnd);
                AddMobileBuddyFeedbackForm flashForm = new AddMobileBuddyFeedbackForm(this._iFrameworkWindow, (MobileBuddy) e.Contact);
                flashForm.WindowState = FormWindowState.Minimized;
                flashForm.add_FormClosed(new FormClosedEventHandler(this, (IntPtr) this.<handleArgeeMobileBuddy>b__1c));
                flashForm.Show(this._iFrameworkWindow.MainWindow);
                ControlHelper.FlashWindow(flashForm, 5);
            }
        }

        private void playOnlineNotifySound()
        {
            try
            {
                string path = (string) this._owner.Configuration.UserSetting.SoundSetting.OnlineNotify;
                if (File.Exists(path))
                {
                    using (SoundPlayer player = new SoundPlayer(path))
                    {
                        player.Play();
                    }
                }
            }
            catch
            {
            }
        }

⌨️ 快捷键说明

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