private void frmMain_Load(object sender, EventArgs e) { CurrentWorkspace = Workspace.FromFile("default.json"); if (CurrentWorkspace != null) { RefreshWorkspace(); } }
private void btnLoad_Click(object sender, EventArgs e) { openFileDialog1.InitialDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); switch (openFileDialog1.ShowDialog()) { case DialogResult.OK: case DialogResult.Yes: CurrentWorkspace = Workspace.FromFile(openFileDialog1.FileName); txtFolder1.Text = CurrentWorkspace.Folder1; txtFolder2.Text = CurrentWorkspace.Folder2; foreach (var item in CurrentWorkspace.Exclusions) { lstExclusions.Items.Add(item); } foreach (var item in CurrentWorkspace.ExclusionPatterns) { lstPatterns.Items.Add(item); } break; default: break; } }
private void btnWorkspace_Click(object sender, EventArgs e) { frmWorkSpace workspaceForm = new frmWorkSpace(); switch (workspaceForm.ShowDialog()) { case DialogResult.OK: case DialogResult.Yes: this.CurrentWorkspace = workspaceForm.CurrentWorkspace; RefreshWorkspace(); break; default: break; } }
private void SaveWorkspace(bool prompt) { if (!Directory.Exists(txtFolder1.Text)) MessageBox.Show("The folder in Folder1 does not exist", "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Warning); if (!Directory.Exists(txtFolder2.Text)) MessageBox.Show("The folder in Folder2 does not exist", "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Warning); CurrentWorkspace = new Workspace() { Folder1 = txtFolder1.Text, Folder2 = txtFolder2.Text, Exclusions = new List<string>(), ExclusionPatterns = new List<string>() }; foreach (var item in lstExclusions.Items) { CurrentWorkspace.Exclusions.Add(item.ToString()); } foreach (var item in lstPatterns.Items) { CurrentWorkspace.ExclusionPatterns.Add(item.ToString()); } if (prompt) { saveFileDialog1.InitialDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); switch (saveFileDialog1.ShowDialog()) { case DialogResult.OK: case DialogResult.Yes: CurrentWorkspace.ToFile(saveFileDialog1.FileName); break; default: break; } } else { CurrentWorkspace.ToFile(openFileDialog1.FileName); } }