Ejemplo n.º 1
0
        private void ChatInput_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == 13)
            {
                if (ChatInput.Text == "")
                {
                    return;
                }
                if (IsPrivate && ChatInput.Text.StartsWith("/me"))
                {
                    WriteMessage(new ChatMessage(MessageType.Message, CommandType.Me, Program.UserInfo, Name, Program.UserInfo.username + " " + ChatInput.Text.Replace("/me", "").Trim()));
                    Program.ChatServer.SendMessage(MessageType.PrivateMessage, CommandType.Me, Name, ChatInput.Text.Substring(4));
                }
                else if (IsPrivate && ChatInput.Text.StartsWith("/"))
                {
                    WriteMessage(new ChatMessage(MessageType.System, CommandType.None, Name, "Unknown Command."));
                    ChatInput.Clear();
                    e.Handled = true;
                    return;
                }
                else if (IsPrivate)
                {
                    WriteMessage(new ChatMessage(MessageType.PrivateMessage, CommandType.None, Program.UserInfo, Name, ChatInput.Text));
                    Program.ChatServer.SendMessage(MessageType.PrivateMessage, CommandType.None, Name, ChatInput.Text);
                }

                ChatInput.Clear();
                e.Handled = true;
            }
        }
Ejemplo n.º 2
0
        private void sendButton_Click(object sender, RoutedEventArgs e)
        {
            //Aquire message from input box.
            string messageToSend = ChatInput.Text;

            //Add message to local message box.
            LiveSupportListBox.Items.Add("Me: " + messageToSend);

            //Send message to connected client.
            connectedClient.supportMessagefromServer(messageToSend);

            //Clear the box that sent the message.
            ChatInput.Clear();
        }
Ejemplo n.º 3
0
        //This method will send a message. This method will be used inside other methods.
        //Still needs connection to server.
        private async Task <bool> SendMessageAsync()
        {
            //creates unixtimestamp to the current time.
            long now = (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
            //creates message and sends it to the server. Clears inputfield afterwards
            //MessageData msgD = new MessageData() { ID = chatID, Sender=userSender, TimeStamp=now, Text=ChatInput.Text };
            MessageData msgD = new MessageData()
            {
                ID = chatID, message = ChatInput.Text, timestamp = now, sender = userSender, seen = false
            };
            NewMessageData nMsgD = new NewMessageData()
            {
                chat = chatID, content = msgD
            };
            await MatchmakerAPI_Client.PostNewMessage(nMsgD);

            ChatInput.Clear();
            return(true);
        }
Ejemplo n.º 4
0
        private void sendButton_Click(object sender, RoutedEventArgs e)
        {
            if (portalConnected)
            {
                //Aquire message from input box.
                string messageToSend = ChatInput.Text;

                //Add message to local message box.
                LiveSupportListBox.Items.Add("Me: " + messageToSend);

                //Send message to connected portal.
                currentConnection.supportMessagefromClient(messageToSend);
            }
            else
            {
                MessageBox.Show("Connection required for Live Support");
            }

            //Clear the box that sent the message.
            ChatInput.Clear();
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Happens when a key goes down in the chat text box.
        /// </summary>
        /// <param name="sender">The Sender</param>
        /// <param name="e">Event Arguments</param>
        private void ChatInputPreviewKeyDown(object sender, KeyEventArgs e)
        {
            if (this.room == null)
            {
                return;
            }

            if (e.Key == Key.LeftShift || e.Key == Key.RightShift)
            {
                this.shiftDown = true;
            }

            if (this.HandleAutoComplete(e))
            {
                return;
            }

            if (AutoCompleteVisible)
            {
                return;
            }

            if (!this.shiftDown && (e.Key == Key.Return || e.Key == Key.Enter))
            {
                var message = ParseCards(ChatInput.Text);
                this.messageCache.Add(message);
                if (this.messageCache.Count >= 51)
                {
                    this.messageCache.Remove(this.messageCache.Last());
                }

                this.room.SendMessage(message);
                ChatInput.Clear();
                this.curMessageCacheItem = -1;
                e.Handled = true;
            }
            else if (String.IsNullOrWhiteSpace(ChatInput.Text))
            {
                switch (e.Key)
                {
                case Key.Up:
                    if (this.messageCache.Count == 0)
                    {
                        return;
                    }

                    if (this.curMessageCacheItem - 1 >= 0)
                    {
                        this.curMessageCacheItem--;
                    }
                    else
                    {
                        this.curMessageCacheItem = this.messageCache.Count - 1;
                    }

                    this.ChatInput.Text = this.messageCache[this.curMessageCacheItem];
                    break;

                case Key.Down:
                    if (this.messageCache.Count == 0)
                    {
                        return;
                    }

                    if (this.curMessageCacheItem + 1 <= this.messageCache.Count - 1)
                    {
                        this.curMessageCacheItem++;
                    }
                    else
                    {
                        this.curMessageCacheItem = 0;
                    }

                    this.ChatInput.Text = this.messageCache[this.curMessageCacheItem];
                    break;
                }
            }
        }
Ejemplo n.º 6
0
 public void submitText(object sender, EventArgs e)
 {
     Client.SendMessage(input);
     ChatInput.Clear();
 }
Ejemplo n.º 7
0
        /// <summary>
        /// Happens when a key goes down in the chat text box.
        /// </summary>
        /// <param name="sender">The Sender</param>
        /// <param name="e">Event Arguments</param>
        private void ChatInputPreviewKeyDown(object sender, KeyEventArgs e)
        {
            if (this.room == null)
            {
                return;
            }

            if (e.Key == Key.LeftShift || e.Key == Key.RightShift)
            {
                this.shiftDown = true;
            }

            if (!this.shiftDown && e.Key == Key.Enter)
            {
                this.messageCache.Add(ChatInput.Text);
                if (this.messageCache.Count >= 51)
                {
                    this.messageCache.Remove(this.messageCache.Last());
                }

                this.room.SendMessage(ChatInput.Text);
                ChatInput.Clear();
                this.curMessageCacheItem = -1;
                e.Handled = true;
            }
            else
            {
                switch (e.Key)
                {
                case Key.Up:
                    if (this.messageCache.Count == 0)
                    {
                        return;
                    }

                    if (this.curMessageCacheItem - 1 >= 0)
                    {
                        this.curMessageCacheItem--;
                    }
                    else
                    {
                        this.curMessageCacheItem = this.messageCache.Count - 1;
                    }

                    this.ChatInput.Text = this.messageCache[this.curMessageCacheItem];
                    break;

                case Key.Down:
                    if (this.messageCache.Count == 0)
                    {
                        return;
                    }

                    if (this.curMessageCacheItem + 1 <= this.messageCache.Count - 1)
                    {
                        this.curMessageCacheItem++;
                    }
                    else
                    {
                        this.curMessageCacheItem = 0;
                    }

                    this.ChatInput.Text = this.messageCache[this.curMessageCacheItem];
                    break;
                }
            }
        }