private void bAdd_Click(object sender, RoutedEventArgs e) { if (tbText.Text != null && tbText.Text.Length > 0) { var elem = AddTextToList(tbText.Text); TextAdded?.Invoke(elem); tbText.Text = ""; } }
public Result <IDisposable> AddText(Identity identity, RenderedText text) { if (renderedText.ContainsKey(identity)) { return(Result.FailWith <IDisposable>(State.Forbidden, $"TargetRenderer already contains text {identity.Id}.")); } renderedText.Add(identity, text); TextAdded?.Invoke(this, new RenderedTextEventArgs(identity, text)); return(Result.Ok(Disposable.For(() => { if (renderedText.ContainsKey(identity)) { renderedText.Remove(identity); TextRemoved?.Invoke(this, new RenderedTextEventArgs(identity, text)); } }))); }
public bool SendMessage(string username, string message) { if (string.IsNullOrWhiteSpace(username) || string.IsNullOrWhiteSpace(message)) { return(false); } string line = $"<{username}> {message}"; TextAdded?.Invoke(null, line); ChatHistory.Enqueue(line); if (ChatHistory.Count > 100) { RemoveHistory(); } return(true); }
public bool SendMessage(string username, string message) { if (string.IsNullOrWhiteSpace(username) || string.IsNullOrWhiteSpace(message)) { return(false); } string line = $"<{username}> {message}"; lock (SyncRoot) { ChatHistory.Add(line); while (ChatHistory.Count > 50) { ChatHistory.RemoveAt(0); } ChatWindowText = string.Join("\r\n", ChatHistory.Take(50)); } TextAdded?.Invoke(this, EventArgs.Empty); return(true); }
protected virtual void OnTextAdded(string npcId, int numChars) { TextAdded?.Invoke(this, string.Format("NpcID {0} ({1} chars)", npcId, numChars)); }
protected virtual void OnTextAdded(TextAddedEventArgs e) { TextAdded?.Invoke(this, e); }