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();
            }
    
    
        }
  • 相关阅读:
    单链表的基本操作(查找,插入,删除)
    线性表的基本操作(插入,删除,查找)
    双人五子棋对战(需要EasyX图像库)
    2016ACM竞赛训练暑期课期末考试 a题
    百练_1664 放苹果
    百练_4120 硬币(DP)
    PAT_1046 划拳
    PAT_1026 程序运行时间
    学Android开发 这19个开发工具助你顺风顺水
    JAVA利用axis2发布webservice
  • 原文地址:https://www.cnblogs.com/wgscd/p/5248560.html
Copyright © 2011-2022 走看看