-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Fixed possible NullReferenceExceptions in the Background agent - Moved some tuff into own library to allow sharing it with the background agent class - Changed tile updating to run fully on the phone - Changed primary tile to support wide tiles: ! Still needs a medium and small icon - Known issue: The constructor deletes the tile images for debug purposes. A debug build will not have back background images after the background task has run. This behaviour is not present in release builds. - Moved notification formatting into own helper class - In app notifications are now full text if only one notification is present
- Loading branch information
Showing
23 changed files
with
500 additions
and
192 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
| ||
namespace SparklrWP.Utils | ||
{ | ||
public static class Globals | ||
{ | ||
public delegate void LoggingDelegate(string format, params object[] objects); | ||
public static LoggingDelegate LoggingFunction; | ||
|
||
internal static void log(string format, params object[] objects) | ||
{ | ||
if (LoggingFunction != null) | ||
LoggingFunction(format, objects); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
using ImageTools; | ||
using System; | ||
using System.IO; | ||
using System.Net; | ||
using System.Threading.Tasks; | ||
using System.Windows.Media.Imaging; | ||
|
||
namespace SparklrWP.Utils.Imaging | ||
{ | ||
public static class Helpers | ||
{ | ||
/// <summary> | ||
/// Initializes the Helper class | ||
/// </summary> | ||
static Helpers() | ||
{ | ||
ImageToolsHelper.InitializeImageTools(); | ||
} | ||
|
||
/// <summary> | ||
/// Loads an extended image from an Url asynchronously | ||
/// </summary> | ||
/// <param name="location">The location of the image</param> | ||
/// <returns>A BitmapImage, that can be set as a source</returns> | ||
public static async Task<ExtendedImage> LoadExtendedImageFromUrlAsync(Uri location) | ||
{ | ||
WebClient client = new WebClient(); | ||
ExtendedImage image = new ExtendedImage(); | ||
Stream source = await client.OpenReadTaskAsync(location); | ||
|
||
if (location.ToString().EndsWith("gif", StringComparison.InvariantCultureIgnoreCase)) | ||
{ | ||
image.SetSource(source); | ||
|
||
TaskCompletionSource<ExtendedImage> imageLoaded = new TaskCompletionSource<ExtendedImage>(); | ||
|
||
EventHandler loadingCompleteHandler = new EventHandler((sender, e) => | ||
{ | ||
imageLoaded.SetResult(image); | ||
}); | ||
|
||
EventHandler<UnhandledExceptionEventArgs> loadingFailedHandler = new EventHandler<UnhandledExceptionEventArgs>((sender, e) => | ||
{ | ||
imageLoaded.SetResult(image); | ||
#if DEBUG | ||
if (System.Diagnostics.Debugger.IsAttached) | ||
System.Diagnostics.Debugger.Break(); | ||
#endif | ||
}); | ||
|
||
|
||
|
||
image.LoadingCompleted += loadingCompleteHandler; | ||
image.LoadingFailed += loadingFailedHandler; | ||
|
||
image = await imageLoaded.Task; | ||
|
||
//Remove handlers, otherwise the object might be kept in the memory | ||
image.LoadingCompleted -= loadingCompleteHandler; | ||
image.LoadingFailed -= loadingFailedHandler; | ||
} | ||
else | ||
{ | ||
BitmapImage bmp = new BitmapImage(); | ||
bmp.SetSource(source); | ||
WriteableBitmap writeable = new WriteableBitmap(bmp); | ||
image = ImageExtensions.ToImage(writeable); | ||
} | ||
|
||
source.Close(); | ||
return image; | ||
} | ||
|
||
/// <summary> | ||
/// Loads an extended image from an Url asynchronously | ||
/// </summary> | ||
/// <param name="location">The location of the image</param> | ||
/// <returns>A BitmapImage, that can be set as a source</returns> | ||
public static Task<ExtendedImage> LoadExtendedImageFromUrlAsync(string location) | ||
{ | ||
return LoadExtendedImageFromUrlAsync(new Uri(location)); | ||
} | ||
|
||
/// <summary> | ||
/// Loads an image from an Url asynchronously | ||
/// </summary> | ||
/// <param name="location">The location of the image</param> | ||
/// <returns>A BitmapImage, that can be set as a source</returns> | ||
public static Task<BitmapImage> LoadImageFromUrlAsync(Uri location) | ||
{ | ||
TaskCompletionSource<BitmapImage> loadingTask = new TaskCompletionSource<BitmapImage>(); | ||
SmartDispatcher.BeginInvoke(async () => | ||
{ | ||
WebClient client = new WebClient(); | ||
BitmapImage image = new BitmapImage(); | ||
image.SetSource(await client.OpenReadTaskAsync(location)); | ||
loadingTask.SetResult(image); | ||
}); | ||
return loadingTask.Task; | ||
} | ||
|
||
/// <summary> | ||
/// Loads an image from an Url asynchronously | ||
/// </summary> | ||
/// <param name="location">The location of the image</param> | ||
/// <returns>A BitmapImage, that can be set as a source</returns> | ||
public static Task<BitmapImage> LoadImageFromUrlAsync(string location) | ||
{ | ||
return LoadImageFromUrlAsync(new Uri(location)); | ||
} | ||
} | ||
} |
5 changes: 2 additions & 3 deletions
5
SparklrWP/Utils/ImageToolsHelper.cs → SparklrWP.Utils/ImageToolsHelper.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.