private void Table_FormClosing(object sender, FormClosingEventArgs e) { e.Cancel = !canClose; if (!canClose && !shutdown) { SaveForm gj = new SaveForm(); gj.ShowDialog(); switch (gj.DialogResult) { case DialogResult.Cancel: gj.Close(); break; case DialogResult.Yes: GameController.timer.Stop(); if (picJogada0.Image == null && picJogada1.Image == null && picJogada2.Image == null && picJogada3.Image == null) { SaveFileDialog sfd = new SaveFileDialog(); sfd.Filter = "xml files (*.xml)|*.xml"; if (sfd.ShowDialog() != DialogResult.OK) return; if (SaveGame != null) { SaveGame(sfd.FileName); } MessageBox.Show("Saved Successfully"); canClose = true; this.Close(); Application.Restart(); } else { MessageBox.Show("Cannot save while playing"); GameController.timer.Start(); } break; case DialogResult.No: // fechar canClose = true; // mostrar janela principal this.Close(); Application.Restart(); break; default: break; } } else if (shutdown) { canClose = true; shutdown = false; this.Close(); Application.Restart(); } }
private void Table_FormClosing(object sender, FormClosingEventArgs e) { e.Cancel = !canClose; if (!canClose && !shutdown) { SaveForm gj = new SaveForm(); gj.ShowDialog(); switch (gj.DialogResult) { case DialogResult.Cancel: gj.Close(); break; case DialogResult.Yes: // gravar jogo utilizando serializaĆ§Ć£o XML case DialogResult.No: // fechar canClose = true; // mostrar janela principal this.Close(); Application.Restart(); break; default: break; } } else if (shutdown) { canClose = true; shutdown = false; this.Close(); Application.Restart(); } }