Example #1
0
        private void btnCreateGame_Click(object sender, EventArgs e)
        {
            string gameName = tbxGameName.Text;
            string password = tbxGamePassword.Text;

            if (String.IsNullOrEmpty(gameName))
            {
                FormMessage fm = new FormMessage("Game name must be specified!");
                fm.Opacity = 0;
                fm.ShowDialog();
                tbxGameName.Focus();
                return;
            }

            if (_selectedIndex >= 0)
            {
                _names.Remove(_names[_selectedIndex]);
            }

            FormGame f = new FormGame(this);

            f.Opacity = 0;
            IModel      m = new ModelGame(gameName, password);
            IController c = new ControllerInternet(m, (IView)f);

            f.GameController = c;
            c.CreateGame();
            f.Show();
        }
Example #2
0
        private void LoadServerIP()
        {
            if (!File.Exists("./server.txt"))
            {
                FormMessage fm = new FormMessage("Missing file: server.txt");
                fm.ShowDialog();
                return;
            }

            StreamReader sr = new StreamReader("./server.txt");
            string       ip = sr.ReadLine();

            ConfigurationManager.AppSettings["ServerIPAddress"] = ip;
        }
Example #3
0
        private void btnDefault_Click(object sender, EventArgs e)
        {
            ResourceCollection.SetDefaultCollection();
            StreamWriter sw = new StreamWriter("./config.txt");

            sw.WriteLine("Default");
            sw.Close();

            FormMessage fm = new FormMessage("Default theme loaded! Resterting game!");

            fm.Opacity = 0;
            if (DialogResult.OK == fm.ShowDialog())
            {
                Application.Restart();
            }
        }
Example #4
0
        private void btnJoinGame_Click(object sender, EventArgs e)
        {
            if (dgvGames.RowCount == 1)
            {
                return;
            }

            string gameName = dgvGames.SelectedRows[0].Cells[0].Value as string;
            string ip       = dgvGames.SelectedRows[0].Cells[1].Value as string;
            string pass     = dgvGames.SelectedRows[0].Cells[2].Value as string;

            var    item = new GameItem(gameName, ip, pass);
            string pwd  = tbxPasswordGame.Text;

            if (item.PasswordProtected == "False")
            {
                pwd = "";
            }

            bool joined = ctrl.JoinGame(item, pwd);

            if (joined)
            {
                fg.Opacity = 0;
                fg.EnableTimer(true);
                fg.Show();
                fg.DisplayMessage("You connected!");
            }
            else
            {
                FormMessage fm = new FormMessage("Can't connect!");
                fm.Opacity = 0;
                fm.ShowDialog();
                btnRefresh.PerformClick();
            }
        }