Example #1
0
        private void HeadPat()
        {
            Utils.WeebCDNRandomResponse Pat;
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Utils.Constants.WeebCDNAPIURL + "pats/random");

            request.AutomaticDecompression = DecompressionMethods.GZip;
            request.UserAgent = "ModAssistant/" + App.Version;

            using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
                using (Stream stream = response.GetResponseStream())
                    using (StreamReader reader = new StreamReader(stream))
                    {
                        var serializer = new JavaScriptSerializer();
                        Pat = serializer.Deserialize <Utils.WeebCDNRandomResponse>(reader.ReadToEnd());
                    }
            PatImage.Load(Pat.url);
        }
Example #2
0
        private async Task <bool> HeadPat()
        {
            try
            {
                var image = await WeebCDN("pats");

                PatImage.Load(image);

                return(true);
            }
            catch (Exception ex)
            {
                var buttonType = (string)FindResource("About:HeadpatsButton");
                var title      = string.Format((string)FindResource("About:ImageError:Title"), buttonType);
                var message    = string.Format((string)FindResource("About:ImageError:Message"), buttonType);

                MessageBox.Show($"{message}\n{ex.Message}", title, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
        }
Example #3
0
 private void HeadPat()
 {
     PatImage.Load(WeebCDN("pats"));
 }
Example #4
0
 private async Task HeadPat()
 {
     PatImage.Load(await WeebCDN("pats"));
 }