Inheritance: MonoBehaviour
Exemplo n.º 1
0
 private void ChatHistoryTextInput(object sender, TextCompositionEventArgs e)
 {
     // Redirect input from the chat history to the chat input
     ChatInput.Focus();
     ChatInput.SelectedText = e.Text;
     ChatInput.Select(ChatInput.SelectionStart + e.Text.Length, 0);
 }
Exemplo n.º 2
0
        public MainWindow()
        {
            if (!Debugger.IsAttached)
            {
                AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
            }

            m_options            = new ChatOptions();
            m_playSounds         = m_options.GetOption("PlaySounds", true);
            m_highlightQuestions = m_options.GetOption("HighlightQuestions", true);
            m_confirmBans        = m_options.GetOption("ConfirmBans", true);
            m_confirmTimeouts    = m_options.GetOption("ConfirmTimeouts", false);
            m_showIcons          = m_options.GetOption("ShowIcons", true);
            m_showTimestamp      = m_options.GetOption("ShowTimestamps", false);
            m_fontSize           = 14;
            OnTop     = m_options.GetOption("OnTop", false);
            m_channel = m_options.Stream.ToLower();
            TwitchHttp.Instance.PollChannelData(m_channel);
            TwitchHttp.Instance.ChannelDataReceived += Instance_ChannelDataReceived;

            m_thread = new Thread(ThreadProc);
            m_thread.Start();

            Messages = new ObservableCollection <ChatItem>();

            InitializeComponent();
            Channel.Text = m_channel;
            ChatInput.Focus();
        }
Exemplo n.º 3
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;
            }
        }
Exemplo n.º 4
0
        public async Task <IActionResult> AllowUserToChatSync([FromQuery] ChatInput input)
        {
            try
            {
                //check if user exists or if the security code belongs to that one
                var user = DB.Users.Where(u => u.SecurityCode == input.SecurityCode && u.UserId == input.UserId).SingleOrDefault();
                if (user == null)
                {
                    return(BadRequest("Cannot find the user"));
                }


                //check if contact exists between user that is sending the message and receipment, if no add one
                var contactExists = DB.UserContacts.Where(c => c.UserId == input.UserId && c.ContactUserId == input.RecipientId).Any();
                if (!contactExists)
                {
                    await DB.UserContacts.AddAsync(new UserContacts { ContactUserId = input.RecipientId, UserId = input.UserId });

                    await DB.SaveChangesAsync();
                }
                //save the message to the db
                await DB.ChatMessages.AddAsync(new ChatMessage { Message = input.Message, Date = DateTime.Now, UserId = input.UserId, RecipientId = input.RecipientId });

                await DB.SaveChangesAsync();

                //send the message to user via signalR method
                await Hub.Clients.User(input.UserId).SendAsync("ReceiveMessage", input.Message);

                return(Ok(true));
            }
            catch (Exception ex)
            {
                return(StatusCode((int)HttpStatusCode.InternalServerError, "Internal server error"));
            }
        }
Exemplo n.º 5
0
        public MainWindow()
        {
            if (!Debugger.IsAttached)
            {
                AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
            }

            m_options            = new ChatOptions();
            m_playSounds         = m_options.GetOption("PlaySounds", true);
            m_highlightQuestions = m_options.GetOption("HighlightQuestions", true);
            m_confirmBans        = m_options.GetOption("ConfirmBans", true);
            m_confirmTimeouts    = m_options.GetOption("ConfirmTimeouts", false);
            m_showIcons          = m_options.GetOption("ShowIcons", true);
            m_showTimestamp      = m_options.GetOption("ShowTimestamps", false);
            m_fontSize           = 14;
            OnTop         = m_options.GetOption("OnTop", false);
            m_channelName = m_options.Stream.ToLower();


            LoadAsyncData();

            DispatcherTimer dispatcherTimer = new DispatcherTimer();

            dispatcherTimer.Tick    += new EventHandler(dispatcherTimer_Tick);
            dispatcherTimer.Interval = new TimeSpan(0, 2, 0);
            dispatcherTimer.Start();

            Messages = new ObservableCollection <ChatItem>();

            InitializeComponent();
            Channel.Text = m_channelName;
            ChatInput.Focus();
        }
