2011-03-28 21:22:11 +03:00
parent a4c09735f0
commit 00f97e41d6
130 changed files with 13440 additions and 0 deletions
@@ -0,0 +1,58 @@
<?xml version="1.0"?>
<configuration>
<system.serviceModel>
<services>
<service behaviorConfiguration="PushServiceBehavior" name="WindowsPhone.Recipes.Push.Server.Services.PushService">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration=""
contract="WindowsPhone.Recipes.Push.Server.Services.IPushService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8000/PushService/" />
</baseAddresses>
</host>
</service>
<service behaviorConfiguration="ImageServiceBehavior" name="WindowsPhone.Recipes.Push.Server.Services.ImageService">
<endpoint address="" behaviorConfiguration="EndpointImageServiceBehavior"
binding="webHttpBinding" contract="WindowsPhone.Recipes.Push.Server.Services.IImageService" />
<host>
<baseAddresses>
<add baseAddress="http://localhost:8000/ImageService/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="EndpointImageServiceBehavior">
<webHttp />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="ImageServiceBehavior">
<serviceDebug includeExceptionDetailInFaults="false" />
<serviceMetadata httpGetEnabled="true" />
</behavior>
<behavior name="PushServiceBehavior">
<serviceMetadata/>
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
</configuration>
@@ -0,0 +1,22 @@
<Application x:Class="WindowsPhone.Recipes.Push.Server.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Resources/DefaultSkin.xaml"/>
<ResourceDictionary Source="Resources/DataTemplates/AskToPinPushPatternViewModel.xaml"/>
<ResourceDictionary Source="Resources/DataTemplates/CustomTileImagePushPatternViewModel.xaml"/>
<ResourceDictionary Source="Resources/DataTemplates/CounterPushPatternViewModel.xaml"/>
<ResourceDictionary Source="Resources/DataTemplates/OneTimePushPatternViewModel.xaml"/>
<ResourceDictionary Source="Resources/DataTemplates/TileSchedulePushPatternViewModel.xaml"/>
<ResourceDictionary Source="Resources/DataTemplates/MessageStatusViewModel.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
@@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Windows;
using System.ComponentModel.Composition;
using System.ComponentModel.Composition.Hosting;
using WindowsPhone.Recipes.Push.Server.Services;
using WindowsPhone.Recipes.Push.Server.ViewModels;
namespace WindowsPhone.Recipes.Push.Server
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
public CompositionContainer Container { get; private set; }
protected override void OnStartup(StartupEventArgs e)
{
// Initialize MEF to export parts from current assembly.
var catalog = new AssemblyCatalog(typeof(App).Assembly);
Container = new CompositionContainer(catalog);
Container.ComposeParts();
// Create and show the main window where MainViewModel is the default source for data-binding.
new MainWindow
{
DataContext = Container.GetExportedValue<MainViewModel>()
}.Show();
base.OnStartup(e);
}
}
}
@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Imaging;
namespace WindowsPhone.Recipes.Push.Server.Behaviors
{
public interface IVisualHost
{
Visual Visual { get; set; }
}
}
@@ -0,0 +1,59 @@
using System;
using System.Collections;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Interactivity;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.IO;
namespace WindowsPhone.Recipes.Push.Server.Behaviors
{
/// <summary>
/// An attached behavior that handle a visual element from the visual tree to associated view-model implementing the <see cref="IVisualHost"/> interface.
/// </summary>
public class VisualBinderBehavior : Behavior<FrameworkElement>
{
private IVisualHost _visualHost;
protected override void OnAttached()
{
_visualHost = FindVisualHost();
if (_visualHost == null)
{
throw new InvalidOperationException("Visual host wasn't found in the data context hierarchy.");
}
_visualHost.Visual = AssociatedObject;
base.OnAttached();
}
protected override void OnDetaching()
{
_visualHost.Visual = null;
base.OnDetaching();
}
private IVisualHost FindVisualHost()
{
DependencyObject targetObject = AssociatedObject;
IVisualHost visualHost = AssociatedObject.DataContext as IVisualHost;
while (targetObject != null)
{
if (visualHost != null)
{
return visualHost;
}
targetObject = VisualTreeHelper.GetParent(targetObject);
}
return null;
}
}
}
@@ -0,0 +1,49 @@
<Window x:Class="WindowsPhone.Recipes.Push.Server.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow"
Height="700" Width="650" MinHeight="600" MinWidth="650"
WindowStyle="None"
AllowsTransparency="True"
WindowStartupLocation="CenterScreen"
Background="Transparent"
Foreground="{DynamicResource ViewTextBrush}">
<Border BorderThickness="8" CornerRadius="10" Background="#FF2A2A2A">
<Border.BorderBrush>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FF6A6A6A" Offset="0"/>
<GradientStop Color="#FF3D3D3D" Offset="1"/>
<GradientStop Color="#FF848D91" Offset="0.471"/>
</LinearGradientBrush>
</Border.BorderBrush>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="400" />
<RowDefinition Height="*" />
<RowDefinition Height="30" />
</Grid.RowDefinitions>
<TabControl ItemsSource="{Binding PushPatterns}" Margin="4"
SelectedItem="{Binding ActivePattern}"
BorderThickness="0"
Background="{DynamicResource ViewBackgroundBrush}"
ItemContainerStyle="{StaticResource TabItemStyle}"
ContentTemplate="{StaticResource TabContentTemplate}">
</TabControl>
<ContentControl Grid.Row="1" Content="{Binding MessageStatus}" Margin="4" />
<StatusBar Grid.Row="2" Background="{x:Null}" VerticalAlignment="Center">
<StatusBarItem Margin="4,0,0,0" Content="Subscribers: " Background="{x:Null}" Foreground="{StaticResource ViewTextBrush}" />
<StatusBarItem Content="{Binding Subscribers}" Background="{x:Null}" Foreground="{StaticResource ViewTextBrush}" />
</StatusBar>
<Button Content="Button" HorizontalAlignment="Right" Height="16" VerticalAlignment="Top" Width="16" Template="{DynamicResource CloseButtonControlTemplate}" Margin="0,4,4,0" Click="Button_Click" />
</Grid>
</Border>
</Window>
@@ -0,0 +1,45 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.ServiceModel;
using System.Windows.Threading;
using System.ComponentModel.Composition;
using WindowsPhone.Recipes.Push.Server.Services;
namespace WindowsPhone.Recipes.Push.Server
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
{
// Drag window from anywhere.
DragMove();
base.OnMouseLeftButtonDown(e);
}
private void Button_Click(object sender, RoutedEventArgs e)
{
Application.Current.Shutdown();
}
}
}
@@ -0,0 +1,93 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using WindowsPhone.Recipes.Push.Messasges;
using WindowsPhone.Recipes.Push.Server.Models;
namespace WindowsPhone.Recipes.Push.Server.Models
{
/// <summary>
/// Represents a push notification message send response status.
/// </summary>
public class MessageStatus
{
private static readonly Dictionary<Type, string> MessageTypes = new Dictionary<Type, string>
{
{typeof(TilePushNotificationMessage), "Tile"},
{typeof(ToastPushNotificationMessage), "Toast"},
{typeof(RawPushNotificationMessage), "Raw"}
};
/// <summary>
/// Gets the push notification pattern type.
/// </summary>
public string Pattern { get; private set; }
/// <summary>
/// Gets the response time stamp.
/// </summary>
public DateTimeOffset Timestamp { get; private set; }
/// <summary>
/// Gets the message type.
/// </summary>
public string MessageType { get; private set; }
/// <summary>
/// Gets the message ID.
/// </summary>
public Guid MessageId { get; private set; }
/// <summary>
/// Gets the notification channel URI.
/// </summary>
public Uri ChannelUri { get; private set; }
/// <summary>
/// Gets the response status code.
/// </summary>
public HttpStatusCode StatusCode { get; private set; }
/// <summary>
/// Gets the notification status.
/// </summary>
public NotificationStatus NotificationStatus { get; private set; }
/// <summary>
/// Gets the device connection status.
/// </summary>
public DeviceConnectionStatus DeviceConnectionStatus { get; private set; }
/// <summary>
/// Gets the subscription status.
/// </summary>
public SubscriptionStatus SubscriptionStatus { get; private set; }
/// <summary>
/// Initialize a new instance of this type.
/// </summary>
public MessageStatus(string pattern, MessageSendResult result)
{
Pattern = pattern;
Timestamp = result.Timestamp;
MessageType = MessageTypes[result.AssociatedMessage.GetType()];
MessageId = result.AssociatedMessage.Id;
ChannelUri = result.ChannelUri;
StatusCode = result.StatusCode;
NotificationStatus = result.NotificationStatus;
DeviceConnectionStatus = result.DeviceConnectionStatus;
SubscriptionStatus = result.SubscriptionStatus;
}
/// <summary>
/// Initialize a new instance of this type.
/// </summary>
public MessageStatus(PushPatternType pattern, MessageSendException exception)
{
}
}
}
@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
namespace WindowsPhone.Recipes.Push.Server.Models
{
/// <summary>
/// Types of server push patterns.
/// </summary>
public enum PushPatternType
{
/// <value>One time server push pattern.</value>
OneTime,
/// <value>Login counter server push pattern.</value>
LoginCounter,
/// <value>Ask to pin server push pattern.</value>
AskToPin,
/// <value>Custom tile image server push pattern.</value>
CustomTileImage,
/// <value>Tile shedule server push pattern.</value>
TileSchedule,
}
}
@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
namespace WindowsPhone.Recipes.Push.Server.Models
{
/// <summary>
/// Server status data contract.
/// </summary>
[DataContract]
public class ServerInfo
{
/// <summary>
/// Current push pattern.
/// </summary>
[DataMember]
public string PushPattern { get; set; }
/// <summary>
/// Current tile counter value.
/// </summary>
[DataMember]
public int Counter { get; set; }
}
}
@@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security;
namespace WindowsPhone.Recipes.Push.Server.Models
{
/// <summary>
/// Represents user subscription.
/// </summary>
public class Subscription
{
/// <summary>
/// Gets the user name.
/// </summary>
public string UserName { get; private set; }
/// <summary>
/// Gets the notification channel uri.
/// </summary>
public Uri ChannelUri { get; private set; }
/// <summary>
/// Initialize a new instance of this type.
/// </summary>
public Subscription(string userName, Uri channelUri)
{
UserName = userName;
ChannelUri = channelUri;
}
/// <summary>
/// Initialize a new instance of this type.
/// </summary>
public Subscription(string userName, string channelUri)
: this (userName, new Uri(channelUri, UriKind.Absolute))
{
}
}
}
@@ -0,0 +1,55 @@
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("WindowsPhone.Recipes.Push.Server")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("WindowsPhone.Recipes.Push.Server")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2010")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
//In order to begin building localizable applications, set
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
//inside a <PropertyGroup>. For example, if you are using US english
//in your source files, set the <UICulture> to en-US. Then uncomment
//the NeutralResourceLanguage attribute below. Update the "en-US" in
//the line below to match the UICulture setting in the project file.
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
@@ -0,0 +1,63 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.1
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace WindowsPhone.Recipes.Push.Server.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WindowsPhone.Recipes.Push.Server.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}
@@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
@@ -0,0 +1,26 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.1
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace WindowsPhone.Recipes.Push.Server.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
}
}
@@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>
@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
namespace WindowsPhone.Recipes.Push.Server.Resources.Converters
{
/// <summary>
/// Converts null to default tile image.
/// </summary>
public class NullTileImageConverter : IValueConverter
{
/// <value>Default tile image resource relative path.</value>
private static readonly Uri DefaultTileImage = new Uri("/Resources/TileImages/Null.jpg", UriKind.Relative);
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return value ?? DefaultTileImage;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotSupportedException();
}
}
}
@@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using System.IO;
namespace WindowsPhone.Recipes.Push.Server.Resources.Converters
{
/// <summary>
/// Image file name to image file name with relevant path.
/// </summary>
public class UserFileImageConverter : IValueConverter
{
/// <value>Default tile image resource relative path.</value>
private static readonly Uri DefaultTileImage = new Uri("/Resources/TileImages/Null.jpg", UriKind.Relative);
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
Uri imageUri = DefaultTileImage;
string fileName = value as string;
if (value != null)
{
string imageFullPath = Path.Combine(@"Resources\TileImages\Numbers", (string)value);
if (File.Exists(imageFullPath))
{
imageUri = new Uri(@"\" + imageFullPath, UriKind.Relative);
}
}
return imageUri;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotSupportedException();
}
}
}
@@ -0,0 +1,70 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="clr-namespace:WindowsPhone.Recipes.Push.Server.ViewModels"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:behaviors="clr-namespace:WindowsPhone.Recipes.Push.Server.Behaviors"
mc:Ignorable="d">
<DataTemplate DataType="{x:Type vm:AskToPinPushPatternViewModel}">
<Border Style="{DynamicResource ViewBorderStyle}">
<Grid d:LayoutOverrides="Width">
<HeaderedContentControl Width="Auto" VerticalAlignment="Top">
<HeaderedContentControl.Header>
<TextBlock Text="Tile Message" FontWeight="Bold" />
</HeaderedContentControl.Header>
<Grid Height="Auto">
<StackPanel Margin="0,0,185,84">
<TextBlock Text="Count" Margin="4" />
<Slider Minimum="0" Maximum="99" IsSnapToTickEnabled="True" TickFrequency="1" AutoToolTipPlacement="BottomRight" Value="{Binding Count, UpdateSourceTrigger=PropertyChanged}" />
<TextBlock Text="Title" Margin="4" />
<TextBox TextWrapping="Wrap" Margin="4" Text="{Binding Title, UpdateSourceTrigger=PropertyChanged}" />
</StackPanel>
<ListBox ItemsSource="{Binding TileImages}"
SelectedItem="{Binding BackgroundImageUri}"
Margin="0,0,0,-63"
VerticalAlignment="Bottom"
HorizontalAlignment="Right" Width="183"
BorderThickness="0" Background="Transparent"
ItemContainerStyle="{DynamicResource ImageListBoxItemStyle}">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Image Source="{Binding}" Width="48" Height="48" Stretch="UniformToFill" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ListBox>
<Border BorderThickness="5" BorderBrush="#FFDEDEDE" Background="#FF333333" HorizontalAlignment="Right" VerticalAlignment="Center">
<Grid Width="173" Height="173">
<Image Source="{Binding BackgroundImageUri, Converter={StaticResource NullTileImageConverter}}" Stretch="UniformToFill" />
<Grid x:Name="counter" HorizontalAlignment="Right" Height="30.733" Margin="0,12,12,0" VerticalAlignment="Top" Width="30.733">
<Ellipse Fill="Black" HorizontalAlignment="Stretch" Height="Auto" Margin="0" Stroke="Black" VerticalAlignment="Stretch" Width="Auto" StrokeThickness="0"/>
<TextBlock HorizontalAlignment="Center" Height="Auto" TextWrapping="Wrap" Text="{Binding Count}" VerticalAlignment="Stretch" Width="Auto" TextAlignment="Center" FontSize="21.333" d:LayoutOverrides="Height" Margin="0,-0.321,0,2.679"/>
</Grid>
<TextBlock Height="22" TextWrapping="NoWrap" Text="{Binding Title}" VerticalAlignment="Bottom" Margin="6,0,6,6" FontSize="18.667" FontWeight="Bold" Width="158" HorizontalAlignment="Center"/>
</Grid>
</Border>
</Grid>
</HeaderedContentControl>
<Button Content="Send" Height="Auto" Command="{Binding SendCommand}" VerticalAlignment="Bottom" d:LayoutOverrides="GridBox" Width="64" RenderTransformOrigin="2.643,1.088" HorizontalAlignment="Right" Margin="0,0,0,2.68" />
</Grid>
</Border>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding Count}" Value="0">
<Setter TargetName="counter" Property="Visibility" Value="Hidden" />
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
</ResourceDictionary>
@@ -0,0 +1,60 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="clr-namespace:WindowsPhone.Recipes.Push.Server.ViewModels"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:behaviors="clr-namespace:WindowsPhone.Recipes.Push.Server.Behaviors"
mc:Ignorable="d">
<DataTemplate DataType="{x:Type vm:CounterPushPatternViewModel}">
<Border Style="{DynamicResource ViewBorderStyle}">
<Grid d:LayoutOverrides="Width">
<HeaderedContentControl Width="Auto" VerticalAlignment="Top">
<HeaderedContentControl.Header>
<TextBlock Text="Tile Message" FontWeight="Bold" />
</HeaderedContentControl.Header>
<Grid Height="Auto">
<StackPanel Margin="0,0,185,84">
<TextBlock Text="Title" Margin="4" />
<TextBox TextWrapping="Wrap" Margin="4" Text="{Binding Title, UpdateSourceTrigger=PropertyChanged}" />
</StackPanel>
<ListBox ItemsSource="{Binding TileImages}"
SelectedItem="{Binding BackgroundImageUri}"
Margin="0,0,0,-63"
VerticalAlignment="Bottom"
HorizontalAlignment="Right"
Width="183"
BorderThickness="0" Background="Transparent"
ItemContainerStyle="{DynamicResource ImageListBoxItemStyle}">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Image Source="{Binding}" Width="48" Height="48" Stretch="UniformToFill" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ListBox>
<Border BorderThickness="5" BorderBrush="#FFDEDEDE" Background="#FF333333" HorizontalAlignment="Right" VerticalAlignment="Center">
<Grid Width="173" Height="173">
<Image Source="{Binding BackgroundImageUri, Converter={StaticResource NullTileImageConverter}}" Stretch="UniformToFill" />
<TextBlock Height="22" TextWrapping="NoWrap" Text="{Binding Title}" VerticalAlignment="Bottom" Margin="6,0,6,6" FontSize="18.667" FontWeight="Bold" Width="158" HorizontalAlignment="Center"/>
</Grid>
</Border>
</Grid>
</HeaderedContentControl>
<Button Content="Send" Height="Auto" Command="{Binding SendCommand}" VerticalAlignment="Bottom" d:LayoutOverrides="GridBox" Width="64" RenderTransformOrigin="2.643,1.088" HorizontalAlignment="Right" Margin="0,0,0,2.68" />
</Grid>
</Border>
</DataTemplate>
</ResourceDictionary>
@@ -0,0 +1,84 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="clr-namespace:WindowsPhone.Recipes.Push.Server.ViewModels"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:behaviors="clr-namespace:WindowsPhone.Recipes.Push.Server.Behaviors"
mc:Ignorable="d">
<DataTemplate DataType="{x:Type vm:CustomTileImagePushPatternViewModel}">
<Border Style="{DynamicResource ViewBorderStyle}">
<Grid>
<HeaderedContentControl Width="Auto" VerticalAlignment="Top">
<HeaderedContentControl.Header>
<TextBlock Text="Tile Message" FontWeight="Bold" />
</HeaderedContentControl.Header>
<Grid>
<Border Grid.Column="1" Grid.Row="1" BorderThickness="5" BorderBrush="#FFDEDEDE" Width="Auto" Height="Auto" Background="#FF333333" HorizontalAlignment="Right" VerticalAlignment="Top">
<Grid Width="Auto" Height="Auto">
<Grid Width="173" Height="173">
<i:Interaction.Behaviors>
<behaviors:VisualBinderBehavior />
</i:Interaction.Behaviors>
<Image Source="{Binding TileBackground, Converter={StaticResource NullTileImageConverter}}" Stretch="UniformToFill" />
<TextBlock HorizontalAlignment="Center" Margin="4,48,4,0" TextWrapping="Wrap" FontSize="{Binding TextSize}" Foreground="{Binding TextColors/}" Text="{Binding FreeText}" VerticalAlignment="Top"/>
<Rectangle Fill="Transparent" Stroke="Black">
<Rectangle.InputBindings>
<MouseBinding MouseAction="LeftClick" Command="{Binding PickImageCommand}" />
</Rectangle.InputBindings>
</Rectangle>
</Grid>
<Grid x:Name="counter" HorizontalAlignment="Right" Height="30.733" Margin="0,12,12,0" VerticalAlignment="Top" Width="30.733">
<Ellipse Fill="Black" HorizontalAlignment="Stretch" Height="Auto" Margin="0" Stroke="Black" VerticalAlignment="Stretch" Width="Auto" StrokeThickness="0"/>
<TextBlock HorizontalAlignment="Center" Height="Auto" TextWrapping="Wrap" Text="{Binding Count}" VerticalAlignment="Stretch" Width="Auto" TextAlignment="Center" FontSize="21.333" d:LayoutOverrides="Height" Margin="0,-0.321,0,2.679"/>
</Grid>
<TextBlock Height="22" TextWrapping="NoWrap" Text="{Binding Title}" VerticalAlignment="Bottom" Margin="6,0,6,6" FontSize="18.667" FontWeight="Bold" Width="158" HorizontalAlignment="Center"/>
<TextBlock x:Name="ImageComment" HorizontalAlignment="Center" TextWrapping="Wrap" VerticalAlignment="Center" />
</Grid>
</Border>
<StackPanel Grid.Row="0" HorizontalAlignment="Stretch" Margin="0,0,187,0" d:LayoutOverrides="GridBox">
<TextBlock TextWrapping="Wrap" Text="Free Text" Margin="4" />
<TextBox TextWrapping="Wrap" Margin="4" Text="{Binding FreeText, UpdateSourceTrigger=PropertyChanged}" />
<TextBlock TextWrapping="Wrap" Text="Text Size" Margin="4" />
<Slider Minimum="18" Maximum="32" IsSnapToTickEnabled="True" TickFrequency="2" AutoToolTipPlacement="BottomRight" Value="{Binding TextSize, UpdateSourceTrigger=PropertyChanged}" />
<TextBlock TextWrapping="Wrap" Text="Text Color" Margin="4" />
<ComboBox ItemsSource="{Binding TextColors}" SelectedIndex="0" IsSynchronizedWithCurrentItem="True">
<ComboBox.ItemTemplate>
<DataTemplate>
<DockPanel Height="36">
<Rectangle Stroke="Black" StrokeThickness="0.5" Fill="{Binding FallbackValue=Transparent}" Width="120" Height="28" Margin="4" />
</DockPanel>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<TextBlock TextWrapping="Wrap" Text="Count" Margin="4" />
<Slider Minimum="0" Maximum="99" IsSnapToTickEnabled="True" TickFrequency="1" AutoToolTipPlacement="BottomRight" Value="{Binding Count, UpdateSourceTrigger=PropertyChanged}" />
<TextBlock TextWrapping="Wrap" Text="Title" Margin="4" />
<TextBox TextWrapping="Wrap" Margin="4" Text="{Binding Title, UpdateSourceTrigger=PropertyChanged}" />
</StackPanel>
</Grid>
</HeaderedContentControl>
<Button Content="Send" Height="Auto" Command="{Binding SendCommand}" VerticalAlignment="Bottom" d:LayoutOverrides="GridBox" Width="64" RenderTransformOrigin="2.643,1.088" HorizontalAlignment="Right" Margin="0,0,0,2.68" />
</Grid>
</Border>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding Count}" Value="0">
<Setter TargetName="counter" Property="Visibility" Value="Hidden" />
</DataTrigger>
<DataTrigger Binding="{Binding TileBackground}" Value="{x:Null}">
<Setter TargetName="ImageComment" Property="Text" Value="Click here to pick an image" />
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
</ResourceDictionary>
@@ -0,0 +1,160 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="clr-namespace:WindowsPhone.Recipes.Push.Server.ViewModels"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:behaviors="clr-namespace:WindowsPhone.Recipes.Push.Server.Behaviors"
mc:Ignorable="d">
<DataTemplate DataType="{x:Type vm:MessageStatusViewModel}">
<DataTemplate.Resources>
<Style x:Key="DefaultGridElementStyle" TargetType="{x:Type TextBlock}">
<Setter Property="Padding" Value="15,3,0,3" />
</Style>
</DataTemplate.Resources>
<Grid>
<DataGrid ItemsSource="{Binding Status}"
AutoGenerateColumns="False"
IsReadOnly="True"
SelectionMode="Single"
SelectionUnit="FullRow"
CanUserResizeRows="False"
HeadersVisibility="Column"
BorderThickness="2"
BorderBrush="{StaticResource ViewBackgroundBrush}"
GridLinesVisibility="None"
AlternatingRowBackground="#FF535353"
RowDetailsVisibilityMode="VisibleWhenSelected"
Background="{DynamicResource ViewBackgroundBrush}"
Foreground="{DynamicResource ViewTextBrush}"
RowBackground="#FF424242" ColumnHeaderStyle="{DynamicResource DataGridColumnHeaderStyle}" CellStyle="{DynamicResource DataGridCellStyle}">
<DataGrid.Columns>
<DataGridTextColumn Header="Pattern" Binding="{Binding Pattern, Mode=OneTime}" ElementStyle="{StaticResource DefaultGridElementStyle}" />
<DataGridTextColumn Header="Message" Binding="{Binding MessageType, Mode=OneTime}" ElementStyle="{StaticResource DefaultGridElementStyle}" />
<DataGridTemplateColumn Header="Status">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<StackPanel Margin="15,0,0,0" VerticalAlignment="Center" Orientation="Horizontal">
<Ellipse x:Name="indicator" VerticalAlignment="Center" Margin="0,0,6,0" Width="6" Height="6" Fill="Red" />
<TextBlock VerticalAlignment="Center" Text="{Binding StatusCode, Mode=OneTime}" />
</StackPanel>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding StatusCode}" Value="OK">
<Setter TargetName="indicator" Property="Fill" Value="LightGreen" />
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Header="Connection">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<StackPanel Margin="15,0,0,0" VerticalAlignment="Center" Orientation="Horizontal">
<Ellipse x:Name="indicator" VerticalAlignment="Center" Margin="0,0,6,0" Width="6" Height="6" />
<TextBlock VerticalAlignment="Center" Text="{Binding DeviceConnectionStatus, Mode=OneTime}" />
</StackPanel>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding DeviceConnectionStatus}" Value="Connected">
<Setter TargetName="indicator" Property="Fill" Value="LightGreen" />
</DataTrigger>
<DataTrigger Binding="{Binding DeviceConnectionStatus}" Value="TempDisconnected">
<Setter TargetName="indicator" Property="Fill" Value="Red" />
</DataTrigger>
<DataTrigger Binding="{Binding DeviceConnectionStatus}" Value="Inactive">
<Setter TargetName="indicator" Property="Fill" Value="Gray" />
</DataTrigger>
<DataTrigger Binding="{Binding DeviceConnectionStatus}" Value="NotApplicable">
<Setter TargetName="indicator" Property="Fill" Value="Black" />
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Header="Subscription">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<StackPanel Margin="15,0,0,0" VerticalAlignment="Center" Orientation="Horizontal">
<Ellipse x:Name="indicator" VerticalAlignment="Center" Margin="0,0,6,0" Width="6" Height="6" />
<TextBlock VerticalAlignment="Center" Text="{Binding SubscriptionStatus, Mode=OneTime}" />
</StackPanel>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding SubscriptionStatus}" Value="Active">
<Setter TargetName="indicator" Property="Fill" Value="LightGreen" />
</DataTrigger>
<DataTrigger Binding="{Binding SubscriptionStatus}" Value="Expired">
<Setter TargetName="indicator" Property="Fill" Value="Red" />
</DataTrigger>
<DataTrigger Binding="{Binding SubscriptionStatus}" Value="NotApplicable">
<Setter TargetName="indicator" Property="Fill" Value="Black" />
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTemplateColumn Header="Notification">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<StackPanel Margin="15,0,0,0" VerticalAlignment="Center" Orientation="Horizontal">
<Ellipse x:Name="indicator" VerticalAlignment="Center" Margin="0,0,6,0" Width="6" Height="6" />
<TextBlock VerticalAlignment="Center" Text="{Binding NotificationStatus, Mode=OneTime}" />
</StackPanel>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding NotificationStatus}" Value="Received">
<Setter TargetName="indicator" Property="Fill" Value="LightGreen" />
</DataTrigger>
<DataTrigger Binding="{Binding NotificationStatus}" Value="QueueFull">
<Setter TargetName="indicator" Property="Fill" Value="Red" />
</DataTrigger>
<DataTrigger Binding="{Binding NotificationStatus}" Value="Suppressed">
<Setter TargetName="indicator" Property="Fill" Value="Gray" />
</DataTrigger>
<DataTrigger Binding="{Binding NotificationStatus}" Value="Dropped">
<Setter TargetName="indicator" Property="Fill" Value="Gray" />
</DataTrigger>
<DataTrigger Binding="{Binding NotificationStatus}" Value="NotApplicable">
<Setter TargetName="indicator" Property="Fill" Value="Black" />
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns>
<DataGrid.RowDetailsTemplate>
<DataTemplate>
<StackPanel Margin="2" Background="#FF2A2A2A">
<StackPanel Margin="1">
<TextBlock FontWeight="Bold" Margin="0,0,0,1" Text="Time Stamp" />
<TextBlock Text="{Binding Timestamp, Mode=OneTime, StringFormat=G}" />
</StackPanel>
<StackPanel Margin="1">
<TextBlock FontWeight="Bold" Margin="0,0,0,1" Text="Message Id" />
<TextBlock Text="{Binding MessageId, Mode=OneTime}" />
</StackPanel>
<StackPanel Margin="1">
<TextBlock FontWeight="Bold" Margin="0,0,0,1" Text="Channel URI" />
<TextBlock Text="{Binding ChannelUri, Mode=OneTime}" />
</StackPanel>
</StackPanel>
</DataTemplate>
</DataGrid.RowDetailsTemplate>
</DataGrid>
</Grid>
</DataTemplate>
</ResourceDictionary>
@@ -0,0 +1,92 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="clr-namespace:WindowsPhone.Recipes.Push.Server.ViewModels"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:behaviors="clr-namespace:WindowsPhone.Recipes.Push.Server.Behaviors"
mc:Ignorable="d">
<DataTemplate DataType="{x:Type vm:OneTimePushPatternViewModel}">
<Border Style="{DynamicResource ViewBorderStyle}">
<Grid d:LayoutOverrides="Width">
<HeaderedContentControl Width="Auto" VerticalAlignment="Top">
<HeaderedContentControl.Header>
<CheckBox Content="Tile Message" FontWeight="Bold" Foreground="{StaticResource ViewTextBrush}" IsChecked="{Binding IsTileEnabled, Mode=TwoWay}" />
</HeaderedContentControl.Header>
<Grid Height="Auto">
<StackPanel Margin="0,0,185,84">
<TextBlock Text="Count" Margin="4" />
<Slider Minimum="0" Maximum="99" IsSnapToTickEnabled="True" TickFrequency="1" AutoToolTipPlacement="BottomRight" Value="{Binding Count, UpdateSourceTrigger=PropertyChanged}" />
<TextBlock Text="Title" Margin="4" />
<TextBox TextWrapping="Wrap" Margin="4" Text="{Binding Title, UpdateSourceTrigger=PropertyChanged}" />
</StackPanel>
<ListBox ItemsSource="{Binding TileImages}"
SelectedItem="{Binding BackgroundImageUri}"
Margin="0,0,0,-63"
VerticalAlignment="Bottom"
HorizontalAlignment="Right"
Width="183"
BorderThickness="0" Background="Transparent"
ItemContainerStyle="{DynamicResource ImageListBoxItemStyle}">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Image x:Name="image" Source="{Binding}" Width="48" Height="48" Stretch="UniformToFill" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ListBox>
<Border BorderThickness="5" BorderBrush="#FFDEDEDE" Background="#FF333333" HorizontalAlignment="Right" VerticalAlignment="Center">
<Grid Width="173" Height="173">
<Image Source="{Binding BackgroundImageUri, Converter={StaticResource NullTileImageConverter}}" Stretch="UniformToFill" />
<Grid x:Name="counter" HorizontalAlignment="Right" Height="30.733" Margin="0,12,12,0" VerticalAlignment="Top" Width="30.733">
<Ellipse Fill="Black" HorizontalAlignment="Stretch" Height="Auto" Margin="0" Stroke="Black" VerticalAlignment="Stretch" Width="Auto" StrokeThickness="0"/>
<TextBlock HorizontalAlignment="Center" Height="Auto" TextWrapping="Wrap" Text="{Binding Count}" VerticalAlignment="Stretch" Width="Auto" TextAlignment="Center" FontSize="21.333" d:LayoutOverrides="Height" Margin="0,-0.321,0,2.679"/>
</Grid>
<TextBlock Height="22" TextWrapping="NoWrap" Text="{Binding Title}" VerticalAlignment="Bottom" Margin="6,0,6,6" FontSize="18.667" FontWeight="Bold" Width="158" HorizontalAlignment="Center"/>
</Grid>
</Border>
</Grid>
</HeaderedContentControl>
<HeaderedContentControl Width="Auto" HorizontalContentAlignment="Stretch" Margin="0,130.6,184,0" VerticalAlignment="Top">
<HeaderedContentControl.Header>
<CheckBox Content="Raw Message" FontWeight="Bold" Foreground="{StaticResource ViewTextBrush}" IsChecked="{Binding IsRawEnabled, Mode=TwoWay}" />
</HeaderedContentControl.Header>
<StackPanel Margin="4">
<TextBlock Text="Raw Message" Margin="4" />
<TextBox Margin="4" Text="{Binding RawMessage, UpdateSourceTrigger=PropertyChanged}" />
</StackPanel>
</HeaderedContentControl>
<HeaderedContentControl Width="Auto" Margin="0,215.52,184,0" VerticalAlignment="Stretch" d:LayoutOverrides="Height">
<HeaderedContentControl.Header>
<CheckBox Content="Toast Message" FontWeight="Bold" Foreground="{StaticResource ViewTextBrush}" IsChecked="{Binding IsToastEnabled, Mode=TwoWay}" />
</HeaderedContentControl.Header>
<StackPanel Margin="4">
<TextBlock Text="Title" Margin="4" />
<TextBox Margin="4" Text="{Binding ToastTitle, UpdateSourceTrigger=PropertyChanged}" />
<TextBlock Text="Subtitle" Margin="4" />
<TextBox Margin="4" Text="{Binding ToastSubTitle, UpdateSourceTrigger=PropertyChanged}" />
</StackPanel>
</HeaderedContentControl>
<Button Content="Send" Height="Auto" Command="{Binding SendCommand}" VerticalAlignment="Bottom" d:LayoutOverrides="GridBox" Width="64" RenderTransformOrigin="2.643,1.088" HorizontalAlignment="Right" Margin="0,0,0,2.68" />
</Grid>
</Border>
<DataTemplate.Triggers>
<DataTrigger Binding="{Binding Count}" Value="0">
<Setter TargetName="counter" Property="Visibility" Value="Hidden" />
</DataTrigger>
</DataTemplate.Triggers>
</DataTemplate>
</ResourceDictionary>
@@ -0,0 +1,38 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="clr-namespace:WindowsPhone.Recipes.Push.Server.ViewModels"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:behaviors="clr-namespace:WindowsPhone.Recipes.Push.Server.Behaviors"
mc:Ignorable="d">
<DataTemplate DataType="{x:Type vm:TileSchedulePushPatternViewModel}">
<Border Style="{DynamicResource ViewBorderStyle}">
<Grid d:LayoutOverrides="Width">
<HeaderedContentControl Width="Auto" VerticalAlignment="Top">
<HeaderedContentControl.Header>
<TextBlock Text="User Parameters" FontWeight="Bold" />
</HeaderedContentControl.Header>
<Grid Height="Auto">
<StackPanel Margin="0,0,185,84">
<TextBlock Text="Image File Name" Margin="4" />
<TextBox IsReadOnly="True" TextWrapping="Wrap" Margin="4" Text="{Binding ImageFileName, UpdateSourceTrigger=PropertyChanged}" />
</StackPanel>
<Border BorderThickness="5" BorderBrush="#FFDEDEDE" Background="#FF333333" HorizontalAlignment="Right" VerticalAlignment="Center">
<Grid Width="173" Height="173">
<Image Source="{Binding ImageFileName, Converter={StaticResource UserFileImageConverter}}" Stretch="UniformToFill" />
<TextBlock Height="22" TextWrapping="NoWrap" Text="{Binding Title}" VerticalAlignment="Bottom" Margin="6,0,6,6" FontSize="18.667" FontWeight="Bold" Width="158" HorizontalAlignment="Center"/>
</Grid>
</Border>
</Grid>
</HeaderedContentControl>
</Grid>
</Border>
</DataTemplate>
</ResourceDictionary>
@@ -0,0 +1,507 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vm="clr-namespace:WindowsPhone.Recipes.Push.Server.ViewModels"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:behaviors="clr-namespace:WindowsPhone.Recipes.Push.Server.Behaviors"
xmlns:converters="clr-namespace:WindowsPhone.Recipes.Push.Server.Resources.Converters"
xmlns:Microsoft_Windows_Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero"
mc:Ignorable="d">
<!-- Converters -->
<converters:NullTileImageConverter x:Key="NullTileImageConverter" />
<converters:UserFileImageConverter x:Key="UserFileImageConverter" />
<!-- Brushes -->
<SolidColorBrush x:Key="ViewBackgroundBrush" Color="#FF595959"/>
<SolidColorBrush x:Key="SelectedViewBackgroundBrush" Color="Gray"/>
<SolidColorBrush x:Key="ViewTextBrush" Color="#FFF3F3F3"/>
<SolidColorBrush x:Key="TabControlNormalBorderBrush" Color="#8C8E94"/>
<SolidColorBrush x:Key="StandardBorderBrush" Color="DarkGray"></SolidColorBrush>
<SolidColorBrush x:Key="StandardBrush" Color="LightGray"></SolidColorBrush>
<SolidColorBrush x:Key="PressedBrush" Color="Gray"></SolidColorBrush>
<SolidColorBrush x:Key="HoverBrush" Color="#fefefe"></SolidColorBrush>
<SolidColorBrush x:Key="GlyphBrush" Color="#333333"></SolidColorBrush>
<SolidColorBrush x:Key="{x:Static DataGrid.FocusBorderBrushKey}" Color="#FF000000"/>
<!-- Styles -->
<Style x:Key="ViewBorderStyle" TargetType="{x:Type Border}">
<Setter Property="TextElement.Foreground" Value="{DynamicResource ViewTextBrush}" />
<Setter Property="Background" Value="Transparent" />
</Style>
<Style x:Key="ImageListBoxItemStyle" TargetType="{x:Type ListBoxItem}">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="VerticalContentAlignment" Value="Stretch"/>
<Setter Property="Padding" Value="3"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListBoxItem}">
<Border x:Name="Bd" CornerRadius="3" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="true" RenderTransformOrigin="0.5,0.5">
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="true">
<Setter Property="Background" TargetName="Bd" Value="AliceBlue"/>
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsSelected" Value="true"/>
<Condition Property="Selector.IsSelectionActive" Value="false"/>
</MultiTrigger.Conditions>
<Setter Property="Background" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
</MultiTrigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="TabItemStyle" TargetType="{x:Type TabItem}">
<Setter Property="Foreground" Value="{DynamicResource ViewTextBrush}" />
<Setter Property="Background" Value="{DynamicResource ViewBackgroundBrush}" />
<Setter Property="Header" Value="{Binding DisplayName}" />
<Setter Property="Template" Value="{DynamicResource TabItemControlTemplate}"/>
</Style>
<ControlTemplate x:Key="TabItemControlTemplate" TargetType="{x:Type TabItem}">
<Grid SnapsToDevicePixels="True">
<Border x:Name="Bd" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="1,1,1,0" Padding="{TemplateBinding Padding}" Background="#FF404040">
<ContentPresenter x:Name="Content" ContentTemplate="{TemplateBinding HeaderTemplate}" Content="{TemplateBinding Header}" ContentStringFormat="{TemplateBinding HeaderStringFormat}" ContentSource="Header" HorizontalAlignment="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type ItemsControl}}}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{Binding VerticalContentAlignment, RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type ItemsControl}}}"/>
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" TargetName="Bd" Value="{DynamicResource SelectedViewBackgroundBrush}"/>
</Trigger>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Panel.ZIndex" Value="1"/>
<Setter Property="Background" TargetName="Bd" Value="{DynamicResource ViewBackgroundBrush}"/>
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsSelected" Value="False"/>
<Condition Property="IsMouseOver" Value="True"/>
</MultiTrigger.Conditions>
<Setter Property="BorderBrush" TargetName="Bd" Value="#FF3C7FB1"/>
</MultiTrigger>
<Trigger Property="TabStripPlacement" Value="Bottom">
<Setter Property="BorderThickness" TargetName="Bd" Value="1,0,1,1"/>
</Trigger>
<Trigger Property="TabStripPlacement" Value="Left">
<Setter Property="BorderThickness" TargetName="Bd" Value="1,1,0,1"/>
</Trigger>
<Trigger Property="TabStripPlacement" Value="Right">
<Setter Property="BorderThickness" TargetName="Bd" Value="0,1,1,1"/>
</Trigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsSelected" Value="True"/>
<Condition Property="TabStripPlacement" Value="Top"/>
</MultiTrigger.Conditions>
<Setter Property="Margin" Value="-2,-2,-2,-1"/>
<Setter Property="Margin" TargetName="Content" Value="0,0,0,1"/>
</MultiTrigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsSelected" Value="True"/>
<Condition Property="TabStripPlacement" Value="Bottom"/>
</MultiTrigger.Conditions>
<Setter Property="Margin" Value="-2,-1,-2,-2"/>
<Setter Property="Margin" TargetName="Content" Value="0,1,0,0"/>
</MultiTrigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsSelected" Value="True"/>
<Condition Property="TabStripPlacement" Value="Left"/>
</MultiTrigger.Conditions>
<Setter Property="Margin" Value="-2,-2,-1,-2"/>
<Setter Property="Margin" TargetName="Content" Value="0,0,1,0"/>
</MultiTrigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsSelected" Value="True"/>
<Condition Property="TabStripPlacement" Value="Right"/>
</MultiTrigger.Conditions>
<Setter Property="Margin" Value="-1,-2,-2,-2"/>
<Setter Property="Margin" TargetName="Content" Value="1,0,0,0"/>
</MultiTrigger>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Background" TargetName="Bd" Value="#FFF4F4F4"/>
<Setter Property="BorderBrush" TargetName="Bd" Value="#FFC9C7BA"/>
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<DataTemplate x:Key="TabContentTemplate">
<Border BorderThickness="0">
<DockPanel LastChildFill="True">
<Border DockPanel.Dock="Right" BorderBrush="Black" BorderThickness="1" Width="150" Padding="4" Margin="2,0,0,0" Background="{DynamicResource ViewBackgroundBrush}">
<HeaderedContentControl Foreground="{DynamicResource ViewTextBrush}">
<HeaderedContentControl.Header>
<TextBlock Text="{Binding DisplayName}" FontWeight="Bold" />
</HeaderedContentControl.Header>
<TextBlock Text="{Binding Description}" TextWrapping="Wrap" FontSize="12" />
</HeaderedContentControl>
</Border>
<Border BorderBrush="Black" BorderThickness="1" Margin="0,0,2,0" Padding="4" Background="{DynamicResource ViewBackgroundBrush}">
<ContentControl Content="{Binding}" Foreground="{DynamicResource ViewTextBrush}" />
</Border>
</DockPanel>
</Border>
</DataTemplate>
<ControlTemplate x:Key="CloseButtonControlTemplate" TargetType="{x:Type Button}">
<Grid x:Name="grid" Width="Auto" Height="Auto" Background="{x:Null}">
<Path Data="M8.75,0 L11.25,0 11.25,8.75 20,8.75 20,11.25 11.25,11.25 11.25,20 8.75,20 8.75,11.25 0,11.25 0,8.75 8.75,8.75 z" Fill="#FFF4F4F5" Height="Auto" Stretch="Fill" HorizontalAlignment="Center" VerticalAlignment="Center" RenderTransformOrigin="0.5,0.5">
<Path.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform Angle="45"/>
<TranslateTransform/>
</TransformGroup>
</Path.RenderTransform>
</Path>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" TargetName="grid">
<Setter.Value>
<RadialGradientBrush>
<GradientStop Color="#7CFFAF00" Offset="0"/>
<GradientStop Color="#1CE9A000" Offset="1"/>
</RadialGradientBrush>
</Setter.Value>
</Setter>
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter Property="Background" TargetName="grid">
<Setter.Value>
<RadialGradientBrush>
<GradientStop Color="#BCFFB800" Offset="0.216"/>
<GradientStop Color="#80795800" Offset="1"/>
</RadialGradientBrush>
</Setter.Value>
</Setter>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<Style x:Key="ColumnHeaderGripperStyle" TargetType="{x:Type Thumb}">
<Setter Property="Width" Value="1"/>
<Setter Property="Background" Value="DarkGray"/>
<Setter Property="Cursor" Value="SizeWE"/>
</Style>
<Style x:Key="DataGridColumnHeaderStyle" TargetType="{x:Type DataGridColumnHeader}">
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Padding" Value="4" />
<Setter Property="MinWidth" Value="80" />
<Setter Property="MinHeight" Value="30" />
<Setter Property="Background" Value="{DynamicResource ViewBackgroundBrush}"/>
<Setter Property="Foreground" Value="{DynamicResource ViewTextBrush}"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type DataGridColumnHeader}">
<Grid>
<Microsoft_Windows_Themes:DataGridHeaderBorder BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" IsClickable="{TemplateBinding CanUserSort}" IsPressed="{TemplateBinding IsPressed}" IsHovered="{TemplateBinding IsMouseOver}" Padding="{TemplateBinding Padding}" SortDirection="{TemplateBinding SortDirection}" SeparatorBrush="{TemplateBinding SeparatorBrush}" SeparatorVisibility="{TemplateBinding SeparatorVisibility}">
<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
</Microsoft_Windows_Themes:DataGridHeaderBorder>
<Thumb x:Name="PART_LeftHeaderGripper" HorizontalAlignment="Left" Style="{StaticResource ColumnHeaderGripperStyle}"/>
<Thumb x:Name="PART_RightHeaderGripper" HorizontalAlignment="Right" Style="{StaticResource ColumnHeaderGripperStyle}"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="DataGridCellStyle" TargetType="{x:Type DataGridCell}">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderBrush" Value="Transparent"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type DataGridCell}">
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" SnapsToDevicePixels="True">
<ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="BorderThickness" Value="0"/>
</Style>
<Style x:Key="VerticalScrollBarThumbStyle" TargetType="{x:Type Thumb}">
<Setter Property="IsTabStop" Value="False"/>
<Setter Property="Focusable" Value="False"/>
<Setter Property="Margin" Value="1,0,1,0" />
<Setter Property="BorderBrush" Value="{StaticResource StandardBorderBrush}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Thumb}">
<Rectangle Width="8" Name="ellipse" Stroke="{StaticResource StandardBorderBrush}"
Fill="{StaticResource StandardBrush}"
RadiusX="5" RadiusY="5"></Rectangle>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="ellipse" Property="Fill" Value="{StaticResource HoverBrush}"></Setter>
</Trigger>
<Trigger Property="IsDragging" Value="True">
<Setter TargetName="ellipse" Property="Fill" Value="{StaticResource PressedBrush}"></Setter>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="HorizontalScrollBarThumbStyle" TargetType="{x:Type Thumb}">
<Setter Property="IsTabStop" Value="False"/>
<Setter Property="Focusable" Value="False"/>
<Setter Property="Margin" Value="0,1,0,1" />
<Setter Property="BorderBrush" Value="{StaticResource StandardBorderBrush}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Thumb}">
<Rectangle Height="8" Name="ellipse" Stroke="{StaticResource StandardBorderBrush}"
Fill="{StaticResource StandardBrush}"
RadiusX="5" RadiusY="5"></Rectangle>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="ellipse" Property="Fill" Value="{StaticResource HoverBrush}"></Setter>
</Trigger>
<Trigger Property="IsDragging" Value="True">
<Setter TargetName="ellipse" Property="Fill" Value="{StaticResource PressedBrush}"></Setter>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="LineButtonUpStyle" TargetType="{x:Type RepeatButton}">
<Setter Property="Focusable" Value="False"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type RepeatButton}">
<Grid Margin="1" Height="18" >
<Path Stretch="None" HorizontalAlignment="Center"
VerticalAlignment="Center" Name="Path" Fill="{StaticResource StandardBrush}"
Data="M 0 8 L 8 8 L 4 0 Z"></Path>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="Path" Property="Fill"
Value="{StaticResource HoverBrush}" />
</Trigger>
<Trigger Property="IsPressed" Value="true">
<Setter TargetName="Path" Property="Fill"
Value="{StaticResource PressedBrush}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="LineButtonDownStyle" TargetType="{x:Type RepeatButton}">
<Setter Property="Focusable" Value="False"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type RepeatButton}">
<Grid Margin="1" Height="18" >
<Path Stretch="None" HorizontalAlignment="Center"
VerticalAlignment="Center" Name="Path" Fill="{StaticResource StandardBrush}"
Data="M 0 0 L 4 8 L 8 0 Z"></Path>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="Path" Property="Fill"
Value="{StaticResource HoverBrush}" />
</Trigger>
<Trigger Property="IsPressed" Value="true">
<Setter TargetName="Path" Property="Fill"
Value="{StaticResource PressedBrush}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="LineButtonLeftStyle" TargetType="{x:Type RepeatButton}">
<Setter Property="Focusable" Value="False"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type RepeatButton}">
<Grid Margin="1" Width="18" >
<Path Stretch="None" HorizontalAlignment="Center"
VerticalAlignment="Center" Name="Path" Fill="{StaticResource StandardBrush}"
Data="M 0 0 L -8 4 L 0 8 Z"></Path>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="Path" Property="Fill"
Value="{StaticResource HoverBrush}" />
</Trigger>
<Trigger Property="IsPressed" Value="true">
<Setter TargetName="Path" Property="Fill"
Value="{StaticResource PressedBrush}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="LineButtonRightStyle" TargetType="{x:Type RepeatButton}">
<Setter Property="Focusable" Value="False"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type RepeatButton}">
<Grid Margin="1" Width="18" >
<Path Stretch="None" HorizontalAlignment="Center"
VerticalAlignment="Center" Name="Path" Fill="{StaticResource StandardBrush}"
Data="M 0 0 L 8 4 L 0 8 Z"></Path>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="true">
<Setter TargetName="Path" Property="Fill"
Value="{StaticResource HoverBrush}" />
</Trigger>
<Trigger Property="IsPressed" Value="true">
<Setter TargetName="Path" Property="Fill"
Value="{StaticResource PressedBrush}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="ScrollBarPageButtonStyle" TargetType="{x:Type RepeatButton}">
<Setter Property="IsTabStop" Value="False"/>
<Setter Property="Focusable" Value="False"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type RepeatButton}">
<Border Background="Transparent" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<ControlTemplate x:Key="VerticalScrollBar" TargetType="{x:Type ScrollBar}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition MaxHeight="18"/>
<RowDefinition Height="*"/>
<RowDefinition MaxHeight="18"/>
</Grid.RowDefinitions>
<Grid.Background>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientStop Offset="0" Color="#4c4c4c"></GradientStop>
<GradientStop Offset="1" Color="#434343"></GradientStop>
</LinearGradientBrush>
</Grid.Background>
<RepeatButton Grid.Row="0" Height="18"
Style="{StaticResource LineButtonUpStyle}"
Command="ScrollBar.LineUpCommand" >
</RepeatButton>
<Track Name="PART_Track" Grid.Row="1" IsDirectionReversed="True" >
<Track.DecreaseRepeatButton>
<RepeatButton Command="ScrollBar.PageUpCommand"
Style="{StaticResource ScrollBarPageButtonStyle}">
</RepeatButton>
</Track.DecreaseRepeatButton>
<Track.Thumb>
<Thumb Style="{StaticResource VerticalScrollBarThumbStyle}">
</Thumb>
</Track.Thumb>
<Track.IncreaseRepeatButton>
<RepeatButton Command="ScrollBar.PageDownCommand"
Style="{StaticResource ScrollBarPageButtonStyle}">
</RepeatButton>
</Track.IncreaseRepeatButton>
</Track>
<RepeatButton Grid.Row="2" Height="18"
Style="{StaticResource LineButtonDownStyle}"
Command="ScrollBar.LineDownCommand">
</RepeatButton>
</Grid>
</ControlTemplate>
<ControlTemplate x:Key="HorizontalScrollBar" TargetType="{x:Type ScrollBar}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition MaxWidth="18"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition MaxWidth="18"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.Background>
<LinearGradientBrush StartPoint="0,0" EndPoint="1,0">
<GradientStop Offset="0" Color="#4c4c4c"></GradientStop>
<GradientStop Offset="1" Color="#434343"></GradientStop>
</LinearGradientBrush>
</Grid.Background>
<RepeatButton Grid.Column="0" Width="18"
Style="{StaticResource LineButtonLeftStyle}"
Command="ScrollBar.LineLeftCommand" >
</RepeatButton>
<Track Name="PART_Track" Grid.Column="1" IsDirectionReversed="False" >
<Track.DecreaseRepeatButton>
<RepeatButton Command="ScrollBar.PageLeftCommand"
Style="{StaticResource ScrollBarPageButtonStyle}">
</RepeatButton>
</Track.DecreaseRepeatButton>
<Track.Thumb>
<Thumb Style="{StaticResource HorizontalScrollBarThumbStyle}">
</Thumb>
</Track.Thumb>
<Track.IncreaseRepeatButton>
<RepeatButton Command="ScrollBar.PageRightCommand"
Style="{StaticResource ScrollBarPageButtonStyle}">
</RepeatButton>
</Track.IncreaseRepeatButton>
</Track>
<RepeatButton Grid.Column="2" Width="18"
Style="{StaticResource LineButtonRightStyle}"
Command="ScrollBar.LineRightCommand">
</RepeatButton>
</Grid>
</ControlTemplate>
<Style TargetType="{x:Type ScrollBar}">
<Setter Property="SnapsToDevicePixels" Value="True"/>
<Setter Property="OverridesDefaultStyle" Value="true"/>
<Style.Triggers>
<Trigger Property="Orientation" Value="Vertical">
<Setter Property="Width" Value="18"/>
<Setter Property="Height" Value="Auto" />
<Setter Property="Template" Value="{StaticResource VerticalScrollBar}" />
</Trigger>
<Trigger Property="Orientation" Value="Horizontal">
<Setter Property="Width" Value="Auto"/>
<Setter Property="Height" Value="18" />
<Setter Property="Template" Value="{StaticResource HorizontalScrollBar}" />
</Trigger>
</Style.Triggers>
</Style>
</ResourceDictionary>
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using System.IO;
using System.ServiceModel.Web;
namespace WindowsPhone.Recipes.Push.Server.Services
{
/// <summary>
/// Provides custom tile images.
/// </summary>
[ServiceContract]
public interface IImageService
{
/// <summary>
/// Get custom tile image.
/// </summary>
/// <param name="parameter">The tile image request parameter.</param>
/// <returns>Custom tile image stream.</returns>
[OperationContract, WebGet]
Stream GetTileImage(string parameter);
}
}
@@ -0,0 +1,39 @@
using System.IO;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Xml.Linq;
using System;
using WindowsPhone.Recipes.Push.Server.Models;
namespace WindowsPhone.Recipes.Push.Server.Services
{
/// <summary>
/// Push server services.
/// </summary>
[ServiceContract]
public interface IPushService
{
/// <summary>
/// Register user name with a push channel uri.
/// </summary>
/// <param name="userName">User name.</param>
/// <param name="channelUri">Push notification channel uri.</param>
[OperationContract]
void Register(string userName, Uri channelUri);
/// <summary>
/// Get current server information/status.
/// </summary>
/// <returns>Current server status.</returns>
[OperationContract]
ServerInfo GetServerInfo();
/// <summary>
/// Send a tile update with given parameter.
/// </summary>
/// <returns>User parameter to send with the tile update request.</returns>
[OperationContract]
void UpdateTile(Uri channelUri, string parameter);
}
}
@@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace WindowsPhone.Recipes.Push.Server.Services
{
/// <summary>
/// Image request event arguments.
/// </summary>
internal class ImageRequestEventArgs : EventArgs
{
/// <summary>
/// Tile image maximum size in bytes.
/// </summary>
public const int MaxTileImageSize = 80 * 1024; // The max tile image size is 80k.
public string Parameter { get; private set; }
public Stream ImageStream { get; private set; }
/// <summary>
/// Initializes a new instance with a memory stream maximum size of <see cref="ImageRequestEventArgs.MaxTileImageSize"/>.
/// </summary>
public ImageRequestEventArgs(string parameter)
{
Parameter = parameter;
ImageStream = new MemoryStream(MaxTileImageSize);
}
}
}
@@ -0,0 +1,85 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using System.ComponentModel.Composition;
using System.IO;
namespace WindowsPhone.Recipes.Push.Server.Services
{
/// <summary>
/// Represents a tile image REST service.
/// </summary>
[Export, PartCreationPolicy(CreationPolicy.Shared), ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
internal class ImageService : IImageService
{
#region Constants
/// <value>Url of the GetTileImage REST service.</value>
public const string GetTileImageService = "http://localhost:8000/ImageService/GetTileImage?parameter={0}";
#endregion
#region Fields
private ServiceHost _serviceHost;
#endregion
#region Events
/// <summary>
/// Raise when dynamic image creation is requested.
/// </summary>
public event EventHandler<ImageRequestEventArgs> ImageRequest;
#endregion
#region Operations
/// <summary>
/// Host this service using WCF.
/// </summary>
public void Host()
{
_serviceHost = new ServiceHost(this);
_serviceHost.Open();
}
/// <summary>
/// Get a generated custom tile image stream for the given uri.
/// </summary>
/// <param name="parameter">The tile image request parameter.</param>
/// <returns>A stream of the custom tile image generated.</returns>
public Stream GetTileImage(string parameter)
{
if (ImageRequest != null)
{
var args = new ImageRequestEventArgs(parameter);
ImageRequest(this, args);
// Seek the stream back to the begining just in case.
args.ImageStream.Seek(0, SeekOrigin.Begin);
return args.ImageStream;
}
return Stream.Null;
}
#endregion
#region Privates Logic
private void OnImageRequest(ImageRequestEventArgs args)
{
if (ImageRequest != null)
{
ImageRequest(this, args);
}
}
#endregion
}
}
@@ -0,0 +1,184 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.ServiceModel;
using System.ComponentModel.Composition;
using WindowsPhone.Recipes.Push.Server.Models;
using System.Xml.Linq;
namespace WindowsPhone.Recipes.Push.Server.Services
{
/// <summary>
/// Current push server services implementation.
/// </summary>
[Export, PartCreationPolicy(CreationPolicy.Shared), ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)]
internal class PushService : IPushService
{
#region Fields
private ServiceHost _serviceHost;
/// <value>Dictionary contains users subscription objects.</value>
private readonly Dictionary<string, Subscription> _subscribers = new Dictionary<string, Subscription>();
/// <value>Sync access to the subscribers dictionary.</value>
private readonly object SubscribersSync = new object();
#endregion
#region Events
/// <summary>
/// Raise when user subscribed.
/// </summary>
public event EventHandler<SubscriptionEventArgs> Subscribed;
/// <summary>
/// Raise when current server status is requested.
/// </summary>
public event EventHandler<ServerInfoEventArgs> GetInfo;
/// <summary>
/// Raise when user requests a tile update.
/// </summary>
public event EventHandler<TileUpdateRequestEventArgs> TileUpdateRequest;
#endregion
#region Properties
/// <summary>
/// Get subscription list.
/// </summary>
public IEnumerable<Subscription> Subscribers
{
get
{
lock (_subscribers)
{
var subscribers = new Subscription[_subscribers.Count];
_subscribers.Values.CopyTo(subscribers, 0);
return subscribers;
}
}
}
/// <summary>
/// Get subscription count.
/// </summary>
public int SubscribersCount
{
get
{
lock (_subscribers)
{
return _subscribers.Count;
}
}
}
#endregion
#region Operations
/// <summary>
/// Register user with notification channel uri.
/// </summary>
/// <param name="userName">The user name to register.</param>
/// <param name="channelUri">The notification channel uri.</param>
public void Register(string userName, Uri channelUri)
{
if (string.IsNullOrEmpty(userName))
{
throw new ArgumentException("Invalid user name", "userName");
}
if (channelUri == null)
{
throw new ArgumentNullException("channelUri");
}
var subscription = new Subscription(userName, channelUri);
lock (SubscribersSync)
{
// Add or update existing.
_subscribers[userName] = subscription;
}
OnSubscribed(new SubscriptionEventArgs(subscription));
}
/// <summary>
/// Gets current server info.
/// </summary>
/// <returns>An instance info object contains server status.</returns>
public ServerInfo GetServerInfo()
{
var args = new ServerInfoEventArgs();
OnGetInfo(args);
return args.ServerInfo;
}
/// <summary>
/// Send a tile update with given parameter.
/// </summary>
/// <param name="channelUri">An instance info object contains server status.</param>
/// <param name="parameter">User parameter to send with the tile update request.</param>
public void UpdateTile(Uri channelUri, string parameter)
{
OnTileUpdateRequest(new TileUpdateRequestEventArgs(channelUri, parameter));
}
internal Subscription TryGetSubscription(string userName)
{
lock (SubscribersSync)
{
Subscription subscription;
if (!_subscribers.TryGetValue(userName, out subscription))
{
subscription = null;
}
return subscription;
}
}
#endregion
#region Privates Logic
public void Host()
{
_serviceHost = new ServiceHost(this);
_serviceHost.Open();
}
private void OnSubscribed(SubscriptionEventArgs args)
{
if (Subscribed != null)
{
Subscribed(this, args);
}
}
private void OnGetInfo(ServerInfoEventArgs args)
{
if (GetInfo != null)
{
GetInfo(this, args);
}
}
private void OnTileUpdateRequest(TileUpdateRequestEventArgs args)
{
if (TileUpdateRequest != null)
{
TileUpdateRequest(this, args);
}
}
#endregion
}
}
@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WindowsPhone.Recipes.Push.Server.Models;
namespace WindowsPhone.Recipes.Push.Server.Services
{
/// <summary>
/// Server info event arguments.
/// </summary>
internal class ServerInfoEventArgs : EventArgs
{
/// <summary>
/// Gets or sets the server info.
/// </summary>
public ServerInfo ServerInfo { get; set; }
}
}
@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WindowsPhone.Recipes.Push.Server.Models;
namespace WindowsPhone.Recipes.Push.Server.Services
{
/// <summary>
/// Subscription event arguments.
/// </summary>
internal class SubscriptionEventArgs : EventArgs
{
public Subscription Subscription { get; private set; }
public SubscriptionEventArgs(Subscription subscription)
{
Subscription = subscription;
}
}
}
@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace WindowsPhone.Recipes.Push.Server.Services
{
/// <summary>
/// Tile update request event arguments.
/// </summary>
internal class TileUpdateRequestEventArgs : EventArgs
{
public Uri ChannelUri { get; private set; }
public string Parameter { get; private set; }
public TileUpdateRequestEventArgs(Uri channelUri, string parameter)
{
this.ChannelUri = channelUri;
this.Parameter = parameter;
}
}
}
@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WindowsPhone.Recipes.Push.Messasges;
using WindowsPhone.Recipes.Push.Server.Models;
namespace WindowsPhone.Recipes.Push.Server.ViewModels
{
/// <summary>
/// Implement this interface to log push notification messages send result and error.
/// </summary>
internal interface IMessageSendResultLogger
{
/// <summary>
/// Implement this method by logging push notification messages send result.
/// </summary>
/// <param name="patternName">The server push pattern used while reporting this message send result.</param>
/// <param name="result">The message send result to log.</param>
void Log(string patternName, MessageSendResult result);
/// <summary>
/// Implement this method by logging push notification messages error result.
/// </summary>
/// <param name="patternName">The server push pattern used while reporting this message send error.</param>
/// <param name="result">The message send result to log.</param>
void Log(string patternName, MessageSendException exception);
}
}
@@ -0,0 +1,86 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;
using System.ComponentModel.Composition;
using System.ServiceModel;
using WindowsPhone.Recipes.Push.Server.Services;
namespace WindowsPhone.Recipes.Push.Server.ViewModels
{
[Export, PartCreationPolicy(CreationPolicy.Shared)]
internal class MainViewModel : ViewModelBase
{
private PushService _pushService;
private ImageService _imageService;
private PushPatternViewModel _activePattern;
[ImportingConstructor]
public MainViewModel([ImportMany(typeof(PushPatternViewModel))] IEnumerable<PushPatternViewModel> pushPatterns)
{
PushPatterns = pushPatterns;
ActivePattern = pushPatterns.FirstOrDefault();
}
[Import]
private PushService PushService
{
get { return _pushService; }
set
{
_pushService = value;
_pushService.Subscribed += (s, e) => NotifyPropertyChanged("Subscribers");
_pushService.Host();
}
}
[Import]
private ImageService ImageService
{
get { return _imageService; }
set
{
_imageService = value;
_imageService.Host();
}
}
public IEnumerable<PushPatternViewModel> PushPatterns { get; private set; }
[Import]
public MessageStatusViewModel MessageStatus { get; private set; }
public PushPatternViewModel ActivePattern
{
get { return _activePattern; }
set
{
if (_activePattern != value)
{
if (_activePattern != null)
{
// Deactivate old pattern.
_activePattern.IsActive = false;
}
_activePattern = value;
if (_activePattern != null)
{
// Activate new pattern.
_activePattern.IsActive = true;
}
NotifyPropertyChanged("ActivePattern");
}
}
}
public int Subscribers
{
get { return PushService.SubscribersCount; }
}
}
}
@@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;
using System.Windows.Threading;
using System.ComponentModel.Composition;
using WindowsPhone.Recipes.Push.Messasges;
using WindowsPhone.Recipes.Push.Server.Models;
namespace WindowsPhone.Recipes.Push.Server.ViewModels
{
[Export, Export(typeof(IMessageSendResultLogger)), PartCreationPolicy(CreationPolicy.Shared)]
internal class MessageStatusViewModel : ViewModelBase, IMessageSendResultLogger
{
private readonly ObservableCollection<MessageStatus> _status = new ObservableCollection<MessageStatus>();
public ObservableCollection<MessageStatus> Status
{
get { return _status; }
}
void IMessageSendResultLogger.Log(string patternName, MessageSendResult result)
{
Dispatcher.BeginInvoke(() => Status.Add(new MessageStatus(patternName, result)));
}
void IMessageSendResultLogger.Log(string patternName, MessageSendException exception)
{
Dispatcher.BeginInvoke(() => Status.Add(new MessageStatus(patternName, exception.Result)));
}
}
}
@@ -0,0 +1,166 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.Composition;
using System.Windows.Input;
using WindowsPhone.Recipes.Push.Messasges;
using WindowsPhone.Recipes.Push.Server.Services;
using WindowsPhone.Recipes.Push.Server.Models;
namespace WindowsPhone.Recipes.Push.Server.ViewModels
{
/// <summary>
/// Represents the Ask user to Pin the application push notification pattern.
/// </summary>
/// <remarks>
/// Only users can pin a Windows Phone application to the Start screen, therefore if a given
/// application wants to use the tile functionality and the user didnt pinned
/// the apps tile, we want to notify the user she is missing additional functionality.
/// This pattern is implemented in both client and server-side.
/// </remarks>
[Export(typeof(PushPatternViewModel)), PartCreationPolicy(CreationPolicy.Shared)]
internal sealed class AskToPinPushPatternViewModel : PushPatternViewModel
{
#region Fields
/// <value>A dictionary for tracking tile messages.</value>
private readonly Dictionary<string, TilePushNotificationMessage> _messages = new Dictionary<string, TilePushNotificationMessage>();
/// <value>Synchronizes access to the messages collection.</value>
private readonly object MessageSync = new object();
#endregion
#region Ctor
/// <summary>
/// Initialize new instance of this type with defaults.
/// </summary>
public AskToPinPushPatternViewModel()
{
InitializeDefaults();
}
#endregion
#region Overrides
/// <summary>
/// Send a tile notification to all relevant subscribers.
/// </summary>
protected override void OnSend()
{
// Asynchronously try to send this message to all relevant subscribers.
foreach (var subscriber in PushService.Subscribers)
{
// Create a tile message to send an update.
var tileMsg = GetOrCreateMessage(subscriber.UserName);
tileMsg.SendAsync(
subscriber.ChannelUri,
result =>
{
Log(result);
OnMessageSent(subscriber.UserName, result);
},
Log);
}
}
/// <summary>
/// Once an application is activated again (the client side phone application
/// has subscription logic on startup), try to update the tile again.
/// In case that the application is not pinned, send raw notification message
/// to the client, asking to pin the application. This raw notification message
/// has to be well-known and handled by the client side phone application.
/// In our case the raw message is AskToPin.
/// </summary>
protected override void OnSubscribed(SubscriptionEventArgs args)
{
// Asynchronously try to send Tile message to the relevant subscriber
// with data already sent before so the tile won't change.
var tileMsg = GetOrCreateMessage(args.Subscription.UserName, false);
tileMsg.SendAsync(
args.Subscription.ChannelUri,
result =>
{
Log(result);
OnMessageSent(args.Subscription.UserName, result);
},
Log);
}
#endregion
#region Privates
/// <summary>
/// Once tile update sent, check if handled by the phone.
/// In case that the application is not pinned, ask to pin.
/// </summary>
private void OnMessageSent(string userName, MessageSendResult result)
{
if (!CheckIfPinned(result))
{
AskUserToPin(result.ChannelUri);
}
}
/// <summary>
/// Just in case that the application is running, send a raw message, asking
/// the user to pin the application. This raw message has to be handled in client side.
/// </summary>
private void AskUserToPin(Uri uri)
{
new RawPushNotificationMessage(MessageSendPriority.High)
{
RawData = Encoding.ASCII.GetBytes(RawMessage)
}.SendAsync(uri, Log, Log);
}
private bool CheckIfPinned(MessageSendResult result)
{
// We known if the application is pinned by checking the following send result flags:
return result.DeviceConnectionStatus == DeviceConnectionStatus.Connected &&
result.SubscriptionStatus == SubscriptionStatus.Active &&
result.NotificationStatus == NotificationStatus.Received;
}
private TilePushNotificationMessage GetOrCreateMessage(string userName, bool overrideExisting = true)
{
lock (MessageSync)
{
TilePushNotificationMessage message;
if (!_messages.TryGetValue(userName, out message) || overrideExisting)
{
message = new TilePushNotificationMessage(MessageSendPriority.High)
{
BackgroundImageUri = BackgroundImageUri,
Count = Count,
Title = Title
};
_messages[userName] = message;
}
return message;
}
}
private void InitializeDefaults()
{
DisplayName = "Ask to Pin";
Description = "Only users can pin a Windows Phone application to the Start screen, therefore if a given application wants to use the tile functionality and the user didnt pinned the apps tile, we want to notify the user she is missing additional functionality. This pattern is implemented in both client and server-side.";
BackgroundImageUri = TileImages.Length > 2 ? TileImages[2] : TileImages.FirstOrDefault();
Count = 1;
Title = "Game Update";
RawMessage = "AskToPin";
}
#endregion
}
}
@@ -0,0 +1,164 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.Composition;
using System.Xml.Linq;
using WindowsPhone.Recipes.Push.Messasges;
using WindowsPhone.Recipes.Push.Server.Services;
using WindowsPhone.Recipes.Push.Server.Models;
namespace WindowsPhone.Recipes.Push.Server.ViewModels
{
/// <summary>
/// Represents the Counter push notification pattern.
/// </summary>
/// <remarks>
/// Send a tile push notification message with a counter value.
/// Each time a push notification message is sent the counter value
/// increases by one, unless user is running the application and notifies
/// the server.
/// </remarks>
[Export(typeof(PushPatternViewModel)), PartCreationPolicy(CreationPolicy.Shared)]
internal sealed class CounterPushPatternViewModel : PushPatternViewModel
{
#region Fields
/// <value>A dictionary for tracking tile message count while phone-application is not running.</value>
private readonly Dictionary<string, int> _messageCounter = new Dictionary<string, int>();
/// <value>Synchronizes access to the message counter collection.</value>
private readonly object MessageCounterSync = new object();
#endregion
#region Ctor
/// <summary>
/// Initialize new instance of this type with defaults.
/// </summary>
public CounterPushPatternViewModel()
{
InitializeDefaults();
}
#endregion
#region Overrides
/// <summary>
/// Send raw message to all subscribers. In case that the phone-application
/// is not running, send tile update and increase tile counter.
/// </summary>
protected override void OnSend()
{
// Notify phone for having waiting messages.
var rawMsg = new RawPushNotificationMessage(MessageSendPriority.High)
{
RawData = Encoding.ASCII.GetBytes(RawMessage)
};
foreach (var subscriber in PushService.Subscribers)
{
rawMsg.SendAsync(
subscriber.ChannelUri,
result =>
{
Log(result);
OnRawSent(subscriber.UserName, result);
},
Log);
}
}
/// <summary>
/// On subscription change, reset the subscriber tile counter if exist.
/// </summary>
protected override void OnSubscribed(SubscriptionEventArgs e)
{
// Create a tile message to reset tile count.
var tileMsg = new TilePushNotificationMessage(MessageSendPriority.High)
{
Count = 0,
BackgroundImageUri = BackgroundImageUri,
Title = Title
};
tileMsg.SendAsync(e.Subscription.ChannelUri, Log, Log);
ResetCounter(e.Subscription.UserName);
}
#endregion
#region Privates
private void OnRawSent(string userName, MessageSendResult result)
{
// In case that the device is disconnected, no need to send a tile message.
if (result.DeviceConnectionStatus == DeviceConnectionStatus.TempDisconnected)
{
return;
}
// Checking these three flags we can know what's the state of both the device and apllication.
bool isApplicationRunning =
result.SubscriptionStatus == SubscriptionStatus.Active &&
result.NotificationStatus == NotificationStatus.Received &&
result.DeviceConnectionStatus == DeviceConnectionStatus.Connected;
// In case that the application is not running, send a tile update with counter increase.
if (!isApplicationRunning)
{
var tileMsg = new TilePushNotificationMessage(MessageSendPriority.High)
{
Count = IncreaseCounter(userName),
BackgroundImageUri = BackgroundImageUri,
Title = Title
};
tileMsg.SendAsync(result.ChannelUri, Log, Log);
}
}
private void ResetCounter(string userName)
{
lock (MessageCounterSync)
{
_messageCounter.Remove(userName);
}
}
private int IncreaseCounter(string userName)
{
lock (MessageCounterSync)
{
int counter;
if (_messageCounter.TryGetValue(userName, out counter))
{
++counter;
}
else
{
counter = 1;
}
_messageCounter[userName] = counter;
return counter;
}
}
private void InitializeDefaults()
{
DisplayName = "Counter";
Description = "Send push notification message of Tile type, with a counter value. Each time a push notification message is sent, the counter value increases by one, unless user is running the application and notifies the server.";
BackgroundImageUri = TileImages.Length > 1 ? TileImages[1] : TileImages.FirstOrDefault();
RawMessage = "Game Update";
Count = 0;
Title = "Updates";
}
#endregion
}
}
@@ -0,0 +1,259 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.Composition;
using System.Windows.Input;
using System.Windows.Controls;
using System.Windows.Media.Imaging;
using System.Windows;
using System.Windows.Controls.Primitives;
using System.Windows.Media;
using System.IO;
using System.Reflection;
using Microsoft.Win32;
using WindowsPhone.Recipes.Push.Server.Behaviors;
using WindowsPhone.Recipes.Push.Messasges;
using WindowsPhone.Recipes.Push.Server.Models;
using WindowsPhone.Recipes.Push.Server.Services;
namespace WindowsPhone.Recipes.Push.Server.ViewModels
{
/// <summary>
/// Represents the Custom Tile Image push notification pattern.
/// </summary>
/// <remarks>
/// Send a tile update with a dynamically created image located in the remote server (in our case localhost).
/// The image will be dynamically generated upon each request. The tile Count and Title in the
/// payload are optional.
/// </remarks>
[Export(typeof(PushPatternViewModel)), PartCreationPolicy(CreationPolicy.Shared)]
internal sealed class CustomTileImagePushPatternViewModel : PushPatternViewModel, IVisualHost
{
#region Constants
/// <value>Tile image maximum width.</value>
public const int TileImageWidth = 173;
/// <value>Tile image maximum height.</value>
public const int TileImageHeight = 173;
/// <value>Tile image dpi.</value>
public const int TileImageDpi = 96;
#endregion
#region Fields
/// <value>Collection of brushes for choosing text message color.</value>
private Brush[] _textColors;
/// <value>Selected tile image background.</value>
private ImageSource _tileBackground;
/// <value>Text for diplaying on the tile custom image.</value>
private string _freeText;
/// <value>Tile custom image text size.</value>
private double _textSize;
#endregion
#region Properties
[Import]
private ImageService ImageService { get; set; }
/// <summary>
/// Gets a list of brushes for choosing text message color.
/// </summary>
public Brush[] TextColors
{
get
{
if (_textColors == null)
{
_textColors = (from property in typeof(Brushes).GetProperties(BindingFlags.Static | BindingFlags.Public)
select (Brush)property.GetValue(null, null)).ToArray();
}
return _textColors;
}
}
/// <summary>
/// Gets or sets the visual element used for generating a custom image from.
/// </summary>
public Visual Visual
{
get;
set;
}
/// <summary>
/// Get or sets the prefered tile background image source.
/// </summary>
public ImageSource TileBackground
{
get { return _tileBackground; }
set
{
if (_tileBackground != value)
{
_tileBackground = value;
NotifyPropertyChanged("TileBackground");
}
}
}
/// <summary>
/// Gets or sets a text to be displayed on the tile generated image.
/// </summary>
public string FreeText
{
get { return _freeText; }
set
{
if (_freeText != value)
{
_freeText = value;
NotifyPropertyChanged("FreeText");
}
}
}
/// <summary>
/// Gets or sets the text size of the tile generated image.
/// </summary>
public double TextSize
{
get { return _textSize; }
set
{
if (_textSize != value)
{
_textSize = value;
NotifyPropertyChanged("TextSize");
}
}
}
#endregion
#region Commands
/// <summary>
/// Gets the command for picking a tile background image.
/// </summary>
public ICommand PickImageCommand { get; private set; }
#endregion
#region Ctor
/// <summary>
/// Initialize new instance of this type with defaults.
/// </summary>
public CustomTileImagePushPatternViewModel()
{
InitializeDefaults();
PickImageCommand = new RelayCommand(
p =>
{
// On execution, open file dialog for picking tile background image.
var openDialog = new OpenFileDialog
{
Title = "Tile Background",
Filter = "Jpeg|*.jpg|Bmp|*.bmp",
InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures),
Multiselect = false
};
if (openDialog.ShowDialog() == true)
{
TileBackground = new BitmapImage(new Uri(openDialog.FileName));
}
});
}
#endregion
#region Protected
protected override void OnActivated()
{
base.OnActivated();
// Register to the ImageService.ImageRequest event. This event is raised
// whenever ImageService.GetTileImage is called.
ImageService.ImageRequest += Service_ImageRequest;
}
protected override void OnDeactivated()
{
base.OnDeactivated();
ImageService.ImageRequest -= Service_ImageRequest;
}
protected override void OnSend()
{
// Starts by sending a tile notification to all relvant subscribers.
// This tile notification updates the tile with custom image.
var tileMsg = new TilePushNotificationMessage(MessageSendPriority.High)
{
Count = Count,
Title = Title
};
foreach (var subscriber in PushService.Subscribers)
{
// Set the tile background image uri with the address of the ImageService.GetTileImage,
// REST service, using current subscriber channel uri as a parameter to bo sent to the service.
tileMsg.BackgroundImageUri = new Uri(string.Format(ImageService.GetTileImageService, string.Empty));
tileMsg.SendAsync(subscriber.ChannelUri, Log, Log);
}
}
#endregion
#region Privates
private void Service_ImageRequest(object sender, Services.ImageRequestEventArgs e)
{
// This event is raised by our local push-service as result of
// the tile msg we've sent to each subscriber. This is the time
// to pick the right tile image for the subscriber.
if (Visual != null)
{
RenderImage(Visual, e.ImageStream);
}
}
private static void RenderImage(Visual visual, Stream stream)
{
// The next lines of code uses WPF to dynamically create an image.
// In a real server we shouldn't use WPF, hence a 3rd party image generator library is required.
var renderer = new RenderTargetBitmap(TileImageWidth, TileImageHeight, TileImageDpi, TileImageDpi, PixelFormats.Pbgra32);
renderer.Render(visual);
var pngEncoder = new PngBitmapEncoder();
pngEncoder.Frames.Add(BitmapFrame.Create(renderer));
pngEncoder.Save(stream);
}
private void InitializeDefaults()
{
DisplayName = "Custom Tile";
Description = "Send a tile update with a dynamically created image located in the remote server (in our case localhost). The image will be dynamically generated upon each request. The tile Count and Title in the payload are optional.";
TextSize = 20;
}
#endregion
}
}
@@ -0,0 +1,122 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.Composition;
using System.Windows.Input;
using System.IO;
using Microsoft.Win32;
using WindowsPhone.Recipes.Push.Messasges;
using WindowsPhone.Recipes.Push.Server.Models;
namespace WindowsPhone.Recipes.Push.Server.ViewModels
{
/// <summary>
/// Represents the One Time push notification pattern.
/// </summary>
/// <remarks>
/// This is the simplest push notification pattern of just pushing single time message
/// to a registered client.
/// </remarks>
[Export(typeof(PushPatternViewModel)), PartCreationPolicy(CreationPolicy.Shared)]
internal sealed class OneTimePushPatternViewModel : PushPatternViewModel
{
#region Properties
/// <summary>
/// Gets or sets a value indicating if tile message should be sent.
/// </summary>
public bool IsTileEnabled { get; set; }
/// <summary>
/// Gets or sets a value indicating if toast message should be sent.
/// </summary>
public bool IsToastEnabled { get; set; }
/// <summary>
/// Gets or sets a value indicating if raw message should be sent.
/// </summary>
public bool IsRawEnabled { get; set; }
#endregion
#region Ctor
/// <summary>
/// Initialize new instance of this type with defaults.
/// </summary>
public OneTimePushPatternViewModel()
{
InitializeDefaults();
}
#endregion
#region Overrides
/// <summary>
/// Depends on what message was selected, send all subscribers zero or all three push message types (Tile, Toast, Raw).
/// </summary>
protected override void OnSend()
{
var messages = new List<PushNotificationMessage>();
if (IsTileEnabled)
{
// Prepare a tile push notification message.
messages.Add(new TilePushNotificationMessage(MessageSendPriority.High)
{
BackgroundImageUri = BackgroundImageUri,
Count = Count,
Title = Title
});
}
if (IsToastEnabled)
{
// Prepare a toast push notification message.
messages.Add(new ToastPushNotificationMessage(MessageSendPriority.High)
{
Title = ToastTitle,
SubTitle = ToastSubTitle
});
}
if (IsRawEnabled)
{
// Prepare a raw push notification message.
messages.Add(new RawPushNotificationMessage(MessageSendPriority.High)
{
RawData = Encoding.ASCII.GetBytes(RawMessage)
});
}
foreach (var subscriber in PushService.Subscribers)
{
messages.ForEach(m => m.SendAsync(subscriber.ChannelUri, Log, Log));
}
}
#endregion
#region Privates
private void InitializeDefaults()
{
DisplayName = "One Time";
Description = "This is the simplest push notification pattern of just pushing single time message to a registered client.";
Count = 1;
Title = "Game Update";
ToastTitle = Title;
ToastSubTitle = "Game has been released";
RawMessage = ToastSubTitle;
IsTileEnabled = true;
IsToastEnabled = true;
IsRawEnabled = true;
}
#endregion
}
}
@@ -0,0 +1,352 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.Composition;
using System.Windows.Input;
using WindowsPhone.Recipes.Push.Server.Services;
using System.Windows;
using WindowsPhone.Recipes.Push.Server.Models;
using WindowsPhone.Recipes.Push.Messasges;
namespace WindowsPhone.Recipes.Push.Server.ViewModels
{
/// <summary>
/// Represents a base class for all push pattern view models.
/// </summary>
/// <remarks>
/// A push pattern view model contains the logic and behavior of a server side push notification pattern.
/// For demonstration purposes, and since we are using WPF as the 'face' of this server, each view model
/// exposes properties and commands to be controlled and activated by this server UI.
/// You can find more information about the MVVM pattern in <see cref="http://en.wikipedia.org/wiki/Model_View_ViewModel"/>.
/// </remarks>
internal abstract class PushPatternViewModel : ViewModelBase
{
#region Fields
/// <value>Indicates if current pattern is active or not.</value>
private bool _isActive;
/// <value>Collection of tile image relative uri's available in the phone application.</value>
private Uri[] _tileImages;
/// <value>Selected tile background image uri.</value>
private Uri _backgroundImageUri;
/// <value>Tile message count.</value>
private int _count;
/// <value>Tile message title.</value>
private string _title;
/// <value>Toast message title.</value>
private string _toastTitle;
/// <value>Toast message sub title.</value>
private string _toastSubTitle;
/// <value>Raw text message.</value>
private string _rawMessage;
#endregion
#region Properties
[Import]
protected PushService PushService { get; private set; }
[Import]
private IMessageSendResultLogger ResultLogger { get; set; }
/// <summary>
/// Gets current pattern display name.
/// </summary>
public string DisplayName { get; protected set; }
/// <summary>
/// Gets current pattern description text.
/// </summary>
public string Description { get; protected set; }
/// <summary>
/// Gets or sets value for indicating whether this pattern is active or not.
/// </summary>
public bool IsActive
{
get
{
return _isActive;
}
set
{
if (_isActive != value)
{
_isActive = value;
if (_isActive)
{
OnActivated();
}
else
{
OnDeactivated();
}
NotifyPropertyChanged("IsActive");
}
}
}
/// <summary>
/// Gets a collection of tile image uris available in the phone client application.
/// </summary>
public Uri[] TileImages
{
get
{
if (_tileImages == null)
{
_tileImages = new Uri[]
{
ToUri("TileBackground1.jpg"),
ToUri("TileBackground2.jpg"),
ToUri("TileBackground3.jpg"),
};
BackgroundImageUri = _tileImages[0];
}
return _tileImages;
}
}
/// <summary>
/// Gets or sets the tile background uri.
/// </summary>
public Uri BackgroundImageUri
{
get { return _backgroundImageUri; }
set
{
if (_backgroundImageUri != value)
{
_backgroundImageUri = value;
NotifyPropertyChanged("BackgroundImageUri");
}
}
}
/// <summary>
/// Gets or sets the tile count.
/// </summary>
public int Count
{
get { return _count; }
set
{
if (_count != value)
{
_count = value;
NotifyPropertyChanged("Count");
}
}
}
/// <summary>
/// Gets or sets the tile tiltle.
/// </summary>
public string Title
{
get { return _title; }
set
{
if (_title != value)
{
_title = value;
NotifyPropertyChanged("Title");
}
}
}
/// <summary>
/// Gets or sets the toast title.
/// </summary>
public string ToastTitle
{
get { return _toastTitle; }
set
{
if (_toastTitle != value)
{
_toastTitle = value;
NotifyPropertyChanged("ToastTitle");
}
}
}
/// <summary>
/// Gets or sets the toast sub-title.
/// </summary>
public string ToastSubTitle
{
get { return _toastSubTitle; }
set
{
if (_toastSubTitle != value)
{
_toastSubTitle = value;
NotifyPropertyChanged("ToastSubTitle");
}
}
}
/// <summary>
/// Gets or sets the raw text message.
/// </summary>
public string RawMessage
{
get { return _rawMessage; }
set
{
if (_rawMessage != value)
{
_rawMessage = value;
NotifyPropertyChanged("RawMessage");
}
}
}
#endregion
#region Commands
/// <summary>
/// Gets the command which executes the send operation.
/// </summary>
public ICommand SendCommand
{
get
{
return new RelayCommand(p =>
{
try
{
OnSend();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Send Error");
}
});
}
}
#endregion
#region Protected
/// <summary>
/// Override this to send push message according to the pattern behavior.
/// </summary>
protected abstract void OnSend();
/// <summary>
/// Override this to add additional pattern-activation logic.
/// </summary>
protected virtual void OnActivated()
{
UpdateClient();
PushService.Subscribed += PushService_Subscribed;
PushService.GetInfo += PushService_GetInfo;
}
/// <summary>
/// Override this to add additional pattern-deactivation logic.
/// </summary>
protected virtual void OnDeactivated()
{
PushService.Subscribed -= PushService_Subscribed;
PushService.GetInfo -= PushService_GetInfo;
}
/// <summary>
/// Override this to add logic when clients login.
/// </summary>
protected virtual void OnSubscribed(SubscriptionEventArgs args)
{
}
/// <summary>
/// Override this to add logic when clients request server's info.
/// </summary>
protected virtual void OnGetInfo(ServerInfoEventArgs args)
{
args.ServerInfo = new ServerInfo
{
PushPattern = DisplayName,
Counter = Count
};
}
/// <summary>
/// Logs push message result.
/// </summary>
protected void Log(MessageSendResult result)
{
ResultLogger.Log(DisplayName, result);
}
/// <summary>
/// Logs push message error.
/// </summary>
protected void Log(MessageSendException exception)
{
ResultLogger.Log(DisplayName, exception);
}
#endregion
#region Event Handlers
private void UpdateClient()
{
// Notify subscribers to get new info from the server.
foreach (var subscriber in PushService.Subscribers)
{
new RawPushNotificationMessage(MessageSendPriority.High)
{
RawData = Encoding.ASCII.GetBytes("Update Info")
}.SendAsync(subscriber.ChannelUri);
}
}
private void PushService_Subscribed(object sender, SubscriptionEventArgs args)
{
OnSubscribed(args);
}
private void PushService_GetInfo(object sender, ServerInfoEventArgs args)
{
OnGetInfo(args);
}
#endregion
#region Helpers
private static Uri ToUri(string imageName)
{
return new Uri(string.Format("/Resources/TileImages/{0}", imageName), UriKind.Relative);
}
#endregion
}
}
@@ -0,0 +1,139 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.Composition;
using System.Windows.Input;
using System.IO;
using Microsoft.Win32;
using WindowsPhone.Recipes.Push.Messasges;
using WindowsPhone.Recipes.Push.Server.Models;
using WindowsPhone.Recipes.Push.Server.Services;
namespace WindowsPhone.Recipes.Push.Server.ViewModels
{
/// <summary>
/// Represents the Tile Schedule push notification pattern.
/// </summary>
/// <remarks>
/// This push pattern is passive. The user schedule a tile image update request,
/// by using the Windows Phone API, and at the time, MPNS fetches the image using
/// the uri provided with the request.
/// </remarks>
[Export(typeof(PushPatternViewModel)), PartCreationPolicy(CreationPolicy.Shared)]
internal sealed class TileSchedulePushPatternViewModel : PushPatternViewModel
{
#region Fields
private string _imageFileName;
#endregion
#region Properties
[Import]
private ImageService ImageService { get; set; }
/// <summary>
/// Gets or sets a image file name sent by the user.
/// </summary>
public string ImageFileName
{
get { return _imageFileName; }
set
{
if (_imageFileName != value)
{
_imageFileName = value;
NotifyPropertyChanged("ImageFileName");
}
}
}
#endregion
#region Ctor
/// <summary>
/// Initialize new instance of this type with defaults.
/// </summary>
public TileSchedulePushPatternViewModel()
{
InitializeDefaults();
}
#endregion
#region Overrides
protected override void OnActivated()
{
base.OnActivated();
// Register to the PushService.TileUpdateRequest event. This event is raised
// whenever a user asks to update its tile.
PushService.TileUpdateRequest += PushService_TileUpdateRequest;
// Register to the ImageService.ImageRequest event. This event is raised
// whenever ImageService.GetTileImage is called.
ImageService.ImageRequest += Service_ImageRequest;
}
protected override void OnDeactivated()
{
base.OnDeactivated();
PushService.TileUpdateRequest -= PushService_TileUpdateRequest;
ImageService.ImageRequest -= Service_ImageRequest;
}
protected override void OnSend()
{
// Nothing to do here.
}
#endregion
#region Privates
private void PushService_TileUpdateRequest(object sender, TileUpdateRequestEventArgs e)
{
// Send a tile notification message to the relevant device.
var tileMsg = new TilePushNotificationMessage(MessageSendPriority.High)
{
BackgroundImageUri = new Uri(string.Format(ImageService.GetTileImageService, e.Parameter))
};
tileMsg.SendAsync(e.ChannelUri, Log, Log);
}
private void Service_ImageRequest(object sender, Services.ImageRequestEventArgs e)
{
ImageFileName = e.Parameter;
// This event is raised by our local push-service as result of
// the tile msg we've sent to a subscriber. This is the time
// to pick the right tile image for the subscriber.
string imageFile = Path.Combine("Resources/TileImages/Numbers", e.Parameter);
if (File.Exists(imageFile))
{
using (var reader = File.OpenRead(imageFile))
{
byte[] imageBuffer = new byte[reader.Length];
int bytesRead = reader.Read(imageBuffer, 0, imageBuffer.Length);
e.ImageStream.Write(imageBuffer, 0, bytesRead);
}
}
}
private void InitializeDefaults()
{
DisplayName = "Tile Schedule";
Description = "This push pattern is passive. The user schedule a tile image update request, by using the Windows Phone API, and at the time, MPNS fetches the image using the uri provided with the request.";
}
#endregion
}
}
@@ -0,0 +1,69 @@
using System;
using System.Diagnostics;
using System.Windows.Input;
namespace WindowsPhone.Recipes.Push.Server.ViewModels
{
/// <summary>
/// A custom implementation of a WPF command, command whose sole purpose is
/// to relay its functionality to other objects by invoking delegates.
/// The default return value for the CanExecute method is 'true'.
/// </summary>
public class RelayCommand : ICommand
{
#region Fields
private readonly Action<object> _execute;
private readonly Predicate<object> _canExecute;
#endregion // Fields
#region Constructors
/// <summary>
/// Creates a new command that can always execute.
/// </summary>
/// <param name="execute">The execution logic.</param>
public RelayCommand(Action<object> execute)
: this(execute, null)
{
}
/// <summary>
/// Creates a new command.
/// </summary>
/// <param name="execute">The execution logic.</param>
/// <param name="canExecute">The execution status logic.</param>
public RelayCommand(Action<object> execute, Predicate<object> canExecute)
{
if (execute == null)
throw new ArgumentNullException("execute");
_execute = execute;
_canExecute = canExecute;
}
#endregion // Constructors
#region ICommand Members
[DebuggerStepThrough]
public bool CanExecute(object parameter)
{
return _canExecute == null ? true : _canExecute(parameter);
}
public event EventHandler CanExecuteChanged
{
add { CommandManager.RequerySuggested += value; }
remove { CommandManager.RequerySuggested -= value; }
}
public void Execute(object parameter)
{
_execute(parameter);
}
#endregion // ICommand Members
}
}
@@ -0,0 +1,92 @@
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Windows.Threading;
using System.Windows;
namespace WindowsPhone.Recipes.Push.Server.ViewModels
{
/// <summary>
/// Base class for all ViewModel classes in the application.
/// It provides support for property change notifications
/// and has a DisplayName property. This class is abstract.
/// </summary>
public abstract class ViewModelBase : INotifyPropertyChanged
{
#region Properties
public Dispatcher Dispatcher
{
get { return Application.Current.Dispatcher; }
}
#endregion
#region Constructor
protected ViewModelBase()
{
}
#endregion // Constructor
#region Debugging
/// <summary>
/// Warns the developer if this object does not have
/// a public property with the specified name. This
/// method does not exist in a Release build.
/// </summary>
[Conditional("DEBUG")]
[DebuggerStepThrough]
public void VerifyPropertyName(string propertyName)
{
// Verify that the property name matches a real,
// public, instance property on this object.
if (TypeDescriptor.GetProperties(this)[propertyName] == null)
{
string msg = "Invalid property name: " + propertyName;
if (this.ThrowOnInvalidPropertyName)
throw new Exception(msg);
else
Debug.Fail(msg);
}
}
/// <summary>
/// Returns whether an exception is thrown, or if a Debug.Fail() is used
/// when an invalid property name is passed to the VerifyPropertyName method.
/// The default value is false, but subclasses used by unit tests might
/// override this property's getter to return true.
/// </summary>
protected virtual bool ThrowOnInvalidPropertyName { get; private set; }
#endregion // Debugging Aides
#region INotifyPropertyChanged Members
/// <summary>
/// Raised when a property on this object has a new value.
/// </summary>
public event PropertyChangedEventHandler PropertyChanged;
/// <summary>
/// Raises this object's PropertyChanged event.
/// </summary>
/// <param name="propertyName">The property that has a new value.</param>
protected void NotifyPropertyChanged(string propertyName)
{
this.VerifyPropertyName(propertyName);
PropertyChangedEventHandler handler = this.PropertyChanged;
if (handler != null)
{
var e = new PropertyChangedEventArgs(propertyName);
handler(this, e);
}
}
#endregion // INotifyPropertyChanged Members
}
}
@@ -0,0 +1,238 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{AC4A77E5-583A-4BB3-AB6B-8FE759906D5D}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>WindowsPhone.Recipes.Push.Server</RootNamespace>
<AssemblyName>PushServer</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>
<Utf8Output>true</Utf8Output>
<ExpressionBlendVersion>4.0.20824.0</ExpressionBlendVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup />
<PropertyGroup>
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>
<ItemGroup>
<Reference Include="PresentationFramework.Aero" />
<Reference Include="System" />
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.Data" />
<Reference Include="System.Net" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.ServiceModel" />
<Reference Include="System.ServiceModel.Web" />
<Reference Include="System.Web" />
<Reference Include="System.Windows.Interactivity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\Libraries\WPF_Interactivity\System.Windows.Interactivity.dll</HintPath>
</Reference>
<Reference Include="System.Windows.Presentation" />
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="Behaviors\VisualBinderBehavior.cs" />
<Compile Include="Behaviors\IVisualHost.cs" />
<Compile Include="Models\ServerInfo.cs" />
<Compile Include="Models\PushPatternType.cs" />
<Compile Include="Models\Subscription.cs" />
<Compile Include="Resources\Converters\NullTileImageConverter.cs" />
<Compile Include="Resources\Converters\UserFileImageConverter.cs" />
<Compile Include="Services\IImageService.cs" />
<Compile Include="Services\ImageRequestEventArgs.cs" />
<Compile Include="Services\ImageService.cs" />
<Compile Include="Services\ServerInfoEventArgs.cs" />
<Compile Include="Services\IPushService.cs" />
<Compile Include="Services\PushService.cs" />
<Compile Include="Services\SubscriptionEventArgs.cs" />
<Compile Include="Models\MessageStatus.cs" />
<Compile Include="Services\TileUpdateRequestEventArgs.cs" />
<Compile Include="ViewModels\Patterns\AskToPinPushPatternViewModel.cs" />
<Compile Include="ViewModels\Patterns\TileSchedulePushPatternViewModel.cs" />
<Compile Include="ViewModels\Patterns\CustomTileImagePushPatternViewModel.cs" />
<Compile Include="ViewModels\Patterns\CounterPushPatternViewModel.cs" />
<Compile Include="ViewModels\IMessageSendResultLogger.cs" />
<Compile Include="ViewModels\MainViewModel.cs" />
<Compile Include="ViewModels\MessageStatusViewModel.cs" />
<Compile Include="ViewModels\Patterns\OneTimePushPatternViewModel.cs" />
<Compile Include="ViewModels\Patterns\PushPatternViewModel.cs" />
<Compile Include="ViewModels\RelayCommand.cs" />
<Compile Include="ViewModels\ViewModelBase.cs" />
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Page Include="Resources\DataTemplates\TileSchedulePushPatternViewModel.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Resources\DefaultSkin.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Resources\DataTemplates\AskToPinPushPatternViewModel.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Resources\DataTemplates\CustomTileImagePushPatternViewModel.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Resources\DataTemplates\CounterPushPatternViewModel.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Resources\DataTemplates\OneTimePushPatternViewModel.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Resources\DataTemplates\MessageStatusViewModel.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="App.config" />
<None Include="app.manifest">
<SubType>Designer</SubType>
</None>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<AppDesigner Include="Properties\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\WindowsPhone.Recipes.Push.Messasges\WindowsPhone.Recipes.Push.Messasges.csproj">
<Project>{E4691236-9F54-4250-BDBE-916BBB07A378}</Project>
<Name>WindowsPhone.Recipes.Push.Messasges</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Resource Include="..\WindowsPhone.Recipes.Push.Client\Resources\TileImages\TileBackground1.jpg">
<Link>Resources\TileImages\TileBackground1.jpg</Link>
</Resource>
<Resource Include="..\WindowsPhone.Recipes.Push.Client\Resources\TileImages\TileBackground2.jpg">
<Link>Resources\TileImages\TileBackground2.jpg</Link>
</Resource>
<Resource Include="..\WindowsPhone.Recipes.Push.Client\Resources\TileImages\TileBackground3.jpg">
<Link>Resources\TileImages\TileBackground3.jpg</Link>
</Resource>
<Resource Include="..\WindowsPhone.Recipes.Push.Client\Background.png">
<Link>Resources\TileImages\Background.png</Link>
</Resource>
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\TileImages\Null.jpg" />
<Content Include="Resources\TileImages\Numbers\number0.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Resources\TileImages\Numbers\number1.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Resources\TileImages\Numbers\number2.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Resources\TileImages\Numbers\number3.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Resources\TileImages\Numbers\number4.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Resources\TileImages\Numbers\number5.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Resources\TileImages\Numbers\number6.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Resources\TileImages\Numbers\number7.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Resources\TileImages\Numbers\number8.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Resources\TileImages\Numbers\number9.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<assemblyIdentity version="1.0.0.0" name="WindowsPhone.Recipes.Push.Server.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
</application>
</compatibility>
</asmv1:assembly>