Ejemplo n.º 1
0
        private void ExecuteOnDialogSearch()
        {
            try
            {
                Task.Run(() =>
                {
                    try
                    {
                        if (IsDialogSearchVisible)
                        {
                            if (SelectedContact != null)
                            {
                                _view.MessageList.Clear();
                                var res = new List <BaseMessage>();

                                if (SelectedContact is UserUiInfo)
                                {
                                    var userUiInfo = SelectedContact as UserUiInfo;
                                    res.AddRange(UserServiceClient.GetUserMessages(GlobalBase.CurrentUser.Id, userUiInfo.UserId, messageLimit));
                                }
                                else if (SelectedContact is ChatGroupUiInfo)
                                {
                                    var chatGroupUiInfo = SelectedContact as ChatGroupUiInfo;
                                    res.AddRange(UserServiceClient.GetGroupMessages(chatGroupUiInfo.ChatGroupId, messageLimit));
                                }

                                if (res.Count != 0)
                                {
                                    foreach (var mes in res)
                                    {
                                        if (GlobalBase.Base64Decode(mes.Text).Contains(DialogSearchStr))
                                        {
                                            GlobalBase.AddMessageOnUi.Invoke(mes);
                                        }
                                    }
                                }

                                GlobalBase.UpdateMessagesOnUI();
                            }
                        }
                        else
                        {
                            SelectedContactChanged();
                        }
                    }
                    catch (Exception)
                    {
                    }
                });
            }
            catch (Exception)
            {
            }
        }
Ejemplo n.º 2
0
        public EditMessageVM(BaseMessage message, IView View) : base()
        {
            try
            {
                _view = View;

                Message     = message;
                MessageText = GlobalBase.Base64Decode(message.Text);
            }
            finally
            {
            }
        }
Ejemplo n.º 3
0
        private void UpdateMessage(BaseMessage message, Func <BaseMessage, bool> UiUpdateStrategy)
        {
            try
            {
                var mes    = "New message from  @";
                var sender = UserServiceClient.GetUserById(message.SenderId);

                if (message is GroupMessage gMes)
                {
                    if (SelectedContact is ChatGroupUiInfo)
                    {
                        if (gMes.ChatGroupId != (SelectedContact as ChatGroupUiInfo).ChatGroupId)
                        {
                            gMes.SenderName = sender.FirstName;
                            ChatGroup chatGroup = UserServiceClient.GetChatGroupById(gMes.ChatGroupId);

                            mes += chatGroup.Name;
                            mes += " group \n";
                            mes += "\"" + GlobalBase.Base64Decode(message.Text) + "\"";
                            GlobalBase.ShowNotify("New message", mes);
                        }
                        else
                        {
                            UiUpdateStrategy(message);
                        }
                    }
                }
                else if (message is UserMessage uMes)
                {
                    if (SelectedContact is UserUiInfo)
                    {
                        if (uMes.SenderId != (SelectedContact as UserUiInfo).UserId)
                        {
                            mes += sender.FirstName + sender.LastName + "\n";
                            mes += "\"" + GlobalBase.Base64Decode(message.Text) + "\"";
                            GlobalBase.ShowNotify("New message", mes);
                        }
                        else
                        {
                            UiUpdateStrategy(message);
                        }
                    }
                }

                Debug.WriteLine("Receave Message from - ", sender.Login);
            }
            catch (Exception)
            {
            }
        }
Ejemplo n.º 4
0
        public SendMessage(BaseMessage message)
        {
            InitializeComponent();

            if (message.Text != null)
            {
                MessageText.Text = GlobalBase.Base64Decode(message.Text);
            }

            SendTime.Text          = message.DateOfSending.ToString("hh:mm");
            ButtonDwnld.Visibility = message.ChatFileId != 0 ? Visibility.Visible : Visibility.Collapsed;

            DataContext = new MessageControlVM(message);
        }
Ejemplo n.º 5
0
        public ReceiveMessage(BaseMessage message)
        {
            InitializeComponent();

            if (message.Text != null)
            {
                MessageText.Text = GlobalBase.Base64Decode(message.Text);
            }

            SendTime.Text          = message.DateOfSending.ToString("hh:mm");
            ButtonDwnld.Visibility = message.ChatFileId != 0 ? Visibility.Visible : Visibility.Collapsed;

            if (message is GroupMessage mes)
            {
                SenderName.Visibility = Visibility.Visible;
                SenderName.Text       = mes.SenderName;
            }
            else
            {
                SenderName.Visibility = Visibility.Collapsed;
            }

            DataContext = new MessageControlVM(message);
        }
Ejemplo n.º 6
0
 private string GetContent()
 {
     return(GlobalBase.Base64Decode(Message.Text));
 }