Example #1
0
 public override void Update()
 {
     this.TypeButton.IsEnabled = false;
     if (this.OKButton.IsClicked)
     {
         DialogsManager.HideDialog(this);
     }
     if (this.ImportButton.IsClicked)
     {
         if (!Directory.Exists(CreatorMain.CacheDirectory))
         {
             Directory.CreateDirectory(CreatorMain.CacheDirectory);
         }
         string sdFile  = CreatorMain.OneKeyFile;
         string _sdFile = CreatorMain.Export_OnekeyFile_Directory + "/" + (string)this.ListView.SelectedItem;
         if (!FileOperation.IsFileInUse(_sdFile) && (!File.Exists(sdFile) || !FileOperation.IsFileInUse(sdFile)))
         {
             FileStream fileStream = new FileStream(_sdFile, FileMode.Open);
             FileStream file       = new FileStream(sdFile, FileMode.Create);
             fileStream.CopyTo(file);
             file.Dispose();
             fileStream.Dispose();
             player.ComponentGui.DisplaySmallMessage("导入成功!", true, false);
         }
         else
         {
             player.ComponentGui.DisplaySmallMessage("操作失败!", true, false);
         }
         DialogsManager.HideDialog(this);
     }
     if (DeleteButton.IsClicked)
     {
         string sdFile = CreatorMain.Export_OnekeyFile_Directory + "/" + (string)this.ListView.SelectedItem;
         if (FileOperation.Delete(sdFile))
         {
             player.ComponentGui.DisplaySmallMessage("删除成功!", true, false);
             UpList();
         }
         else
         {
             player.ComponentGui.DisplaySmallMessage("操作失败!", true, false);
         }
     }
     this.DerivedButton.IsEnabled = File.Exists(CreatorMain.OneKeyFile);
     if (this.DerivedButton.IsClicked)
     {
         DialogsManager.ShowDialog(player.View.GameWidget, new DerivedDialog(player, this, this.ListView));
     }
     if (this.CreateButton.IsClicked)
     {
         if (creatorAPI.Position[2] == new Point3(0, -1, 0))
         {
             player.ComponentGui.DisplaySmallMessage("请设置点3!", true, false);
         }
         else
         {
             Task.Run(() =>
             {
                 try
                 {
                     if (!Directory.Exists(CreatorMain.CacheDirectory))
                     {
                         Directory.CreateDirectory(CreatorMain.CacheDirectory);
                     }
                     OnekeyGeneration.CreateOnekey(creatorAPI, CreatorMain.CacheDirectory + "/", "CacheFile.od", creatorAPI.Position[0], creatorAPI.Position[1], creatorAPI.Position[2]);
                 }
                 catch (Exception e)
                 {
                     player.ComponentGui.DisplaySmallMessage(e.Message, true, false);
                 }
             });
         }
         DialogsManager.HideDialog(this);
     }
     if (ListView.SelectedIndex == null)
     {
         this.ImportButton.IsEnabled = false;
         this.DeleteButton.IsEnabled = false;
     }
     else
     {
         this.ImportButton.IsEnabled = true;
         this.DeleteButton.IsEnabled = true;
     }
     if (creatorAPI.oneKeyGeneration)
     {
         OnAndOffButton.Color = Color.Yellow;
     }
     else
     {
         OnAndOffButton.Color = Color.Red;
     }
     if (OnAndOffButton.IsClicked)
     {
         if (creatorAPI.oneKeyGeneration)
         {
             creatorAPI.oneKeyGeneration = false;
         }
         else
         {
             creatorAPI.oneKeyGeneration = true;
         }
     }
 }