-
Notifications
You must be signed in to change notification settings - Fork 17
/
MainWindow.cs
145 lines (118 loc) · 4.87 KB
/
MainWindow.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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
using MetroFramework.Controls;
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 MainWindow : Form
{
public MainWindow()
{
InitializeComponent();
}
JObject repojson = Functions.apiFunctions.getGames();
public void setgameWindow(int index)
{
if (index == -1)
return;
gameLbl.Text = repojson["games"][index]["name"].ToString();
WebClient client = new WebClient();
Stream stream_data = new MemoryStream(client.DownloadData(repojson["games"][index]["picture_url"].ToString()));
gamePicture.Image = Image.FromStream(stream_data);
}
private void LoadGameMod(int index)
{
if (index == -1)
return;
Functions.Console.log("Loading Game: " + repojson["games"][index]["name"].ToString(), this.consoleOutput);
// Functions.Console.log(repojson["games"][index].ToString(), this.consoleOutput);
// Functions.Console.log("========================================================", this.consoleOutput);
gameloadDialog gameDialog = new gameloadDialog();
gameDialog.gameName = repojson["games"][index]["name"].ToString();
gameDialog.picture_url = repojson["games"][index]["picture_url"].ToString();
gameDialog.app_id = int.Parse(repojson["games"][index]["app_id"].ToString());
gameDialog.isSteamGame = bool.Parse(repojson["games"][index]["isSteamGame"].ToString());
gameDialog.StartPosition = FormStartPosition.Manual;
gameDialog.Location = new Point(this.Location.X + this.Width / 2, this.Location.Y + this.Height / 2);
gameDialog.ShowDialog();
}
public void checkUpdates()
{
Functions.Console.log("Checking Updates...", this.consoleOutput);
JObject updateJson = Functions.apiFunctions.getUpdates();
if (updateJson["update"][0]["code"].ToString() != Application.ProductVersion)
{
label1.Visible = true;
label1.Text = "New update found!";
Functions.Console.log("New Update found! (current: "+Application.ProductVersion+" new:"+updateJson["update"][0]["code"].ToString()+")", this.consoleOutput);
UpdateWindow updateW = new UpdateWindow();
updateW.updateJson = updateJson;
updateW.ShowDialog();
}
else
{
label1.Visible = true;
label1.Text = "You are using latest version!";
}
}
private void MainWindow_Load(object sender, EventArgs e)
{
//Check updates
versionLbl.Text = "Current Version: v" + Application.ProductVersion;
//checkUpdates();
//Setup GamesTab
Functions.Console.log("Setting up games tab...", this.consoleOutput);
listBox1.Items.Clear();
foreach (var item in repojson["games"])
{
listBox1.Items.Add(item["name"].ToString());
Functions.Console.log(item["name"].ToString() + " loaded!", this.consoleOutput);
Functions.Console.log(item["picture_url"].ToString() + " loaded!", this.consoleOutput);
}
Functions.Console.log("Program Initialized!", this.consoleOutput);
//Fix index issues
metroTabControl1.SelectedIndex = 0;
listBox1.SelectedIndex = 0;
}
private void metroTextBox1_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar == Convert.ToChar(Keys.Enter))
Functions.Console.HandleCmd(this.consoleOutput, this.consoleInputBox);
}
private void gameTab_Click(object sender, EventArgs e)
{
}
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
setgameWindow(listBox1.SelectedIndex);
}
private void metroButton1_Click(object sender, EventArgs e)
{
LoadGameMod(listBox1.SelectedIndex);
}
private void metroToggle1_CheckedChanged(object sender, EventArgs e)
{
if (setting_darkModeToggle.Checked)
{
//Dark mode exec code
metroStyleManager1.Theme = MetroFramework.MetroThemeStyle.Dark;
}
}
private void metroButton2_Click(object sender, EventArgs e)
{
checkUpdates();
}
private void groupBox2_Enter(object sender, EventArgs e)
{
}
}
}