private void AddButton_Click(object sender, EventArgs e) { Action <string> showMessage = (message) => { MessageBox.Show(message); }; name = NameTextBox.Text; googleUrl = GoogleSheetPathTextBox.Text; action = (string)ActionComboBox.SelectedItem == "Overwrite" ? UpdaterAction.Overwrite : UpdaterAction.Append; int fromRange; int toRange; bool t1 = int.TryParse(FromRangeTextBox.Text, out fromRange); bool t2 = int.TryParse(ToRangeTextBox.Text, out toRange); if (name == "" || name == "Name") { showMessage("Enter name"); return; } if (googleUrl == "" || googleUrl == "Google url") { showMessage("Enter google url"); return; } if (folder == "") { showMessage("Pick folder"); return; } if (!t1 | !t2) { removableRows = null; } else { removableRows = new Tuple <int, int>(fromRange, toRange); } try { (caller as Form1).AppendNewUpdaterItem(new UpdaterItem(name, folder, googleUrl, action, removableRows)); } catch (FileNotFoundException) { showMessage("Directory not found"); return; } Close(); }
public UpdaterItem(string name, string localPath, string googlePath, UpdaterAction action, Tuple <int, int> range) { if (!Directory.Exists(SaveFolder)) { Directory.CreateDirectory(SaveFolder); } if (!Directory.Exists(localPath)) { throw new FileNotFoundException("Directory not exists", localPath); } if (googlePath.Split('=').Length == 0) { throw new ArgumentException("Google path not exists", googlePath); } this.name = name; this.localPath = localPath; this.googlePath = googlePath; this.action = action; this.range = range; }