2011-11-06 5 views
4

로컬 SqlCe 데이터베이스를 사용하는 망고 WP7.5 앱이 있습니다. 현재 날짜와 월을 기준으로 로컬 DB에서 가져온 정보를 보여주는 LiveTile 업데이트를 추가하고 싶습니다.로컬 데이터를 사용하여 망고의 라이브 타일을 업데이트 할 수 있습니까?

내가 찾은 모든 샘플은 서버에서 원격 이미지를 다운로드하여 백그라운드를 업데이트하지만 로컬 데이터베이스 쿼리를 만들고 내 타일에 문자열을 표시하기 만하면됩니다.

사용할 수 있습니까? 방법?

답변

7

예, 가능합니다. 당신은

  • 는 격리 된 저장소에 이미지를 저장하고 isostore URI를 통해
  • 액세스를 당신의 텍스트 정보가 포함 된 이미지를 생성

    1. 에 있습니다. 여기

  • 코드는이 작업을 수행하는 방법을 보여주고있다 (이것은 응용 프로그램 타일을 업데이트) :

    // set properties of the Application Tile 
    private void button1_Click(object sender, RoutedEventArgs e) 
    { 
        // Application Tile is always the first Tile, even if it is not pinned to Start 
        ShellTile TileToFind = ShellTile.ActiveTiles.First(); 
    
        // Application Tile should always be found 
        if (TileToFind != null) 
        { 
         // create bitmap to write text to 
         WriteableBitmap wbmp = new WriteableBitmap(173, 173); 
         TextBlock text = new TextBlock() { FontSize = (double)Resources["PhoneFontSizeExtraLarge"], Foreground = new SolidColorBrush(Colors.White) }; 
         // your text from database goes here: 
         text.Text = "Hello\nWorld"; 
         wbmp.Render(text, new TranslateTransform() { Y = 20 }); 
         wbmp.Invalidate(); 
    
         // save image to isolated storage 
         using (IsolatedStorageFile isf = IsolatedStorageFile.GetUserStoreForApplication()) 
         { 
          // use of "/Shared/ShellContent/" folder is mandatory! 
          using (IsolatedStorageFileStream imageStream = new IsolatedStorageFileStream("/Shared/ShellContent/MyImage.jpg", System.IO.FileMode.Create, isf)) 
          { 
           wbmp.SaveJpeg(imageStream, wbmp.PixelWidth, wbmp.PixelHeight, 0, 100); 
          } 
         } 
    
         StandardTileData NewTileData = new StandardTileData 
         { 
          Title = "Title", 
          // reference saved image via isostore URI 
          BackgroundImage = new Uri("isostore:/Shared/ShellContent/MyImage.jpg", UriKind.Absolute), 
         }; 
    
         // update the Application Tile 
         TileToFind.Update(NewTileData); 
        } 
    } 
    
    관련 문제