This repository was archived by the owner on Sep 1, 2019. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathForm1.cs
More file actions
92 lines (77 loc) · 2.51 KB
/
Copy pathForm1.cs
File metadata and controls
92 lines (77 loc) · 2.51 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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using System.Diagnostics;
using Squirrel;
namespace MyApp
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
Assembly assembly = Assembly.GetExecutingAssembly();
locationTextBox.Text = assembly.Location;
versionTextBox.Text = assembly.GetName().Version.ToString(3);
CheckForUpdates();
}
async Task CheckForUpdates()
{
status.Text = "Checking for Updates";
using (var mgr = new UpdateManager("http://www.onemoreblock.com/Atmosphir/standalone/windows-squirrel"))
{
await mgr.UpdateApp();
}
status.Text = "Updates Checked";
button1.Enabled = true;
}
void StartGame()
{
status.Text = "Starting Game";
// Prepare the process to run
ProcessStartInfo start = new ProcessStartInfo();
// Enter in the command line arguments, everything you would enter after the executable name itself
start.Arguments = "";
// Enter the executable to run, including the complete path
start.FileName = AssemblyDirectory + "\\Atmosphir\\Atmosphir.exe";
// Do you want to show a console window?
// start.WindowStyle = ProcessWindowStyle.Hidden;
// start.CreateNoWindow = true;
int exitCode;
// Run the external process & wait for it to finish
using (Process proc = Process.Start(start))
{
proc.WaitForExit();
// Retrieve the app's exit code
exitCode = proc.ExitCode;
}
// terminate launcher process
Application.Exit();
}
public static string AssemblyDirectory
{
get
{
string codeBase = Assembly.GetExecutingAssembly().CodeBase;
UriBuilder uri = new UriBuilder(codeBase);
string path = Uri.UnescapeDataString(uri.Path);
return Path.GetDirectoryName(path);
}
}
private void button1_Click(object sender, EventArgs e)
{
StartGame();
}
}
}