Esempio n. 1
0
        void DownloadImageAndSetToLock(string url)
        {
            try
            {
                WebClient client = new WebClient();

                string fileName;
                Uri    currentImage = new Uri("http://Init");

                try
                {
                    currentImage = LockScreen.GetImageUri();
                }
                catch
                {
                    //safety net for first run
                }

                if (currentImage.ToString().EndsWith("_A.jpg"))
                {
                    fileName = "LiveLockBackground_B.jpg";
                }
                else
                {
                    fileName = "LiveLockBackground_A.jpg";
                }

                var lockImage = string.Format("{0}", fileName);

                client.OpenReadAsync(new Uri(url));
                client.OpenReadCompleted += async(sender, args) =>
                {
                    Debug.WriteLine("Downloaded " + fileName);
                    await LocalStorageHelper.WriteData("LockImage", fileName, StreamToByteArray(args.Result));

                    LockHelper("LockImage\\" + fileName, false);
                };
            }
            catch (Exception e)
            {
                Debug.WriteLine("Download of Lock Screen Image Failed");
            }
        }
Esempio n. 2
0
        async Task DownloadImageAndSetToLock(string url)
        {
            try
            {
                HttpClient client = new HttpClient();

                string fileName;
                Uri    currentImage = new Uri("http://Init");

                try
                {
                    currentImage = LockScreen.GetImageUri();
                }
                catch
                {
                    //safety net for first run
                }

                if (currentImage.ToString().EndsWith("_A.jpg"))
                {
                    fileName = "LiveLockBackground_B.jpg";
                }
                else
                {
                    fileName = "LiveLockBackground_A.jpg";
                }

                var lockImage = string.Format("{0}", fileName);

                var imageBytes = await client.GetByteArrayAsync(new Uri(url));

                Debug.WriteLine("Downloaded " + fileName);
                await LocalStorageHelper.WriteData("LockImage", fileName, imageBytes);

                LockHelper("LockImage\\" + fileName, false);
            }
            catch (Exception e)
            {
                Debug.WriteLine("Download of Lock Screen Image Failed");
            }
        }