簡體   English   中英

帶有PNG和自定義顏色的WP7瓷磚

[英]WP7 Tiles with PNG and Custom Colors

是否可以在WP7中添加動態圖塊,在那里我將帶有徽標的PNG文件放在中心並為其添加背景色?

它看起來應該像這樣:

在此處輸入圖片說明

目前,我以如下方式創建我的圖塊:

private void addShortcut_Click(object sender, EventArgs e)
    {
        string Url = GlobalVariables.Uri;
        StandardTileData NewTileData = new StandardTileData
        {
            BackgroundImage = new Uri("img/red.jpg", UriKind.Relative),
            Title = "Energy "+GlobalVariables.Name,
            Count = 0,
            BackTitle = "Radion Energy",
            BackContent = "Hitmusic Only!",
            BackBackgroundImage = new Uri("img/test.jpg", UriKind.Relative)
        };
        try
        {
            // Create the Tile and pin it to Start. This will cause a navigation to Start and a deactivation of our application.
            ShellTile.Create(new Uri("/MainPage.xaml?stationName=" + stationName + "&tile=true&name=" + GlobalVariables.Name + "&url=" + Url, UriKind.Relative), NewTileData);
        }
        catch
        {
            MessageBox.Show("Channel-Tile exists already.");
        }
    }

因此,目前背景顏色始終與Phonestyle本身相同。 (我真的不明白為什么,因為red.jpg實際上是一個紅色正方形。:)目前,我沒有徽標,所以它只是空白。

謝謝 :)

您確定圖像設置為“內容”嗎?

我使用了Ree7 Tile Toolkit,該工具包允許您設置具有自定義背景色的tile,源代碼包括一個示例項目,該項目說明並演示了如何使用該工具包:-

http://wp7tiletoolkit.codeplex.com/

private const string FLICKR_LIVE_TILE = "/Shared/ShellContent/flickr_live_tile.jpg";
private const string FLTile = "/Shared/ShellContent/FLTile.jpg";

使用所需的任何源准備WriteableBitmap

IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication();
                if (myIsolatedStorage.FileExists(FLTile))
                {
                    myIsolatedStorage.DeleteFile(FLTile);
                }
                using (IsolatedStorageFileStream iso = new IsolatedStorageFileStream(FLTile, FileMode.OpenOrCreate, IsolatedStorageFile.GetUserStoreForApplication()))
                {
                    WriteableBitmap1 .SaveJpeg(iso, 768, 200, 0, 100);
                    iso.Close();
                }
                if (myIsolatedStorage.FileExists(FLICKR_LIVE_TILE))
                {
                    myIsolatedStorage.DeleteFile(FLICKR_LIVE_TILE);
                }
                using (
             IsolatedStorageFileStream isoFileStream = new IsolatedStorageFileStream(FLICKR_LIVE_TILE, FileMode.OpenOrCreate,
             IsolatedStorageFile.GetUserStoreForApplication()))
                {
                    WriteableBitmap2 .SaveJpeg(isoFileStream, 336, 200, 0, 100);
                    isoFileStream.Close();
                }




                var shellTileData = new FlipTileData
                {
                    BackgroundImage = new Uri("isostore:" + FLICKR_LIVE_TILE, UriKind.RelativeOrAbsolute),
                    //BackContent = "Connectivity Slab",
                    SmallBackgroundImage = new Uri("isostore:" + FLICKR_LIVE_TILE, UriKind.RelativeOrAbsolute),
                    WideBackgroundImage = new Uri("isostore:" + FLTile, UriKind.RelativeOrAbsolute),
                    WideBackBackgroundImage = new Uri("isostore:" + FLTile, UriKind.RelativeOrAbsolute),
                    BackBackgroundImage = new Uri("isostore:" + FLICKR_LIVE_TILE, UriKind.RelativeOrAbsolute),
                };
                var tile = ShellTile.ActiveTiles.First();
                tile.Update(shellTileData);

這將有助於創建寬和短圖塊圖像

如果它僅顯示一個Square,則說明您未正確設置圖片的URI :-)

編輯:圖像也應設置在“內容”上(已經提到)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM