public Main() { InitializeComponent(); if (!File.Exists(NameXml)) { NameXml = null; Game = new Mines(0); } else { Game = new Mines(0, NameXml); } gph = panel1.CreateGraphics(); appLog.Write("[START]"); UpdateForm(); }
private void новичокToolStripMenuItem_Click(object sender, EventArgs e) { новичокToolStripMenuItem.Checked = true; профессионалToolStripMenuItem.Checked = false; экспертToolStripMenuItem.Checked = false; if (NameXml == null) { Game = new Mines(0); } else { Game = new Mines(0, NameXml); } gph.Clear(Color.White); timer.Stop(); UpdateForm(); }
private void изменитьToolStripMenuItem_Click(object sender, EventArgs e) { try { if (openFileDialog1.ShowDialog() == DialogResult.OK) { Valid = true; XmlReaderSettings gameSettings = new XmlReaderSettings(); gameSettings.Schemas.Add(null, "table.xsd"); gameSettings.ValidationType = ValidationType.Schema; gameSettings.ValidationEventHandler += new ValidationEventHandler(gameSettingsValidationEventHandler); XmlReader games = XmlReader.Create(openFileDialog1.FileName, gameSettings); while (games.Read()) { } if (!Valid) { NameXml = null; Game = new Mines(0); gph.Clear(Color.White); timer.Stop(); throw new Exception(); } else { NameXml = openFileDialog1.FileName; Game = new Mines(0, NameXml); gph.Clear(Color.White); timer.Stop(); } } } catch (Exception ex) { MessageBox.Show("Выбран неверный файл"); appLog.Write(ex.Message); } finally { UpdateForm(); } }
private void новаяИграToolStripMenuItem_Click(object sender, EventArgs e) { if (NameXml != null) { if (новичокToolStripMenuItem.Checked) { Game = new Mines(0, NameXml); } else if (профессионалToolStripMenuItem.Checked) { Game = new Mines(2, NameXml); } else if (экспертToolStripMenuItem.Checked) { Game = new Mines(1, NameXml); } } else { if (новичокToolStripMenuItem.Checked) { Game = new Mines(0); } else if (профессионалToolStripMenuItem.Checked) { Game = new Mines(2); } else if (экспертToolStripMenuItem.Checked) { Game = new Mines(1); } } gph.Clear(Color.White); ShowField(gph); UpdateForm(); }