private void AutoActivityItemsCodeChange(object sender, RoutedEventArgs e)
        {
            Button obj = (Button)sender;

            if (FarmInfoRootData.Sons.Count() > 0)
            {
                ActivityItemsCodeChange(null, null);
            }
            else if (AutoSearch())
            {
                SData.TotalLoadFromUserData(gameinfopath + "\\farms.data", FarmInfoRootData);
                string itemcodes = TxtItemCodes.Text;
                string legalcode = itemcodes.Replace("\"Rewards\":", "").TrimEnd(',');
                Console.WriteLine(legalcode);

                SData dt = FarmInfoRootData.TurnTo("\"Rewards\"");
                dt.sonKind = 0;
                dt.Value   = legalcode;

                if (SData.TotalSaveUserData())
                {
                    MessageBox.Show("修改成功!");
                }
            }
            else
            {
                obj.Content = "自动搜索失败,请使用下面的按钮手动选择存档";
            }
        }
        private void ActivityItemsCodeChange(object sender, RoutedEventArgs e)
        {
            if (FarmInfoRootData.Sons.Count() <= 0)
            {
                Microsoft.Win32.OpenFileDialog op = new Microsoft.Win32.OpenFileDialog();
                op.Title  = "请选择farms.data文件,这通常在remote文件夹中";
                op.Filter = "farms.data文件|farms.data";
                op.ShowDialog();
                string addr = op.FileName;
                if (addr == "" || addr == null)
                {
                    return;
                }
                SData.TotalLoadFromUserData(addr, FarmInfoRootData);
            }

            //下面是修改过程
            string itemcodes = TxtItemCodes.Text;
            string legalcode = itemcodes.Replace("\"Rewards\":", "").TrimEnd(',');

            if (legalcode[0] != '[' || legalcode[legalcode.Length - 1] != ']')
            {
                MessageBox.Show("代码格式错误。请检查输入的代码。");
                return;
            }
            SData dt = FarmInfoRootData.TurnTo("\"Rewards\"");

            dt.sonKind = 0;
            dt.Value   = legalcode;

            if (SData.TotalSaveUserData())
            {
                MessageBox.Show("修改成功!");
            }
        }
        }//自动搜寻存档位置并返回成功或失败的bool

        private bool InitComboBox()//按照选好的或者搜到的位置配置下拉列表供选择
        {
            //下面是选择存档号
            Cb_FileNum.Items.Clear();
            SData.TotalLoadFromUserData(gameinfopath + "\\farms.data", FarmInfoRootData);
            farmnames = new List <string>();
            farmnums  = new List <string>();
            int count = 0;//有效存档个数

            foreach (var farm in FarmInfoRootData.TurnTo("\"Farms\"").Sons)
            {
                string thenum = farm.TurnTo("\"slot\"").Value;
                if (File.Exists(gamesavepathNoName + "\\farm_" + thenum + ".data"))
                {
                    string thename = farm.TurnTo("\"name\"").Value;
                    if (farmnames.Contains(thename))
                    {
                        thename += "_" + thenum;
                    }
                    farmnames.Add(thename);
                    Cb_FileNum.Items.Add(thename);
                    farmnums.Add(thenum);

                    if (count == 0)
                    {
                        Cb_FileNum.SelectedItem = thename;
                        Console.WriteLine("usecount=0 at count" + count.ToString());
                    }
                    if (thenum == TheSaveNumber)
                    {
                        CbIsLoading             = false;
                        Cb_FileNum.SelectedItem = thename;
                        Console.WriteLine("use num " + TheSaveNumber + " at count" + count.ToString());
                    }
                    count++;
                }
            }
            if (count > 0)
            {
                CbIsLoading          = false;
                Cb_FileNum.IsEnabled = true;
                return(true);
            }
            else
            {
                CbIsLoading = false;
                return(false);
            }
        }