Example #1
0
        private async void refresh_button_Click(object sender, RoutedEventArgs e)
        {
            server = (server_list.SelectedItem as query_server.Server);
            int port_index = server.addr.IndexOf(':');

            port = server.addr.Remove(0, port_index + 1);
            server select_server = new server(ip, port);

            if (await select_server.connect_server())
            {
                game.Text                 = select_server.Game.TrimEnd('\0');
                name.Text                 = select_server.Name.TrimEnd('\0');
                map.Text                  = select_server.Map.TrimEnd('\0');
                players.Text              = select_server.Players_maxplayers.TrimEnd('\0');
                add_button.Visibility     = Visibility.Visible;
                refresh_button.Visibility = Visibility.Visible;
                await select_server.update_player_list();

                player_list.ItemsSource = select_server.Player_list.Select(x => x.TrimEnd('\0')).ToList <string>();
            }
            else
            {
                game.Text             = "连接失败";
                name.Text             = "";
                map.Text              = "";
                players.Text          = "";
                add_button.Visibility = Visibility.Collapsed;
            }
        }
        private async void detialsItem_Click(object sender, RoutedEventArgs e)
        {
            if (servers.SelectedItem != null)
            {
                ConnectedAnimation animation = null;
                _storedItem = servers.SelectedItem as server;
                await _storedItem.update_player_list();    //

                game_selected.Text    = _storedItem.Game.TrimEnd('\0');
                name_selected.Text    = _storedItem.Name.TrimEnd('\0');
                map_selected.Text     = _storedItem.Map.TrimEnd('\0');
                players_selected.Text = "Players:" + _storedItem.Players_maxplayers.TrimEnd('\0');
                List <string> Player_list = new List <string>();
                Player_list             = _storedItem.Player_list.Select(x => x.TrimEnd('\0')).ToList <string>();
                player_list.ItemsSource = _storedItem.Player_list;
                animation = servers.PrepareConnectedAnimation("forwardAnimation", _storedItem, "connectedElement");

                SmokeGrid.Visibility = Visibility.Visible;

                animation.TryStart(destinationElement);
            }
        }