-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFormManageProjects.cs
More file actions
100 lines (84 loc) · 3.17 KB
/
FormManageProjects.cs
File metadata and controls
100 lines (84 loc) · 3.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Manager
{
public partial class FormManageProjects : Form
{
private List<Project> _projectList;
private Project _selectedProject;
private string _profileName;
public FormManageProjects()
{
InitializeComponent();
CenterToParent();
}
public FormManageProjects(string profileName) : this()
{
_profileName = profileName;
_selectedProject = null;
}
private void FormManageProjects_Load(object sender, EventArgs e)
{
PopulateProjectList();
}
private void PopulateProjectList()
{
_projectList = ProfileHandler.Instance.Profiles.Where(x => x.ProfileName == _profileName).First().ProjectList;
listboxProjects.Items.Clear();
listboxProjects.Items.AddRange(_projectList.ToArray());
listboxProjects.SelectedIndex = 0;
}
private void ListboxProjects_SelectedIndexChanged(object sender, EventArgs e)
{
_selectedProject = _projectList.Where(x => x.Name == listboxProjects.SelectedItem.ToString()).First();
txtProjectName.Text = _selectedProject.Name;
txtRootDirectory.Text = _selectedProject.RootDirectory;
numberGitCommits.Value = _selectedProject.GitLogHistory;
btnUpdate.Tag = _selectedProject.Name;
}
private void BtnBrowse_Click(object sender, EventArgs e)
{
var result = folderBrowserDialog.ShowDialog();
if(result == DialogResult.OK)
{
txtRootDirectory.Text = folderBrowserDialog.SelectedPath;
_selectedProject.RootDirectory = folderBrowserDialog.SelectedPath;
}
}
private void BtnAdd_Click(object sender, EventArgs e)
{
var formAddNewProject = new FormAddProject();
var result = formAddNewProject.ShowDialog();
if (result == DialogResult.OK)
{
var profile = ProfileHandler.Instance.Profiles.Where(x => x.ProfileName == _profileName).First();
ProfileHandler.Instance.CreateProject(profile, formAddNewProject.Project);
PopulateProjectList();
}
}
private void BtnUpdate_Click(object sender, EventArgs e)
{
var profile = ProfileHandler.Instance.Profiles.Where(x => x.ProfileName == _profileName).First();
var project = new Project()
{
Name = txtProjectName.Text,
RootDirectory = txtRootDirectory.Text,
GitLogHistory = (int)numberGitCommits.Value
};
ProfileHandler.Instance.UpdateProject(profile, project, btnUpdate.Tag.ToString());
PopulateProjectList();
}
private void BtnClose_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.OK;
Close();
}
}
}