コード例 #1
0
 private void btndone_Click(object sender, EventArgs e)
 {
     if (txtvillagename.TextLength != 0)
     {
         INationFactory factory = (INationFactory)cboxnation.SelectedItem;
         INation        nation  = factory.GetNation();
         villagewindow.village         = new Village(nation, txtvillagename.Text);
         villagewindow.lblnation.Text  = nation.GetNationName();
         villagewindow.lblvillage.Text = txtvillagename.Text;
         villagewindow.village.initiate(villagewindow.g, villagewindow.p);
         this.Dispose();
     }
 }
コード例 #2
0
 private void btnopen_Click(object sender, EventArgs e)
 {
     if (txtvillagepath.Text != "")
     {
         INationFactory factory    = (INationFactory)cboxnation.SelectedItem;
         INation        nation     = factory.GetNation();
         var            dataString = System.IO.File.ReadAllText(txtvillagepath.Text);
         var            settings   = new JsonSerializerSettings()
         {
             TypeNameHandling = TypeNameHandling.All
         };
         IState state = JsonConvert.DeserializeObject <IState>(dataString, settings);
         villagewindow.village         = new Village(nation, "");
         villagewindow.lblnation.Text  = nation.GetNationName();
         villagewindow.lblvillage.Text = state.GetVillageName();
         villagewindow.village.SetState(state);
         villagewindow.village.initiate(villagewindow.g, villagewindow.p);
         this.Dispose();
     }
 }