Пример #1
0
        public void Update()
        {
            _emitterSettingsController.Update();

            if (_applicationState.IsModalOpen(Modal.NewFileDialog) && !_newFileDialog.DialogIsOpen)
            {
                _newFileDialog.OpenPopup();
            }
            else if (!_applicationState.IsModalOpen(Modal.NewFileDialog) && _newFileDialog.DialogIsOpen)
            {
                _newFileDialog.ClosePopup();
            }

            if (!string.IsNullOrWhiteSpace(_applicationState.ErrorMessage))
            {
                // If a dialog is open, then most likely the error is specific to that dialog
                if (_newFileDialog.DialogIsOpen)
                {
                    _newFileDialog.ErrorMessage = _applicationState.ErrorMessage;
                }
                else
                {
                    _messagePopup.Display(_applicationState.ErrorMessage);
                }
            }
        }
Пример #2
0
 private void ChatListener(CommandResponse res)
 {
     if (Application.Current.Dispatcher.CheckAccess())
     {
         ChatWindow chatWindow = null;
         foreach (Window window in Application.Current.Windows)
         {
             if (window.GetType() == typeof(ChatWindow) && ((ChatWindow)window).TargetUser == res.TargetUser)
             {
                 chatWindow = window as ChatWindow;
                 break;
             }
         }
         Message message = Message.LoadXamlContent(res.TargetUser, false, res.Params[1].ToString());
         message.IsDisplayUser = true;
         FlowDocument messageDoc = new FlowDocument();
         messageDoc.Blocks.AddRange(message);
         string text = new TextRange(messageDoc.ContentStart, messageDoc.ContentEnd).Text;
         text = text.Replace("\r\n", " ");
         if (text.Length >= 30)
         {
             text = text.Replace(text.Substring(30, text.Length - 30), "...");
         }
         if (chatWindow != null)
         {
             chatWindow.Focus();
             chatWindow.ReceiveMessage(message);
         }
         else
         {
             chatWindow = new ChatWindow(res.TargetUser);
             chatWindow.ReceiveMessage(message);
             chatWindow.Show();
         }
         this.Get <UserServiceClient>().MarkAsReadConversation(Convert.ToInt32(res.Params[0]));
         MessagePopup.Display(text, "msg_in", delegate
         {
             chatWindow.BringToFront();
         });
         if (!chatWindow.IsActive)
         {
             chatWindow.FlashWindow();
         }
     }
     else
     {
         Application.Current.Dispatcher.Invoke(new Action(() => { ChatListener(res); }));
     }
 }
Пример #3
0
        private void LogOutListener(CommandResponse res)
        {
            if (_friendListModule.Dispatcher.CheckAccess())
            {
                string user = res.TargetUser;

                _friendListModule.SetFriendStatus(user, false);
                MessagePopup.Display(user + " đã offline !!", "offline", delegate
                {
                    ChatWindow chatWindow = new ChatWindow(user);
                    chatWindow.Show();
                    chatWindow.BringToFront();
                });
            }
            else
            {
                _friendListModule.Dispatcher.Invoke(new Action(() => { LogOutListener(res); }));
            }
        }
Пример #4
0
        private void CheckOnlineListener(CommandResponse res)
        {
            if (_friendListModule.Dispatcher.CheckAccess())
            {
                string user     = res.TargetUser;
                bool   isOnline = (bool)res.Params[0];

                _friendListModule.SetFriendStatus(user, isOnline);

                if ((bool)res.Params[1])
                {
                    MessagePopup.Display(user + " đã online !!", "online", delegate
                    {
                        ChatWindow chatWindow = new ChatWindow(user);
                        chatWindow.Show();
                        chatWindow.BringToFront();
                    });
                }
            }
            else
            {
                _friendListModule.Dispatcher.Invoke(new Action(() => { CheckOnlineListener(res); }));
            }
        }