/// <summary>
        /// return true on success, false on failure
        /// </summary>
        public bool CreateChatMessage(string text, int chat)
        {
            var user = userPanel.GetSelectedUserGuidIfAny();

            if (user == Guid.Empty)
            {
                return(false);
            }
            ChatMessageGUIEvent message = new ChatMessageGUIEvent(text, user, SelectedColor, chat);

            Updater.AddEvent(message);
            Updater.Update();
            return(true);
        }
示例#2
0
 private void ProcessGUIEvents()
 {
     lock (latestGUIEvents)
     {
         for (int i = latestGUIEvents.Count - 1; i >= 0; i--)
         {
             var @event = latestGUIEvents[i];
             if (@event is ChatMessageGUIEvent)
             {
                 ChatMessageGUIEvent message = @event as ChatMessageGUIEvent;
                 var user = users.Where((a) => a.Id == message.UserId);
                 if (user.Count() == 0)
                 {
                     continue;
                 }
                 int actColor = 0;
                 if (invPalette.ContainsKey(curCanvas) && invPalette[curCanvas].ContainsKey(message.Color))
                 {
                     actColor = invPalette[curCanvas][message.Color];
                 }
                 user.First().Client.SendChatMessage(message.Message, actColor, message.Chat);
                 latestGUIEvents.RemoveAt(i);
             }
             else if (@event is ClearQueuesGUIEvent)
             {
                 foreach (Connection user in users)
                 {
                     if (user.Session != null)
                     {
                         user.Session.ClearQueue();
                     }
                 }
                 latestGUIEvents.RemoveAt(i);
             }
         }
     }
 }