-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSplashScreen.xaml.cs
118 lines (97 loc) · 3.42 KB
/
SplashScreen.xaml.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 System;
using System.IO;
using System.Net;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Forms;
using CLauncher2._0.Window;
namespace CLauncher2._0
{
/// <summary>
/// Interaktionslogik für SplashScreen.xaml
/// </summary>
public partial class SplashScreen : System.Windows.Window
{
string Version = "vb1.70";
public SplashScreen()
{
InitializeComponent();
checkIfLauncherIsInDirectory();
this.splashscreen_status.Content = "checking for updates...";
string oldPath = (Environment.CurrentDirectory) + @"\APB CLauncher_old.exe"; //!!!!!!!
File.Delete(oldPath);
}
private System.Windows.Forms.Timer holder;
private readonly System.Windows.Forms.Label say;
public string getVersion() => this.Version;
public void checkForUpdate()
{
string str = new StreamReader(WebRequest.Create("https://beta.clauncher.download/" + "version.txt").GetResponse().GetResponseStream()).ReadLine();
if (this.getVersion() != str)
{
this.splashscreen_status.Content = "Update found! Would you like to update?";
this.Yes.Visibility = Visibility.Visible;
this.No.Visibility = Visibility.Visible;
}
else
{
this.splashscreen_status.Content = "Launcher is on latest version...";
this.StartMainForm();
}
}
public void checkIfLauncherIsInDirectory()
{
String path = Environment.CurrentDirectory;
String target = "\\Binaries\\APB.exe";
if (File.Exists(path + target))
{
}
else
{
this.Hide();
Windows.Fatal_Error FatalError = new Windows.Fatal_Error();
FatalError.Show();
FatalError.ErrorCode.Content = "<Error:FatalError Informations=" + '\u0022' + "Launcher is not located in the APB directory" + '\u0022' + ">";
}
}
private async void StartMainForm()
{
await Task.Delay(2000);
this.Hide();
Window.test MainWindow = new Window.test();
MainWindow.Closed += (EventHandler)((s, args) => this.Close());
MainWindow.Show();
MainWindow = (Window.test)null;
}
private async void StartPatchForm()
{
await Task.Delay(3000);
this.Hide();
frmPatcher PatchForm = new frmPatcher();
PatchForm.Closed += (EventHandler)((s, args) => this.Close());
PatchForm.Show();
PatchForm = (frmPatcher)null;
}
private async void Window_Loaded(object sender, RoutedEventArgs e)
{
await Task.Delay(3000);
if (UserSettings.Default.AutoUpdate == true)
{
this.checkForUpdate();
}
else
{
this.splashscreen_status.Content = "Auto Update deactivated...";
this.StartMainForm();
}
}
private void Yes_Click(object sender, RoutedEventArgs e)
{
this.StartPatchForm();
}
private void No_Click(object sender, RoutedEventArgs e)
{
this.StartMainForm();
}
}
}