Пример #1
0
 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 = "";
     }
 }
Пример #2
0
        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));
                }
            })));
        }
Пример #3
0
        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);
        }
Пример #4
0
        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);
        }
Пример #5
0
 protected virtual void OnTextAdded(string npcId, int numChars)
 {
     TextAdded?.Invoke(this, string.Format("NpcID {0} ({1} chars)", npcId, numChars));
 }
Пример #6
0
 protected virtual void OnTextAdded(TextAddedEventArgs e)
 {
     TextAdded?.Invoke(this, e);
 }