void OnMessageReceived(IBuddy buddy, Guid id, string message, string fontName, System.Drawing.Color color, int fontSize, System.Drawing.FontStyle fontStyle)
 {
     chatState.MessageReceived();
     if ((buddy.IsIgnored || (ignore && IsGroupChat)) && !chatState.ChatStarted)
     {
         chatTextBox.AddInfo(String.Format(Translation.Instance.ChatWindow_Ignore, buddy.DisplayName));
     }
     filters.Filter(message, this, FilterDirection.In, filteredMessage =>
     {
         chatTextBox.AddMessage(id, buddy.DisplayName, filteredMessage, fontName, fontSize, fontStyle, color, parsers, false);
         FlashWindow();
         PlayAlert(AudioAlertType.MessageReceived);
         if (!chatState.ChatStarted && !IsActive)
         {
             if (IsGroupChat)
             {
                 if (!ignore)
                 {
                     TrayPopup.Instance.Show(Translation.Instance.Popup_NewMessage, String.Format("{0} " + Translation.Instance.Global_ContactSays + ": {1}", buddy.DisplayName, filteredMessage), args => this.Restore());
                 }
             }
             else
             {
                 if (!PrimaryBuddy.IsIgnored)
                 {
                     TrayPopup.Instance.Show(Translation.Instance.Popup_NewMessage, String.Format("{0} " + Translation.Instance.Global_ContactSays + ": {1}", buddy.DisplayName, filteredMessage), args => this.Restore());
                 }
             }
         }
     });
     ResetStatus();
     chatState.ChatStarted = true;
 }
示例#2
0
 public void Invite(IBuddy buddy)
 {
     if (buddy != null && chatSession != null && !Buddies.Contains(buddy))
     {
         chatSession.Invite(buddy);
     }
 }
示例#3
0
文件: Chat.cs 项目: dugu01/squiggle
        void LogSessionStart()
        {
            DoHistoryAction(manager =>
            {
                sessionLogged       = true;
                IBuddy primaryBuddy = Buddies.FirstOrDefault();
                var newSession      = new Session()
                {
                    Id          = session.Id.ToString(),
                    ContactId   = primaryBuddy.Id,
                    ContactName = primaryBuddy.DisplayName,
                    Start       = DateTime.Now
                };

                var participants = Buddies.Append(self)
                                   .Select(b => new Participant()
                {
                    Id          = Guid.NewGuid().ToString(),
                    ContactId   = b.Id,
                    ContactName = b.DisplayName,
                }).ToList();

                manager.AddSession(newSession, participants);
            });
        }
示例#4
0
        internal ChatWindow(IBuddy buddy, SquiggleContext context) : this()
        {
            SetContext(context);

            this.Height = Properties.Settings.Default.ChatWindowHeight;
            this.Width  = Properties.Settings.Default.ChatWindowWidth;

            expanderDisplayPics.IsExpanded = Properties.Settings.Default.ChatWindowShowDisplayPictures;

            statusResetTimer          = new DispatcherTimer();
            statusResetTimer.Interval = 5.Seconds();
            statusResetTimer.Tick    += (sender, e) => ResetStatus();
            this.StateChanged        += ChatWindow_StateChanged;

            SettingsProvider.Current.SettingsUpdated += (sender, e) => LoadSettings();
            LoadSettings();
            this.DataContext = this;

            this.PrimaryBuddy = buddy;

            chatTextBox.KeepHistory = !SettingsProvider.Current.Settings.ChatSettings.ClearChatOnWindowClose;

            eventQueue.Enqueue(LoadHistory);

            new ActivityHelper(context).LoadActivitiesMenu(mnuStartActivity, mnuNoActivity, new RelayCommand <IActivity>(StartActivityMenuItem_Click));
        }
