private async Task <bool> SendImageMessage() { var pic = dialogService.OpenFile("Select image file", "Images (*.jpg;*.png)|*.jpg;*.png"); if (string.IsNullOrEmpty(pic)) { return(false); } var img = await Task.Run(() => File.ReadAllBytes(pic)); try { var recepient = _selectedParticipant.Name; await chatService.SendBroadcastMessageAsync(img); return(true); } catch (Exception) { return(false); } finally { ChatMessage msg = new ChatMessage { Author = UserName, Picture = pic, Time = DateTime.Now, IsOriginNative = true }; ChatLog.Add(msg); } }
private async Task <bool> SendTextMessage() { try { //var recepient = _selectedParticipant.Name; await chatService.SendBroadcastMessageAsync(_textMessage); await chatService.SendAnswerAsync(_textMessage); return(true); } catch (Exception) { return(false); } finally { ChatMessage msg = new ChatMessage { Author = UserName, Message = _textMessage, Time = DateTime.Now, IsOriginNative = true }; ChatLog.Add(msg); TextMessage = string.Empty; } }
/// <summary> /// Manually add a combat log message by string. /// </summary> /// <param name="msg">Combat log message to parse and add.</param> public void AddMessage(string m) { ChatMessage msg = ChatMessage.Parse(m); // Is it even a chat message? if (msg != null) { // If so, which one is it? msg = parser.Parse(msg); Helper.RaiseEventOnUIThread(OnChatMessage, new object[] { this, msg }); HandleMeters(msg); chatlog.Add(msg); } }
public override void WarnIfNecessary(ChatLog chat) { if (!isIntelRenderer) { return; } chat.Add("&cIntel graphics cards are known to have issues with the OpenGL build."); chat.Add("&cVSync may not work, and you may see disappearing clouds and map edges."); chat.Add(" "); chat.Add("&cFor Windows, try downloading the Direct3D 9 build as it doesn't have"); chat.Add("&cthese problems. Alternatively, the disappearing graphics can be"); chat.Add("&cpartially fixed by typing \"/client render legacy\" into chat."); }
private static void ReceiveMessage(string speaker, string message) { if (OnNewMessage != null) { NewMessageArgs args = new NewMessageArgs(); args.Speaker = speaker; args.Message = message; OnNewMessage(null, args); } if (message.ToLower().StartsWith(BotCommandPrefix)) { if (ChatLog.Count > 20) { ChatLog.RemoveAt(0); } ChatLog.Add($"\r\n[{speaker}]: {message}"); _commands = GetAllCommands(); if (_commands.Count > 0) { foreach (dynamic command in _commands) { if (message.ToLower().Contains(command.CommandText.ToLower()) && message[1] != ' ') { if (command.IsBotCommand) { RunBotCommand(speaker, message); } else if (command.Response.Length > 0) { SendTwitchMessage(command.Response); } } } } } }
private void NewTextMessage(string name, string msg, MessageType mt) { if (mt == MessageType.Unicast) { ChatMessage cm = new ChatMessage { Author = name, Message = msg, Time = DateTime.Now }; var sender = _participants.Where((u) => string.Equals(u.Name, name)).FirstOrDefault(); ctxTaskFactory.StartNew(() => sender.Chatter.Add(cm)).Wait(); if (!(SelectedParticipant != null && sender.Name.Equals(SelectedParticipant.Name))) { ctxTaskFactory.StartNew(() => sender.HasSentNewMessage = true).Wait(); } } else if (mt == MessageType.Broadcast) { ChatMessage cm = new ChatMessage { Author = name, Message = msg, Time = DateTime.Now, IsOriginNative = false }; ctxTaskFactory.StartNew(() => ChatLog.Add(cm)).Wait(); //ctxTaskFactory.StartNew(() => sender.HasSentNewMessage = true).Wait(); } }
internal static void OpenFrame() { if (GameInfo == null || GameData == null || Observation == null) { if (GameInfo == null) { Logger.Info("GameInfo is null! The application will terminate."); } else if (GameData == null) { Logger.Info("GameData is null! The application will terminate."); } else { Logger.Info("ResponseObservation is null! The application will terminate."); } Pause(); Environment.Exit(0); } actions.Clear(); PopulateUnits(); foreach (var chat in Observation.Chat) { ChatLog.Add(chat.Message); } Frame = Observation.Observation.GameLoop; CurrentSupply = Observation.Observation.PlayerCommon.FoodUsed; MaxSupply = Observation.Observation.PlayerCommon.FoodCap; Minerals = Observation.Observation.PlayerCommon.Minerals; Vespene = Observation.Observation.PlayerCommon.Vespene; //initialization if (Frame == 0) { var resourceCenters = GetUnits(Units.ResourceCenters); if (resourceCenters.Count > 0) { var rcPosition = resourceCenters[0].Position; foreach (var startLocation in GameInfo.StartRaw.StartLocations) { var location = new Vector3(startLocation.X, startLocation.Y, 0); var distance = Vector3.Distance(location, rcPosition); if (distance > 30) { EnemyLocations.Add(location); } else { StartLocation = location; } } } } if (frameDelay > 0) { Thread.Sleep(frameDelay); } }
public void Receive(string source, string message) { ChatLog.Add($"[{Name}'s chat log] {source} : {message}"); }
protected static void AmendChatLog(string msg) { ChatLog.Add(msg); ChatLastLog = msg; }