/// <summary> /// 显示发出的消息 /// </summary> /// <param name="msg"></param> private void ShowSendMsg(ChatMsgData msg) { try { ChatMsg chatmsg = new ChatMsg(); chatmsg.Image = _me.Icon; //此处的Paragraph必须是新New的 if (msg.Type == 9) { Paragraph imgper = new Paragraph(); imgper.Inlines.Add(new InlineUIContainer(msg.MsgImg)); chatmsg.Message.Blocks.Add(imgper); } else { StrToFlDoc(msg.Msg, chatmsg.Message); } chatmsg.FlowDir = FlowDirection.RightToLeft; chatmsg.TbColor = (System.Windows.Media.Brush) new BrushConverter().ConvertFromString("#FF98E165"); ChatList.Add(chatmsg); } catch (Exception ex) { Console.WriteLine(ex); } }
/// <summary> /// 显示收到的信息 /// </summary> /// <param name="msg"></param> private void ShowReceiveMsg(ChatMsgData msg) { ChatMsg chatmsg = new ChatMsg(); Contact_all.ForEach(p => { if (p is ChatUser) { if ((p as ChatUser).UserName == msg.From) { chatmsg.Image = (p as ChatUser).Icon; return; } } }); if (msg.Type == 9) { Paragraph imgper = new Paragraph(new Floater(new BlockUIContainer(msg.MsgImg))); chatmsg.Message.Blocks.Add(imgper); } else { StrToFlDoc(msg.Msg, chatmsg.Message); } chatmsg.FlowDir = FlowDirection.LeftToRight; chatmsg.TbColor = System.Windows.Media.Brushes.White; ChatList.Add(chatmsg); }
//Build database from input file public void build() { string[] lines = text_file.text.Split(line_delim); string[] cols; ChatList c = null; for (int i = 2; ; i++) { cols = lines[i].Split(col_delim); if (cols[0].Trim() == "END") { if (c != null) { add(c); } break; } else if (cols[0].Trim() == "NEW_CATEGORY")//Add category to data, and move on to next category { if (c != null) { add(c); } c = new ChatList(cols[1].Trim()); } else//Add chat line to current category { int chance; int.TryParse(cols[0].Trim(), out chance); c.add(cols[1].Trim().Replace("\"", String.Empty), chance); } } Debug.Log("Done loading chat data"); }
public void InitializedChatsPage(SavedChats savedChats) { try { if (savedChats.SavedPrivateChats != null) { ChatList = new ObservableCollection <PrivateChat>(savedChats.SavedPrivateChats); } ChatList.Add(new PrivateChat { Name = "Олександр Журба" }); ChatList.Add(new PrivateChat { Name = "Fedir Khydzik" }); ChatList.Add(new PrivateChat { Name = "Olya Ivanenko" }); ChatList.Add(new PrivateChat { Name = "Віталій Пилипенко" }); ChatList.Add(new PrivateChat { Name = "Іван Пилипенко" }); ChatList.Add(new PrivateChat { Name = "Volodya Ivan" }); } catch (Exception) { return; } }
private void PAGE_CHAT_Loaded(object sender, RoutedEventArgs e) { Lb_Chat.Items.Clear(); while (state == true) { client.LoadChat(_selectedChat.Id); state2 = true; while (state2 == true) { while (client.IsDone == true) { ChatList = client.LoadinChat(); foreach (var item in ChatList) { TextBlock txtBlock = new TextBlock(); txtBlock.TextWrapping = TextWrapping.Wrap; txtBlock.Text = $"{item.SendDate}: {item.Username}: {item.Text}"; Lb_Chat.Items.Add(txtBlock); } ChatList.Clear(); client.ClearList(); state2 = false; state = false; client.IsDone = false; } } } Task task = Task.Run((Action)CheckForUpdate); }
public ChatsViewModel(IProtoService protoService, ICacheService cacheService, ISettingsService settingsService, IEventAggregator aggregator, INotificationsService notificationsService, ChatList chatList, IChatFilter filter = null) : base(protoService, cacheService, settingsService, aggregator) { _notificationsService = notificationsService; _chatList = chatList; Items = new ItemsCollection(protoService, aggregator, this, chatList, filter); ChatPinCommand = new RelayCommand <Chat>(ChatPinExecute); ChatArchiveCommand = new RelayCommand <Chat>(ChatArchiveExecute); ChatMarkCommand = new RelayCommand <Chat>(ChatMarkExecute); ChatNotifyCommand = new RelayCommand <Chat>(ChatNotifyExecute); ChatDeleteCommand = new RelayCommand <Chat>(ChatDeleteExecute); ChatClearCommand = new RelayCommand <Chat>(ChatClearExecute); ChatSelectCommand = new RelayCommand <Chat>(ChatSelectExecute); ChatsMarkCommand = new RelayCommand(ChatsMarkExecute); ChatsNotifyCommand = new RelayCommand(ChatsNotifyExecute); ChatsArchiveCommand = new RelayCommand(ChatsArchiveExecute); ChatsDeleteCommand = new RelayCommand(ChatsDeleteExecute); ChatsClearCommand = new RelayCommand(ChatsClearExecute); ClearRecentChatsCommand = new RelayCommand(ClearRecentChatsExecute); TopChatDeleteCommand = new RelayCommand <Chat>(TopChatDeleteExecute); #if MOCKUP Items.AddRange(protoService.GetChats(20)); #endif SelectedItems = new MvxObservableCollection <Chat>(); }
public async Task <ActionResult <ChatList> > PostDonHang(ChatList chat) { try { chat.MyUser = Convert.ToInt32(chat.MyUser); chat.FromUser = Convert.ToInt32(chat.FromUser); } catch { } var li = await _context.ChatList.Where(x => x.MyUser == chat.MyUser && x.FromUser == chat.FromUser || x.MyUser == chat.FromUser && x.FromUser == chat.MyUser).SingleAsync(); if (li == null) { //tạo mục liên hệ mới chat.Date = DateTime.Now; _context.ChatList.Add(chat); _context.SaveChanges(); return(chat); } else { li.Date = DateTime.Now; li.LastMs = chat.LastMs; li.MsFrom = chat.MsFrom; li.Status = chat.Status; _context.ChatList.Update(li); _context.SaveChanges(); return(li); } }
public void UpdateCollection(Chat chat) { App.Current.Dispatcher.Invoke((Action) delegate // <--- HERE { ChatList.Add(chat); }); }
public ChatPage(Conversation con) : this() { var vm = new Chat.ViewModels.ChatPageViewModel(con); vm.View = this; this.BindingContext = vm; this.Title = con.Title; ScrollListCommand = new Command(() => { ChatList.ScrollToLast(); }); if (!string.IsNullOrEmpty(con.HTMLTable)) { var webView = MessageBoard.FindByName <WebView>("webView"); webView.Source = new HtmlWebViewSource { Html = con.HTMLTable }; } // ChatList.Opacity = 0; //var itemSource = ChatList.ItemsSource as ObservableCollection<GroupedMessage>; //var lastMessage = itemSource.Last().Last(); ChatList.ScrollToLast(); //ChatList.ScrollToLast(); //ChatList.ScrollTo(lastMessage, ScrollToPosition.MakeVisible, false); // ChatList.Opacity = 1; }
//自动到底部 private void ToDown() { ChatList.Focus(); //获取焦点 ChatList.Select(ChatList.TextLength, 0); //光标定位到文本最后 ChatList.ScrollToCaret(); //滚动到光标处 Say.Focus(); }
public async Task <IActionResult> SignUp(SignUpViewModel model) { if (ModelState.IsValid) { User user = new User { UserName = model.Login }; var result = await _userManager.CreateAsync(user, model.Password); _context.SaveChanges(); if (result.Succeeded) { ChatList commonChats = new ChatList(); _context.ChatLists.Add(commonChats); commonChats.Owner = user; user.CommonChats = commonChats; _context.SaveChanges(); await _signInManager.SignInAsync(user, false); return(RedirectToAction("Private", "Home", user)); } else { foreach (var error in result.Errors) { ModelState.AddModelError(string.Empty, error.Description); } } } return(View(model)); }
private void RefreshOrAddEntryInList(ChannelInfo newOrUpdatedChannel) { var index = ChatList.IndexOf(ChatList.First(a => a.Data.Equals(newOrUpdatedChannel))); index = (index == -1 ? 0 : index); ChatList[index] = new ChatListEntry(newOrUpdatedChannel); }
private void chatservice_OnMessageReceived(object sender, ChatMessage e) { Device.BeginInvokeOnMainThread(() => ChatList.Add(new ChatMessage { LineOne = e.LineOne })); }
/// <summary> /// Changes the order of pinned chats /// </summary> public static Task <Ok> SetPinnedChatsAsync( this Client client, ChatList chatList = default, long[] chatIds = default) { return(client.ExecuteAsync(new SetPinnedChats { ChatList = chatList, ChatIds = chatIds })); }
/// <summary> /// Returns an ordered list of chats from the beginning of a chat list. For informational purposes only. Use loadChats and updates processing instead to maintain chat lists in a consistent state /// </summary> public static Task <Chats> GetChatsAsync( this Client client, ChatList chatList = default, int limit = default) { return(client.ExecuteAsync(new GetChats { ChatList = chatList, Limit = limit })); }
/// <summary> /// Adds a chat to a chat list. A chat can't be simultaneously in Main and Archive chat lists, so it is automatically removed from another one if needed /// </summary> public static Task <Ok> AddChatToListAsync( this Client client, long chatId = default, ChatList chatList = default) { return(client.ExecuteAsync(new AddChatToList { ChatId = chatId, ChatList = chatList })); }
public App() { this.InitializeComponent(); ChatList.Add(new Chatitem("안녕하세요 server입니다 병신아.", "server", "19:20:22", false)); ChatList.Add(new Chatitem("안녕하세요 Client 입니다 병신아.", "Client", "19:20:22", true)); ClientList.Add(new ClientItem("SERVER", "SERVER입니다 반갑습니다.", true)); ClientList.Add(new ClientItem("ME", "나 자신임", false)); }
/// <summary> /// Searches for messages in all chats except secret chats. Returns the results in reverse chronological order (i.e., in order of decreasing (date, chat_id, message_id)). /// </summary> public static Task <Messages> SearchMessagesAsync( this Client client, ChatList chatList = default, string query = default, int offsetDate = default, long offsetChatId = default, long offsetMessageId = default, int limit = default, SearchMessagesFilter filter = default, int minDate = default, int maxDate = default) { return(client.ExecuteAsync(new SearchMessages { ChatList = chatList, Query = query, OffsetDate = offsetDate, OffsetChatId = offsetChatId, OffsetMessageId = offsetMessageId, Limit = limit, Filter = filter, MinDate = minDate, MaxDate = maxDate })); }
//Add ChatList to dictionary. throws a DuplicateKeyException if data already contains a ChatList with c.category private void add(ChatList c) { if (data.ContainsKey(c.category)) { throw new DuplicateKeyException("category " + c.category + " is a duplicate!"); } data.Add(c.category, c); }
/// <summary> /// Returns an ordered list of chats in a chat list. Chats are sorted by the pair (chat.position.order, chat.id) in descending order. (For example, to get a list of chats from the beginning, the offset_order should be equal to a biggest signed 64-bit number 9223372036854775807 == 2^63 - 1). /// </summary> public static Task <Chats> GetChatsAsync( this Client client, ChatList chatList = default, long offsetOrder = default, long offsetChatId = default, int limit = default) { return(client.ExecuteAsync(new GetChats { ChatList = chatList, OffsetOrder = offsetOrder, OffsetChatId = offsetChatId, Limit = limit })); }
/// <summary> /// Changes the pinned state of a chat. There can be up to GetOption("pinned_chat_count_max")/GetOption("pinned_archived_chat_count_max") pinned non-secret chats and the same number of secret chats in the main/arhive chat list /// </summary> public static Task <Ok> ToggleChatIsPinnedAsync( this Client client, ChatList chatList = default, long chatId = default, bool isPinned = default) { return(client.ExecuteAsync(new ToggleChatIsPinned { ChatList = chatList, ChatId = chatId, IsPinned = isPinned })); }
// this method will search through the List of Chat objects // and return the results containing the search key // we are searching in both messages and sender fields public static List <Chat> SearchChat(string searchKey) { searchKey = searchKey.ToLower(); var result = ChatList.Where(x => x.Fields.Message.ToLower().Contains(searchKey) || x.Fields.Username.ToLower().Contains(searchKey)).Select(y => y).ToList(); return(result); }
// Start is called before the first frame update void Start() { //Chat_UI chatUI = GameObject.FindGameObjectWithTag(Constants.Tags.chatUIManager).GetComponent<Chat_UI>(); // chatText = chatUI.chatText; //chatInput = chatUI.chatInput; chatList = GameObject.FindGameObjectWithTag(Constants.Tags.chatManager).GetComponent <ChatList>(); chatList.ChatUpdated += OnChatUpdate; playerName = GetComponent <GamePlayer>().playerName; }
public Chat(string name, string firstMsg, GameObject obj) { ChatObject = obj; ChatName = name; Messages.Add(("msg", firstMsg)); chatNameText = obj.transform.GetChild(1).GetChild(0).GetComponent <Text>(); previewText = obj.transform.GetChild(1).GetChild(1).GetComponent <Text>(); ChatObject.GetComponent <Button>().onClick.AddListener(delegate { activeChatName = name; instance.isTyping.text = $"{name} is typing..."; ChatList.ForEach(A => A.active = false); active = true; instance.MessagePanel.SetActive(true); for (int i = instance.MessageHolder.childCount - 1; i >= 0; i--) { Destroy(instance.MessageHolder.GetChild(i).gameObject); } Messages.ForEach(A => { GameObject msg; switch (A.Item1) { case "msg": msg = Instantiate(instance.MessageFromPrefab, instance.MessageHolder, false); break; case "r": msg = Instantiate(instance.MessageToPrefab, instance.MessageHolder, false); break; case "img": msg = Instantiate(instance.MessageImgPrefab, instance.MessageHolder, false); //IMAGE break; default: msg = new GameObject(); break; } Text msgText = msg.transform.GetChild(0).GetChild(0).GetComponent <Text>(); msgText.text = A.Item2; msgText.GetComponent <ContentSizeFitter>().SetLayoutVertical(); msg.GetComponent <LayoutElement>().minHeight = 60 + (msgText.transform as RectTransform).sizeDelta.y; Button copyBtn = msg.transform.GetChild(0).GetChild(1).GetComponent <Button>(); copyBtn.onClick.AddListener(delegate { TextEditor te = new TextEditor(); te.text = A.Item2; te.SelectAll(); te.Copy(); }); }); }); chatNameText.text = name; previewText.text = string.Join(string.Empty, firstMsg.Take(20)) + "..."; }
/// <summary> /// 读取开始开场动画中的配置文件 /// </summary> /// <returns></returns> public static ChatList GetChatList(string fileName) { ChatList chatList = new ChatList(); string path = VariablePath.Config_OpenAnim + fileName; string jsonStr = Resources.Load <TextAsset>(path).ToString(); chatList = JsonUtility.FromJson <ChatList>(jsonStr); return(chatList); }
/// <summary> /// 显示发出的消息 /// </summary> /// <param name="msg"></param> private void ShowSendMsg(WeChatMsg msg) { ChatMsg chatmsg = new ChatMsg(); chatmsg.Image = _me.Icon; chatmsg.Message = msg.Msg; chatmsg.FlowDir = FlowDirection.RightToLeft; chatmsg.TbColor = (Brush) new BrushConverter().ConvertFromString("#FF98E165"); ChatList.Add(chatmsg); }
/// <summary> /// Moves a chat to a different chat list. Current chat list of the chat must ne non-null /// </summary> public static Task <Ok> SetChatChatListAsync(this Client client, long chatId = default(long), ChatList chatList = default(ChatList)) { return(client.ExecuteAsync(new SetChatChatList { ChatId = chatId, ChatList = chatList, })); }
public async Task <Chats> GetChatListAsync(ChatList chatList, int offset, int limit) { Monitor.Enter(_chatList); var index = GetIdFromChatList(chatList); var count = offset + limit; var sorted = _chatList[index]; #if MOCKUP _haveFullChatList[index] = true; #else if (!_haveFullChatList[index] && count > sorted.Count) { Monitor.Exit(_chatList); var response = await SendAsync(new LoadChats(chatList, count - sorted.Count)); if (response is Ok or Error) { if (response is Error error && error.Code == 404) { _haveFullChatList[index] = true; } // chats had already been received through updates, let's retry request return(await GetChatListAsync(chatList, offset, limit)); } return(null); } #endif // have enough chats in the chat list to answer request var result = new long[Math.Max(0, Math.Min(limit, sorted.Count - offset))]; var pos = 0; using (var iter = sorted.GetEnumerator()) { int max = Math.Min(count, sorted.Count); for (int i = 0; i < max; i++) { iter.MoveNext(); if (i >= offset) { result[pos++] = iter.Current.ChatId; } } } Monitor.Exit(_chatList); return(new Chats(0, result)); }
private void PrepareRecyclerViewAdapter() //TODO buscar lista de mensagens iniciais colocar no outro constructor { LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this); linearLayoutManager.Orientation = LinearLayoutManager.Vertical; ChatList.SetLayoutManager(linearLayoutManager); ChatListAdapter chatListAdapter = new ChatListAdapter(chatMessages); ChatList.SetAdapter(chatListAdapter); }
/** * Add message to chat list */ private void AddMessage(string message) { if (ChatList.InvokeRequired) { ChatList.Invoke(new UpdateChat(UpdateDisplay), message); } else { UpdateDisplay(message); } }
private void EndAsync(IAsyncResult ar) { ChatList d = null; try { System.Runtime.Remoting.Messaging.AsyncResult asres = (System.Runtime.Remoting.Messaging.AsyncResult)ar; d = ((ChatList)asres.AsyncDelegate); d.EndInvoke(ar); } catch { List -= d; } }
public string[] Join(string name) { User = new ChatList(User); }