Exemplo n.º 6
0
        void ReleaseDesignerOutlets()
        {
            if (ChatHistory != null)
            {
                ChatHistory.Dispose();
                ChatHistory = null;
            }

            if (ChatInput != null)
            {
                ChatInput.Dispose();
                ChatInput = null;
            }

            if (ContainerTopConstraint != null)
            {
                ContainerTopConstraint.Dispose();
                ContainerTopConstraint = null;
            }

            if (InterfaceContainer != null)
            {
                InterfaceContainer.Dispose();
                InterfaceContainer = null;
            }

            if (ContainerBottomConstraint != null)
            {
                ContainerBottomConstraint.Dispose();
                ContainerBottomConstraint = null;
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Initialize any components required by this state.
        /// </summary>
        public override void Initialize()
        {
            ServiceManager.Game.FormManager.ClearWindow();
            Options options = ServiceManager.Game.Options;

            RendererAssetPool.DrawShadows = GraphicOptions.ShadowMaps;
            mouseCursor = new MouseCursor(options.KeySettings.Pointer);
            mouseCursor.EnableCustomCursor();
            renderer    = ServiceManager.Game.Renderer;
            fps         = new FrameCounter();
            Chat        = new ChatArea();
            Projectiles = new ProjectileManager();
            Tiles       = new TexturedTileGroupManager();
            Utilities   = new UtilityManager();
            cd          = new Countdown();
            Lazers      = new LazerBeamManager(this);
            Scene.Add(Lazers, 0);
            Players            = new PlayerManager();
            currentGameMode    = ServiceManager.Theater.GetCurrentGameMode();
            Flags              = new FlagManager();
            Bases              = new BaseManager();
            EnvironmentEffects = new EnvironmentEffectManager();
            buffbar            = new BuffBar();
            Scores             = new ScoreBoard(currentGameMode, Players);
            input              = new ChatInput(new Vector2(5, ServiceManager.Game.GraphicsDevice.Viewport.Height), 300);//300 is a magic number...Create a chat width variable.
            input.Visible      = false;
            hud              = HUD.GetHudForPlayer(Players.GetLocalPlayer());
            localPlayer      = Players.GetLocalPlayer();
            Scene.MainEntity = localPlayer;
            sky              = ServiceManager.Resources.GetTexture2D("textures\\misc\\background\\sky");
            tips             = new GameTips(new GameContext(CurrentGameMode, localPlayer));
            helpOverlay      = new HelpOverlay();
        }
Exemplo n.º 8
0
        // Chat Input KeyDown if and only if message is text message
        private void ChatInput_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Return)
            {
                if (Keyboard.IsKeyDown(Key.LeftShift) || Keyboard.IsKeyDown(Key.RightShift))
                {
                    ChatInput.AppendText(Environment.NewLine);
                    ChatInput.CaretIndex = ChatInput.Text.Length;
                    return;
                }

                // Send message here
                if (String.IsNullOrEmpty(ChatInput.Text))
                {
                    return;
                }

                SendMessage(new TextMessage()
                {
                    Message = ChatInput.Text
                });

                // Clear textbox
                ChatInput.Text = String.Empty;
            }
        }
Exemplo n.º 9
0
    /// <summary>
    ///
    /// </summary>
    public void OnChatSend()
    {
        ChatInput chat_input = ((GameObject)this["Background/Chat Input"]).GetComponent <ChatInput>();

        chat_input.OnSubmit();

        AddMessageCount();
    }
Exemplo n.º 10
0
 private void Channel_PreviewKeyDown(object sender, KeyEventArgs e)
 {
     if (e.Key == Key.Enter)
     {
         e.Handled = true;
         UpdateChannel(Channel.Text);
         ChatInput.Focus();
     }
 }
