private void btnResume_Click(object sender, EventArgs e) { if (tbUserName.Text == "") { MessageBox.Show("Please supply a user name"); return; } if (tbPassword.Text == "" && tbUserName.Text != "Admin") { MessageBox.Show("Please supply a password"); return; } XDocument xDoc = XDocument.Load(Player.SavePath); String password = Player.EncryptPassword(tbPassword.Text); String xPath = "Players/Player[Name= \"" + tbUserName.Text + "\" and Password = \"" + password + "\"]"; int cnt = xDoc.XPathSelectElements(xPath).Count(); if(tbUserName.Text == "Admin") { MainForm mf = new MainForm(); this.Hide(); mf.ShowDialog(); this.Dispose(); } else if (cnt == 0) { MessageBox.Show("User name or password incorrect"); } else { MainForm mf = new MainForm(tbUserName.Text); this.Hide(); mf.ShowDialog(); this.Dispose(); } }
private void btnStart_Click(object sender, EventArgs e) { if (turnDoc.XPathSelectElements("Turn").Nodes().Count() == 0) { var elem = playerDoc.XPathSelectElement("Players/Player[Position=1]"); players.Add(new Player(elem.Element("Name").Value, 1, elem.Element("Race").Value, elem.Element("Password").Value, false, int.Parse(elem.Element("Horizontal").Value), int.Parse(elem.Element("Vertical").Value))); Turn t = new Turn(players); } MainForm mf = new MainForm(); this.Hide(); mf.ShowDialog(); this.Dispose(); }