示例#5
0
        ChatWindow CreateChatWindow(IBuddy buddy, IChat chatSession, bool initiatedByUser)
        {
            ChatWindow window = null;

            if (chatSession == null || !chatSession.IsGroupChat)
            {
                window = chatWindows.Find(w => buddy.Equals(w.PrimaryBuddy) && !w.IsGroupChat);
            }

            if (window == null)
            {
                window         = new ChatWindow(buddy, context);
                window.Closed += (sender, e) => chatWindows.Remove(window);
                window.SetChatSession(chatSession ?? context.ChatClient.StartChat(buddy));
                chatWindows.Add(window);
            }
            else if (chatSession != null)
            {
                window.SetChatSession(chatSession);
            }

            window.Show(initiatedByUser);

            return(window);
        }
示例#6
0
文件: Chat.cs 项目: dugu01/squiggle
 public void Invite(IBuddy buddy)
 {
     Task.Run(() =>
     {
         var endpoint = new SquiggleEndPoint(buddy.Id, ((Buddy)buddy).ChatEndPoint);
         ExceptionMonster.EatTheException(() => session.Invite(endpoint), "sending chat invite to " + endpoint);
     });
 }
示例#7
0
 protected override void OnExecute(string argument, Plugins.IChatWindow window, Components.SquiggleContext context)
 {
     string displayName = argument.Trim();
     IBuddy buddy = context.ChatClient.Buddies.FirstOrDefault(b => b.DisplayName.Trim().Equals(displayName, StringComparison.InvariantCultureIgnoreCase));
     if (buddy == null)
         ((ChatWindow)window).chatTextBox.AddError(String.Format(Translation.Instance.ChatWindow_NoBuddyWithName, argument), String.Empty);
     else
         window.Invite(buddy);
 }
 void OnLikeReceived(IBuddy buddy)
 {
     if (chatState.CanReceiveLike)
     {
         chatTextBox.AddInfo(String.Format("{0} " + Translation.Instance.ChatWindow_HasSentYouLike, buddy.DisplayName));
         DoLikeAction();
         FlashWindow();
         chatState.LikeReceived();
     }
 }
示例#9
0
 void LogStatus(IBuddy buddy)
 {
     if (EnableLogging)
     {
         ExceptionMonster.EatTheException(() =>
         {
             history.AddStatusUpdate(buddy.Id, buddy.DisplayName, (int)buddy.Status);
         }, "logging history.");
     }
 }
示例#10
0
        void OnBuddyLeft(IBuddy buddy)
        {
            if (buddy == PrimaryBuddy && Buddies.Any())
            {
                PrimaryBuddy = Buddies.FirstOrDefault();
            }

            StopMonitoring(buddy);
            chatTextBox.AddInfo(String.Format("{0} " + Translation.Instance.ChatWindow_HasLeftConversation, buddy.DisplayName));
            OnParticipantsChanged();
        }
示例#11
0
 void OnBuddyOnline(IBuddy buddy, bool discovered)
 {
     if (!discovered)
     {
         LogStatus(buddy);
     }
     BuddyOnline(this, new BuddyOnlineEventArgs()
     {
         Buddy = buddy, Discovered = discovered
     });
 }
示例#12
0
文件: Chat.cs 项目: dugu01/squiggle
 void LogHistory(EventType eventType, IBuddy sender, string data = null)
 {
     DoHistoryAction(manager =>
     {
         if (!sessionLogged)
         {
             LogSessionStart();
         }
         manager.AddSessionEvent(session.Id.ToString(), eventType, sender.Id, sender.DisplayName, buddies.Select(b => b.Id), data);
     });
 }
示例#13
0
        public IChat StartChat(IBuddy buddy)
        {
            if (!IsLoggedIn)
            {
                throw new InvalidOperationException("Not logged in.");
            }

            IChatSession session = chatService.CreateSession(new SquiggleEndPoint(buddy.Id, ((Buddy)buddy).ChatEndPoint));
            var          chat    = new Chat(session, CurrentUser, new[] { buddy }, id => buddies[id], history);

            return(chat);
        }