Exemplo n.º 11
0
        private void SetupGestures()
        {
            var swipeGesture = new UISwipeGestureRecognizer(OnSwipeDetected)
            {
                Direction = UISwipeGestureRecognizerDirection.Down,
            };

            ChatInput.AddGestureRecognizer(swipeGesture);
            ChatInput.ShouldReturn = TextFieldShouldReturn;
        }
Exemplo n.º 12
0
        void ReleaseDesignerOutlets()
        {
            if (ChatInput != null)
            {
                ChatInput.Dispose();
                ChatInput = null;
            }

            if (InputBox != null)
            {
                InputBox.Dispose();
                InputBox = null;
            }

            if (InputBoxBottomConstraint != null)
            {
                InputBoxBottomConstraint.Dispose();
                InputBoxBottomConstraint = null;
            }

            if (InputBoxTopRuler != null)
            {
                InputBoxTopRuler.Dispose();
                InputBoxTopRuler = null;
            }

            if (InputRightConstraint != null)
            {
                InputRightConstraint.Dispose();
                InputRightConstraint = null;
            }

            if (MessageTable != null)
            {
                MessageTable.Dispose();
                MessageTable = null;
            }

            if (Send != null)
            {
                Send.Dispose();
                Send = null;
            }

            if (SendRightConstraint != null)
            {
                SendRightConstraint.Dispose();
                SendRightConstraint = null;
            }
        }
Exemplo n.º 13
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();
        }
Exemplo n.º 14
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);
        }
Exemplo n.º 15
0
        public async Task <IActionResult> GetPreviousChatAsync([FromQuery] ChatInput input)
        {
            try
            {
                //validate user inputs for userId, RecipientId and SecurityCode
                if (string.IsNullOrEmpty(input.UserId))
                {
                    return(BadRequest("User Id is not valid"));
                }
                if (string.IsNullOrEmpty(input.RecipientId))
                {
                    return(BadRequest("Recipient Id is not valid"));
                }
                if (string.IsNullOrEmpty(input.SecurityCode))
                {
                    return(BadRequest("Security Code is not valid"));
                }
                //check if user exists or if the security code belongs to that one
                var user = DB.Users.Where(u => u.SecurityCode == input.SecurityCode && u.UserId == input.UserId).SingleOrDefault();
                if (user == null)
                {
                    return(BadRequest("Cannot find the user"));
                }
                //base url
                var BaseUrl = $"{this.Request.Scheme}://{this.Request.Host}{this.Request.PathBase}";
                //get the chat list from db
                var previousChat = await DB.ChatMessages
                                   .Where(c => c.UserId == input.UserId && c.RecipientId == input.RecipientId)
                                   .OrderByDescending(c => c.Id)
                                   .Select(c => new ChatResponse
                {
                    Image   = string.IsNullOrEmpty(c.Image) ? null : Path.Combine(BaseUrl, "Files", c.Image),
                    Message = c.Message
                }).FirstOrDefaultAsync();

                //return the chatList
                return(Ok(previousChat));
            }
            catch (Exception ex)
            {
                return(StatusCode((int)HttpStatusCode.InternalServerError, "Internal server error"));
            }
        }
        void ReleaseDesignerOutlets()
        {
            if (ChatInput != null)
            {
                ChatInput.Dispose();
                ChatInput = null;
            }

            if (ChatRequestButton != null)
            {
                ChatRequestButton.Dispose();
                ChatRequestButton = null;
            }

            if (ChatSend != null)
            {
                ChatSend.Dispose();
                ChatSend = null;
            }
        }
Exemplo n.º 17
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();
        }
        void SendMessage_Clicked(object sender, EventArgs e)
        {
            ChatText = Entry_ChatText.Text;

            ChatInput cInput = new ChatInput();

            cInput.room    = roomname;
            cInput.name    = ChatName;
            cInput.message = ChatText;

            if (Entry_ChatText.Text == null)
            {
                //alert soon
            }
            else
            {
                var obj = JsonConvert.SerializeObject(cInput, Formatting.Indented);
                _socketClient.SendMessage(obj);
            }


            Entry_ChatText.Text = ""; //clears value for new message.
        }
 void OnHistoryTextInput(object sender, TextCompositionEventArgs e)
 {
     ChatInput.SelectedText = e.Text;
     ChatInput.Select(ChatInput.SelectionStart + ChatInput.SelectionLength, 0);
     ChatInput.Focus();
 }
