Example #1
0
 public static void Cache(Quote dailyQuote)
 {
     var settings = IsolatedStorageSettings.ApplicationSettings;
     if (!settings.Contains(IS_DailyQuote_Key))
         settings.Add(IS_DailyQuote_Key, null);
     settings[IS_DailyQuote_Key] = dailyQuote;
     settings.Save();
 }
Example #2
0
        public static Task<bool> UpdateTileAndLockscreen(Quote quote)
        {
            TaskCompletionSource<bool> completionSource = new TaskCompletionSource<bool>();
            Deployment.Current.Dispatcher.BeginInvoke(new Action(() =>
            {
                try
                {
                    UpdateTile(quote);
                    UpdateLockscreen(quote);

                    completionSource.SetResult(true);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                    completionSource.SetResult(false);
                }
            }));

            return completionSource.Task;
        }
Example #3
0
        private static void UpdateLockscreen(Quote quote)
        {
            if (LockScreenManager.IsProvidedByCurrentApplication)
            {
                var lockScreenJpg = LockScreenImage.Create(
                    GetCurrentLockScreenUri().EndsWith("1.jpg")
                        ? "lockScreen2.jpg"
                        : "lockScreen1.jpg",
                    string.Format("\"{0}\"\n\n{1}", quote.Text, quote.Author),
                    GetLockScreenColor(), 45, new Size(768, 1280));

                LockScreen.SetImageUri(lockScreenJpg);
            }
        }
Example #4
0
        private static void UpdateTile(Quote quote)
        {
            var text = string.Format("\"{0}\"", quote.Text);

            var mediumFrontJpg = TileImage.Create("mediumFront.jpg", text, null, GetTileColor(), 45, true, new Size(336, 336));
            var mediumBackJpg = TileImage.Create("mediumBack.jpg", text, null, GetTileColor(), 45, true, new Size(336, 336));
            var wideFrontJpg = TileImage.Create("wideFront.jpg", text, null, GetTileColor(), 45, true, new Size(691, 336));
            var wideBackJpg = TileImage.Create("wideBack.jpg", text, null, GetTileColor(), 45, true, new Size(691, 336));

            ShellTile.ActiveTiles.First().Update(new FlipTileData()
            {
                Title = quote.Author,
                BackTitle = quote.Author,
                BackgroundImage = mediumFrontJpg,
                BackBackgroundImage = mediumBackJpg,
                WideBackgroundImage = wideFrontJpg,
                WideBackBackgroundImage = wideBackJpg
            });
        }