Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows phone 7 我可以使用本地数据更新Mango中的live互动程序吗?_Windows Phone 7_Live Tile - Fatal编程技术网

Windows phone 7 我可以使用本地数据更新Mango中的live互动程序吗?

Windows phone 7 我可以使用本地数据更新Mango中的live互动程序吗?,windows-phone-7,live-tile,Windows Phone 7,Live Tile,我有一个Mango WP7.5应用程序,它使用本地SqlCe数据库。我想添加一个LiveTile更新,显示基于当前日期和月份从本地数据库获取的信息 我发现的所有示例都通过从服务器下载远程图像来更新背景,但我只需要进行本地数据库查询并在我的互动程序中显示一个字符串 我能做吗?怎么做?是的,你可以。你必须 生成包含文本信息的图像 将此映像保存到独立的存储和 通过isostoreURI访问它 下面是显示如何执行此操作的代码(它会更新应用程序磁贴): // set properties of the A

我有一个Mango WP7.5应用程序,它使用本地SqlCe数据库。我想添加一个LiveTile更新,显示基于当前日期和月份从本地数据库获取的信息

我发现的所有示例都通过从服务器下载远程图像来更新背景,但我只需要进行本地数据库查询并在我的互动程序中显示一个字符串


我能做吗?怎么做?

是的,你可以。你必须

  • 生成包含文本信息的图像
  • 将此映像保存到独立的存储和
  • 通过
    isostore
    URI访问它
  • 下面是显示如何执行此操作的代码(它会更新应用程序磁贴):

    // 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);
        }
    }