summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Konstantin2013-02-24 01:57:39 +0400
committerGravatar Konstantin2013-02-24 02:00:43 +0400
commitd06477d49cc8e8daf6f87c7b439c2a80515687f1 (patch)
tree24db44dba31f847522cfa5d4e52fec486c5876be
parent3e83f498fdee386ee90730665f6be82fe01e3887 (diff)
update tiles
-rw-r--r--Juick/App.xaml.cs13
-rw-r--r--Juick/ApplicationSmallTile.pngbin0 -> 3889 bytes
-rw-r--r--Juick/ApplicationWideTile.pngbin0 -> 5534 bytes
-rw-r--r--Juick/Classes/TileHelper.cs78
-rw-r--r--Juick/Juick.csproj5
-rw-r--r--Juick/Properties/WMAppManifest.xml3
6 files changed, 97 insertions, 2 deletions
diff --git a/Juick/App.xaml.cs b/Juick/App.xaml.cs
index 9d3ac9a..c0f6134 100644
--- a/Juick/App.xaml.cs
+++ b/Juick/App.xaml.cs
@@ -96,7 +96,18 @@ namespace Juick
// This code will not execute when the application is reactivated
private void Application_Launching(object sender, LaunchingEventArgs e)
{
-
+ const string JuickCaption = "Juick";
+ TileHelper.UpdateFlipTile(
+ JuickCaption,
+ string.Empty,
+ JuickCaption,
+ JuickCaption,
+ null,
+ "/ApplicationSmallTile.png",
+ "/ApplicationTile.png",
+ null,
+ "/ApplicationWideTile.png",
+ null);
}
// Code to execute when the application is activated (brought to foreground)
diff --git a/Juick/ApplicationSmallTile.png b/Juick/ApplicationSmallTile.png
new file mode 100644
index 0000000..95947f4
--- /dev/null
+++ b/Juick/ApplicationSmallTile.png
Binary files differ
diff --git a/Juick/ApplicationWideTile.png b/Juick/ApplicationWideTile.png
new file mode 100644
index 0000000..e0b6bd6
--- /dev/null
+++ b/Juick/ApplicationWideTile.png
Binary files differ
diff --git a/Juick/Classes/TileHelper.cs b/Juick/Classes/TileHelper.cs
new file mode 100644
index 0000000..223340b
--- /dev/null
+++ b/Juick/Classes/TileHelper.cs
@@ -0,0 +1,78 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+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)
+ {
+ if (!CanUseLiveTiles)
+ {
+ return;
+ }
+ var smallBackgroundImage = CreateRelativeUri(smallBackgroundImageStringUri);
+ var backgroundImage = CreateRelativeUri(backgroundImageStringUri);
+ var backBackgroundImage = CreateRelativeUri(backBackgroundImageStringUri);
+ var wideBackgroundImage = CreateRelativeUri(wideBackgroundImageStringUri);
+ var wideBackBackgroundImage = CreateRelativeUri(wideBackBackgroundImageStringUri);
+
+ Type flipTileDataType = Type.GetType("Microsoft.Phone.Shell.FlipTileData, Microsoft.Phone");
+
+ // Get the ShellTile type so we can call the new version of "Update" that takes the new Tile templates.
+ Type shellTileType = Type.GetType("Microsoft.Phone.Shell.ShellTile, Microsoft.Phone");
+
+ // Loop through any existing Tiles that are pinned to Start.
+ foreach (var tileToUpdate in ShellTile.ActiveTiles)
+ {
+ var UpdateTileData = flipTileDataType.GetConstructor(new Type[] { }).Invoke(null);
+
+ // Set the properties.
+ SetProperty(UpdateTileData, "Title", title);
+ SetProperty(UpdateTileData, "Count", count);
+ SetProperty(UpdateTileData, "BackTitle", backTitle);
+ SetProperty(UpdateTileData, "BackContent", backContent);
+ SetProperty(UpdateTileData, "SmallBackgroundImage", smallBackgroundImage);
+ SetProperty(UpdateTileData, "BackgroundImage", backgroundImage);
+ SetProperty(UpdateTileData, "BackBackgroundImage", backBackgroundImage);
+ SetProperty(UpdateTileData, "WideBackgroundImage", wideBackgroundImage);
+ SetProperty(UpdateTileData, "WideBackBackgroundImage", wideBackBackgroundImage);
+ SetProperty(UpdateTileData, "WideBackContent", wideBackContent);
+
+ // Invoke the new version of ShellTile.Update.
+ shellTileType.GetMethod("Update").Invoke(tileToUpdate, new Object[] { UpdateTileData });
+ }
+ }
+
+ static Uri CreateRelativeUri(string uriString)
+ {
+ return !string.IsNullOrEmpty(uriString) ? new Uri(uriString, UriKind.Relative) : null;
+ }
+
+ static void SetProperty(object instance, string name, object value)
+ {
+ var setMethod = instance.GetType().GetProperty(name).GetSetMethod();
+ setMethod.Invoke(instance, new object[] { value });
+ }
+
+ static readonly Version targetedVersion78 = new Version(7, 10, 8858);
+
+ static bool CanUseLiveTiles
+ {
+ get { return Environment.OSVersion.Version >= targetedVersion78; }
+ }
+ }
+}
diff --git a/Juick/Juick.csproj b/Juick/Juick.csproj
index c74da5b..1ae974a 100644
--- a/Juick/Juick.csproj
+++ b/Juick/Juick.csproj
@@ -75,6 +75,7 @@
<Compile Include="Classes\DependencyPropertyListener.cs" />
<Compile Include="Classes\ExpressionHelper.cs" />
<Compile Include="Classes\ScrollViewerMonitor.cs" />
+ <Compile Include="Classes\TileHelper.cs" />
<Compile Include="Controls\HyperLinkRichTextBox.cs" />
<Compile Include="LoginView.xaml.cs">
<DependentUpon>LoginView.xaml</DependentUpon>
@@ -142,7 +143,9 @@
<Resource Include="Images\appbar.favs.addto.rest.png" />
<Resource Include="Images\appbar.favs.rest.png" />
<Resource Include="Images\appbar.feature.camera.rest.png" />
- <Resource Include="ApplicationTile.png" />
+ <Content Include="ApplicationTile.png" />
+ <Content Include="ApplicationSmallTile.png" />
+ <Content Include="ApplicationWideTile.png" />
<Content Include="Images\appbar.attach.png" />
<Content Include="Images\appbar.feature.email.rest.png" />
<Resource Include="Images\appbar.feature.search.rest.png" />
diff --git a/Juick/Properties/WMAppManifest.xml b/Juick/Properties/WMAppManifest.xml
index 8f7b6da..15e3611 100644
--- a/Juick/Properties/WMAppManifest.xml
+++ b/Juick/Properties/WMAppManifest.xml
@@ -33,5 +33,8 @@
<Extensions>
<Extension ExtensionName="Photos_Extra_Share" ConsumerID="{5B04B775-356B-4AA0-AAF8-6491FFEA5632}" TaskID="_default" />
</Extensions>
+ <!--<AppExtra xmlns="" AppPlatformVersion="8.0">
+ <Extra Name="Tiles"/>
+ </AppExtra>-->
</App>
</Deployment> \ No newline at end of file