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();
            }
    
    
        }
  • 相关阅读:
    iOS应用崩溃日志分析
    使用Crashlytics来保存应用崩溃信息
    Mac和iOS开发资源汇总
    简单配置PonyDebugger
    程序员的工作不能用“生产效率”这个词来衡量
    使用Reveal 调试iOS应用程序
    MySQL 笔记
    flex弹性布局
    回调函数
    微信小程序开发
  • 原文地址:https://www.cnblogs.com/wgscd/p/5248560.html
Copyright © 2011-2022 走看看