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(); }
public OptionWindow(MainController mainController, SettingsBase settings) { InitializeComponent(); this.controller = mainController; this.Icon = ResourceHandler.GetIcon("mono", 16, 16); GetButtonImages(); GuiGeneralSettings genSettings = settings.LoadSettings <GuiGeneralSettings>("General Settings"); MaxConnectionsNumericUpDown.Value = genSettings.GlobalMaxConnections; MaxDownloadSpeedNumericUpDown.Value = genSettings.GlobalMaxDownloadSpeed; HalfOpenConnectionsNumericUpDown.Value = genSettings.GlobalMaxHalfOpenConnections; MaxUploadSpeedNumericUpDown.Value = genSettings.GlobalMaxUploadSpeed; ListenPortNumericUpDown.Value = genSettings.ListenPort; SavePathTextBox.Text = genSettings.SavePath; TorrentPathTextBox.Text = genSettings.TorrentsPath; UseUPnPCheckBox.Checked = genSettings.UsePnP; }