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; }
public void Invite(IBuddy buddy) { if (buddy != null && chatSession != null && !Buddies.Contains(buddy)) { chatSession.Invite(buddy); } }
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); }); }
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)); }
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); }
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); }); }
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(); } }
void LogStatus(IBuddy buddy) { if (EnableLogging) { ExceptionMonster.EatTheException(() => { history.AddStatusUpdate(buddy.Id, buddy.DisplayName, (int)buddy.Status); }, "logging history."); } }
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(); }
void OnBuddyOnline(IBuddy buddy, bool discovered) { if (!discovered) { LogStatus(buddy); } BuddyOnline(this, new BuddyOnlineEventArgs() { Buddy = buddy, Discovered = discovered }); }
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); }); }
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); }
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(); } }
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; }
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); }
public IChatWindow StartChat(IBuddy buddy) { var window = CreateChatWindow(buddy, null, true); return(window); }
public void Invite(IBuddy buddy) { throw new InvalidOperationException("Can not invite buddies in a broadcast chat."); }
public ActivityInvitationReceivedEventArgs(IBuddy buddy) : base(buddy) { }
public BuddyEventArgs(IBuddy buddy) { this.Buddy = buddy; }
public static bool IsOnline(this IBuddy buddy) { return(buddy.Status != Core.Presence.UserStatus.Offline); }
void StopMonitoring(IBuddy buddy) { buddy.PropertyChanged -= buddy_PropertyChanged; }
void OnMessageUpdated(IBuddy buddy, Guid id, string message) { chatState.MessageReceived(); chatTextBox.UpdateMessage(id, message); ResetStatus(); }
void Monitor(IBuddy buddy) { StopMonitoring(buddy); buddy.PropertyChanged += buddy_PropertyChanged; }
void UpdateBuddy(IBuddy buddy, IUserInfo user) { ((Buddy)buddy).Update(user.Status, user.DisplayName, user.ChatEndPoint, user.Properties); }
void OnBuddyJoined(IBuddy buddy) { Monitor(buddy); chatTextBox.AddInfo(String.Format("{0} " + Translation.Instance.ChatWindow_HasJoinedConversation, buddy.DisplayName)); OnParticipantsChanged(); }
void OnBuddyOffline(IBuddy buddy) { LogStatus(buddy); BuddyOffline(this, new BuddyEventArgs(buddy)); }
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; } } }