zoukankan      html  css  js  c++  java
  • 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();
            }
    
    
        }
  • 相关阅读:
    C#判断一个字符串是否是数字或者含有某个数字
    SQL多字段排序
    对于过长字符串的大小比对
    WebFrom页面绑定数据过于冗长的处理方法
    webform的导出
    SQL数据库Truncate的相关用法
    SQL的CharIndex用法
    近期总结
    每周一水(4-1)
    Codeforces Round #238 (Div. 2) 解题报告
  • 原文地址:https://www.cnblogs.com/wgscd/p/5248560.html
Copyright © 2011-2022 走看看