首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >windows 8的LockScreen

windows 8的LockScreen
EN

Stack Overflow用户
提问于 2013-08-23 12:29:53
回答 1查看 141关注 0票数 0

嗨,我正在开发一个锁屏应用程序,当我点击一个按钮设置锁定屏幕时,我正在使用images.After的列表框选择一个图像,它应该updated.But It bot更新.Here是我的代码。

代码语言:javascript
复制
private async void ApplicationBarIconButton_Click(object sender, EventArgs e)
    {
        MediaLibrary mediaLibrary = new MediaLibrary();
        //ImageSource im = image1.Source;
        BitmapImage bitmap = new BitmapImage();
        bitmap.SetSource(mediaLibrary.Pictures[imageList.SelectedIndex].GetImage());

        String tempJPEG = "MyWallpaper1.jpg";

        using (IsolatedStorageFile myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication())
        {
            if (myIsolatedStorage.FileExists(tempJPEG))
            {
                myIsolatedStorage.DeleteFile(tempJPEG);
            }

            IsolatedStorageFileStream fileStream = myIsolatedStorage.CreateFile(tempJPEG);

            StreamResourceInfo sri = null;
            Uri uri = new Uri(tempJPEG, UriKind.Relative);
            sri = Application.GetResourceStream(uri);

            WriteableBitmap wb = new WriteableBitmap(bitmap);

            Extensions.SaveJpeg(wb, fileStream, wb.PixelWidth, wb.PixelHeight, 0, 90);

            fileStream.Close();
        }

        LockScreenChange(tempJPEG);

    }

    private async void LockScreenChange(string filePathOfTheImage)
    {
        if (!LockScreenManager.IsProvidedByCurrentApplication)
        {
            await LockScreenManager.RequestAccessAsync();
        }

        if (LockScreenManager.IsProvidedByCurrentApplication)
        {
            var schema = "ms-appdata:///Local/";
            var uri = new Uri(schema + filePathOfTheImage, UriKind.Absolute);

            LockScreen.SetImageUri(uri);
            var currentImage = LockScreen.GetImageUri();
            MessageBox.Show("Success", "LockScreen changed", MessageBoxButton.OK);
        }
        else
        {
            MessageBox.Show("Background cant be changed. Please check your permissions to this application.");
        }
    }

实际上,当第一次启动应用程序时,当我单击“设置”按钮时,当前选定的图像被设置为锁定屏幕,之后,当我选择另一个图像时,它显示的是锁定屏幕更改、success.No错误和无异常,我不知道问题在哪里。请帮忙.

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-01-31 07:19:52

它通过将临时文件名更改为原始文件名(即字符串tempJpeg )来解决。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18402914

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档