UWP 设置桌面壁纸、锁屏图片
private static Uri imgUri = new Uri("ms-appx:///pic1.jpg");
private async void btnSetWallpaper_Click(object sender, RoutedEventArgs e)
{
var msg = new MessageDialog("");
if (!UserProfilePersonalizationSettings.IsSupported())
{
//msg = new MessageDialog("人品太差,不支持哦!");
msg.Content = "人品太差,不支持哦!";
await msg.ShowAsync();
}
//获取文件
StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(imgUri);
//设置背景
UserProfilePersonalizationSettings setting = UserProfilePersonalizationSettings.Current;
bool b = await setting.TrySetWallpaperImageAsync(file);
if (b)
{
msg.Content = "set ok!";
await msg.ShowAsync();
}
else
{
msg.Content = "can not set Wallpaper !";
await msg.ShowAsync();
}
}
设置锁屏图片
private async void btnSetLockScreen_Click(object sender, RoutedEventArgs e)
{
var msg = new MessageDialog("");
if (!UserProfilePersonalizationSettings.IsSupported())
{
//msg = new MessageDialog("人品太差,不支持哦!");
msg.Content = "人品太差,不支持哦!";
await msg.ShowAsync();
}
//获取文件
StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(imgUri);
//设置背景
UserProfilePersonalizationSettings setting = UserProfilePersonalizationSettings.Current;
bool b = await setting.TrySetLockScreenImageAsync(file);
if (b)
{
msg.Content = "set ok!";
await msg.ShowAsync();
}
else
{
msg.Content = "can not set lock screen!";
await msg.ShowAsync();
}
}
fffffffffffffffff
test red font.
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步