예제 #1
0
 //恢复默认设置
 private void btnDefault_Click(object sender, EventArgs e)
 {
     //询问是否恢复默认设置
      if (MessageBox.Show("恢复默认设置?当前未保存的设置将会丢失", "恢复默认设置", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.Cancel)
      {
     return;
      }
      //保存新设置
      AcDownSettings s = new AcDownSettings();
      Config.setting = s;
      Config.SaveSettings();
      //关闭窗体
      this.Close();
 }
예제 #2
0
        /// <summary>
        /// 读取设置
        /// </summary>
        /// <returns></returns>
        public static AcDownSettings LoadSettings()
        {
            try
            {
                AcDownSettings s;
                string         path = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
                path = Path.Combine(path, @"Kaedei\AcDown\config.xml");
                using (FileStream fs = new FileStream(path, FileMode.Open))
                {
                    XmlSerializer formatter = new XmlSerializer(typeof(AcDownSettings));
                    s = (AcDownSettings)formatter.Deserialize(fs);
                }

                if (s != null)
                {
                    setting = s;
                }
                else
                {
                    throw new Exception();
                }
            }
            catch
            {
                setting = new AcDownSettings();
                SaveSettings();
            }
            finally
            {
                GlobalSettings.GetSettings().NetworkTimeout   = setting.NetworkTimeout;
                GlobalSettings.GetSettings().RetryTimes       = setting.RetryTimes;
                GlobalSettings.GetSettings().RetryWaitingTime = setting.RetryWaitingTime;
                GlobalSettings.GetSettings().ToolFormTimeout  = setting.ToolFormTimeout;
            }
            return(setting);
        }
예제 #3
0
        /// <summary>
        /// 读取设置
        /// </summary>
        /// <returns></returns>
        public static AcDownSettings LoadSettings()
        {
            try
             {
            AcDownSettings s;
            string path = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
            path = Path.Combine(path, @"Kaedei\AcDown\config.xml");
            using (FileStream fs = new FileStream(path, FileMode.Open))
            {
               XmlSerializer formatter = new XmlSerializer(typeof(AcDownSettings));
               s = (AcDownSettings)formatter.Deserialize(fs);
            }

            if (s != null)
               setting = s;
            else
               throw new Exception();
             }
             catch
             {
            setting = new AcDownSettings();
            SaveSettings();
             }
             finally
             {
            GlobalSettings.GetSettings().NetworkTimeout = setting.NetworkTimeout;
            GlobalSettings.GetSettings().RetryTimes = setting.RetryTimes;
            GlobalSettings.GetSettings().RetryWaitingTime = setting.RetryWaitingTime;
            GlobalSettings.GetSettings().ToolFormTimeout = setting.ToolFormTimeout;
             }
             return setting;
        }
예제 #4
0
파일: FormConfig.cs 프로젝트: kwedr/acdown
		//恢复默认设置
		private void btnDefault_Click(object sender, EventArgs e)
		{
			//询问是否恢复默认设置
			if (MessageBox.Show("恢复默认设置?当前未保存的设置将会丢失", "恢复默认设置", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.Cancel)
			{
				return;
			}
			//保存新设置
			AcDownSettings s = new AcDownSettings();
			CoreManager.ConfigManager.Settings = s;
			CoreManager.ConfigManager.SaveSettings();
			//删除Firstrun文件
			FirstrunHandler fh = new FirstrunHandler();
			fh.DeleteFirstRunFile();

			//关闭窗体
			this.Close();
		}