-
Notifications
You must be signed in to change notification settings - Fork 38
/
WebScriptApi.cs
71 lines (61 loc) · 2.19 KB
/
WebScriptApi.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
using System;
using System.Diagnostics;
using System.Threading;
using System.Windows.Forms;
namespace SapphireBootWPF
{
public class WebScriptApi
{
private MainWindow window;
public WebScriptApi( MainWindow window )
{
this.window = window;
}
public void Boot( string sid, string serverLobbyAddress, string serverFrontierAddress )
{
try
{
BootClient.StartClient( sid, serverLobbyAddress, serverFrontierAddress );
if ( Properties.Settings.Default.CloseOnLaunch )
{
Process.GetCurrentProcess().Kill();
}
}
catch ( Exception ex )
{
MessageBox.Show( $"An error has occured. Please check your game path and server addresses.\n\nMore info:\n{ex}",
"Launch failed", MessageBoxButtons.OK, MessageBoxIcon.Error );
}
}
public void OpenClientPathChooser()
{
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Filter = "EXE files (*.exe)|*.exe|All files (*.*)|*.*";
openFileDialog.ShowDialog();
if ( openFileDialog.FileName != "" )
Properties.Settings.Default.ClientPath = openFileDialog.FileName;
Properties.Settings.Default.Save();
//window.webBrowser.GetBrowser( ).MainFrame.ExecuteJavaScriptAsync( string.Format( "updateClientPath({0})", Properties.Settings.Default.ClientPath ) );
}
public void SaveWebServerUrl( string url )
{
Properties.Settings.Default.WebServerUrl = url;
Properties.Settings.Default.Save();
}
public void Navigate( string url )
{
window.webBrowser.Address = url;
}
public void SwitchWindows()
{
window.Dispatcher.Invoke( () =>
{
ServerWindow nWindow = new ServerWindow();
nWindow.Left = window.Left;
nWindow.Top = window.Top;
nWindow.Show();
window.Close();
} );
}
}
}