public static bool MainWindowSetFlat()//从主窗口过来的一键设置平原
        {
            Microsoft.Win32.OpenFileDialog op = new Microsoft.Win32.OpenFileDialog();
            op.Filter = "游戏存档文件(farm_*.data)|farm_*.data";
            op.ShowDialog();
            if (op.FileName == "" || op.FileName == null)
            {
                return(false);
            }
            SaveAddress = op.FileName;
            SData.LoadFromSave(SaveAddress, RootData);

            SData chunks = RootData.TurnTo("Chunks");

            foreach (var chunk in chunks.Sons)
            {
                Console.WriteLine(chunk.TurnTo("ChunkPosition").Value);
                chunk.TurnTo("ChunkId").Value = "\"Flat_Chunk\"";
            }
            if (!Directory.Exists(Directory.GetCurrentDirectory() + "\\DataGenerated"))
            {
                Directory.CreateDirectory(Directory.GetCurrentDirectory() + "\\DataGenerated");
            }
            StreamWriter SW0 = new StreamWriter("DataGenerated\\farm_" + TheSaveNumber);

            SData.SaveFromSData(RootData, SW0);
            SW0.Close();
            return(SData.GzipPack());
        }
 private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (Cb_FileNum.Items.Count <= 0)
     {
         return;
     }
     if (CbIsLoading)
     {
         return;
     }
     TheSaveNumber = farmnums[farmnames.IndexOf(Cb_FileNum.SelectedItem.ToString())];
     SaveAddress   = gamesavepathNoName + "\\farm_" + TheSaveNumber + ".data";
     SData.LoadFromSave(SaveAddress, RootData);
     RefreshChunks();
 }
        private void OpenFileAndLoad(object sender, RoutedEventArgs e)//打开存档文件并将其同目录下的所有文档添加到备选下拉菜单,同时加载选择的存档到内存中
        {
            CbIsLoading = true;
            Microsoft.Win32.OpenFileDialog op = new Microsoft.Win32.OpenFileDialog();
            op.Filter = "游戏存档文件(farm_*.data)|farm_*.data";
            op.ShowDialog();
            if (op.FileName == "" || op.FileName == null)
            {
                return;
            }
            SaveAddress = op.FileName;
            string[] splt    = SaveAddress.Split('_');
            string   savenum = splt[splt.Length - 1];

            savenum       = savenum.Split('.')[0];
            TheSaveNumber = savenum;//剥离出存档编码并存储
            try
            {
                string savedir = System.IO.Path.GetDirectoryName(SaveAddress);
                gamesavepathNoName = savedir;
                DirectoryInfo savedirInfo = new DirectoryInfo(savedir);
                string        farminfodir = savedirInfo.Parent.FullName;
                if (File.Exists(farminfodir + "\\farms.data"))
                {
                    gameinfopath = farminfodir;
                    if (!InitComboBox())
                    {
                        SData.LoadFromSave(SaveAddress, RootData);
                    }
                    BtSaveTheChange.Background = new SolidColorBrush(Color.FromRgb(162, 243, 139));
                    BtAutoFlat.Background      = new SolidColorBrush(Color.FromRgb(162, 243, 139));
                }
                else
                {
                    Cb_FileNum.IsEnabled = false;
                    SData.LoadFromSave(SaveAddress, RootData);
                    BtSaveTheChange.Background = new SolidColorBrush(Color.FromRgb(162, 243, 139));
                    BtAutoFlat.Background      = new SolidColorBrush(Color.FromRgb(162, 243, 139));
                }
            }
            catch { }
        }