summaryrefslogtreecommitdiff
path: root/Juick/Classes/TileHelper.cs
blob: aa26690f54de068329f0e6c9ab65a7c6f1fb306b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using System;
using Microsoft.Phone.Shell;

namespace Juick.Classes
{
    static class TileHelper
    {
        public static void UpdateFlipTile(
            string title,
            string backTitle,
            string backContent,
            string wideBackContent,
            int? count,
            string smallBackgroundImageStringUri,
            string backgroundImageStringUri,
            string backBackgroundImageStringUri,
            string wideBackgroundImageStringUri,
            string wideBackBackgroundImageStringUri)
        {
            var smallBackgroundImage = CreateRelativeUri(smallBackgroundImageStringUri);
            var backgroundImage = CreateRelativeUri(backgroundImageStringUri);
            var backBackgroundImage = CreateRelativeUri(backBackgroundImageStringUri);
            var wideBackgroundImage = CreateRelativeUri(wideBackgroundImageStringUri);
            var wideBackBackgroundImage = CreateRelativeUri(wideBackBackgroundImageStringUri);
            
            // Loop through any existing Tiles that are pinned to Start.
            foreach (var tileToUpdate in ShellTile.ActiveTiles)
            {
                var updateTileData = new FlipTileData
                                         {
                                             Title = title,
                                             Count = count,
                                             BackTitle = backTitle,
                                             BackContent = backContent,
                                             SmallBackgroundImage = smallBackgroundImage,
                                             BackgroundImage = backgroundImage,
                                             BackBackgroundImage = backBackgroundImage,
                                             WideBackgroundImage = wideBackgroundImage,
                                             WideBackBackgroundImage = wideBackBackgroundImage,
                                             WideBackContent = wideBackContent
                                         };

                tileToUpdate.Update(updateTileData);
            }
        }

        static Uri CreateRelativeUri(string uriString)
        {
            return !string.IsNullOrEmpty(uriString) ? new Uri(uriString, UriKind.Relative) : null;
        }
    }
}