Exemplo n.º 20
0
        public override void Startup()
        {
            _gameTicker     = EntitySystem.Get <ClientGameTicker>();
            _characterSetup = new CharacterSetupGui(_entityManager, _resourceCache, _preferencesManager,
                                                    _prototypeManager);
            LayoutContainer.SetAnchorPreset(_characterSetup, LayoutContainer.LayoutPreset.Wide);

            _lobby = new LobbyGui(_entityManager, _preferencesManager);
            _userInterfaceManager.StateRoot.AddChild(_lobby);

            _characterSetup.CloseButton.OnPressed += _ =>
            {
                _userInterfaceManager.StateRoot.AddChild(_lobby);
                _userInterfaceManager.StateRoot.RemoveChild(_characterSetup);
            };

            _characterSetup.SaveButton.OnPressed += _ =>
            {
                _characterSetup.Save();
                _lobby?.CharacterPreview.UpdateUI();
            };

            LayoutContainer.SetAnchorPreset(_lobby, LayoutContainer.LayoutPreset.Wide);

            _chatManager.SetChatBox(_lobby.Chat);
            _voteManager.SetPopupContainer(_lobby.VoteContainer);

            _lobby.ServerName.Text = _baseClient.GameInfo?.ServerName;

            ChatInput.SetupChatInputHandlers(_inputManager, _lobby.Chat);

            UpdateLobbyUi();

            _lobby.CharacterPreview.CharacterSetupButton.OnPressed += _ =>
            {
                SetReady(false);
                _userInterfaceManager.StateRoot.RemoveChild(_lobby);
                _userInterfaceManager.StateRoot.AddChild(_characterSetup);
            };

            _lobby.ReadyButton.OnPressed += _ =>
            {
                if (!_gameTicker.IsGameStarted)
                {
                    return;
                }

                new LateJoinGui().OpenCentered();
            };

            _lobby.ReadyButton.OnToggled += args =>
            {
                SetReady(args.Pressed);
            };

            _lobby.LeaveButton.OnPressed   += _ => _consoleHost.ExecuteCommand("disconnect");
            _lobby.OptionsButton.OnPressed += _ => new OptionsMenu().Open();

            UpdatePlayerList();

            _playerManager.PlayerListUpdated       += PlayerManagerOnPlayerListUpdated;
            _gameTicker.InfoBlobUpdated            += UpdateLobbyUi;
            _gameTicker.LobbyStatusUpdated         += LobbyStatusUpdated;
            _gameTicker.LobbyReadyUpdated          += LobbyReadyUpdated;
            _gameTicker.LobbyLateJoinStatusUpdated += LobbyLateJoinStatusUpdated;
        }
Exemplo n.º 21
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;
                }
            }
        }
Exemplo n.º 22
0
 private void OnSwipeDetected()
 {
     ChatInput.ResignFirstResponder();
 }
Exemplo n.º 23
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;
                }
            }
        }
Exemplo n.º 24
0
        public async Task <IActionResult> SendAsync([FromBody] ChatInput chatInput)
        {
            GetResultMessageOutput messages = await _chatService.SendAsync(chatInput.Message, GetUserName(), chatInput.DialogId);

            return(Ok(messages));
        }
Exemplo n.º 25
0
 private void Awake()
 {
     Instance = this;
 }
Exemplo n.º 26
0
 public void OnListTapped(object sender, ItemTappedEventArgs e)
 {
     ChatInput.UnFocusEntry();
 }
Exemplo n.º 27
0
 public void submitText(object sender, EventArgs e)
 {
     Client.SendMessage(input);
     ChatInput.Clear();
 }