private void SendText(string text, SenderSide side = SenderSide.Local) { var chatText = new ChatTextViewModel() { Text = text, SentDateTime = DateTime.Now, SenderSide = side }; ChatItems.Add(chatText); }
private void SendImage(BitmapSource image, SenderSide side = SenderSide.Local) { var chatImage = new ChatImageViewModel() { Image = image, SentDateTime = DateTime.Now, SenderSide = side }; ChatItems.Add(chatImage); }
private async void DeleteMethod(object obj) { try { if (await UserDialogs.Instance.ConfirmAsync(new ConfirmConfig { CancelText = "Cancel", OkText = "Ok", Message = App.Idioma.TwoLetterISOLanguageName == MyIdioma.Español ? "¿Estás seguro de eliminar el chat?" : "Are you sure you want to delete the chat ?", })) { var x = (ChatDetail)obj; ChatContact ch = new ChatContact() { UserID = x.UserID, ContactUserID = x.ContactID, IDPosition = x.IDPosition }; //Agregar el metodo de borrado de position if (await Services.Chat.ChatService.DeleteContactAsync(ch)) { if (ItemIndex >= 0) { ChatItems.RemoveAt(ItemIndex); } await Application.Current.MainPage.DisplayAlert("JobMe", App.Idioma.TwoLetterISOLanguageName == MyIdioma.Español? "Se elimino correctamente el chat" : "Chat successfully deleted", "OK"); //ListView.ResetSwipe(); //MessagingCenter.Send<EditJobViewModel, int>(this, "UpdateList", 1); } else { await Application.Current.MainPage.DisplayAlert("JobMe", App.Idioma.TwoLetterISOLanguageName == MyIdioma.Español? "Ocurrío un error al eliminar el chat" : "Error deleting chat", "OK"); } } ListView.ResetSwipe(); } catch (Exception ex) { await Application.Current.MainPage.DisplayAlert("JobMe", App.Idioma.TwoLetterISOLanguageName == MyIdioma.Español? "Ocurrío un error al eliminar el chat" : "Error deleting chat", "OK"); //throw; } }
private void ChatHistory_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { ChatItems.ScrollToItem(ChatItems.Items.Count - 1); /* * if (VisualTreeHelper.GetChildrenCount(ChatItems) > 0) * { * * Border border = (Border)VisualTreeHelper.GetChild(ChatItems, 0); * ScrollViewer scrollViewer = (ScrollViewer)VisualTreeHelper.GetChild(border, 0); * scrollViewer.ScrollToBottom(); * }*/ }
public void AddChatText(string nickname, Brush nicknameColor, Brush chatColor, string chatBody) { System.Windows.Application.Current.Dispatcher.BeginInvoke(new ThreadStart(() => { ChatItem newItem = new ChatItem(); newItem.Nickname = nickname; newItem.NicknameColor = nicknameColor; newItem.ChatTextColor = chatColor; newItem.ChatText = chatBody; ChatItems.Add(newItem); })); }
/// <summary> /// 选择要转发的聊天室 /// </summary> /// <param name="obj"></param> private void SelectedChatItemChanged(object obj) { var tempChatInfo = obj as ChatInfo; var tempSelectedItem = SelectedChatList.FirstOrDefault(m => m.ChatID == tempChatInfo.ChatID && m.IsGroup == tempChatInfo.IsGroup); var tempChatItems = ChatItems.Where(m => m.ChatID == tempChatInfo.ChatID && m.IsGroup == tempChatInfo.IsGroup)?.ToList(); if (tempSelectedItem == null) { if (SelectedChatList.Count == 9) { //IsMsgExist = true; //FowardTips = "最多只能选择9个联系人"; IsMoreContact = true; timer.Tick += new EventHandler(Timer_Tick); timer.Interval = new TimeSpan(0, 0, 1); timer.Start(); return; } SelectedChatList.Add(tempChatInfo); if (tempChatItems?.Count > 0) { foreach (var chatItem in tempChatItems) { chatItem.IsChatSelected = true; } } } else { SelectedChatList.Remove(tempSelectedItem); if (tempChatItems?.Count > 0) { foreach (var chatItem in tempChatItems) { chatItem.IsChatSelected = false; } } } if (SelectedChatList.Count > 0) { IsEnabled = true; } else { IsEnabled = false; } }
public void ChangeServerStatus_LostConnect() { chatProgramIsStart = false; ChatSettingPanelVisibility = false; ConnectStatusText = "서버 생성/연결 되지않음"; ConnectStatusColor = Brushes.Red; Nickname = "홍길동"; NicknameColor = Brushes.Green; ChatColor = Brushes.Black; System.Windows.Application.Current.Dispatcher.BeginInvoke(new ThreadStart(() => { ChatItems.Clear(); })); }
/// <summary> /// 删除选中的聊天室 /// </summary> /// <param name="obj"></param> private void RemoveSelectedChat(object obj) { var tempChatInfo = obj as ChatInfo; var tempSelectedItem = SelectedChatList.FirstOrDefault(m => m.ChatID == tempChatInfo.ChatID && m.IsGroup == tempChatInfo.IsGroup); if (tempSelectedItem != null) { SelectedChatList.Remove(tempSelectedItem); var tempChatItems = ChatItems.Where(m => m.ChatID == tempChatInfo.ChatID && m.IsGroup == tempChatInfo.IsGroup)?.ToList(); if (tempChatItems?.Count > 0) { foreach (var chatItem in tempChatItems) { chatItem.IsChatSelected = false; } } } if (SelectedChatList?.Count == 0) { IsEnabled = false; } }
/// <summary> /// 选择要转发的聊天室 /// </summary> /// <param name="obj"></param> private void SelectedChatItemChanged(object obj) { ChatInfo currentSelectItem = obj as ChatInfo;//当前选择的聊天条目 ChatItems.ToList().ForEach(x => x.IsChatSelected = false); List <ChatInfo> tempChatInfos = ChatItems.Where(x => x.ChatID == currentSelectItem.ChatID && x.IsGroup == currentSelectItem.IsGroup).ToList(); SelectedChatList.Clear(); currentSelectItem.IsChatSelected = true; SelectedChatList.Add(currentSelectItem); if (tempChatInfos?.Count > 0) { tempChatInfos.ForEach(x => x.IsChatSelected = true); } if (SelectedChatList.Count > 0) { IsEnabled = true; } else { IsEnabled = false; } }