Beispiel #1
0
        private void ChatBox_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter && Settings.isConnected)
            {
                string message = ChatBox.Text.Replace("\r\n", string.Empty);

                ChatWindow.AppendText(Settings.displayName + ": " + message + "\n");


                Console.WriteLine(message);
                if (message.StartsWith("/"))
                {
                    if (message.StartsWith("/me"))
                    {
                        try
                        {
                            client.SendAction(message.Substring(4), client.Channels[0].Name);
                        }
                        catch (ArgumentOutOfRangeException)
                        {
                            //This means they sent nothing after /me
                        }
                    }
                    else
                    {
                        //action switch case here.. I lazy MAyne.
                    }
                }
                else
                {
                    client.SendMessage(message, client.Channels[0].Name);
                }
                ChatBox.Clear();
            }
        }
        protected override void OnLoad(object[] args)
        {
            // By default we want the menu to not be visible
            menu.Visible = false;

            // Hook into window focus event so we can
            // toggle the menu when needed
            Window.OnFocusChanged += Window_OnFocusChanged;

            // Attempt to grab the server address and playername
            // from the args.
            IPEndPoint endPoint;

            if (args.Length != 2 ||
                (endPoint = args[0] as IPEndPoint) == null ||
                (playerName = args[1] as string) == null)
            {
                throw new ArgumentException("MultiplayerScreen requires a IPEndPoint and a string argument.");
            }

            // Attempt to connect to the server
            NetDenialReason?denialReason;

            if (TryConnect(endPoint, out denialReason))
            {
                // Hook into disconnected event so we can handle
                // unexpected disconnections
                client.OnDisconnected += Client_OnDisconnected;

                // Hook into packet receiving
                client.AddPacketHook(OnCustomPacket);

                // Hook into component events
                objectComponent.OnCreatableInstantiated += ObjectComponent_OnCreatableInstantiated;
                objectComponent.OnCreatableDestroyed    += ObjectComponent_OnCreatableDestroyed;

                // Show the loading bar
                loadingBar.ClearAndShow();

                // Create the world and hook into it's events
                World = new MPWorld(Renderer);
                hud.SetWorld(World);

                // Send our information to the server
                netPlayerComponent.SendClientInfo(playerName);

                // Clear the chat
                chat.Clear();
            }
            else
            {
                // If we fail to connect, just kickback to the MainMenu with a message.
                Window.SwitchScreen("MainMenu", "Failed to connect to server: " + denialReason.Value.ToString());
            }

            base.OnLoad(args);
        }
Beispiel #3
0
 private void clearChat()
 {
     if (this.InvokeRequired)
     {
         this.Invoke(Cleaner);
         return;
     }
     ChatBox.Clear();
 }
Beispiel #4
0
 private void SendButton_Click(object sender, EventArgs e)
 {
     if (clientside.IsConnected && ChatBox != null)
     {
         Server.Server.recruiter = name;
         Server.Server.seeker    = other;
         clientside.Send(ChatBox.Text);
         ChangeText("Me : " + ChatBox.Text);
         ChatBox.Clear();
     }
 }
Beispiel #5
0
        private void ChatBox_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Enter && !string.IsNullOrWhiteSpace(ChatBox.Text) && _connection.IsStrangerConnected)
            {
                _connection.SendMessage(ChatBox.Text);

                if (SettingsSelector.GetConfigurationValue <bool>("Behavior_SendChatstate"))
                {
                    _connection.ReportChatstate(false);
                    _typing = false;
                }

                MessageLog.AddMessage(new Message(ChatBox.Text, -1, -1, MessageType.Chat), false);
                ChatBox.Clear();

                OnMessageSent();
            }
        }
Beispiel #6
0
        private void Connection_ConversationEnded(object sender, ConversationEndedEventArgs e)
        {
            Application.Current.Dispatcher.Invoke(() =>
            {
                if (!e.DisconnectInfo.IsReminder)
                {
                    MessageLog.AddPresence(false);
                }

                ChatBox.Clear();
                ChatBox.IsEnabled = false;

                StatusTextBlock.Text = LocaleSelector.GetLocaleString("StatusIndicator_ConnectedToServer");

                Toolbar.DisconnectFromStrangerButton.IsEnabled = false;
                Toolbar.SearchForStrangerButton.IsEnabled      = true;
                Toolbar.FlagStrangerButton.IsEnabled           = false;
                Toolbar.RequestRandomTopicButton.IsEnabled     = false;
            });
        }
Beispiel #7
0
        public void LoadGameIntoUI(List <Player> players, string rosterName)
        {
            if (players == null)
            {
                players = SalemUtil.CreateDummyPlayers();
            }

            _chatBox.Clear();
            _listBox.Items.Clear();

            _roster         = SalemUtil.GetRoster(rosterName);
            _roster.Players = players;

            _playersBox.LoadPlayers(players);
            _rosterBox.LoadRoster(_roster);

            players.AddUpdateAction(_roster.DoUpdate);
            players.AddUpdateAction(_playersBox.DoUpdate);
            players.AddUpdateAction(_rosterBox.DoUpdate);
            players.AddUpdateAction(_chatBox.DoUpdate);
        }
