Esempio n. 1
0
        private static async Task RenderTileSVG(string crypto)
        {
            var grid = await LiveTileGenerator.SecondaryTileGrid(crypto);

            try {
                var rtb = new RenderTargetBitmap();
                await rtb.RenderAsync(grid);

                var pixelBuffer = await rtb.GetPixelsAsync();

                var pixels             = pixelBuffer.ToArray();
                var displayInformation = DisplayInformation.GetForCurrentView();
                var file = await ApplicationData.Current.LocalFolder.CreateFileAsync($"tile-{crypto}.png",
                                                                                     CreationCollisionOption.ReplaceExisting);

                using (var stream = await file.OpenAsync(FileAccessMode.ReadWrite)) {
                    var encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.PngEncoderId, stream);

                    encoder.SetPixelData(BitmapPixelFormat.Bgra8,
                                         BitmapAlphaMode.Premultiplied,
                                         (uint)rtb.PixelWidth,
                                         (uint)rtb.PixelHeight,
                                         displayInformation.RawDpiX,
                                         displayInformation.RawDpiY,
                                         pixels);
                    await encoder.FlushAsync();
                }
            }
            catch (Exception ex) {
                var z = ex.Message;
            }
        }
Esempio n. 2
0
        /// Generate the XML
        private static async Task <XmlDocument> GenerateCoinTile(string crypto)
        {
            var count = hist.Count - 1;

            var price   = Rounder(hist[count].Average);
            var _diff1d = ((price - hist[count - 25].Average) / price) * 100;
            var _diff7d = ((price - hist[0].Average) / price) * 100;

            var arrow1d = _diff1d < 0 ? "24h: ▼" : "24h: ▲";
            var arrow7d = _diff7d < 0 ? " 7d: ▼" : " 7d: ▲";
            var diff1d  = new Tuple <string, string>(arrow1d, $"{Math.Abs(_diff1d):N}%");
            var diff7d  = new Tuple <string, string>(arrow7d, $"{Math.Abs(_diff7d):N}%");

            return(LiveTileGenerator.SecondaryTileXML(crypto, currencySymbol, price, diff1d, diff7d));
        }