示例#1
0
        public async static Task <Bitmap> GetBrDailyImageAsync(this BrDailyStore brStore)
        {
            var cultureInfo = new CultureInfo("en-GB", true);

            cultureInfo.NumberFormat.CurrencySymbol   = "£";
            CultureInfo.DefaultThreadCurrentCulture   = cultureInfo;
            CultureInfo.DefaultThreadCurrentUICulture = cultureInfo;
            CultureInfo.CurrentUICulture = cultureInfo;
            var grpLst = brStore.data.GroupBy(f => f.store.isFeatured).ToList();
            Dictionary <bool, Image> Windows = new Dictionary <bool, Image>();
            var vbuckIcon = await GetImage("https://cdn.discordapp.com/emojis/523870428192571402.png?v=1");

            foreach (var item in grpLst)
            {
                var img = await GenerateWindowAsync(item, vbuckIcon);

                Windows.Add(item.Key, img);
            }
            int    x = 0, y = 50;
            int    tW  = Windows.Sum(f => f.Value.Width) + 10;
            int    tH  = Windows.Max(f => f.Value.Height) + y;
            Bitmap btm = new Bitmap(tW, tH, PixelFormat.Format32bppRgb);

            btm.MakeTransparent(btm.GetPixel(0, 0));
            using (Graphics gr = Graphics.FromImage(btm))
            {
                gr.Clear(Color.FromArgb(54, 57, 63));
                gr.SmoothingMode      = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
                gr.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;

                SolidBrush solidBrush = new SolidBrush(Color.White);
                Font       font       = new Font("Arial Black", 29f, FontStyle.Bold);
                foreach (var window in Windows)
                {
                    string Title = window.Key == true ? "FEATURED" : "DAILY";
                    gr.DrawImage(window.Value, x, y);
                    using (StringFormat sf = new StringFormat())
                    {
                        sf.Alignment = StringAlignment.Center;
                        Point p = new Point(btm.Width / 2 / 2, 3);
                        if (window.Key == false)
                        {
                            p = new Point(btm.Width / 2 + btm.Width / 2 / 2, 3);
                        }
                        gr.DrawString(Title, font, solidBrush, p, sf);
                    }
                    x += window.Value.Width + 20;
                }
            }
            var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, brStore.GetBrDailyImageName());

            btm.Save(filePath, ImageFormat.Png);
            return(btm);
        }
示例#2
0
 public static string GetBrDailyTime(this BrDailyStore brStore)
 {
     try
     {
         var LastUpdateTime = DateTimeOffset.UtcNow;
         return(LastUpdateTime.ToString("dd/MMMM/yyyy"));
     }
     catch (Exception)
     {
         return(null);
     }
 }
示例#3
0
        public static string GetBrDailyTitle(this BrDailyStore brStore)
        {
            try
            {
                var LastUpdateTime = DateTimeOffset.UtcNow;
                //Fortnite: **Battle Royale Daily Store** [ *12 May 2019* ]
                return($"**Battle Royale Store** [ *{LastUpdateTime.ToString("dd MMMM yyyy")}* ]");
            }

            catch (Exception e)

            {
                return(null);
            }
        }
示例#4
0
 public static string GetBrDailyImageName(this BrDailyStore brStore)
 {
     return($"{nameof(BrDailyStore)}.png");
 }