Beispiel #8
0
        private void OnUserSelect(object sender, EventArgs e)
        {
            ChatBox.Clear();
            var recipient = Interlocutors
                            .Find(x => x.Name == (string)UserList.SelectedItem);

            _recipientId = recipient?.Id ?? 0;
            if (recipient == null || recipient.MessageHistory == null)
            {
                return;
            }
            try
            {
                foreach (var record in recipient.MessageHistory)
                {
                    DrawText($"{(record.IsIncoming ? recipient.Name : "Me")}: {record.Message}");
                }
            }
            catch (Exception ex)
            {
                StatusBar.Text = ex.Message;
            }
        }
Beispiel #9
0
        /// <summary>
        /// Event when user presses a key inside the chat box
        /// </summary>
        /// <param name="sender">Object that raised the event</param>
        /// <param name="e">Key press event info</param>
        private void ChatBox_KeyPress(object sender, KeyPressEventArgs e)
        {
            // Don't do anything if the client is null or the user
            // didn't press return to send a message
            if (Globals.Client == null || e.KeyChar != (char)Keys.Return)
            {
                return;
            }

            Room curRoom = Globals.Client.GetRoom(_curSelectedRoom);

            if (curRoom == null)
            {
                return;// Room was removed and chat stayed open
            }

            string formattedMessage;

            if (_curSelectedRoom == "SERVER")
            {
                // Used for debugging purposes for manually formatted messages
                formattedMessage = ChatBox.Text;
            }
            else if (curRoom.PrivateRoom())
            {
                // Direct message
                formattedMessage = HelperMethods.FormatMessage(Headers.PrivMsg, curRoom.RoomName(), ChatBox.Text);
            }
            else
            {
                // General room message
                formattedMessage = HelperMethods.FormatMessage(Headers.RoomMsg, curRoom.RoomName(), ChatBox.Text);
            }

            Globals.Client.MessageClient(formattedMessage); // Send the message
            ChatBox.Clear();                                // Clear the chat box since the message has been sent
        }
Beispiel #10
0
 /// <summary>
 /// Allows the other pages to return to this menu screen.
 /// </summary>
 public void GoBack()
 {
     TextBoxChat.Clear();
     ChatBox.Clear();
     Content = content;
 }
Beispiel #11
0
        public MainPage()
        {
            InitializeComponent();

            close = new Method(Close);

            Closing                  += OnClosing; //Делегат для отлова закрытия окна
            isMicOn                   = true;
            isHeadPhonesOn            = true;
            isVideoOn                 = false;
            _flag                     = false;
            lobbyCount                = 0;
            chatCount                 = 0;
            lobbyButtonsMargin        = 10;
            chatTextblockMargin       = 5;
            voiceChatTextBlock.Text   = "Голосовой чат подключен";
            videoTextBlock.Text       = "Видео отключено";
            videoTextBlock.Foreground = Brushes.DarkGray;
            //hellob
            function                  = null;
            isAddVetexOn              = false;
            isRemoveVertexOn          = false;
            isFreeModeOn              = false;
            ispaint                   = false;
            paintsize                 = 20;
            FreeModeCanvas.Visibility = Visibility.Hidden;

            Camera3.Visibility = Visibility.Hidden;

            conferenssionString.Text = "Конференция № ...";
            if (GuestInfo.Name == "test")
            {
                nameString.Text     = UserInfo.Name;
                userRoleString.Text = "Пользователь";
            }
            else
            {
                nameString.Text     = GuestInfo.Name;
                userRoleString.Text = "Гость";
            }
            nameString.Text                  = UserInfo.Name;
            userRoleString.Text              = "Пользователь";
            ControlCanvas.Visibility         = Visibility.Hidden;
            infoTextBlock.Visibility         = Visibility.Visible;
            leaveButton.Visibility           = Visibility.Hidden;
            CancelLobbyButton.Visibility     = Visibility.Hidden;
            ConferensionIDTextBox.Visibility = Visibility.Hidden;
            ConnectToLobbyButton.Visibility  = Visibility.Hidden;
            chatGrid.Visibility              = Visibility.Hidden;
            Chromium.settings.CefCommandLineArgs.Add("enable-media-stream", "1");
            Cef.Initialize(Chromium.settings);
            leaveButton.Click += (s, ea) =>
            {
                LobbyLeave_ClickAsync(s, ea);
                ChatBox.Clear();
                chatTextBox.Clear();
                foreach (UIElement temp in VideoChatCanvas.Children)
                {
                    try
                    {
                        ((ChromiumWebBrowser)temp).Dispose();
                    }
                    catch { }
                }
                VideoChatCanvas.Children.Clear();
            };
            RefreshRooms();
        }