예제 #1
0
 private static void CheckForEmptyCover(BookTile tile)
 {
     if (tile.ImageSource == null)
     {
         tile.BookNameTextBlock.VerticalAlignment = VerticalAlignment.Top;
     }
 }
예제 #2
0
 private static void CheckForEmptyCover(BookTile tile)
 {
     if (tile.ImageSource == null)
     {
         tile.BookNameTextBlock.VerticalAlignment = VerticalAlignment.Top;
     }
 }
예제 #3
0
        public void CreateTileForBook(string bookId)
        {
            if (string.IsNullOrWhiteSpace(bookId))
                throw new ArgumentException("bookId is invalid");

            var book = _bookRepository.Get(bookId);

            var uri = _navigationService.UriFor<ReadPageViewModel>()
                .WithParam(vm => vm.BookId, bookId)
                .WithParam(vm => vm.ToLastReadPage, true)
                .BuildUri();


            string title = book.Title;
            BitmapImage bmp;
            using (var storage = IsolatedStorageFile.GetUserStoreForApplication())
            {

                if (storage.FileExists(ModelExtensions.GetBookCoverPath(book.BookID)))
                {
                    bmp = new BitmapImage() { CreateOptions = BitmapCreateOptions.None };
                    using (var file = storage.OpenFile(ModelExtensions.GetBookCoverPath(book.BookID), FileMode.Open))
                    {
                        bmp.SetSource(file);
                        title = string.Empty;
                    }
                }
                else
                    bmp = null;//.UriSource = new Uri("/Resources/Icons/tile.png", UriKind.RelativeOrAbsolute);
            }

            BookTile tile = new BookTile();
            tile.ImageSource = bmp;
            tile.Title = title;
            tile.UpdateLayout();

            LiveTileHelper.CreateOrUpdateTile(new RadExtendedTileData() {VisualElement = tile}, uri);
        }