C# 带有PNG和自定义颜色的WP7瓷砖
是否有可能在WP7中添加一个动态平铺,在WP7中,我将一个PNG文件的徽标放在中间,并向其添加背景色 应该是这样的:C# 带有PNG和自定义颜色的WP7瓷砖,c#,windows-phone-7,dynamic,png,C#,Windows Phone 7,Dynamic,Png,是否有可能在WP7中添加一个动态平铺,在WP7中,我将一个PNG文件的徽标放在中间,并向其添加背景色 应该是这样的: private void addShortcut_Click(object sender, EventArgs e) { string Url = GlobalVariables.Uri; StandardTileData NewTileData = new StandardTileData { Ba
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.");
}
}
目前,我创建的瓷砖如下所示:
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.");
}
}
因此,目前背景的颜色始终与电话样式本身的颜色相同。(我真的不明白为什么,因为red.jpg实际上是一个红色的正方形。)目前我没有一个标志,所以它只是blanc
谢谢:)您确定您的图像设置为“内容”吗?您确定您的图像设置为“内容”吗?我使用了Ree7互动程序工具包,它允许您设置具有自定义背景颜色的互动程序,源代码包括一个示例项目,该项目解释并演示了如何使用该工具包:-
我使用了Ree7互动程序工具包,它允许您使用自定义背景颜色设置互动程序,源代码包括一个示例项目,该项目解释并演示了如何使用该工具包:-
如果它只显示一个正方形,则说明您设置的图片URI不正确:-)
编辑:图像也应该设置为“内容”(已经提到)如果它只显示一个正方形,那么您设置的图片URI不正确:-) 编辑:图像也应设置为“内容”(已提及) 准备
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);
它将有助于创建宽平铺图像和短平铺图像
准备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);
它将有助于创建宽平铺图像和短平铺图像,因此在没有工具包的情况下,WP7库无法实现这一点?基于创建具有特定背景颜色的图像,可能有。该工具包所做的是动态创建背景平铺图像,从独立存储中引用它们,因此无需在项目中包含每种不同颜色的图像。好的,谢谢。我试图在我的项目中实现这一点:)我希望它能工作^^^因此,如果没有工具包,就无法使用WP7库实现这一点?基于创建具有特定背景颜色的图像,可能是这样的。该工具包所做的是动态创建背景平铺图像,从独立存储中引用它们,因此无需在项目中包含每种不同颜色的图像。好的,谢谢。我试图在我的项目中实现这一点:)我希望它能工作^^如果设置为“内容”,这是什么意思?我没有发现一个属性在那里说的内容,除了“BackContent”,在那里我已经设置了字符串:“Hitmusikonly!”好的,我找到了你的意思。。。但这不正是我想要的吗如果设置为“内容”,这是什么意思?我没有发现一个属性在那里说的内容,除了“BackContent”,在那里我已经设置了字符串:“Hitmusikonly!”好的,我找到了你的意思。。。但这不正是我想要的吗