-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathSplashWindow.cs
118 lines (93 loc) · 3.18 KB
/
SplashWindow.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
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
116
117
118
using ComponentFactory.Krypton.Toolkit;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace DualSenseAT
{
public partial class SplashWindow : KryptonForm
{
public SplashWindow()
{
InitializeComponent();
}
static int steps = 0;
private void LoadLangsList()
{
DirectoryInfo d = new DirectoryInfo(Constants.LANG_PATH);
Session.langList = d.GetFiles("*.json"); //Getting Json files
}
public void DownloadHome()
{
UpdateLbl.Text = "Fetching Home data...";
using (WebClient cliente = new WebClient())
{
var pathfinal = Constants.BASE_TEMP_PATH + "home.json";
var uri = new Uri(Constants.BASE_URL + "home/home.json");
cliente.DownloadProgressChanged += new DownloadProgressChangedEventHandler(ProgressChanged);
cliente.DownloadFileCompleted += new AsyncCompletedEventHandler(Completed);
cliente.DownloadFileAsync(uri, pathfinal);
}
}
private void ProgressChanged(object sender, DownloadProgressChangedEventArgs e)
{
metroProgressBar1.Value = e.ProgressPercentage;
}
private void Completed(object sender, AsyncCompletedEventArgs e)
{
UpdateLbl.Text = "Fetching Games...";
Functions.apiFunctions.getGames();
steps++;
if (steps == 1)
{
this.Hide();
this.ShowInTaskbar = false;
MainWindowV3 mainWindow = new MainWindowV3();
mainWindow.Location = this.Location;
mainWindow.Show();
}
}
private void EveryTick_Tick(object sender, EventArgs e)
{
}
private void SplashWindow_Load(object sender, EventArgs e)
{
UpdateLbl.Text = "Checking Updates...";
this.Text = "DualSense AT v" + Application.ProductVersion;
checkUpdates.RunWorkerAsync();
}
private void checkUpdates_DoWork(object sender, DoWorkEventArgs e)
{
JObject updateJson = Functions.apiFunctions.getUpdates();
if (updateJson["update"][0]["code"].ToString() != Application.ProductVersion)
{
e.Result = updateJson;
}
else
{
e.Result = false;
}
//Load Land List to Session Namespace;
LoadLangsList();
}
private void checkUpdates_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
if (e.Result.GetType() == typeof(JObject))
{
UpdateWindow updateW = new UpdateWindow();
updateW.updateJson = (JObject)e.Result;
updateW.ShowDialog();
}
DownloadHome();
EveryTick.Enabled = true;
}
}
}