Exemple #1
0
        private void ExportConfigBtn_Click(object sender, EventArgs e)
        {
            YML yml = new YML();                                                               //添加配置文件

            yml.AddValue("Width", this.Width.ToString());                                      //窗口宽度
            yml.AddValue("Height", this.Height.ToString());                                    //窗口高度
            yml.AddValue("LocationX", this.Location.X.ToString());                             //窗口所在位置(X)
            yml.AddValue("LocationY", this.Location.Y.ToString());                             //窗口所在位置(Y)
            yml.AddValue("NumFrom", this.NumFrom.Text);                                        //抽取号码范围从
            yml.AddValue("NumTo", this.NumTo.Text);                                            //抽取号码范围到
            yml.AddValue("Continuous", this.ContinuousBox.Checked.ToString());                 //是否连续抽取
            yml.AddValue("ContinuousNumBox", this.ContinuousNumBox.Text);                      //连续抽取个数
            yml.AddValue("ContinuousInterval", this.ContinuousIntervalBox.Checked.ToString()); //连续抽取间隔时间开关
            yml.AddValue("IntervalTime", this.IntervalTime.Text);                              //连续抽取间隔时间
            yml.AddValue("NoRep", this.NoRep.Checked.ToString());                              //抽取不重复开关
            string         configuration = yml.ToString();                                     //导出配置
            SaveFileDialog O             = new SaveFileDialog                                  //打开保存文件对话框
            {
                Filter = "|*.yml"                                                              //文件后缀为.yml
            };

            if (O.ShowDialog() == DialogResult.OK)
            {
                File.WriteAllText(O.FileName, configuration);//写配置文件
                MessageBox.Show("导出配置文件完成");
            }
        }
Exemple #2
0
        private void Form_Load(object sender, EventArgs e)
        {
            CheckForIllegalCrossThreadCalls = false;//防卡死
            YML yml = new YML();

            yml.Load(File.ReadAllText("config.yml"));                                                                                                                                       //读配置文件
            MoveWindow(this.Handle, int.Parse(yml.GetValue("LocationX")), int.Parse(yml.GetValue("LocationY")), int.Parse(yml.GetValue("Width")), int.Parse(yml.GetValue("Height")), true); //窗口位置和大小
            this.NumFrom.Text                  = yml.GetValue("NumFrom");                                                                                                                   //抽取号码范围从
            this.NumTo.Text                    = yml.GetValue("NumTo");                                                                                                                     //抽取号码范围到
            this.ContinuousBox.Checked         = Convert.ToBoolean(yml.GetValue("Continuous"));                                                                                             //是否连续抽取
            this.ContinuousNumBox.Text         = yml.GetValue("ContinuousNumBox");                                                                                                          //连续抽取个数
            this.ContinuousIntervalBox.Checked = Convert.ToBoolean(yml.GetValue("ContinuousInterval"));                                                                                     //连续抽取间隔时间开关
            this.IntervalTime.Text             = yml.GetValue("IntervalTime");                                                                                                              //连续抽取间隔时间
            this.NoRep.Checked                 = Convert.ToBoolean(yml.GetValue("NoRep"));                                                                                                  //抽取不重复开关
        }
Exemple #3
0
 private void Form_FormClosing(object sender, FormClosingEventArgs e)//关闭程序时保存配置文件
 {
     if (NoSaveConfig.Checked == false)
     {
         YML yml = new YML();                                                               //添加配置文件
         yml.AddValue("Width", this.Width.ToString());                                      //窗口宽度
         yml.AddValue("Height", this.Height.ToString());                                    //窗口高度
         yml.AddValue("LocationX", this.Location.X.ToString());                             //窗口所在位置(X)
         yml.AddValue("LocationY", this.Location.Y.ToString());                             //窗口所在位置(Y)
         yml.AddValue("NumFrom", this.NumFrom.Text);                                        //抽取号码范围从
         yml.AddValue("NumTo", this.NumTo.Text);                                            //抽取号码范围到
         yml.AddValue("Continuous", this.ContinuousBox.Checked.ToString());                 //是否连续抽取
         yml.AddValue("ContinuousNumBox", this.ContinuousNumBox.Text);                      //连续抽取个数
         yml.AddValue("ContinuousInterval", this.ContinuousIntervalBox.Checked.ToString()); //连续抽取间隔时间开关
         yml.AddValue("IntervalTime", this.IntervalTime.Text);                              //连续抽取间隔时间
         yml.AddValue("NoRep", this.NoRep.Checked.ToString());                              //抽取不重复开关
         string configuration = yml.ToString();                                             //导出配置
         File.WriteAllText("config.yml", configuration);                                    //写配置文件
     }
 }
Exemple #4
0
        private void ImportConfig_Click(object sender, EventArgs e)
        {
            YML            yml = new YML();         //添加配置文件
            OpenFileDialog O   = new OpenFileDialog //打开打开文件对话框
            {
                Filter = "|*.yml"                   //文件后缀为.yml
            };

            if (O.ShowDialog() == DialogResult.OK)
            {
                yml.Load(File.ReadAllText(O.FileName));                                                                                                                                         //读配置文件
                MoveWindow(this.Handle, int.Parse(yml.GetValue("LocationX")), int.Parse(yml.GetValue("LocationY")), int.Parse(yml.GetValue("Width")), int.Parse(yml.GetValue("Height")), true); //窗口位置和大小
                this.NumFrom.Text                  = yml.GetValue("NumFrom");                                                                                                                   //抽取号码范围从
                this.NumTo.Text                    = yml.GetValue("NumTo");                                                                                                                     //抽取号码范围到
                this.ContinuousBox.Checked         = Convert.ToBoolean(yml.GetValue("Continuous"));                                                                                             //是否连续抽取
                this.ContinuousNumBox.Text         = yml.GetValue("ContinuousNumBox");                                                                                                          //连续抽取个数
                this.ContinuousIntervalBox.Checked = Convert.ToBoolean(yml.GetValue("ContinuousInterval"));                                                                                     //连续抽取间隔时间开关
                this.IntervalTime.Text             = yml.GetValue("IntervalTime");                                                                                                              //连续抽取间隔时间
                this.NoRep.Checked                 = Convert.ToBoolean(yml.GetValue("NoRep"));                                                                                                  //抽取不重复开关
                MessageBox.Show("读取配置文件完成");
            }
        }