This repository was archived by the owner on Feb 22, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathMainForm.cs
54 lines (49 loc) · 1.74 KB
/
MainForm.cs
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
using System;
using System.Collections.Generic;
using System.Windows.Forms;
namespace PathCleaner
{
public partial class MainForm : Form
{
public MainForm() => InitializeComponent();
private static readonly IEnumerable<IPathChecker> pathCheckers = new IPathChecker[]
{
new DuplicatePathChecker(),
new MissingPathChecker(),
new EmptyPathChecker(),
new NoExecutablesPathChecker(),
};
#pragma warning disable IDE1006 // Naming Styles
private void MainForm_Load(object sender, EventArgs e) => findProblematicItems();
#pragma warning restore IDE1006 // Naming Styles
private void findProblematicItems()
{
UseWaitCursor = true;
problemList.Items.Clear();
var path = new PathString();
var identifier = new ProblemIdentifier(path, pathCheckers);
var problems = identifier.FindProblems();
foreach (var item in problems)
{
var listItem = new ListViewItem(item.Path);
_ = listItem.SubItems.Add(new ListViewItem.ListViewSubItem(listItem, item.Reason));
_ = problemList.Items.Add(listItem);
}
UseWaitCursor = false;
}
private void cleanupButton_Click(object sender, EventArgs e)
{
var path = new PathString();
foreach (ListViewItem item in problemList.SelectedItems)
{
int index = path.Folders.IndexOf(item.Text);
if (index >= 0)
{
path.Folders.RemoveAt(index);
}
}
path.UpdateEnvironmentVariable();
findProblematicItems();
}
}
}