public Add_Server(Servers.Server server) { InitializeComponent(); textBox1.Text = server.Name; textBox2.Text = server.ServerUrl; textBox3.Text = server.URL; }
public static Servers Load() { if (File.Exists(path)) { XmlSerializer ser = new XmlSerializer(typeof(Servers)); Stream s = File.Open(path, FileMode.Open); Servers deserialized = (Servers)ser.Deserialize(s); s.Close(); s.Dispose(); return deserialized; } else { Servers s = new Servers(); s.ServerList = new Server[1]; s.ServerList[0] = new Server(); s.ServerList[0].Name = "EU PVE EasyBuild (from the creator of this tool)"; s.ServerList[0].ServerUrl = "ldjserver.cloudapp.net:28015"; s.ServerList[0].URL = "https://onedrive.live.com/download?resid=8108DCD12D320C6F!11536&authkey=!AJJ2QrPHZAjnuLw&ithint=file%2ctxt"; s.Save(); return s; } }
void RefreshServer(Servers.Server s) { s.GetOnline(); if (s.Online != null) { int i = 0; bool found = false; foreach (string[] item in Identifiers) { if (item[0] == s.Online[0] && item[1] == s.Online[1]) { found = true; break; } i++; } if (found) { s.Folder = RustDirs[i]; } else { s.Folder = ""; } } }
private void Form1_Load(object sender, EventArgs e) { //RustLauncher2.Properties.Resources.Version options = Options.Load(); new License().ShowDialog(); DownL("http://bit.ly/RustLauncher2Version", "LauncherVersion.txt"); Servers = Servers.Load(); string[] dirs = Directory.GetDirectories(Environment.CurrentDirectory); RustDirs = new List<string>(); foreach (string dir in dirs) { if (File.Exists(Path.Combine(dir, "Rust.exe")) && File.Exists(Path.Combine(dir, "RustClient.exe"))) { RustDirs.Add(dir); } } Identifiers = new List<string[]>(); foreach (string dir in RustDirs) { Identifiers.Add(MakeIdentifier(dir)); } foreach (Servers.Server s in Servers.ServerList) { RefreshServer(s); listBox1.Items.Add(s); listBox1.Refresh(); } }