public void RefreshMotd()
        {
            try
            {
                Action a = () =>
                {
                    var motdFile = GetFileViaHttp(new Uri($"{webResourceDomain}/rtc/releases/MOTD.txt"));
                    var motd     = string.Empty;
                    if (motdFile == null)
                    {
                        motd = "Couldn't load the RTC MOTD from Redscientist.com";
                    }
                    else
                    {
                        motd = Encoding.UTF8.GetString(motdFile);
                    }

                    FormSync.FormExecute(() => {
                        lbMOTD.Text = motd;
                    });
                };
                Task.Run(a);
            }
            catch
            {
                lbMOTD.Text = "Couldn't load the RTC MOTD from Redscientist.com";
                MessageBox.Show("Couldn't connect to the server.");
            }

            lbMOTD.Visible = true;
        }
Beispiel #2
0
        public void refreshVersions()
        {
            Action a = () =>
            {
                var versionFile = MainForm.GetFileViaHttp(new Uri($"{MainForm.webResourceDomain}/rtc/releases/version.php"));

                if (versionFile == null)
                {
                    return;
                }

                var str = Encoding.UTF8.GetString(versionFile);

                //Ignores any build containing the word Launcher in it
                var onlineVersions = str.Split('|').Where(it => !it.Contains("Launcher")).OrderByNaturalDescending(x => x).Select(it => it.Replace(".zip", string.Empty)).ToArray();

                FormSync.FormExecute(() =>
                {
                    onlineVersionsObjects = new List <dynamic>();

                    lbOnlineVersions.DataSource    = null;
                    lbOnlineVersions.DisplayMember = "Text";
                    lbOnlineVersions.ValueMember   = "Value";

                    lbOnlineVersions.Items.Clear();
                    if (onlineVersions.Length > 0)
                    {
                        for (var i = 0; i < onlineVersions.Length; i++)
                        {
                            var value = onlineVersions[i];

                            if (i == 0)
                            {
                                onlineVersions[i] += latestVersionString;
                            }

                            var key = onlineVersions[i];

                            onlineVersionsObjects.Add(new { Text = key, Value = value });
                        }
                    }

                    lbOnlineVersions.DataSource = null;
                    lbOnlineVersions.DataSource = onlineVersionsObjects;

                    //lbOnlineVersions.Items.AddRange(onlineVersionsTuples);
                });
            };

            Task.Run(a);
        }