Ejemplo n.º 1
0
        public static async Task <FrameworkElement> CreateStaticTileBackgroundControl(StopGroup stop, Route route, Tuple <DateTime, Trip>[] timeTable, DateTime now)
        {
            DateTime hourNow    = new DateTime(now.Year, now.Month, now.Day, now.Hour, 0, 0);
            var      hourGroups = timeTable.Where(x => x.Item1 >= hourNow).GroupBy(x => (int)(x.Item1 - hourNow).TotalHours).ToList();

            int[]   hours   = hourGroups.Select(x => int.Parse(x.First().Item1.HourString())).ToArray();
            int[][] minutes = hourGroups.Select(x => x.Select(y => y.Item1.Minute).ToArray()).ToArray();

            return(await RouteStopTile.CreateRouteStopTile(route.RouteGroup.Name, route.Name, stop.Name, hours, minutes));
        }
Ejemplo n.º 2
0
        //forrás: http://www.visuallylocated.com/post/2014/04/19/Creating-live-tiles-with-WriteableBitmap-and-transparent-backgrounds.aspx
        public static Uri GenerateTileImage(RouteStopTile tileBackground, string fileName)
        {
            fileName = Path.Combine("Shared", "ShellContent", fileName);
            double width  = tileBackground.FrameRoot.Width;
            double height = tileBackground.FrameRoot.Height;

            using (var stream = IsolatedStorageFile.GetUserStoreForApplication().CreateFile(fileName))
            {
                tileBackground.Measure(new Size(width, height));
                tileBackground.Arrange(new Rect(0, 0, width, height));
                var bitmap = new WriteableBitmap(tileBackground, null);
                //bitmap.SaveJpeg(stream, (int)tileBackground.Width, (int)tileBackground.Height, 0, 100);
                bitmap.WritePNG(stream);
            }
            return(new Uri("isostore:/" + fileName, UriKind.Absolute));
        }
Ejemplo n.º 3
0
        public static RouteStopTile CreateTileBackgroundControl(StopGroup stop, Route route, Tuple <DateTime, Trip>[] timeTable, DateTime now)
        {
            var tileControl = new RouteStopTile
            {
                RouteShortName = route.RouteGroup.Name,
                RouteDirName   = route.Name,
                StopName       = stop.Name
            };
            DateTime hourNow    = new DateTime(now.Year, now.Month, now.Day, now.Hour, 0, 0);
            var      hourGroups = timeTable.Where(x => x.Item1 >= hourNow).GroupBy(x => (int)(x.Item1 - hourNow).TotalHours).ToList();

            int[]   hours   = hourGroups.Select(x => int.Parse(x.First().Item1.HourString())).ToArray();
            int[][] minutes = hourGroups.Select(x => x.Select(y => y.Item1.Minute).ToArray()).ToArray();
            tileControl.SetItemSource(hours, minutes);
            tileControl.FrameRoot.Background = new SolidColorBrush(Colors.Transparent);

            return(tileControl);
        }