示例#1
0
        private void removeGame(String name)
        {
            String gname = GameList.removeGame(name);

            if (gname != "")
            {
                this.gameList.Items.Remove(gname);
            }
            else
            {
                MessageBox.Show("An error was found removing game with name \"" + gname + "\".");
            }
        }
示例#2
0
        void gameList_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            if (gameList.SelectedIndex == -1)
            {
                return;
            }
            String NAME = gameList.SelectedValue.ToString();
            String IP   = GameList.getGame(NAME).getIP();

            openGame(NAME, IP);

            //throw new NotImplementedException();
        }
示例#3
0
        public void decipherURL(String url)//, Window1 mT)
        {
            String data = url.Split('?')[1];

            String[] args = data.Split('&');
            String   type = "";
            String   aux1 = "";
            String   aux2 = "";
            String   aux3 = "";
            String   aux4 = "";

            foreach (String arg in args)
            {
                String[] line = arg.Split('=');
                if (line[0].Equals("type"))
                {
                    type = line[1];
                }
                else
                {
                    if (type == "chat")
                    {
                        if (line[0] == "username")
                        {
                            aux1 = line[1];
                        }
                        if (line[0] == "message")
                        {
                            aux2 = line[1];
                        }
                        if (line[0] == "personal")
                        {
                            aux3 = line[1];
                        }
                    }
                    if (type == "game")
                    {
                        if (line[0] == "subtype")
                        {
                            aux1 = line[1];
                        }
                        if (line[0] == "name")
                        {
                            aux2 = line[1];
                        }
                        if (line[0] == "players")
                        {
                            aux3 = line[1];
                        }
                        if (line[0] == "ipaddress")
                        {
                            aux4 = line[1];
                        }
                    }
                    if (type == "player")
                    {
                        if (line[0] == "subtype")
                        {
                            aux1 = line[1];
                        }
                        if (line[0] == "name")
                        {
                            aux2 = line[1];
                        }
                        if (line[0] == "ammount")
                        {
                            aux3 = line[1];
                        }
                    }
                }
            }
            if (type == "chat")
            {
                string username = aux1;
                string message  = aux2;
                message = message.Replace("_~~~_~_~~~_", " ");
                string personalFrom = aux3;
                if (personalFrom != "")
                {
                    message = "(personal):: " + message;
                }
                //send back to window thread
                chatList.Dispatcher.BeginInvoke(new Action(delegate()
                {
                    chatList.Items.Add(username + ": " + message);
                }));
            }
            if (type == "game")
            {
                string subtype          = aux1;
                string name             = aux2;
                string ammountOfPlayers = aux3;
                string ipaddress        = aux4;
                if (subtype == "add")
                {
                    if (GameList.getGame(name) != null)
                    {
                        GameList.addGame(new Game(name, ipaddress));
                    }
                    else
                    {
                        //remove from gamelist
                        //foreach(String s i
                        chatList.Dispatcher.BeginInvoke(new Action(delegate()
                        {
                            //chatList.Items.Add(username + ":" + personalFrom + message);
                        }));
                    }


                    gameList.Dispatcher.BeginInvoke(new Action(delegate()
                    {
                        gameList.Items.Add(name + "(" + ammountOfPlayers + ")");
                    }));
                }
            }
            if (type == "player")
            {
                string subtype = aux1;
                string name    = aux2;
                string ammount = aux3;
                playerList.Dispatcher.BeginInvoke(new Action(delegate()
                {
                    if (subtype == "add")
                    {
                        players_List.Add(name);
                        playerList.Items.Add(name);
                    }
                    else if (subtype == "all")
                    {
                        Console.WriteLine("onecheck");
                        string[] values = name.Split('-');
                        playerList.Items.Clear();
                        foreach (string s in values)
                        {
                            playerList.Items.Add(s);
                            players_List.Add(s);
                        }
                    }
                    else if (subtype == "remove")
                    {
                        playerList.Items.Remove(name);
                        players_List.Remove(name);
                    }
                }));
            }
        }
示例#4
0
 private void addGame(String name, String IP)
 {
     this.gameList.Items.Add(GameList.addGame(new Game(name, IP)));
 }