private void menuSaveScenario_Click(object sender, EventArgs e)
 {
     if (this.CanSave)
     {
         HintForm form = new HintForm();
         try
         {
             form.SetHint("正在保存剧本文件……");
             form.Show();
             Application.DoEvents();
             File.Copy(this.OpenedFileName, this.OpenedFileName + ".bak", true);
             File.Delete(this.OpenedFileName);
             File.Copy(Application.StartupPath + "/GameData/Common/SaveTemplate.mdb", this.OpenedFileName);
             this.pnlMap.SaveMapData();
             this.connectionStringBuilder.DataSource = this.OpenedFileName;
             this.Scenario.SaveGameScenarioToDatabase(this.connectionStringBuilder.ConnectionString, true, this.Scenario.UsingOwnCommonData);
             form.Close();
             File.Delete(this.OpenedFileName + ".bak");
         }
         catch
         {
             form.Close();
             File.Copy(this.OpenedFileName + ".bak", this.OpenedFileName, true);
             File.Delete(this.OpenedFileName + ".bak");
             MessageBox.Show(this.OpenedFileName + "保存时产生错误,已恢复到修改前的状态。");
         }
         try
         {
             form = new HintForm();
             form.SetHint("正在保存一般数据……");
             form.Show();
             Application.DoEvents();
             File.Copy(this.CommonDataFileName, this.CommonDataFileName + ".bak", true);
             this.connectionStringBuilder.DataSource = this.CommonDataFileName;
             this.Scenario.GameCommonData.SaveToDatabase(this.connectionStringBuilder.ConnectionString);
             form.Close();
             File.Delete(this.CommonDataFileName + ".bak");
         }
         catch
         {
             form.Close();
             File.Copy(this.CommonDataFileName + ".bak", this.CommonDataFileName, true);
             File.Delete(this.CommonDataFileName + ".bak");
             MessageBox.Show(this.CommonDataFileName + "保存时产生错误,已恢复到修改前的状态。");
         }
     }
 }
 private void menuOpenScenario_Click(object sender, EventArgs e)
 {
     this.openScenario.InitialDirectory = ".";
     if (this.openScenario.ShowDialog() == System.Windows.Forms.DialogResult.OK)
     {
         this.connectionStringBuilder.DataSource = this.openScenario.FileName;
         this.OpenedFileName = this.openScenario.FileName;
         HintForm form = new HintForm();
         form.SetHint("正在读取……");
         form.Show();
         Application.DoEvents();
         this.Scenario.LoadGameScenarioFromDatabase(this.connectionStringBuilder.ConnectionString);
         this.pnlMap.LoadMapData();
         this.pnlMap.TileWidth = this.pnlMap.Scenario.ScenarioMap.TileWidth;
         this.mtbTileWidth.Text = this.pnlMap.TileWidth.ToString();
         this.mtbWidth.Text = this.Scenario.ScenarioMap.MapDimensions.X.ToString();
         this.mtbHeight.Text = this.Scenario.ScenarioMap.MapDimensions.Y.ToString();
         this.pnlMap.ResetMapPanelSize(1);
         this.pnlMap.StartPaintingMap = true;
         this.pnlMap.SetShowRegion(0, 0, this.pnlBase.Width, this.pnlBase.Height);
         this.pnlMap.Invalidate();
         this.CanSave = true;
         this.menuSaveScenario.Enabled = true;
         this.menuShowErrors.Enabled = true;
         this.menuEdit.Enabled = true;
         form.Close();
     }
 }