private void btnLoadGamestate_Click(object sender, EventArgs e) { var FD = new System.Windows.Forms.OpenFileDialog(); if (FD.ShowDialog() == System.Windows.Forms.DialogResult.OK) { string fileToOpen = FD.FileName; GameState gameState = new GameState(); XmlSerializer deserializer = new XmlSerializer(typeof(GameState)); TextReader reader = new StreamReader(fileToOpen); gameState = (GameState)deserializer.Deserialize(reader); gameState.DieSet.Dice.RemoveRange(0, 5); reader.Close(); //Console.WriteLine(playerList.Count); MainForm gameForm = new MainForm(); gameForm.ProcessGameState(gameState); gameForm.UpdateActivePlayer(); gameForm.Show(); Close(); } }
//对登陆进行判断,如果用户和密码正确,进入主界面,若其中一个错误,则弹出相应错误提示 private void button1_Click(object sender, EventArgs e) { Accessor accessor = Accessor.Instance; //在数据库中查询输入用户名 IList<Users> s = accessor.GetUsersByFirstname(textBox1.Text); //判断数据库中用户名是否存在 if (s.Count != 0) //如果用户名存在,则判断密码是否正确 if (s[0].password.ToString() == textBox2.Text) { //密码正确,将原窗口隐藏,显示新的窗口 MainForm Reg = new MainForm(this.textBox1.Text); this.Hide(); Reg.Owner = this; //让新建的窗口不在任务栏显示并显示新窗口 Reg.ShowDialog(); //新建的窗口关闭后,再使原窗口可见 this.Show(); } else { this.errorProvider1.SetError(textBox2, "输入密码错误"); } else { this.errorProvider1.SetError(textBox1, "输入用户名不存在"); } }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); var mainform = new MainForm(); var mainPresenter = new MainPresenter(mainform); Application.Run(mainform); }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); mCore.Init(EventHandler); test = new MainForm(); Application.Run(test); Application.ApplicationExit += new EventHandler(Application_ApplicationExit); }
static unsafe void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); _hookID = KeyboardHook.SetHook(proc); frm = new MainForm(); Application.Run(frm); KeyboardHook.UnhookWindowsHookEx(_hookID); }
private void startGame(GameState game) { PlayerList myPlayerList = new PlayerList(); foreach (Player player in game.Players.Players) { if (myLocalPlayers.Contains(player.Name)) { myPlayerList.Players.Add(new HumanPlayer(player.Name)); } else if (myAIPlayers.Contains(player.Name)) { //myPlayerList.Players.Add(new ComputerPlayer(player.Name)); // NEED TO GET AI TYPE } else { myPlayerList.Players.Add(new NetworkPlayer(player.Name)); } } foreach (Player player in myPlayerList.Players) { player.ScoreSheet.setupGame("Yahtzee"); } MainForm gameForm = new MainForm(); gameForm.PlayerList.Players = myPlayerList.Players; gameForm.PlayerList.makeNamesUnique(); gameForm.createScoreSheet(); gameForm.isNetworkGame = true; gameForm.Show(); Close(); }
private void startGameBtn_Click(object sender, EventArgs e) { if (playerList.Count == 0) { MessageBox.Show("Please Add At Least One Player"); return; } if (cmbGameType.SelectedItem.ToString() != "Yahtzee") { foreach (Player player in playerList) { if (player.PlayerType == "Computer") { MessageBox.Show("Sorry, the AI players refuse to play any game type but Yahtzee. Please either change the game type to Yahtzee or remove the computer players."); return; } } } foreach (Player player in playerList) { player.ScoreSheet.setupGame(cmbGameType.SelectedItem.ToString()); } Console.WriteLine(playerList.Count); MainForm gameForm = new MainForm(); gameForm.PlayerList.Players = playerList; gameForm.PlayerList.makeNamesUnique(); gameForm.createScoreSheet(); gameForm.isNetworkGame = false; gameForm.Show(); Close(); }
private void loginBtn_Click(object sender, EventArgs e) { var mainForm = new MainForm(); mainForm.Show(); }
// CONNECT ============================================================ private void btnConnect_Click(object sender, EventArgs e) { MainForm MainForm = new MainForm(); MainForm.Show(); }