This repository was archived by the owner on May 19, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathForm2.cs
More file actions
118 lines (100 loc) · 3.39 KB
/
Copy pathForm2.cs
File metadata and controls
118 lines (100 loc) · 3.39 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
116
117
118
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using UnityLauncherTools;
namespace UnityLauncher
{
public partial class Form2 : Form
{
public static string currentVersion = "";
public Form2()
{
InitializeComponent();
}
private void Form2_Load(object sender, EventArgs e)
{
Start();
}
void Start()
{
// update unity installations list
lstUnityVersions.Items.AddRange(Form1.unityList.Keys.ToArray());
// show available versions, autoselect nearest one
if (string.IsNullOrEmpty(currentVersion) == false)
{
string nearestVersion = Tools.FindNearestVersion(currentVersion, Form1.unityList.Keys.ToList());
// preselect most likely version
int likelyIndex = lstUnityVersions.FindString(nearestVersion);
if (likelyIndex > -1)
{
lstUnityVersions.SetSelected(likelyIndex, true);
}
else
{
// just select first item then
lstUnityVersions.SetSelected(0, true);
}
// enable release and dl buttons
btn_GoInstallMissingVersion.Enabled = true;
btn_OpenMissingVersionReleasePage.Enabled = true;
}
else // we dont have current version
{
btn_GoInstallMissingVersion.Enabled = false;
btn_OpenMissingVersionReleasePage.Enabled = false;
currentVersion = "None";
// just select first item then
if (lstUnityVersions != null && lstUnityVersions.Items.Count > 0) lstUnityVersions.SetSelected(0, true);
}
// fill textbox
txtUpgradeCurrentVersion.Text = currentVersion;
}
#region UI Events
private void btnConfirmUpgrade_Click(object sender, EventArgs e)
{
UpgradeToSelected();
}
private void btnCancelUpgrade_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
}
private void btn_OpenMissingVersionReleasePage_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Ignore; // opens release notes
}
private void btn_GoInstallMissingVersion_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Retry; // download package
}
#endregion
private void lstUnityVersions_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Return)
{
UpgradeToSelected();
}
else if (e.KeyCode == Keys.Escape)
{
DialogResult = DialogResult.Cancel;
}
}
void UpgradeToSelected()
{
if (lstUnityVersions.SelectedIndex > -1)
{
currentVersion = lstUnityVersions.Items[lstUnityVersions.SelectedIndex].ToString();
DialogResult = DialogResult.Yes;
}
else
{
// no version selected
}
}
}
}