private void depotSaveButton_Click(object sender, EventArgs e) { Depot depot = new Depot(int.Parse(depotListBox.SelectedItem.ToString())) { ContentRoot = depotContentRootPath.Text, FileMappings = new List <FileMapping>() }; AppendLog($"Saving depot '{depot.DepotId}'..."); foreach ( DataGridViewRow row in FileMappingGrid.Rows.Cast <DataGridViewRow>().Where(x => x.Cells[0].Value != null) ) { depot.FileMappings.Add(new FileMapping { LocalPath = row.Cells[0].Value.ToString(), DepotPath = row.Cells[1].Value.ToString(), Recursive = int.Parse(row.Cells[2].Value.ToString()) }); } depot.FileExclusions = new List <FileExclusion>(); foreach (DataGridViewRow row in ExclusionsDataGrid.Rows) { if (row.Cells[0].Value == null) { continue; } depot.FileExclusions.Add(new FileExclusion { Pattern = row.Cells[0].Value.ToString() }); } File.WriteAllText(Application.StartupPath + $@"\scripts\depot_build_{depot.DepotId}.vdf", depot.ToString()); depotSaveButton.Enabled = depotRevertButton.Enabled = false; AppendLog($"Depot '{depot.DepotId}' saved successfully."); }
private void AddNewDepotButton_Click(object sender, EventArgs e) { if (depotSaveButton.Enabled) { if (MessageBox.Show("All unsaved changes will be lost. Are you sure want to continue?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No) { return; } } AddDepotForm form = new AddDepotForm(); DialogResult result = form.ShowDialog(); if (result != DialogResult.OK) { return; } if (depotListBox.Items.Contains(form.depotId.Text)) { return; } depotListBox.Items.Add(form.depotId.Text); Depot depot = new Depot(int.Parse(form.depotId.Text)); File.WriteAllText(Application.StartupPath + $@"\scripts\depot_build_{depot.DepotId}.vdf", depot.ToString()); depotSaveButton.Enabled = false; depotListBox.SelectedItem = form.depotId.Text; AppendLog($"Depot '{depot.DepotId}' created successfully."); }