示例#14
0
 void OnBuzzReceived(IBuddy buddy)
 {
     if (chatState.CanReceiveBuzz)
     {
         chatTextBox.AddInfo(String.Format("{0} " + Translation.Instance.ChatWindow_HasSentYouBuzz, buddy.DisplayName));
         if (this.WindowState != System.Windows.WindowState.Minimized)
         {
             DoBuzzAction();
         }
         else
         {
             chatState.BuzzPending = true;
         }
         FlashWindow();
         chatState.BuzzReceived();
     }
 }
示例#15
0
文件: Chat.cs 项目: dugu01/squiggle
        public Chat(IChatSession session, IBuddy self, IEnumerable <IBuddy> buddies, BuddyResolver buddyResolver, HistoryManager history)
        {
            this.self = self;

            this.buddies                   = new ChatBuddies(session, buddyResolver, buddies);
            this.buddies.BuddyJoined      += buddies_BuddyJoined;
            this.buddies.BuddyLeft        += buddies_BuddyLeft;
            this.buddies.GroupChatStarted += buddies_GroupChatStarted;

            this.session                    = session;
            session.MessageReceived        += session_MessageReceived;
            session.MessageUpdated         += session_MessageUpdated;
            session.UserTyping             += session_UserTyping;
            session.BuzzReceived           += session_BuzzReceived;
            session.ActivityInviteReceived += session_ActivityInviteReceived;

            this.history = history;
        }
示例#16
0
        IChatWindow StartChat(IBuddy buddy, bool sendFile, params string[] filePaths)
        {
            IChatWindow window = StartChat(buddy);

            if (sendFile)
            {
                if (filePaths == null || filePaths.Length == 0)
                {
                    window.SendFile();
                }
                else
                {
                    window.SendFiles(filePaths);
                }
            }

            return(window);
        }
示例#17
0
        public IChatWindow StartChat(IBuddy buddy)
        {
            var window = CreateChatWindow(buddy, null, true);

            return(window);
        }
示例#18
0
 public void Invite(IBuddy buddy)
 {
     throw new InvalidOperationException("Can not invite buddies in a broadcast chat.");
 }
示例#19
0
 public ActivityInvitationReceivedEventArgs(IBuddy buddy) : base(buddy)
 {
 }
示例#20
0
 public BuddyEventArgs(IBuddy buddy)
 {
     this.Buddy = buddy;
 }
示例#21
0
 public static bool IsOnline(this IBuddy buddy)
 {
     return(buddy.Status != Core.Presence.UserStatus.Offline);
 }
示例#22
0
 void StopMonitoring(IBuddy buddy)
 {
     buddy.PropertyChanged -= buddy_PropertyChanged;
 }
示例#23
0
 void OnMessageUpdated(IBuddy buddy, Guid id, string message)
 {
     chatState.MessageReceived();
     chatTextBox.UpdateMessage(id, message);
     ResetStatus();
 }
示例#24
0
 void Monitor(IBuddy buddy)
 {
     StopMonitoring(buddy);
     buddy.PropertyChanged += buddy_PropertyChanged;
 }
示例#25
0
 void UpdateBuddy(IBuddy buddy, IUserInfo user)
 {
     ((Buddy)buddy).Update(user.Status, user.DisplayName, user.ChatEndPoint, user.Properties);
 }
示例#26
0
 void OnBuddyJoined(IBuddy buddy)
 {
     Monitor(buddy);
     chatTextBox.AddInfo(String.Format("{0} " + Translation.Instance.ChatWindow_HasJoinedConversation, buddy.DisplayName));
     OnParticipantsChanged();
 }
示例#27
0
 void OnBuddyOffline(IBuddy buddy)
 {
     LogStatus(buddy);
     BuddyOffline(this, new BuddyEventArgs(buddy));
 }
示例#28
0
 private void OnIncomingBuddy(IBuddy oBuddy)
 {
     foreach (Control item in uiflowLayoutPanelBuddies.Controls)
     {
         uiBuddy buddy = (uiBuddy)item;
         if (buddy.BuddyName == oBuddy.Name)
         {
             buddy.Status = oBuddy.Status;
             break;
         }
     }
 }