-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMain.cs
More file actions
115 lines (100 loc) · 3.28 KB
/
Main.cs
File metadata and controls
115 lines (100 loc) · 3.28 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
using CapuchinModManager.Classes;
using CapuchinModManager.Utilities;
using Newtonsoft.Json.Linq;
using System.ComponentModel;
using System.Diagnostics;
using static System.Net.WebRequestMethods;
namespace CapuchinModManager
{
public partial class Main : Form
{
public static Main Instance;
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public string TaskLabelText
{
get => taskLabel.Text ?? "f";
set
{
if (InvokeRequired)
Invoke((Action)(() => taskLabel.Text = value));
else
taskLabel.Text = value;
}
}
public void TaskProgressBar(int where, int start, int finish)
{
if (InvokeRequired)
{
Invoke(() => TaskProgressBar(where, start, finish));
return;
}
taskProgress.Minimum = start;
taskProgress.Maximum = finish;
taskProgress.Value = where;
}
public void RefreshModList(List<Mod> mods)
{
modsList.Items.Clear();
if (InvokeRequired)
{
Invoke(() => RefreshModList(mods));
return;
}
TaskUtilities.ReportCurrentTask("Loading mod list", 0, 1);
foreach (var mod in mods)
{
modsList.Items.Add(new ListViewItem
{
Text = mod.Name,
SubItems = { mod.Author, mod.NetworkData.Version }
});
}
TaskUtilities.ReportCurrentTask("No tasks running", 1, 1);
}
public void RefreshMods()
{
modsList.Items.Clear();
Task.Run(() =>
{
var mods = ModUtilities.FetchMods();
RefreshModList(mods);
});
}
public Main()
{
InitializeComponent();
Instance = this;
}
private void Main_Load(object sender, EventArgs e)
{
RefreshMods();
}
private void aboutCapuchinModManagerToolStripMenuItem_Click(object sender, EventArgs e)
{
MessageBox.Show(
$"CapuchinModManager v{Program.Version}\n(C) Copyright 2024 - 2026 github.com/CapuchinModding\nMIT License\n\nMade with <3 by the Capuchin Modding Community",
"About CapuchinModManager",
MessageBoxButtons.OK,
MessageBoxIcon.Asterisk
);
}
private void capuchinModdingCommunityToolStripMenuItem_Click(object sender, EventArgs e)
{
Process.Start(new ProcessStartInfo
{
FileName = Program.DiscordInviteUrl,
UseShellExecute = true
});
}
private void gitRepositoryToolStripMenuItem_Click(object sender, EventArgs e)
{
Process.Start(new ProcessStartInfo
{
FileName = "https://github.com/CapuchinModding/CapuchinModManager",
UseShellExecute = true
});
}
private void refreshListToolStripMenuItem_Click(object sender, EventArgs e) =>
RefreshMods();
}
}