-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathPackageManager.cs
70 lines (62 loc) · 1.54 KB
/
PackageManager.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
using GameArchives;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LibArchiveExplorer
{
public class PackageManager
{
private static PackageManager _pm;
public static PackageManager GetInstance()
{
if(_pm == null)
{
return (_pm = new PackageManager());
}
return _pm;
}
public bool Ready { get; private set; }
public Func<IFile, Task<PackageView>> Loader { get; set; }
private System.Windows.Forms.ToolStripStatusLabel statusLabel;
private System.Windows.Forms.ToolStripStatusLabel spinner;
private PackageManager()
{
Ready = true;
}
public System.Windows.Forms.ToolStripStatusLabel Spinner
{
set { spinner = value; }
}
public System.Windows.Forms.ToolStripStatusLabel StatusLabel
{
set { statusLabel = value; }
}
public void SetReady()
{
Ready = true;
if(spinner != null)
spinner.Visible = false;
if (statusLabel != null)
statusLabel.Text = "Ready.";
}
public void SetBusyState(string busyState)
{
Ready = false;
if (spinner != null)
spinner.Visible = true;
if (statusLabel != null)
statusLabel.Text = busyState;
}
public async void LoadFile(IFile f, PackageView owner = null)
{
if(Loader == null) return;
var pkgView = await Loader(f);
if(owner != null && pkgView != null)
{
owner.AddChildPackage(pkgView);
}
}
}
}