Ejemplo n.º 1
0
        private void SaveButton_Click(object sender, EventArgs e)
        {
            if (!Directory.Exists(SavePathTextBox.Text))
            {
                MessageBox.Show("Bad Save Path");
                return;
            }
            if (!Directory.Exists(TorrentPathTextBox.Text))
            {
                MessageBox.Show("Bad torrents Path");
                return;
            }

			GuiGeneralSettings settings = new GuiGeneralSettings();

			try
			{
				settings.GlobalMaxConnections = Convert.ToInt32(MaxConnectionsNumericUpDown.Value);
				settings.GlobalMaxDownloadSpeed = Convert.ToInt32(MaxDownloadSpeedNumericUpDown.Value);
				settings.GlobalMaxHalfOpenConnections = Convert.ToInt32(HalfOpenConnectionsNumericUpDown.Value);
				settings.GlobalMaxUploadSpeed = Convert.ToInt32(MaxUploadSpeedNumericUpDown.Value);
				settings.ListenPort = Convert.ToInt32(ListenPortNumericUpDown.Value);
			}
			catch (FormatException ex)
			{
				MessageBox.Show("You must set a number! \r\n" + ex.ToString());
				return;
			}
			settings.SavePath = SavePathTextBox.Text;
			settings.TorrentsPath = TorrentPathTextBox.Text;
			settings.UsePnP = UseUPnPCheckBox.Checked;
			controller.UpdateGeneralSettings(settings);
			this.DialogResult = DialogResult.OK;
            this.Close();
        }
Ejemplo n.º 2
0
		/// <summary>
        /// update general settings
        /// </summary>
        /// <param name="settings"></param>
		public void UpdateGeneralSettings(GuiGeneralSettings settings)
        {
            settingsBase.SaveSettings<GuiGeneralSettings>("General Settings", settings);
            EngineSettings savedSettings = settings.GetEngineSettings();
            EngineSettings engine = clientEngine.Settings;
            engine.AllowLegacyConnections = savedSettings.AllowLegacyConnections;
            engine.GlobalMaxConnections = savedSettings.GlobalMaxDownloadSpeed;
            engine.GlobalMaxUploadSpeed = savedSettings.GlobalMaxUploadSpeed;
            engine.HaveSupressionEnabled = savedSettings.HaveSupressionEnabled;
            engine.ListenPort = savedSettings.ListenPort;
            engine.MaxOpenFiles = savedSettings.MaxOpenFiles;
            engine.MaxReadRate = savedSettings.MaxReadRate;
            engine.MaxWriteRate = savedSettings.MaxWriteRate;
            engine.MinEncryptionLevel = savedSettings.MinEncryptionLevel;
            engine.SavePath = savedSettings.SavePath;
		}