예제 #1
0
        private void Formsetup_Load(object sender, EventArgs e)
        {
            runParh  = Directory.GetCurrentDirectory();
            savedata = MainForm.savedata;
            String saveSay = savedata.Read("SaveSay", "key", "0");

            if (saveSay == "0")
            {
                RadioBtn1.Select();
                PathText.Text      = runParh;
                Selectpath.Enabled = false;
            }
            else if (saveSay == "1")
            {
                RadioBtn2.Select();
                PathText.Text      = savedata.Read("SavePath", "key", runParh);
                Selectpath.Enabled = true;
            }
        }
예제 #2
0
        //检测配置配置文件
        public static void CheckDeploy()
        {
            if (Directory.Exists(BakcupPath) || check_old_config())
            {
                if (File.Exists(BakcupPath + @"\BackupMap.ini") || check_old_config())
                {
                    // TODO 读取配置文件并载入
                    // TODO 循环备份的时间 ms  小于一分钟就抛出异常
                    ini = new InIFile(BakcupPath + @"\BackupMap.ini");
                    try
                    {
                        Profile.TickTime = Int32.Parse(ini.Read("Tick", "TickTime", "0"));
                        if (Profile.TickTime < 1000 * 60)
                        {
                            Console.WriteLine("[" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " Error]Tick时间必须大于一分钟");
                            return;
                        }
                        TimerTick.Interval = Profile.TickTime;
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("[" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " Error]配置文件中Tick循环时间项出错:" + e.ToString());
                    }

                    // TODO 保存的总文件夹
                    Profile.HomeDire = ini.Read("SaveMap", "SavePath", MapPath);

                    // TODO 阙值
                    Profile.EnabledThreshold = ini.Read("Threshold", "Enabled", "0") != "0";
                    if (Profile.EnabledThreshold)
                    {
                        Profile.Threshold = int.Parse(ini.Read("Threshold", "Threshold", "0"));
                    }

                    // TODO 备份的相同文件夹名称的存档是否覆盖或跳过
                    Profile.Isleapfrog = ini.Read("SaveMap", "Leapfrog", "0") != "0";

                    // TODO 是否只在有玩家玩过服务器的情况下备份存档
                    Profile.NeedPlayerBakcup = ini.Read("SaveMap", "NeedPlayer", "0") != "0";

                    //备份时是否压缩存档到ZIP文件
                    Profile.Zip = ini.Read("SaveMap", "Zip", "0") != "0";

                    //备份完成之后要打开的文件或脚本或程序(附带参数)
                    Profile.run = ini.Read("Cmd", "Run", "0");

                    TimerTick.Enabled = true;
                    TimerTick.Start();

                    return;
                }
            }
            else
            {
                Directory.CreateDirectory(BakcupPath);
            }

            //显示窗口
            new Thread(() => {
                System.Windows.Forms.Application.Run(new Form1());
            }).Start();
        }