2011-03-28 21:22:11 +03:00
parent a4c09735f0
commit 00f97e41d6
130 changed files with 13440 additions and 0 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

@@ -0,0 +1,56 @@
<?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>{33915750-A749-4D9D-A5E9-E1B01773D724}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Libraries</RootNamespace>
<AssemblyName>Libraries</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>
</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>
<ItemGroup>
<Content Include="WP7_Toolkit\Microsoft.Phone.Controls.Toolkit.Design.dll" />
<Content Include="WP7_Toolkit\Microsoft.Phone.Controls.Toolkit.dll" />
<Content Include="WP7_Toolkit\Microsoft.Phone.Controls.Toolkit.pdb" />
<Content Include="WP7_Toolkit\Microsoft.Phone.Controls.Toolkit.xml" />
<Content Include="WPF_Interactivity\System.Windows.Interactivity.dll" />
<Content Include="WPF_Interactivity\System.Windows.Interactivity.xml" />
</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,69 @@
<Application xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone" xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone" xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit" xmlns:toolkitPrimitives="clr-namespace:Microsoft.Phone.Controls.Primitives;assembly=Microsoft.Phone.Controls.Toolkit" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"
x:Class="WindowsPhone.Recipes.Push.Client.App"
>
<!--Application Resources-->
<Application.Resources>
<ItemsPanelTemplate x:Key="ItemsPanelTemplate">
<StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
<Style x:Key="PatternListBoxItemStyle" TargetType="ListBoxItem">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="BorderBrush" Value="Transparent"/>
<Setter Property="Padding" Value="2"/>
<Setter Property="Margin" Value="2"/>
<Setter Property="Width" Value="85"/>
<Setter Property="Height" Value="60"/>
<Setter Property="HorizontalContentAlignment" Value="Center"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBoxItem">
<Border x:Name="LayoutRoot" HorizontalAlignment="{TemplateBinding HorizontalAlignment}" VerticalAlignment="{TemplateBinding VerticalAlignment}" Background="Transparent">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal"/>
<VisualState x:Name="MouseOver"/>
<VisualState x:Name="Disabled">
<Storyboard>
<DoubleAnimation Duration="0" To=".5" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="ContentContainer"/>
</Storyboard>
</VisualState>
</VisualStateGroup>
<VisualStateGroup x:Name="SelectionStates">
<VisualStateGroup.Transitions>
<VisualTransition GeneratedDuration="0:0:0.4" To="Selected"/>
</VisualStateGroup.Transitions>
<VisualState x:Name="Unselected"/>
<VisualState x:Name="Selected">
<Storyboard>
<ColorAnimation Duration="0" To="#FF1BA1E2" Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)" Storyboard.TargetName="LayoutRoot" d:IsOptimized="True"/>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<ContentControl x:Name="ContentContainer"
ContentTemplate="{TemplateBinding ContentTemplate}"
Content="{TemplateBinding Content}"
Foreground="{StaticResource PhoneForegroundBrush}"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
Margin="{TemplateBinding Padding}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Application.Resources>
<Application.ApplicationLifetimeObjects>
<!--Required object that handles lifetime events for the application-->
<shell:PhoneApplicationService
Launching="Application_Launching" Closing="Application_Closing"
Activated="Application_Activated" Deactivated="Application_Deactivated"/>
</Application.ApplicationLifetimeObjects>
</Application>
@@ -0,0 +1,137 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
namespace WindowsPhone.Recipes.Push.Client
{
public partial class App : Application
{
internal const string ServerAddress = "http://localhost:8000";
/// <summary>
/// Provides easy access to the root frame of the Phone Application.
/// </summary>
/// <returns>The root frame of the Phone Application.</returns>
public PhoneApplicationFrame RootFrame { get; private set; }
/// <summary>
/// Constructor for the Application object.
/// </summary>
public App()
{
// Global handler for uncaught exceptions.
UnhandledException += Application_UnhandledException;
// Show graphics profiling information while debugging.
if (System.Diagnostics.Debugger.IsAttached)
{
// Display the current frame rate counters.
Application.Current.Host.Settings.EnableFrameRateCounter = true;
// Show the areas of the app that are being redrawn in each frame.
//Application.Current.Host.Settings.EnableRedrawRegions = true;
// Enable non-production analysis visualization mode,
// which shows areas of a page that are being GPU accelerated with a colored overlay.
//Application.Current.Host.Settings.EnableCacheVisualization = true;
}
// Standard Silverlight initialization
InitializeComponent();
// Phone-specific initialization
InitializePhoneApplication();
}
// Code to execute when the application is launching (eg, from Start)
// This code will not execute when the application is reactivated
private void Application_Launching(object sender, LaunchingEventArgs e)
{
}
// Code to execute when the application is activated (brought to foreground)
// This code will not execute when the application is first launched
private void Application_Activated(object sender, ActivatedEventArgs e)
{
}
// Code to execute when the application is deactivated (sent to background)
// This code will not execute when the application is closing
private void Application_Deactivated(object sender, DeactivatedEventArgs e)
{
}
// Code to execute when the application is closing (eg, user hit Back)
// This code will not execute when the application is deactivated
private void Application_Closing(object sender, ClosingEventArgs e)
{
}
// Code to execute if a navigation fails
private void RootFrame_NavigationFailed(object sender, NavigationFailedEventArgs e)
{
if (System.Diagnostics.Debugger.IsAttached)
{
// A navigation has failed; break into the debugger
System.Diagnostics.Debugger.Break();
}
}
// Code to execute on Unhandled Exceptions
private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
{
if (System.Diagnostics.Debugger.IsAttached)
{
// An unhandled exception has occurred; break into the debugger
System.Diagnostics.Debugger.Break();
}
}
#region Phone application initialization
// Avoid double-initialization
private bool phoneApplicationInitialized = false;
// Do not add any additional code to this method
private void InitializePhoneApplication()
{
if (phoneApplicationInitialized)
return;
// Create the frame but don't set it as RootVisual yet; this allows the splash
// screen to remain active until the application is ready to render.
RootFrame = new PhoneApplicationFrame();
RootFrame.Navigated += CompleteInitializePhoneApplication;
// Handle navigation failures
RootFrame.NavigationFailed += RootFrame_NavigationFailed;
// Ensure we don't initialize again
phoneApplicationInitialized = true;
}
// Do not add any additional code to this method
private void CompleteInitializePhoneApplication(object sender, NavigationEventArgs e)
{
// Set the root visual to allow the application to render
if (RootVisual != RootFrame)
RootVisual = RootFrame;
// Remove this handler since it is no longer needed
RootFrame.Navigated -= CompleteInitializePhoneApplication;
}
#endregion
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

@@ -0,0 +1,19 @@
<UserControl x:Class="WindowsPhone.Recipes.Push.Client.Controls.NotificationBox"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
d:DesignHeight="189" d:DesignWidth="480">
<StackPanel Background="Black">
<TextBlock Margin="4" Text="{Binding Title}" />
<TextBlock Margin="4" Text="{Binding Message}" TextWrapping="Wrap" />
<CheckBox IsChecked="{Binding ShowAgain, Mode=TwoWay}" Content="Show this message again" />
<Button Margin="4" HorizontalAlignment="Right" Width="200" Content="OK" Click="buttonOk_Click" />
</StackPanel>
</UserControl>
@@ -0,0 +1,91 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.IO.IsolatedStorage;
using System.Windows.Controls.Primitives;
using Microsoft.Phone.Controls;
namespace WindowsPhone.Recipes.Push.Client.Controls
{
public partial class NotificationBox : UserControl
{
#region Fields
private readonly IsolatedStorageSettings Settings = IsolatedStorageSettings.ApplicationSettings;
private static Popup _popup;
#endregion
public string Title { get; set; }
public string Message { get; set; }
public bool ShowAgain
{
get
{
bool showAgain;
if (!Settings.TryGetValue("NotificationBox.ShowAgain", out showAgain))
{
showAgain = true;
ShowAgain = showAgain;
}
return showAgain;
}
set
{
Settings["NotificationBox.ShowAgain"] = value;
}
}
private NotificationBox()
{
DataContext = this;
InitializeComponent();
}
public static void Show(string title, string message)
{
if (_popup != null)
{
return;
}
var root = Application.Current.RootVisual as PhoneApplicationFrame;
var notificationBox = new NotificationBox
{
Title = title,
Message = message,
Width = root.ActualWidth,
MaxHeight = root.ActualHeight,
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center
};
if (!notificationBox.ShowAgain)
return;
_popup = new Popup
{
Child = notificationBox,
IsOpen = true,
};
}
private void buttonOk_Click(object sender, RoutedEventArgs e)
{
_popup.IsOpen = false;
_popup = null;
}
}
}
@@ -0,0 +1,61 @@
using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Data;
using System.Globalization;
namespace WindowsPhone.Recipes.Push.Client.Controls
{
public sealed class BooleanToVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var flag = false;
if (value is bool)
{
flag = (bool)value;
}
else if (value is bool?)
{
var nullable = (bool?)value;
flag = nullable.GetValueOrDefault();
}
if (parameter != null)
{
if (bool.Parse((string)parameter))
{
flag = !flag;
}
}
if (flag)
{
return Visibility.Visible;
}
else
{
return Visibility.Collapsed;
}
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
var back = ((value is Visibility) && (((Visibility)value) == Visibility.Visible));
if (parameter != null)
{
if ((bool)parameter)
{
back = !back;
}
}
return back;
}
}
}
@@ -0,0 +1,161 @@
<UserControl x:Class="WindowsPhone.Recipes.Push.Client.Controls.ProgressBarWithText"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:localHelpers="clr-namespace:WindowsPhone.Recipes.Push.Client.Controls"
xmlns:unsupported="clr-namespace:WindowsPhone.Recipes.Push.Client.Controls"
mc:Ignorable="d"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
d:DesignHeight="480" d:DesignWidth="480"
>
<UserControl.Resources>
<localHelpers:BooleanToVisibilityConverter x:Key="booleanToVisibilityConverter" />
<Style x:Key="PerformanceProgressBar" TargetType="ProgressBar">
<Setter Property="Foreground" Value="{StaticResource PhoneAccentBrush}"/>
<Setter Property="Background" Value="{StaticResource PhoneAccentBrush}"/>
<Setter Property="Maximum" Value="100"/>
<Setter Property="IsHitTestVisible" Value="False"/>
<Setter Property="Padding" Value="{StaticResource PhoneHorizontalMargin}"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ProgressBar">
<unsupported:RelativeAnimatingContentControl HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch">
<unsupported:RelativeAnimatingContentControl.Resources>
<ExponentialEase EasingMode="EaseOut" Exponent="1" x:Key="ProgressBarEaseOut"/>
<ExponentialEase EasingMode="EaseOut" Exponent="1" x:Key="ProgressBarEaseIn"/>
</unsupported:RelativeAnimatingContentControl.Resources>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Determinate"/>
<VisualState x:Name="Indeterminate">
<Storyboard RepeatBehavior="Forever" Duration="00:00:04.4">
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="IndeterminateRoot">
<DiscreteObjectKeyFrame KeyTime="0">
<DiscreteObjectKeyFrame.Value>
<Visibility>Visible</Visibility>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="DeterminateRoot">
<DiscreteObjectKeyFrame KeyTime="0">
<DiscreteObjectKeyFrame.Value>
<Visibility>Collapsed</Visibility>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00.0" Storyboard.TargetProperty="X" Storyboard.TargetName="R1TT">
<LinearDoubleKeyFrame KeyTime="00:00:00.0" Value="0.1"/>
<EasingDoubleKeyFrame KeyTime="00:00:00.5" Value="33.1" EasingFunction="{StaticResource ProgressBarEaseOut}"/>
<LinearDoubleKeyFrame KeyTime="00:00:02.0" Value="66.1"/>
<EasingDoubleKeyFrame KeyTime="00:00:02.5" Value="100.1" EasingFunction="{StaticResource ProgressBarEaseIn}"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00.2" Storyboard.TargetProperty="X" Storyboard.TargetName="R2TT">
<LinearDoubleKeyFrame KeyTime="00:00:00.0" Value="0.1"/>
<EasingDoubleKeyFrame KeyTime="00:00:00.5" Value="33.1" EasingFunction="{StaticResource ProgressBarEaseOut}"/>
<LinearDoubleKeyFrame KeyTime="00:00:02.0" Value="66.1"/>
<EasingDoubleKeyFrame KeyTime="00:00:02.5" Value="100.1" EasingFunction="{StaticResource ProgressBarEaseIn}"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00.4" Storyboard.TargetProperty="X" Storyboard.TargetName="R3TT">
<LinearDoubleKeyFrame KeyTime="00:00:00.0" Value="0.1"/>
<EasingDoubleKeyFrame KeyTime="00:00:00.5" Value="33.1" EasingFunction="{StaticResource ProgressBarEaseOut}"/>
<LinearDoubleKeyFrame KeyTime="00:00:02.0" Value="66.1"/>
<EasingDoubleKeyFrame KeyTime="00:00:02.5" Value="100.1" EasingFunction="{StaticResource ProgressBarEaseIn}"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00.6" Storyboard.TargetProperty="X" Storyboard.TargetName="R4TT">
<LinearDoubleKeyFrame KeyTime="00:00:00.0" Value="0.1"/>
<EasingDoubleKeyFrame KeyTime="00:00:00.5" Value="33.1" EasingFunction="{StaticResource ProgressBarEaseOut}"/>
<LinearDoubleKeyFrame KeyTime="00:00:02.0" Value="66.1"/>
<EasingDoubleKeyFrame KeyTime="00:00:02.5" Value="100.1" EasingFunction="{StaticResource ProgressBarEaseIn}"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00.8" Storyboard.TargetProperty="X" Storyboard.TargetName="R5TT">
<LinearDoubleKeyFrame KeyTime="00:00:00.0" Value="0.1"/>
<EasingDoubleKeyFrame KeyTime="00:00:00.5" Value="33.1" EasingFunction="{StaticResource ProgressBarEaseOut}"/>
<LinearDoubleKeyFrame KeyTime="00:00:02.0" Value="66.1"/>
<EasingDoubleKeyFrame KeyTime="00:00:02.5" Value="100.1" EasingFunction="{StaticResource ProgressBarEaseIn}"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00.0" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="R1">
<DiscreteDoubleKeyFrame KeyTime="0" Value="1"/>
<DiscreteDoubleKeyFrame KeyTime="00:00:02.5" Value="0"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00.2" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="R2">
<DiscreteDoubleKeyFrame KeyTime="0" Value="1"/>
<DiscreteDoubleKeyFrame KeyTime="00:00:02.5" Value="0"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00.4" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="R3">
<DiscreteDoubleKeyFrame KeyTime="0" Value="1"/>
<DiscreteDoubleKeyFrame KeyTime="00:00:02.5" Value="0"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00.6" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="R4">
<DiscreteDoubleKeyFrame KeyTime="0" Value="1"/>
<DiscreteDoubleKeyFrame KeyTime="00:00:02.5" Value="0"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00.8" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="R5">
<DiscreteDoubleKeyFrame KeyTime="0" Value="1"/>
<DiscreteDoubleKeyFrame KeyTime="00:00:02.5" Value="0"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Grid>
<Grid x:Name="DeterminateRoot" Margin="{TemplateBinding Padding}" Visibility="Visible">
<Rectangle x:Name="ProgressBarTrack" Fill="{TemplateBinding Background}" Height="4" Opacity="0.1"/>
<Rectangle x:Name="ProgressBarIndicator" Fill="{TemplateBinding Foreground}" HorizontalAlignment="Left" Height="4"/>
</Grid>
<Border x:Name="IndeterminateRoot" Margin="{TemplateBinding Padding}" Visibility="Collapsed">
<Grid HorizontalAlignment="Left">
<Rectangle Fill="{TemplateBinding Foreground}" Height="4" IsHitTestVisible="False" Width="4" x:Name="R1" Opacity="0" CacheMode="BitmapCache">
<Rectangle.RenderTransform>
<TranslateTransform x:Name="R1TT"/>
</Rectangle.RenderTransform>
</Rectangle>
<Rectangle Fill="{TemplateBinding Foreground}" Height="4" IsHitTestVisible="False" Width="4" x:Name="R2" Opacity="0" CacheMode="BitmapCache">
<Rectangle.RenderTransform>
<TranslateTransform x:Name="R2TT"/>
</Rectangle.RenderTransform>
</Rectangle>
<Rectangle Fill="{TemplateBinding Foreground}" Height="4" IsHitTestVisible="False" Width="4" x:Name="R3" Opacity="0" CacheMode="BitmapCache">
<Rectangle.RenderTransform>
<TranslateTransform x:Name="R3TT"/>
</Rectangle.RenderTransform>
</Rectangle>
<Rectangle Fill="{TemplateBinding Foreground}" Height="4" IsHitTestVisible="False" Width="4" x:Name="R4" Opacity="0" CacheMode="BitmapCache">
<Rectangle.RenderTransform>
<TranslateTransform x:Name="R4TT"/>
</Rectangle.RenderTransform>
</Rectangle>
<Rectangle Fill="{TemplateBinding Foreground}" Height="4" IsHitTestVisible="False" Width="4" x:Name="R5" Opacity="0" CacheMode="BitmapCache">
<Rectangle.RenderTransform>
<TranslateTransform x:Name="R5TT"/>
</Rectangle.RenderTransform>
</Rectangle>
</Grid>
</Border>
</Grid>
</unsupported:RelativeAnimatingContentControl>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</UserControl.Resources>
<StackPanel x:Name="stackPanel"
Visibility="{Binding ShowProgress, Converter={StaticResource booleanToVisibilityConverter}}"
VerticalAlignment="Center"
>
<TextBlock
Text="{Binding Text}"
HorizontalAlignment="Center"
/>
<ProgressBar
Foreground="White"
IsIndeterminate="{Binding ShowProgress}"
Style="{StaticResource PerformanceProgressBar}"
Margin="0,5,0,0"
/>
</StackPanel>
</UserControl>
@@ -0,0 +1,69 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
namespace WindowsPhone.Recipes.Push.Client.Controls
{
public partial class ProgressBarWithText : UserControl
{
public ProgressBarWithText()
{
InitializeComponent();
stackPanel.DataContext = this;
}
#region ShowProgress
/// <summary>
/// ShowProgress Dependency Property
/// </summary>
public static readonly DependencyProperty ShowProgressProperty =
DependencyProperty.Register("ShowProgress", typeof(bool), typeof(ProgressBarWithText),
new PropertyMetadata((bool)false));
/// <summary>
/// Gets or sets the ShowProgress property. This dependency property
/// indicates whether to show the progress bar.
/// </summary>
public bool ShowProgress
{
get { return (bool)GetValue(ShowProgressProperty); }
set { SetValue(ShowProgressProperty, value); }
}
#endregion
#region Text
/// <summary>
/// Text Dependency Property
/// </summary>
public static readonly DependencyProperty TextProperty =
DependencyProperty.Register("Text", typeof(string), typeof(ProgressBarWithText),
new PropertyMetadata((string)""));
/// <summary>
/// Gets or sets the Text property. This dependency property
/// indicates what is the text that appears above the progress bar.
/// </summary>
public string Text
{
get { return (string)GetValue(TextProperty); }
set { SetValue(TextProperty, value); }
}
#endregion
}
}
@@ -0,0 +1,625 @@
// (c) Copyright Microsoft Corporation.
// This source is subject to the Microsoft Public License (Ms-PL).
// Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
// All other rights reserved.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Animation;
// This is a very special primitive control that works around a limitation in
// the core animation subsystem of Silverlight: there is no way to declare in
// VSM states relative properties, such as animating from 0 to 33% the width of
// the control, using double animations for translation.
//
// It's a tough problem to solve property, but this primitive, unsupported
// control does offer a solution based on magic numbers that still allows a
// designer to make alterations to their animation values to present their
// vision for custom templates.
//
// This is instrumental in offering a Windows Phone ProgressBar implementation
// that uses the render thread instead of animating UI thread-only properties.
//
// For questions, please see
// http://www.jeff.wilcox.name/performanceprogressbar/
//
// This control is licensed Ms-PL and as such comes with no warranties or
// official support.
//
// Style Note
// - - -
// The style that must be used with this is present at the bottom of this file.
//
namespace WindowsPhone.Recipes.Push.Client.Controls
{
/// <summary>
/// A very specialized primitive control that works around a specific visual
/// state manager issue. The platform does not support relative sized
/// translation values, and this special control walks through visual state
/// animation storyboards looking for magic numbers to use as percentages.
/// This control is not supported, unofficial, and is a hack in many ways.
/// It is used to enable a Windows Phone native platform-style progress bar
/// experience in indeterminate mode that remains performant.
/// </summary>
public class RelativeAnimatingContentControl : ContentControl
{
/// <summary>
/// A simple Epsilon-style value used for trying to determine the magic
/// state, if any, of a double.
/// </summary>
private const double SimpleDoubleComparisonEpsilon = 0.000009;
/// <summary>
/// The last known width of the control.
/// </summary>
private double _knownWidth;
/// <summary>
/// The last known height of the control.
/// </summary>
private double _knownHeight;
/// <summary>
/// A set of custom animation adapters used to update the animation
/// storyboards when the size of the control changes.
/// </summary>
private List<AnimationValueAdapter> _specialAnimations;
/// <summary>
/// Initializes a new instance of the RelativeAnimatingContentControl
/// type.
/// </summary>
public RelativeAnimatingContentControl()
{
SizeChanged += OnSizeChanged;
}
/// <summary>
/// Handles the size changed event.
/// </summary>
/// <param name="sender">The source object.</param>
/// <param name="e">The event arguments.</param>
private void OnSizeChanged(object sender, SizeChangedEventArgs e)
{
if (e != null && e.NewSize.Height > 0 && e.NewSize.Width > 0)
{
_knownWidth = e.NewSize.Width;
_knownHeight = e.NewSize.Height;
Clip = new RectangleGeometry { Rect = new Rect(0, 0, _knownWidth, _knownHeight), };
UpdateAnyAnimationValues();
}
}
/// <summary>
/// Walks through the known storyboards in the control's template that
/// may contain magic double animation values, storing them for future
/// use and updates.
/// </summary>
private void UpdateAnyAnimationValues()
{
if (_knownHeight > 0 && _knownWidth > 0)
{
// Initially, before any special animations have been found,
// the visual state groups of the control must be explored.
// By definition they must be at the implementation root of the
// control, and this is designed to not walk into any other
// depth.
if (_specialAnimations == null)
{
_specialAnimations = new List<AnimationValueAdapter>();
foreach (VisualStateGroup group in VisualStateManager.GetVisualStateGroups(this))
{
if (group == null)
{
continue;
}
foreach (VisualState state in group.States)
{
if (state != null)
{
Storyboard sb = state.Storyboard;
if (sb != null)
{
// Examine all children of the storyboards,
// looking for either type of double
// animation.
foreach (Timeline timeline in sb.Children)
{
DoubleAnimation da = timeline as DoubleAnimation;
DoubleAnimationUsingKeyFrames dakeys = timeline as DoubleAnimationUsingKeyFrames;
if (da != null)
{
ProcessDoubleAnimation(da);
}
else if (dakeys != null)
{
ProcessDoubleAnimationWithKeys(dakeys);
}
}
}
}
}
}
}
// Update special animation values relative to the current size.
UpdateKnownAnimations();
}
}
/// <summary>
/// Walks through all special animations, updating based on the current
/// size of the control.
/// </summary>
private void UpdateKnownAnimations()
{
foreach (AnimationValueAdapter adapter in _specialAnimations)
{
adapter.UpdateWithNewDimension(_knownWidth, _knownHeight);
}
}
/// <summary>
/// Processes a double animation with keyframes, looking for known
/// special values to store with an adapter.
/// </summary>
/// <param name="da">The double animation using key frames instance.</param>
private void ProcessDoubleAnimationWithKeys(DoubleAnimationUsingKeyFrames da)
{
// Look through all keyframes in the instance.
foreach (DoubleKeyFrame frame in da.KeyFrames)
{
var d = DoubleAnimationFrameAdapter.GetDimensionFromMagicNumber(frame.Value);
if (d.HasValue)
{
_specialAnimations.Add(new DoubleAnimationFrameAdapter(d.Value, frame));
}
}
}
/// <summary>
/// Processes a double animation looking for special values.
/// </summary>
/// <param name="da">The double animation instance.</param>
private void ProcessDoubleAnimation(DoubleAnimation da)
{
// Look for a special value in the To property.
if (da.To.HasValue)
{
var d = DoubleAnimationToAdapter.GetDimensionFromMagicNumber(da.To.Value);
if (d.HasValue)
{
_specialAnimations.Add(new DoubleAnimationToAdapter(d.Value, da));
}
}
// Look for a special value in the From property.
if (da.From.HasValue)
{
var d = DoubleAnimationFromAdapter.GetDimensionFromMagicNumber(da.To.Value);
if (d.HasValue)
{
_specialAnimations.Add(new DoubleAnimationFromAdapter(d.Value, da));
}
}
}
#region Private animation updating system
/// <summary>
/// A selection of dimensions of interest for updating an animation.
/// </summary>
private enum DoubleAnimationDimension
{
/// <summary>
/// The width (horizontal) dimension.
/// </summary>
Width,
/// <summary>
/// The height (vertical) dimension.
/// </summary>
Height,
}
/// <summary>
/// A simple class designed to store information about a specific
/// animation instance and its properties. Able to update the values at
/// runtime.
/// </summary>
private abstract class AnimationValueAdapter
{
/// <summary>
/// Gets or sets the original double value.
/// </summary>
protected double OriginalValue { get; set; }
/// <summary>
/// Initializes a new instance of the AnimationValueAdapter type.
/// </summary>
/// <param name="dimension">The dimension of interest for updates.</param>
public AnimationValueAdapter(DoubleAnimationDimension dimension)
{
Dimension = dimension;
}
/// <summary>
/// Gets the dimension of interest for the control.
/// </summary>
public DoubleAnimationDimension Dimension { get; private set; }
/// <summary>
/// Updates the original instance based on new dimension information
/// from the control. Takes both and allows the subclass to make the
/// decision on which ratio, values, and dimension to use.
/// </summary>
/// <param name="width">The width of the control.</param>
/// <param name="height">The height of the control.</param>
public abstract void UpdateWithNewDimension(double width, double height);
}
private abstract class GeneralAnimationValueAdapter<T> : AnimationValueAdapter
{
/// <summary>
/// Stores the animation instance.
/// </summary>
protected T Instance { get; set; }
/// <summary>
/// Gets the value of the underlying property of interest.
/// </summary>
/// <returns>Returns the value of the property.</returns>
protected abstract double GetValue();
/// <summary>
/// Sets the value for the underlying property of interest.
/// </summary>
/// <param name="newValue">The new value for the property.</param>
protected abstract void SetValue(double newValue);
/// <summary>
/// Gets the initial value (minus the magic number portion) that the
/// designer stored within the visual state animation property.
/// </summary>
protected double InitialValue { get; private set; }
/// <summary>
/// The ratio based on the original magic value, used for computing
/// the updated animation property of interest when the size of the
/// control changes.
/// </summary>
private double _ratio;
/// <summary>
/// Initializes a new instance of the GeneralAnimationValueAdapter
/// type.
/// </summary>
/// <param name="d">The dimension of interest.</param>
/// <param name="instance">The animation type instance.</param>
public GeneralAnimationValueAdapter(DoubleAnimationDimension d, T instance)
: base(d)
{
Instance = instance;
InitialValue = StripMagicNumberOff(GetValue());
_ratio = InitialValue / 100;
}
/// <summary>
/// Approximately removes the magic number state from a value.
/// </summary>
/// <param name="number">The initial number.</param>
/// <returns>Returns a double with an adjustment for the magic
/// portion of the number.</returns>
public double StripMagicNumberOff(double number)
{
return Dimension == DoubleAnimationDimension.Width ? number - .1 : number - .2;
}
/// <summary>
/// Retrieves the dimension, if any, from the number. If the number
/// is not magic, null is returned instead.
/// </summary>
/// <param name="number">The double value.</param>
/// <returns>Returs a double animation dimension, if the number was
/// partially magic; otherwise, returns null.</returns>
public static DoubleAnimationDimension? GetDimensionFromMagicNumber(double number)
{
double floor = Math.Floor(number);
double remainder = number - floor;
if (remainder >= .1 - SimpleDoubleComparisonEpsilon && remainder <= .1 + SimpleDoubleComparisonEpsilon)
{
return DoubleAnimationDimension.Width;
}
if (remainder >= .2 - SimpleDoubleComparisonEpsilon && remainder <= .2 + SimpleDoubleComparisonEpsilon)
{
return DoubleAnimationDimension.Height;
}
return null;
}
/// <summary>
/// Updates the animation instance based on the dimensions of the
/// control.
/// </summary>
/// <param name="width">The width of the control.</param>
/// <param name="height">The height of the control.</param>
public override void UpdateWithNewDimension(double width, double height)
{
double size = Dimension == DoubleAnimationDimension.Width ? width : height;
UpdateValue(size);
}
/// <summary>
/// Updates the value of the property.
/// </summary>
/// <param name="sizeToUse">The size of interest to use with a ratio
/// computation.</param>
private void UpdateValue(double sizeToUse)
{
SetValue(sizeToUse * _ratio);
}
}
/// <summary>
/// Adapter for DoubleAnimation's To property.
/// </summary>
private class DoubleAnimationToAdapter : GeneralAnimationValueAdapter<DoubleAnimation>
{
/// <summary>
/// Gets the value of the underlying property of interest.
/// </summary>
/// <returns>Returns the value of the property.</returns>
protected override double GetValue()
{
return (double)Instance.To;
}
/// <summary>
/// Sets the value for the underlying property of interest.
/// </summary>
/// <param name="newValue">The new value for the property.</param>
protected override void SetValue(double newValue)
{
Instance.To = newValue;
}
/// <summary>
/// Initializes a new instance of the DoubleAnimationToAdapter type.
/// </summary>
/// <param name="dimension">The dimension of interest.</param>
/// <param name="instance">The instance of the animation type.</param>
public DoubleAnimationToAdapter(DoubleAnimationDimension dimension, DoubleAnimation instance)
: base(dimension, instance)
{
}
}
/// <summary>
/// Adapter for DoubleAnimation's From property.
/// </summary>
private class DoubleAnimationFromAdapter : GeneralAnimationValueAdapter<DoubleAnimation>
{
/// <summary>
/// Gets the value of the underlying property of interest.
/// </summary>
/// <returns>Returns the value of the property.</returns>
protected override double GetValue()
{
return (double)Instance.From;
}
/// <summary>
/// Sets the value for the underlying property of interest.
/// </summary>
/// <param name="newValue">The new value for the property.</param>
protected override void SetValue(double newValue)
{
Instance.From = newValue;
}
/// <summary>
/// Initializes a new instance of the DoubleAnimationFromAdapter
/// type.
/// </summary>
/// <param name="dimension">The dimension of interest.</param>
/// <param name="instance">The instance of the animation type.</param>
public DoubleAnimationFromAdapter(DoubleAnimationDimension dimension, DoubleAnimation instance)
: base(dimension, instance)
{
}
}
/// <summary>
/// Adapter for double key frames.
/// </summary>
private class DoubleAnimationFrameAdapter : GeneralAnimationValueAdapter<DoubleKeyFrame>
{
/// <summary>
/// Gets the value of the underlying property of interest.
/// </summary>
/// <returns>Returns the value of the property.</returns>
protected override double GetValue()
{
return Instance.Value;
}
/// <summary>
/// Sets the value for the underlying property of interest.
/// </summary>
/// <param name="newValue">The new value for the property.</param>
protected override void SetValue(double newValue)
{
Instance.Value = newValue;
}
/// <summary>
/// Initializes a new instance of the DoubleAnimationFrameAdapter
/// type.
/// </summary>
/// <param name="dimension">The dimension of interest.</param>
/// <param name="instance">The instance of the animation type.</param>
public DoubleAnimationFrameAdapter(DoubleAnimationDimension dimension, DoubleKeyFrame frame)
: base(dimension, frame)
{
}
}
#endregion
}
/*
This is the style that should be used with the control. Make sure to define
the XMLNS at the top of the style file similar to this:
xmlns:unsupported="clr-namespace:WindowsPhone.Recipes.Push.Client.Controls"
<!--
// Performance Progress Bar
// - - -
// To use this progress bar at runtime, make sure to set the Style
// value to this key. Since the control visually is identical to control
// in the Windows Phone runtime, you will not be able to visually tell
// the difference: except this style will not use the UI thread at
// runtime when IsIndeterminate=true.
//
// <ProgressBar Style="{StaticResource PerformanceProgressBar}"
// IsIndeterminate="true"/>
//
-->
<Style x:Key="PerformanceProgressBar" TargetType="ProgressBar">
<Setter Property="Foreground" Value="{StaticResource PhoneAccentBrush}"/>
<Setter Property="Background" Value="{StaticResource PhoneAccentBrush}"/>
<Setter Property="Maximum" Value="100"/>
<Setter Property="IsHitTestVisible" Value="False"/>
<Setter Property="Padding" Value="{StaticResource PhoneHorizontalMargin}"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ProgressBar">
<unsupported:RelativeAnimatingContentControl HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch">
<unsupported:RelativeAnimatingContentControl.Resources>
<ExponentialEase EasingMode="EaseOut" Exponent="1" x:Key="ProgressBarEaseOut"/>
<ExponentialEase EasingMode="EaseOut" Exponent="1" x:Key="ProgressBarEaseIn"/>
</unsupported:RelativeAnimatingContentControl.Resources>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Determinate"/>
<VisualState x:Name="Indeterminate">
<Storyboard RepeatBehavior="Forever" Duration="00:00:04.4">
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="IndeterminateRoot">
<DiscreteObjectKeyFrame KeyTime="0">
<DiscreteObjectKeyFrame.Value>
<Visibility>Visible</Visibility>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="DeterminateRoot">
<DiscreteObjectKeyFrame KeyTime="0">
<DiscreteObjectKeyFrame.Value>
<Visibility>Collapsed</Visibility>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00.0" Storyboard.TargetProperty="X" Storyboard.TargetName="R1TT">
<LinearDoubleKeyFrame KeyTime="00:00:00.0" Value="0.1"/>
<EasingDoubleKeyFrame KeyTime="00:00:00.5" Value="33.1" EasingFunction="{StaticResource ProgressBarEaseOut}"/>
<LinearDoubleKeyFrame KeyTime="00:00:02.0" Value="66.1"/>
<EasingDoubleKeyFrame KeyTime="00:00:02.5" Value="100.1" EasingFunction="{StaticResource ProgressBarEaseIn}"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00.2" Storyboard.TargetProperty="X" Storyboard.TargetName="R2TT">
<LinearDoubleKeyFrame KeyTime="00:00:00.0" Value="0.1"/>
<EasingDoubleKeyFrame KeyTime="00:00:00.5" Value="33.1" EasingFunction="{StaticResource ProgressBarEaseOut}"/>
<LinearDoubleKeyFrame KeyTime="00:00:02.0" Value="66.1"/>
<EasingDoubleKeyFrame KeyTime="00:00:02.5" Value="100.1" EasingFunction="{StaticResource ProgressBarEaseIn}"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00.4" Storyboard.TargetProperty="X" Storyboard.TargetName="R3TT">
<LinearDoubleKeyFrame KeyTime="00:00:00.0" Value="0.1"/>
<EasingDoubleKeyFrame KeyTime="00:00:00.5" Value="33.1" EasingFunction="{StaticResource ProgressBarEaseOut}"/>
<LinearDoubleKeyFrame KeyTime="00:00:02.0" Value="66.1"/>
<EasingDoubleKeyFrame KeyTime="00:00:02.5" Value="100.1" EasingFunction="{StaticResource ProgressBarEaseIn}"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00.6" Storyboard.TargetProperty="X" Storyboard.TargetName="R4TT">
<LinearDoubleKeyFrame KeyTime="00:00:00.0" Value="0.1"/>
<EasingDoubleKeyFrame KeyTime="00:00:00.5" Value="33.1" EasingFunction="{StaticResource ProgressBarEaseOut}"/>
<LinearDoubleKeyFrame KeyTime="00:00:02.0" Value="66.1"/>
<EasingDoubleKeyFrame KeyTime="00:00:02.5" Value="100.1" EasingFunction="{StaticResource ProgressBarEaseIn}"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00.8" Storyboard.TargetProperty="X" Storyboard.TargetName="R5TT">
<LinearDoubleKeyFrame KeyTime="00:00:00.0" Value="0.1"/>
<EasingDoubleKeyFrame KeyTime="00:00:00.5" Value="33.1" EasingFunction="{StaticResource ProgressBarEaseOut}"/>
<LinearDoubleKeyFrame KeyTime="00:00:02.0" Value="66.1"/>
<EasingDoubleKeyFrame KeyTime="00:00:02.5" Value="100.1" EasingFunction="{StaticResource ProgressBarEaseIn}"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00.0" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="R1">
<DiscreteDoubleKeyFrame KeyTime="0" Value="1"/>
<DiscreteDoubleKeyFrame KeyTime="00:00:02.5" Value="0"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00.2" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="R2">
<DiscreteDoubleKeyFrame KeyTime="0" Value="1"/>
<DiscreteDoubleKeyFrame KeyTime="00:00:02.5" Value="0"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00.4" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="R3">
<DiscreteDoubleKeyFrame KeyTime="0" Value="1"/>
<DiscreteDoubleKeyFrame KeyTime="00:00:02.5" Value="0"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00.6" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="R4">
<DiscreteDoubleKeyFrame KeyTime="0" Value="1"/>
<DiscreteDoubleKeyFrame KeyTime="00:00:02.5" Value="0"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00.8" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="R5">
<DiscreteDoubleKeyFrame KeyTime="0" Value="1"/>
<DiscreteDoubleKeyFrame KeyTime="00:00:02.5" Value="0"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Grid>
<Grid x:Name="DeterminateRoot" Margin="{TemplateBinding Padding}" Visibility="Visible">
<Rectangle x:Name="ProgressBarTrack" Fill="{TemplateBinding Background}" Height="4" Opacity="0.1"/>
<Rectangle x:Name="ProgressBarIndicator" Fill="{TemplateBinding Foreground}" HorizontalAlignment="Left" Height="4"/>
</Grid>
<Border x:Name="IndeterminateRoot" Margin="{TemplateBinding Padding}" Visibility="Collapsed">
<Grid HorizontalAlignment="Left">
<Rectangle Fill="{TemplateBinding Foreground}" Height="4" IsHitTestVisible="False" Width="4" x:Name="R1" Opacity="0" CacheMode="BitmapCache">
<Rectangle.RenderTransform>
<TranslateTransform x:Name="R1TT"/>
</Rectangle.RenderTransform>
</Rectangle>
<Rectangle Fill="{TemplateBinding Foreground}" Height="4" IsHitTestVisible="False" Width="4" x:Name="R2" Opacity="0" CacheMode="BitmapCache">
<Rectangle.RenderTransform>
<TranslateTransform x:Name="R2TT"/>
</Rectangle.RenderTransform>
</Rectangle>
<Rectangle Fill="{TemplateBinding Foreground}" Height="4" IsHitTestVisible="False" Width="4" x:Name="R3" Opacity="0" CacheMode="BitmapCache">
<Rectangle.RenderTransform>
<TranslateTransform x:Name="R3TT"/>
</Rectangle.RenderTransform>
</Rectangle>
<Rectangle Fill="{TemplateBinding Foreground}" Height="4" IsHitTestVisible="False" Width="4" x:Name="R4" Opacity="0" CacheMode="BitmapCache">
<Rectangle.RenderTransform>
<TranslateTransform x:Name="R4TT"/>
</Rectangle.RenderTransform>
</Rectangle>
<Rectangle Fill="{TemplateBinding Foreground}" Height="4" IsHitTestVisible="False" Width="4" x:Name="R5" Opacity="0" CacheMode="BitmapCache">
<Rectangle.RenderTransform>
<TranslateTransform x:Name="R5TT"/>
</Rectangle.RenderTransform>
</Rectangle>
</Grid>
</Border>
</Grid>
</unsupported:RelativeAnimatingContentControl>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
*/
}
@@ -0,0 +1,59 @@
<UserControl x:Class="WindowsPhone.Recipes.Push.Client.Controls.PushSettingsControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:tk="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
xmlns:converters="clr-namespace:WindowsPhone.Recipes.Push.Client.Converters"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
d:DesignHeight="640" d:DesignWidth="480">
<UserControl.Resources>
<converters:BoolBrushConverter x:Key="BoolBrushConverter" />
<Style x:Key="DescTextStyle" TargetType="TextBlock">
<Setter Property="FontSize" Value="14" />
<Setter Property="Foreground" Value="Silver" />
<Setter Property="TextWrapping" Value="Wrap" />
<Setter Property="Margin" Value="16,-38,16,24" />
</Style>
</UserControl.Resources>
<Grid x:Name="LayoutRoot" Background="{StaticResource PhoneChromeBrush}">
<StackPanel>
<StackPanel>
<tk:ToggleSwitch Header="Push Notifications"
IsChecked="{Binding IsPushEnabled, Mode=TwoWay}" />
<TextBlock Style="{StaticResource DescTextStyle}"
Text="Turn on/off push notifications." />
</StackPanel>
<Grid>
<StackPanel Margin="16,0,0,0">
<tk:ToggleSwitch Header="Tile Notifications"
IsChecked="{Binding IsTileEnabled, Mode=TwoWay}" />
<TextBlock Style="{StaticResource DescTextStyle}"
Text="Tile push notifications update the application's tile displayed in the Start Screen. The application must be pinned by the user first." />
<tk:ToggleSwitch Header="Toast Notifications"
IsChecked="{Binding IsToastEnabled, Mode=TwoWay}" />
<TextBlock Style="{StaticResource DescTextStyle}"
Text="Toast push notifications are system-wide notifications that do not disrupt the user workflow or require intervention to resolve and are displayed in the top of the screen for ten seconds." />
<tk:ToggleSwitch Header="Raw Notifications"
IsChecked="{Binding IsRawEnabled, Mode=TwoWay}" />
<TextBlock Style="{StaticResource DescTextStyle}"
Text="Raw push notifications are used to send application specific information. The application must be running first." />
</StackPanel>
<Border Background="{Binding IsPushEnabled, Converter={StaticResource BoolBrushConverter}}" />
</Grid>
</StackPanel>
</Grid>
</UserControl>
@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.IO.IsolatedStorage;
using System.Xml.Linq;
namespace WindowsPhone.Recipes.Push.Client.Controls
{
public partial class PushSettingsControl : UserControl
{
public PushSettingsControl()
{
DataContext = PushContext.Current;
InitializeComponent();
}
}
}
@@ -0,0 +1,43 @@
using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.Generic;
namespace WindowsPhone.Recipes.Push.Client.Controls
{
public class ViewTransitions<T>
{
private class ViewTransition
{
public T To { get; set; }
public Action Action { get; set; }
}
public T _viewState;
private readonly Dictionary<T, ViewTransition> _transitions = new Dictionary<T, ViewTransition>();
public ViewTransitions(T initialState)
{
_viewState = initialState;
}
public void AddTransition(T from, T to, Action action)
{
_transitions[from] = new ViewTransition { To = to, Action = action };
}
public void Transition()
{
var transition = _transitions[_viewState];
_viewState = transition.To;
transition.Action();
}
}
}
@@ -0,0 +1,33 @@
using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Data;
namespace WindowsPhone.Recipes.Push.Client.Converters
{
public class BoolBrushConverter : IValueConverter
{
private static readonly Brush DisabledBrush = new SolidColorBrush
{
Color = Colors.Black,
Opacity = 0.4
};
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return object.Equals(value, true) ? null : DisabledBrush;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotSupportedException();
}
}
}
@@ -0,0 +1,21 @@
using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
namespace WindowsPhone.Recipes.Push.Client
{
public static class ExceptionExtensions
{
public static void Show(this Exception ex, string title = "Error")
{
MessageBox.Show(ex.Message, title, MessageBoxButton.OK);
}
}
}
@@ -0,0 +1,35 @@
<phone:PhoneApplicationPage x:Class="WindowsPhone.Recipes.Push.Client.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
shell:SystemTray.IsVisible="True">
<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!--TitlePanel contains the name of the application and page title-->
<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
<TextBlock x:Name="ApplicationTitle" Text="SERVER PUSH PATTERNS" Style="{StaticResource PhoneTextNormalStyle}"/>
<TextBlock x:Name="PageTitle" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
</StackPanel>
<!--ContentPanel - place additional content here-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<Border x:Name="activeView" />
<Button Visibility="Collapsed" VerticalAlignment="Bottom" Name="button" Click="button_Click" />
</Grid>
</Grid>
</phone:PhoneApplicationPage>
@@ -0,0 +1,168 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.IO.IsolatedStorage;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using WindowsPhone.Recipes.Push.Client.Views;
using WindowsPhone.Recipes.Push.Client.Controls;
namespace WindowsPhone.Recipes.Push.Client
{
public partial class MainPage : PhoneApplicationPage
{
#region Fields
private readonly IsolatedStorageSettings Settings = IsolatedStorageSettings.ApplicationSettings;
private const string ChannelName = "OneTimePatternChannel";
private const string ServiceName = "WindowsPhone.Recipes.Push.Server.PushService";
private static readonly Uri[] AllowedDomains =
{
new Uri(App.ServerAddress)
};
private readonly ViewTransitions<ViewState> _viewTransitions;
#endregion
#region Properties
private UIElement ActiveView
{
get { return activeView.Child; }
set { activeView.Child = value; }
}
#endregion
#region Ctor
public MainPage()
{
InitializeComponent();
var viewState = CheckIfFirstTimeLoaded() ? ViewState.FirstInitial : ViewState.Initial;
_viewTransitions = new ViewTransitions<ViewState>(viewState);
InitializeViewTransitions();
}
#endregion
#region Overrides
protected override void OnNavigatedTo(NavigationEventArgs e)
{
var pushContext = new PushContext(ChannelName, ServiceName, AllowedDomains, Dispatcher);
_viewTransitions.Transition();
base.OnNavigatedTo(e);
}
#endregion
#region Event Handlers
private void userLoginView_Login(object sender, LoginEventArgs e)
{
if (e.Exception != null)
{
e.Exception.Show("Login");
return;
}
var userLoginView = sender as UserLoginView;
userLoginView.Login -= userLoginView_Login;
_viewTransitions.Transition();
}
private void button_Click(object sender, RoutedEventArgs e)
{
_viewTransitions.Transition();
}
#endregion
#region Privates
private bool CheckIfFirstTimeLoaded()
{
object unused;
if (!Settings.TryGetValue("MainPage.Loaded", out unused))
{
Settings["MainPage.Loaded"] = null;
return true;
}
return false;
}
private void DisplayUserLoginView()
{
PageTitle.Text = "registration";
button.Visibility = Visibility.Collapsed;
var userLoginView = new UserLoginView
{
UserName = "tomer.shamam"
};
userLoginView.Login += userLoginView_Login;
ActiveView = userLoginView;
}
private void DisplayPushSettingsView()
{
PageTitle.Text = "push settings";
button.Content = "OK";
button.Visibility = Visibility.Visible;
ActiveView = new PushSettingsView();
}
private void DisplayInboxView()
{
PageTitle.Text = "server status";
button.Content = "Settings";
button.Visibility = Visibility.Visible;
ActiveView = new InboxView();
}
private void InitializeViewTransitions()
{
_viewTransitions.AddTransition(ViewState.FirstInitial, ViewState.FirstSettings, DisplayPushSettingsView);
_viewTransitions.AddTransition(ViewState.Initial, ViewState.Login, DisplayUserLoginView);
_viewTransitions.AddTransition(ViewState.FirstSettings, ViewState.Login, DisplayUserLoginView);
_viewTransitions.AddTransition(ViewState.Login, ViewState.Inbox, DisplayInboxView);
_viewTransitions.AddTransition(ViewState.Settings, ViewState.Inbox, DisplayInboxView);
_viewTransitions.AddTransition(ViewState.Inbox, ViewState.Settings, DisplayPushSettingsView);
}
#endregion
#region ViewState
[Flags]
private enum ViewState
{
FirstTime = 1,
Initial = 2,
Settings = 4,
Login = 8,
Inbox = 16,
FirstInitial = FirstTime | Initial,
FirstSettings = FirstTime | Settings
}
#endregion
}
}
@@ -0,0 +1,6 @@
<Deployment xmlns="http://schemas.microsoft.com/client/2007/deployment"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
>
<Deployment.Parts>
</Deployment.Parts>
</Deployment>
@@ -0,0 +1,35 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 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.Client")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("WindowsPhone.Recipes.Push.Client")]
[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)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("499d0817-8efe-4199-b5dc-e397b79dddc0")]
// 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 Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<Deployment xmlns="http://schemas.microsoft.com/windowsphone/2009/deployment" AppPlatformVersion="7.0">
<App xmlns="" ProductID="{e011615c-5d28-4e9c-9b07-0b140647fbfa}" Title="Push Patterns" RuntimeType="Silverlight" Version="1.0.0.0" Genre="apps.normal" Author="Tomer Shamam" Description="Sample description" Publisher="Microsoft">
<IconPath IsRelative="true" IsResource="false">ApplicationIcon.png</IconPath>
<Capabilities>
<Capability Name="ID_CAP_GAMERSERVICES" />
<Capability Name="ID_CAP_IDENTITY_DEVICE" />
<Capability Name="ID_CAP_IDENTITY_USER" />
<Capability Name="ID_CAP_LOCATION" />
<Capability Name="ID_CAP_MEDIALIB" />
<Capability Name="ID_CAP_MICROPHONE" />
<Capability Name="ID_CAP_NETWORKING" />
<Capability Name="ID_CAP_PHONEDIALER" />
<Capability Name="ID_CAP_PUSH_NOTIFICATION" />
<Capability Name="ID_CAP_SENSORS" />
<Capability Name="ID_CAP_WEBBROWSERCOMPONENT" />
</Capabilities>
<Tasks>
<DefaultTask Name="_default" NavigationPage="MainPage.xaml" />
</Tasks>
<Tokens>
<PrimaryToken TokenID="WindowsPhone.Recipes.Push.Client" TaskName="_default">
<TemplateType5>
<BackgroundImageURI IsRelative="true" IsResource="false">Background.png</BackgroundImageURI>
<Count>0</Count>
<Title>Push Patterns</Title>
</TemplateType5>
</PrimaryToken>
</Tokens>
</App>
</Deployment>
@@ -0,0 +1,360 @@
using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Notification;
using System.Windows.Threading;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO.IsolatedStorage;
using System.ComponentModel;
namespace WindowsPhone.Recipes.Push.Client
{
public sealed class PushContext : INotifyPropertyChanged
{
#region Fields
private readonly IsolatedStorageSettings Settings = IsolatedStorageSettings.ApplicationSettings;
private static PushContext _current;
private bool _isConnected;
#endregion
#region Properties
private Dispatcher Dispatcher { get; set; }
public string ChannelName { get; private set; }
public string ServiceName { get; private set; }
public IList<Uri> AllowedDomains { get; private set; }
public HttpNotificationChannel NotificationChannel { get; private set; }
public static PushContext Current
{
get { return _current; }
}
public bool IsConnected
{
get { return _isConnected; }
set
{
if (_isConnected != value)
{
_isConnected = value;
NotifyPropertyChanged("IsConnected");
}
}
}
public bool IsPushEnabled
{
get { return GetOrCreate<bool>("PushContext.IsPushEnabled", false); }
set
{
SetOrCreate("PushContext.IsPushEnabled", value);
UpdateNotificationBindings();
NotifyPropertyChanged("IsPushEnabled");
}
}
public bool IsTileEnabled
{
get { return GetOrCreate<bool>("PushContext.IsTileEnabled", true); }
set
{
SetOrCreate("PushContext.IsTileEnabled", value);
UpdateNotificationBindings();
NotifyPropertyChanged("IsTileEnabled");
}
}
public bool IsToastEnabled
{
get { return GetOrCreate<bool>("PushContext.IsToastEnabled", true); }
set
{
SetOrCreate("PushContext.IsToastEnabled", value);
UpdateNotificationBindings();
NotifyPropertyChanged("IsToastEnabled");
}
}
public bool IsRawEnabled
{
get { return GetOrCreate<bool>("PushContext.IsRawEnabled", true); }
set
{
SetOrCreate("PushContext.IsRawEnabled", value);
NotifyPropertyChanged("IsRawEnabled");
}
}
#endregion
#region Events
public event EventHandler<PushContextErrorEventArgs> Error;
public event EventHandler<PushContextEventArgs> ChannelPrepared;
public event EventHandler<HttpNotificationEventArgs> RawNotification;
public event PropertyChangedEventHandler PropertyChanged = delegate { };
#endregion
#region Ctor
public PushContext(string channelName, string serviceName, IList<Uri> allowedDomains, Dispatcher dispatcher)
{
if (_current != null)
{
throw new InvalidOperationException("There should be no more than one push context.");
}
ChannelName = channelName;
ServiceName = serviceName;
AllowedDomains = allowedDomains;
Dispatcher = dispatcher;
_current = this;
}
#endregion
#region Public Methods
public void Connect(Action<HttpNotificationChannel> prepared)
{
if (IsConnected)
{
prepared(NotificationChannel);
return;
}
try
{
// First, try to pick up an existing channel.
NotificationChannel = HttpNotificationChannel.Find(ChannelName);
if (NotificationChannel == null)
{
// Create new channel and subscribe events.
CreateChannel(prepared);
}
else
{
// Channel exists, no need to create a new one.
SubscribeToNotificationEvents();
PrepareChannel(prepared);
}
IsConnected = true;
}
catch (Exception ex)
{
OnError(ex);
}
}
public void Disconnect()
{
if (!IsConnected)
{
return;
}
try
{
if (NotificationChannel != null)
{
UnbindFromTileNotifications();
UnbindFromToastNotifications();
NotificationChannel.Close();
}
}
catch (Exception ex)
{
OnError(ex);
}
finally
{
NotificationChannel = null;
IsConnected = false;
}
}
#endregion
#region Privates
/// <summary>
/// Create channel, subscribe to channel events and open the channel.
/// </summary>
private void CreateChannel(Action<HttpNotificationChannel> prepared)
{
// Create a new channel.
NotificationChannel = new HttpNotificationChannel(ChannelName, ServiceName);
// Register to UriUpdated event. This occurs when channel successfully opens.
NotificationChannel.ChannelUriUpdated += (s, e) => Dispatcher.BeginInvoke(() => PrepareChannel(prepared));
SubscribeToNotificationEvents();
// Trying to Open the channel.
NotificationChannel.Open();
}
private void SubscribeToNotificationEvents()
{
// Register to raw notifications.
NotificationChannel.HttpNotificationReceived += (s, e) =>
{
if (IsPushEnabled & IsRawEnabled)
{
Dispatcher.BeginInvoke(() => OnRawNotification(e));
}
};
}
private void OnRawNotification(HttpNotificationEventArgs e)
{
if (RawNotification != null)
{
RawNotification(this, e);
}
}
private void PrepareChannel(Action<HttpNotificationChannel> prepared)
{
try
{
// OnChannelPrepared(new PushContextEventArgs(NotificationChannel));
prepared(NotificationChannel);
UpdateNotificationBindings();
}
catch (Exception ex)
{
OnError(ex);
}
}
private void OnError(Exception exception)
{
if (Error != null)
{
Error(this, new PushContextErrorEventArgs(exception));
}
}
private void OnChannelPrepared(PushContextEventArgs args)
{
if (ChannelPrepared != null)
{
ChannelPrepared(this, args);
}
}
private void BindToTileNotifications()
{
try
{
if (NotificationChannel != null && !NotificationChannel.IsShellTileBound)
{
var listOfAllowedDomains = new Collection<Uri>(AllowedDomains);
NotificationChannel.BindToShellTile(listOfAllowedDomains);
}
}
catch (Exception ex)
{
OnError(ex);
}
}
private void BindToToastNotifications()
{
try
{
if (NotificationChannel != null && !NotificationChannel.IsShellToastBound)
{
NotificationChannel.BindToShellToast();
}
}
catch (Exception ex)
{
OnError(ex);
}
}
private void UnbindFromTileNotifications()
{
try
{
if (NotificationChannel.IsShellTileBound)
{
NotificationChannel.UnbindToShellTile();
}
}
catch (Exception ex)
{
OnError(ex);
}
}
private void UnbindFromToastNotifications()
{
try
{
if (NotificationChannel.IsShellToastBound)
{
NotificationChannel.UnbindToShellToast();
}
}
catch (Exception ex)
{
OnError(ex);
}
}
private void UpdateNotificationBindings()
{
if (IsPushEnabled && IsTileEnabled)
{
BindToTileNotifications();
}
else
{
UnbindFromTileNotifications();
}
if (IsPushEnabled && IsToastEnabled)
{
BindToToastNotifications();
}
else
{
UnbindFromToastNotifications();
}
}
private T GetOrCreate<T>(string key, T defaultValue = default(T))
{
T value;
if (Settings.TryGetValue(key, out value))
{
return value;
}
return defaultValue;
}
private void SetOrCreate<T>(string key, T value)
{
Settings[key] = value;
}
private void NotifyPropertyChanged(string propertyName)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
#endregion
}
}
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace WindowsPhone.Recipes.Push.Client
{
public class PushContextErrorEventArgs : EventArgs
{
public Exception Exception { get; private set; }
public PushContextErrorEventArgs(Exception exception)
{
Exception = exception;
}
}
}
@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Phone.Notification;
namespace WindowsPhone.Recipes.Push.Client
{
public class PushContextEventArgs : EventArgs
{
public HttpNotificationChannel NotificationChannel { get; private set; }
internal PushContextEventArgs(HttpNotificationChannel channel)
{
NotificationChannel = channel;
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

@@ -0,0 +1,444 @@
//------------------------------------------------------------------------------
// <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>
//------------------------------------------------------------------------------
//
// This code was auto-generated by Microsoft.Silverlight.Phone.ServiceReference, version 3.7.0.0
//
namespace WindowsPhone.Recipes.Push.Client.Services {
using System.Runtime.Serialization;
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")]
[System.Runtime.Serialization.DataContractAttribute(Name="ServerInfo", Namespace="http://schemas.datacontract.org/2004/07/WindowsPhone.Recipes.Push.Server.Models")]
public partial class ServerInfo : object, System.ComponentModel.INotifyPropertyChanged {
private int CounterField;
private string PushPatternField;
[System.Runtime.Serialization.DataMemberAttribute()]
public int Counter {
get {
return this.CounterField;
}
set {
if ((this.CounterField.Equals(value) != true)) {
this.CounterField = value;
this.RaisePropertyChanged("Counter");
}
}
}
[System.Runtime.Serialization.DataMemberAttribute()]
public string PushPattern {
get {
return this.PushPatternField;
}
set {
if ((object.ReferenceEquals(this.PushPatternField, value) != true)) {
this.PushPatternField = value;
this.RaisePropertyChanged("PushPattern");
}
}
}
public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
protected void RaisePropertyChanged(string propertyName) {
System.ComponentModel.PropertyChangedEventHandler propertyChanged = this.PropertyChanged;
if ((propertyChanged != null)) {
propertyChanged(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName));
}
}
}
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
[System.ServiceModel.ServiceContractAttribute(ConfigurationName="Services.IPushService")]
public interface IPushService {
[System.ServiceModel.OperationContractAttribute(AsyncPattern=true, Action="http://tempuri.org/IPushService/Register", ReplyAction="http://tempuri.org/IPushService/RegisterResponse")]
System.IAsyncResult BeginRegister(string userName, System.Uri channelUri, System.AsyncCallback callback, object asyncState);
void EndRegister(System.IAsyncResult result);
[System.ServiceModel.OperationContractAttribute(AsyncPattern=true, Action="http://tempuri.org/IPushService/GetServerInfo", ReplyAction="http://tempuri.org/IPushService/GetServerInfoResponse")]
System.IAsyncResult BeginGetServerInfo(System.AsyncCallback callback, object asyncState);
WindowsPhone.Recipes.Push.Client.Services.ServerInfo EndGetServerInfo(System.IAsyncResult result);
[System.ServiceModel.OperationContractAttribute(AsyncPattern=true, Action="http://tempuri.org/IPushService/UpdateTile", ReplyAction="http://tempuri.org/IPushService/UpdateTileResponse")]
System.IAsyncResult BeginUpdateTile(System.Uri channelUri, string parameter, System.AsyncCallback callback, object asyncState);
void EndUpdateTile(System.IAsyncResult result);
}
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
public interface IPushServiceChannel : WindowsPhone.Recipes.Push.Client.Services.IPushService, System.ServiceModel.IClientChannel {
}
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
public partial class GetServerInfoCompletedEventArgs : System.ComponentModel.AsyncCompletedEventArgs {
private object[] results;
public GetServerInfoCompletedEventArgs(object[] results, System.Exception exception, bool cancelled, object userState) :
base(exception, cancelled, userState) {
this.results = results;
}
public WindowsPhone.Recipes.Push.Client.Services.ServerInfo Result {
get {
base.RaiseExceptionIfNecessary();
return ((WindowsPhone.Recipes.Push.Client.Services.ServerInfo)(this.results[0]));
}
}
}
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
public partial class PushServiceClient : System.ServiceModel.ClientBase<WindowsPhone.Recipes.Push.Client.Services.IPushService>, WindowsPhone.Recipes.Push.Client.Services.IPushService {
private BeginOperationDelegate onBeginRegisterDelegate;
private EndOperationDelegate onEndRegisterDelegate;
private System.Threading.SendOrPostCallback onRegisterCompletedDelegate;
private BeginOperationDelegate onBeginGetServerInfoDelegate;
private EndOperationDelegate onEndGetServerInfoDelegate;
private System.Threading.SendOrPostCallback onGetServerInfoCompletedDelegate;
private BeginOperationDelegate onBeginUpdateTileDelegate;
private EndOperationDelegate onEndUpdateTileDelegate;
private System.Threading.SendOrPostCallback onUpdateTileCompletedDelegate;
private BeginOperationDelegate onBeginOpenDelegate;
private EndOperationDelegate onEndOpenDelegate;
private System.Threading.SendOrPostCallback onOpenCompletedDelegate;
private BeginOperationDelegate onBeginCloseDelegate;
private EndOperationDelegate onEndCloseDelegate;
private System.Threading.SendOrPostCallback onCloseCompletedDelegate;
public PushServiceClient() {
}
public PushServiceClient(string endpointConfigurationName) :
base(endpointConfigurationName) {
}
public PushServiceClient(string endpointConfigurationName, string remoteAddress) :
base(endpointConfigurationName, remoteAddress) {
}
public PushServiceClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) :
base(endpointConfigurationName, remoteAddress) {
}
public PushServiceClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) :
base(binding, remoteAddress) {
}
public System.Net.CookieContainer CookieContainer {
get {
System.ServiceModel.Channels.IHttpCookieContainerManager httpCookieContainerManager = this.InnerChannel.GetProperty<System.ServiceModel.Channels.IHttpCookieContainerManager>();
if ((httpCookieContainerManager != null)) {
return httpCookieContainerManager.CookieContainer;
}
else {
return null;
}
}
set {
System.ServiceModel.Channels.IHttpCookieContainerManager httpCookieContainerManager = this.InnerChannel.GetProperty<System.ServiceModel.Channels.IHttpCookieContainerManager>();
if ((httpCookieContainerManager != null)) {
httpCookieContainerManager.CookieContainer = value;
}
else {
throw new System.InvalidOperationException("Unable to set the CookieContainer. Please make sure the binding contains an HttpC" +
"ookieContainerBindingElement.");
}
}
}
public event System.EventHandler<System.ComponentModel.AsyncCompletedEventArgs> RegisterCompleted;
public event System.EventHandler<GetServerInfoCompletedEventArgs> GetServerInfoCompleted;
public event System.EventHandler<System.ComponentModel.AsyncCompletedEventArgs> UpdateTileCompleted;
public event System.EventHandler<System.ComponentModel.AsyncCompletedEventArgs> OpenCompleted;
public event System.EventHandler<System.ComponentModel.AsyncCompletedEventArgs> CloseCompleted;
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
System.IAsyncResult WindowsPhone.Recipes.Push.Client.Services.IPushService.BeginRegister(string userName, System.Uri channelUri, System.AsyncCallback callback, object asyncState) {
return base.Channel.BeginRegister(userName, channelUri, callback, asyncState);
}
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
void WindowsPhone.Recipes.Push.Client.Services.IPushService.EndRegister(System.IAsyncResult result) {
base.Channel.EndRegister(result);
}
private System.IAsyncResult OnBeginRegister(object[] inValues, System.AsyncCallback callback, object asyncState) {
string userName = ((string)(inValues[0]));
System.Uri channelUri = ((System.Uri)(inValues[1]));
return ((WindowsPhone.Recipes.Push.Client.Services.IPushService)(this)).BeginRegister(userName, channelUri, callback, asyncState);
}
private object[] OnEndRegister(System.IAsyncResult result) {
((WindowsPhone.Recipes.Push.Client.Services.IPushService)(this)).EndRegister(result);
return null;
}
private void OnRegisterCompleted(object state) {
if ((this.RegisterCompleted != null)) {
InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
this.RegisterCompleted(this, new System.ComponentModel.AsyncCompletedEventArgs(e.Error, e.Cancelled, e.UserState));
}
}
public void RegisterAsync(string userName, System.Uri channelUri) {
this.RegisterAsync(userName, channelUri, null);
}
public void RegisterAsync(string userName, System.Uri channelUri, object userState) {
if ((this.onBeginRegisterDelegate == null)) {
this.onBeginRegisterDelegate = new BeginOperationDelegate(this.OnBeginRegister);
}
if ((this.onEndRegisterDelegate == null)) {
this.onEndRegisterDelegate = new EndOperationDelegate(this.OnEndRegister);
}
if ((this.onRegisterCompletedDelegate == null)) {
this.onRegisterCompletedDelegate = new System.Threading.SendOrPostCallback(this.OnRegisterCompleted);
}
base.InvokeAsync(this.onBeginRegisterDelegate, new object[] {
userName,
channelUri}, this.onEndRegisterDelegate, this.onRegisterCompletedDelegate, userState);
}
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
System.IAsyncResult WindowsPhone.Recipes.Push.Client.Services.IPushService.BeginGetServerInfo(System.AsyncCallback callback, object asyncState) {
return base.Channel.BeginGetServerInfo(callback, asyncState);
}
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
WindowsPhone.Recipes.Push.Client.Services.ServerInfo WindowsPhone.Recipes.Push.Client.Services.IPushService.EndGetServerInfo(System.IAsyncResult result) {
return base.Channel.EndGetServerInfo(result);
}
private System.IAsyncResult OnBeginGetServerInfo(object[] inValues, System.AsyncCallback callback, object asyncState) {
return ((WindowsPhone.Recipes.Push.Client.Services.IPushService)(this)).BeginGetServerInfo(callback, asyncState);
}
private object[] OnEndGetServerInfo(System.IAsyncResult result) {
WindowsPhone.Recipes.Push.Client.Services.ServerInfo retVal = ((WindowsPhone.Recipes.Push.Client.Services.IPushService)(this)).EndGetServerInfo(result);
return new object[] {
retVal};
}
private void OnGetServerInfoCompleted(object state) {
if ((this.GetServerInfoCompleted != null)) {
InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
this.GetServerInfoCompleted(this, new GetServerInfoCompletedEventArgs(e.Results, e.Error, e.Cancelled, e.UserState));
}
}
public void GetServerInfoAsync() {
this.GetServerInfoAsync(null);
}
public void GetServerInfoAsync(object userState) {
if ((this.onBeginGetServerInfoDelegate == null)) {
this.onBeginGetServerInfoDelegate = new BeginOperationDelegate(this.OnBeginGetServerInfo);
}
if ((this.onEndGetServerInfoDelegate == null)) {
this.onEndGetServerInfoDelegate = new EndOperationDelegate(this.OnEndGetServerInfo);
}
if ((this.onGetServerInfoCompletedDelegate == null)) {
this.onGetServerInfoCompletedDelegate = new System.Threading.SendOrPostCallback(this.OnGetServerInfoCompleted);
}
base.InvokeAsync(this.onBeginGetServerInfoDelegate, null, this.onEndGetServerInfoDelegate, this.onGetServerInfoCompletedDelegate, userState);
}
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
System.IAsyncResult WindowsPhone.Recipes.Push.Client.Services.IPushService.BeginUpdateTile(System.Uri channelUri, string parameter, System.AsyncCallback callback, object asyncState) {
return base.Channel.BeginUpdateTile(channelUri, parameter, callback, asyncState);
}
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Advanced)]
void WindowsPhone.Recipes.Push.Client.Services.IPushService.EndUpdateTile(System.IAsyncResult result) {
base.Channel.EndUpdateTile(result);
}
private System.IAsyncResult OnBeginUpdateTile(object[] inValues, System.AsyncCallback callback, object asyncState) {
System.Uri channelUri = ((System.Uri)(inValues[0]));
string parameter = ((string)(inValues[1]));
return ((WindowsPhone.Recipes.Push.Client.Services.IPushService)(this)).BeginUpdateTile(channelUri, parameter, callback, asyncState);
}
private object[] OnEndUpdateTile(System.IAsyncResult result) {
((WindowsPhone.Recipes.Push.Client.Services.IPushService)(this)).EndUpdateTile(result);
return null;
}
private void OnUpdateTileCompleted(object state) {
if ((this.UpdateTileCompleted != null)) {
InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
this.UpdateTileCompleted(this, new System.ComponentModel.AsyncCompletedEventArgs(e.Error, e.Cancelled, e.UserState));
}
}
public void UpdateTileAsync(System.Uri channelUri, string parameter) {
this.UpdateTileAsync(channelUri, parameter, null);
}
public void UpdateTileAsync(System.Uri channelUri, string parameter, object userState) {
if ((this.onBeginUpdateTileDelegate == null)) {
this.onBeginUpdateTileDelegate = new BeginOperationDelegate(this.OnBeginUpdateTile);
}
if ((this.onEndUpdateTileDelegate == null)) {
this.onEndUpdateTileDelegate = new EndOperationDelegate(this.OnEndUpdateTile);
}
if ((this.onUpdateTileCompletedDelegate == null)) {
this.onUpdateTileCompletedDelegate = new System.Threading.SendOrPostCallback(this.OnUpdateTileCompleted);
}
base.InvokeAsync(this.onBeginUpdateTileDelegate, new object[] {
channelUri,
parameter}, this.onEndUpdateTileDelegate, this.onUpdateTileCompletedDelegate, userState);
}
private System.IAsyncResult OnBeginOpen(object[] inValues, System.AsyncCallback callback, object asyncState) {
return ((System.ServiceModel.ICommunicationObject)(this)).BeginOpen(callback, asyncState);
}
private object[] OnEndOpen(System.IAsyncResult result) {
((System.ServiceModel.ICommunicationObject)(this)).EndOpen(result);
return null;
}
private void OnOpenCompleted(object state) {
if ((this.OpenCompleted != null)) {
InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
this.OpenCompleted(this, new System.ComponentModel.AsyncCompletedEventArgs(e.Error, e.Cancelled, e.UserState));
}
}
public void OpenAsync() {
this.OpenAsync(null);
}
public void OpenAsync(object userState) {
if ((this.onBeginOpenDelegate == null)) {
this.onBeginOpenDelegate = new BeginOperationDelegate(this.OnBeginOpen);
}
if ((this.onEndOpenDelegate == null)) {
this.onEndOpenDelegate = new EndOperationDelegate(this.OnEndOpen);
}
if ((this.onOpenCompletedDelegate == null)) {
this.onOpenCompletedDelegate = new System.Threading.SendOrPostCallback(this.OnOpenCompleted);
}
base.InvokeAsync(this.onBeginOpenDelegate, null, this.onEndOpenDelegate, this.onOpenCompletedDelegate, userState);
}
private System.IAsyncResult OnBeginClose(object[] inValues, System.AsyncCallback callback, object asyncState) {
return ((System.ServiceModel.ICommunicationObject)(this)).BeginClose(callback, asyncState);
}
private object[] OnEndClose(System.IAsyncResult result) {
((System.ServiceModel.ICommunicationObject)(this)).EndClose(result);
return null;
}
private void OnCloseCompleted(object state) {
if ((this.CloseCompleted != null)) {
InvokeAsyncCompletedEventArgs e = ((InvokeAsyncCompletedEventArgs)(state));
this.CloseCompleted(this, new System.ComponentModel.AsyncCompletedEventArgs(e.Error, e.Cancelled, e.UserState));
}
}
public void CloseAsync() {
this.CloseAsync(null);
}
public void CloseAsync(object userState) {
if ((this.onBeginCloseDelegate == null)) {
this.onBeginCloseDelegate = new BeginOperationDelegate(this.OnBeginClose);
}
if ((this.onEndCloseDelegate == null)) {
this.onEndCloseDelegate = new EndOperationDelegate(this.OnEndClose);
}
if ((this.onCloseCompletedDelegate == null)) {
this.onCloseCompletedDelegate = new System.Threading.SendOrPostCallback(this.OnCloseCompleted);
}
base.InvokeAsync(this.onBeginCloseDelegate, null, this.onEndCloseDelegate, this.onCloseCompletedDelegate, userState);
}
protected override WindowsPhone.Recipes.Push.Client.Services.IPushService CreateChannel() {
return new PushServiceClientChannel(this);
}
private class PushServiceClientChannel : ChannelBase<WindowsPhone.Recipes.Push.Client.Services.IPushService>, WindowsPhone.Recipes.Push.Client.Services.IPushService {
public PushServiceClientChannel(System.ServiceModel.ClientBase<WindowsPhone.Recipes.Push.Client.Services.IPushService> client) :
base(client) {
}
public System.IAsyncResult BeginRegister(string userName, System.Uri channelUri, System.AsyncCallback callback, object asyncState) {
object[] _args = new object[2];
_args[0] = userName;
_args[1] = channelUri;
System.IAsyncResult _result = base.BeginInvoke("Register", _args, callback, asyncState);
return _result;
}
public void EndRegister(System.IAsyncResult result) {
object[] _args = new object[0];
base.EndInvoke("Register", _args, result);
}
public System.IAsyncResult BeginGetServerInfo(System.AsyncCallback callback, object asyncState) {
object[] _args = new object[0];
System.IAsyncResult _result = base.BeginInvoke("GetServerInfo", _args, callback, asyncState);
return _result;
}
public WindowsPhone.Recipes.Push.Client.Services.ServerInfo EndGetServerInfo(System.IAsyncResult result) {
object[] _args = new object[0];
WindowsPhone.Recipes.Push.Client.Services.ServerInfo _result = ((WindowsPhone.Recipes.Push.Client.Services.ServerInfo)(base.EndInvoke("GetServerInfo", _args, result)));
return _result;
}
public System.IAsyncResult BeginUpdateTile(System.Uri channelUri, string parameter, System.AsyncCallback callback, object asyncState) {
object[] _args = new object[2];
_args[0] = channelUri;
_args[1] = parameter;
System.IAsyncResult _result = base.BeginInvoke("UpdateTile", _args, callback, asyncState);
return _result;
}
public void EndUpdateTile(System.IAsyncResult result) {
object[] _args = new object[0];
base.EndInvoke("UpdateTile", _args, result);
}
}
}
}
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<ReferenceGroup xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" ID="b34463ab-d06f-4c3e-8f1c-f4011a6cf3de" xmlns="urn:schemas-microsoft-com:xml-wcfservicemap">
<ClientOptions>
<GenerateAsynchronousMethods>true</GenerateAsynchronousMethods>
<EnableDataBinding>true</EnableDataBinding>
<ExcludedTypes />
<ImportXmlTypes>false</ImportXmlTypes>
<GenerateInternalTypes>false</GenerateInternalTypes>
<GenerateMessageContracts>false</GenerateMessageContracts>
<NamespaceMappings />
<CollectionMappings>
<CollectionMapping TypeName="System.Collections.ObjectModel.ObservableCollection`1" Category="List" />
</CollectionMappings>
<GenerateSerializableTypes>false</GenerateSerializableTypes>
<Serializer>Auto</Serializer>
<UseSerializerForFaults>true</UseSerializerForFaults>
<ReferenceAllAssemblies>true</ReferenceAllAssemblies>
<ReferencedAssemblies />
<ReferencedDataContractTypes />
<ServiceContractMappings />
</ClientOptions>
<MetadataSources>
<MetadataSource Address="http://localhost:8000/PushService/mex" Protocol="mex" SourceId="1" />
</MetadataSources>
<Metadata>
<MetadataFile FileName="service.wsdl" MetadataType="Wsdl" ID="873b7a0f-8033-4034-af94-88cc77224416" SourceId="1" SourceUrl="http://localhost:8000/PushService/mex" />
<MetadataFile FileName="service.xsd" MetadataType="Schema" ID="d694fe0f-aa9b-4c7f-81d1-75715872921c" SourceId="1" SourceUrl="http://localhost:8000/PushService/mex" />
<MetadataFile FileName="service1.xsd" MetadataType="Schema" ID="6d271cb2-5886-456f-8ab4-c0d85e8835d1" SourceId="1" SourceUrl="http://localhost:8000/PushService/mex" />
<MetadataFile FileName="WindowsPhone.Recipes.Push.Server.Models.xsd" MetadataType="Schema" ID="6da06e72-aa72-4541-b7c3-de12dc2f6a68" SourceId="1" SourceUrl="http://localhost:8000/PushService/mex" />
</Metadata>
<Extensions>
<ExtensionFile FileName="configuration91.svcinfo" Name="configuration91.svcinfo" />
<ExtensionFile FileName="configuration.svcinfo" Name="configuration.svcinfo" />
</Extensions>
</ReferenceGroup>
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
This file is automatically generated by Visual Studio .Net. It is
used to store generic object data source configuration information.
Renaming the file extension or editing the content of this file may
cause the file to be unrecognizable by the program.
-->
<GenericObjectDataSource DisplayName="ServerInfo" Version="1.0" xmlns="urn:schemas-microsoft-com:xml-msdatasource">
<TypeInfo>WindowsPhone.Recipes.Push.Client.Services.ServerInfo, Service References.Services.Reference.cs, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null</TypeInfo>
</GenericObjectDataSource>
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:tns="http://schemas.datacontract.org/2004/07/WindowsPhone.Recipes.Push.Server.Models" elementFormDefault="qualified" targetNamespace="http://schemas.datacontract.org/2004/07/WindowsPhone.Recipes.Push.Server.Models" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="ServerInfo">
<xs:sequence>
<xs:element minOccurs="0" name="Counter" type="xs:int" />
<xs:element minOccurs="0" name="PushPattern" nillable="true" type="xs:string" />
</xs:sequence>
</xs:complexType>
<xs:element name="ServerInfo" nillable="true" type="tns:ServerInfo" />
</xs:schema>
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<configurationSnapshot xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="urn:schemas-microsoft-com:xml-wcfconfigurationsnapshot">
<behaviors />
<bindings>
<binding digest="System.ServiceModel.Configuration.BasicHttpBindingElement, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089:&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-16&quot;?&gt;&lt;Data maxBufferSize=&quot;2147483647&quot; name=&quot;BasicHttpBinding_IPushService&quot;&gt;&lt;security mode=&quot;None&quot; /&gt;&lt;/Data&gt;" bindingType="basicHttpBinding" name="BasicHttpBinding_IPushService" />
</bindings>
<endpoints>
<endpoint normalizedDigest="&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-16&quot;?&gt;&lt;Data address=&quot;http://localhost:8000/PushService/&quot; binding=&quot;basicHttpBinding&quot; bindingConfiguration=&quot;BasicHttpBinding_IPushService&quot; contract=&quot;Services.IPushService&quot; name=&quot;BasicHttpBinding_IPushService&quot; /&gt;" digest="&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-16&quot;?&gt;&lt;Data address=&quot;http://localhost:8000/PushService/&quot; binding=&quot;basicHttpBinding&quot; bindingConfiguration=&quot;BasicHttpBinding_IPushService&quot; contract=&quot;Services.IPushService&quot; name=&quot;BasicHttpBinding_IPushService&quot; /&gt;" contractName="Services.IPushService" name="BasicHttpBinding_IPushService" />
</endpoints>
</configurationSnapshot>
@@ -0,0 +1,201 @@
<?xml version="1.0" encoding="utf-8"?>
<SavedWcfConfigurationInformation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Version="9.1" CheckSum="S5v8kqHwW6G6hJbtL+pkYskxV7I=">
<bindingConfigurations>
<bindingConfiguration bindingType="basicHttpBinding" name="BasicHttpBinding_IPushService">
<properties>
<property path="/name" isComplexType="false" isExplicitlyDefined="true" clrType="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<serializedValue>BasicHttpBinding_IPushService</serializedValue>
</property>
<property path="/closeTimeout" isComplexType="false" isExplicitlyDefined="true" clrType="System.TimeSpan, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<serializedValue />
</property>
<property path="/openTimeout" isComplexType="false" isExplicitlyDefined="true" clrType="System.TimeSpan, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<serializedValue />
</property>
<property path="/receiveTimeout" isComplexType="false" isExplicitlyDefined="true" clrType="System.TimeSpan, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<serializedValue />
</property>
<property path="/sendTimeout" isComplexType="false" isExplicitlyDefined="true" clrType="System.TimeSpan, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<serializedValue />
</property>
<property path="/allowCookies" isComplexType="false" isExplicitlyDefined="true" clrType="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<serializedValue />
</property>
<property path="/bypassProxyOnLocal" isComplexType="false" isExplicitlyDefined="true" clrType="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<serializedValue />
</property>
<property path="/hostNameComparisonMode" isComplexType="false" isExplicitlyDefined="false" clrType="System.ServiceModel.HostNameComparisonMode, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<serializedValue>StrongWildcard</serializedValue>
</property>
<property path="/maxBufferSize" isComplexType="false" isExplicitlyDefined="true" clrType="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<serializedValue>2147483647</serializedValue>
</property>
<property path="/maxBufferPoolSize" isComplexType="false" isExplicitlyDefined="true" clrType="System.Int64, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<serializedValue />
</property>
<property path="/maxReceivedMessageSize" isComplexType="false" isExplicitlyDefined="true" clrType="System.Int64, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<serializedValue>2147483647</serializedValue>
</property>
<property path="/messageEncoding" isComplexType="false" isExplicitlyDefined="false" clrType="System.ServiceModel.WSMessageEncoding, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<serializedValue>Text</serializedValue>
</property>
<property path="/proxyAddress" isComplexType="false" isExplicitlyDefined="false" clrType="System.Uri, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<serializedValue />
</property>
<property path="/readerQuotas" isComplexType="true" isExplicitlyDefined="false" clrType="System.ServiceModel.Configuration.XmlDictionaryReaderQuotasElement, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<serializedValue>System.ServiceModel.Configuration.XmlDictionaryReaderQuotasElement</serializedValue>
</property>
<property path="/readerQuotas/maxDepth" isComplexType="false" isExplicitlyDefined="false" clrType="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<serializedValue>0</serializedValue>
</property>
<property path="/readerQuotas/maxStringContentLength" isComplexType="false" isExplicitlyDefined="false" clrType="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<serializedValue>0</serializedValue>
</property>
<property path="/readerQuotas/maxArrayLength" isComplexType="false" isExplicitlyDefined="false" clrType="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<serializedValue>0</serializedValue>
</property>
<property path="/readerQuotas/maxBytesPerRead" isComplexType="false" isExplicitlyDefined="false" clrType="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<serializedValue>0</serializedValue>
</property>
<property path="/readerQuotas/maxNameTableCharCount" isComplexType="false" isExplicitlyDefined="false" clrType="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<serializedValue>0</serializedValue>
</property>
<property path="/security" isComplexType="true" isExplicitlyDefined="false" clrType="System.ServiceModel.Configuration.BasicHttpSecurityElement, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<serializedValue>System.ServiceModel.Configuration.BasicHttpSecurityElement</serializedValue>
</property>
<property path="/security/mode" isComplexType="false" isExplicitlyDefined="true" clrType="System.ServiceModel.BasicHttpSecurityMode, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<serializedValue>None</serializedValue>
</property>
<property path="/security/transport" isComplexType="true" isExplicitlyDefined="false" clrType="System.ServiceModel.Configuration.HttpTransportSecurityElement, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<serializedValue>System.ServiceModel.Configuration.HttpTransportSecurityElement</serializedValue>
</property>
<property path="/security/transport/clientCredentialType" isComplexType="false" isExplicitlyDefined="false" clrType="System.ServiceModel.HttpClientCredentialType, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<serializedValue>None</serializedValue>
</property>
<property path="/security/transport/proxyCredentialType" isComplexType="false" isExplicitlyDefined="false" clrType="System.ServiceModel.HttpProxyCredentialType, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<serializedValue>None</serializedValue>
</property>
<property path="/security/transport/extendedProtectionPolicy" isComplexType="true" isExplicitlyDefined="false" clrType="System.Security.Authentication.ExtendedProtection.Configuration.ExtendedProtectionPolicyElement, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<serializedValue>System.Security.Authentication.ExtendedProtection.Configuration.ExtendedProtectionPolicyElement</serializedValue>
</property>
<property path="/security/transport/extendedProtectionPolicy/policyEnforcement" isComplexType="false" isExplicitlyDefined="false" clrType="System.Security.Authentication.ExtendedProtection.PolicyEnforcement, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<serializedValue>Never</serializedValue>
</property>
<property path="/security/transport/extendedProtectionPolicy/protectionScenario" isComplexType="false" isExplicitlyDefined="false" clrType="System.Security.Authentication.ExtendedProtection.ProtectionScenario, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<serializedValue>TransportSelected</serializedValue>
</property>
<property path="/security/transport/extendedProtectionPolicy/customServiceNames" isComplexType="true" isExplicitlyDefined="false" clrType="System.Security.Authentication.ExtendedProtection.Configuration.ServiceNameElementCollection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<serializedValue>(Collection)</serializedValue>
</property>
<property path="/security/transport/realm" isComplexType="false" isExplicitlyDefined="false" clrType="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<serializedValue />
</property>
<property path="/security/message" isComplexType="true" isExplicitlyDefined="false" clrType="System.ServiceModel.Configuration.BasicHttpMessageSecurityElement, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<serializedValue>System.ServiceModel.Configuration.BasicHttpMessageSecurityElement</serializedValue>
</property>
<property path="/security/message/clientCredentialType" isComplexType="false" isExplicitlyDefined="false" clrType="System.ServiceModel.BasicHttpMessageCredentialType, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<serializedValue>UserName</serializedValue>
</property>
<property path="/security/message/algorithmSuite" isComplexType="false" isExplicitlyDefined="false" clrType="System.ServiceModel.Security.SecurityAlgorithmSuite, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<serializedValue>Default</serializedValue>
</property>
<property path="/textEncoding" isComplexType="false" isExplicitlyDefined="false" clrType="System.Text.Encoding, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<serializedValue>System.Text.UTF8Encoding</serializedValue>
</property>
<property path="/transferMode" isComplexType="false" isExplicitlyDefined="false" clrType="System.ServiceModel.TransferMode, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<serializedValue>Buffered</serializedValue>
</property>
<property path="/useDefaultWebProxy" isComplexType="false" isExplicitlyDefined="true" clrType="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<serializedValue />
</property>
</properties>
</bindingConfiguration>
</bindingConfigurations>
<endpoints>
<endpoint name="BasicHttpBinding_IPushService" contract="Services.IPushService" bindingType="basicHttpBinding" address="http://localhost:8000/PushService/" bindingConfiguration="BasicHttpBinding_IPushService">
<properties>
<property path="/address" isComplexType="false" isExplicitlyDefined="true" clrType="System.Uri, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<serializedValue>http://localhost:8000/PushService/</serializedValue>
</property>
<property path="/behaviorConfiguration" isComplexType="false" isExplicitlyDefined="false" clrType="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<serializedValue />
</property>
<property path="/binding" isComplexType="false" isExplicitlyDefined="true" clrType="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<serializedValue>basicHttpBinding</serializedValue>
</property>
<property path="/bindingConfiguration" isComplexType="false" isExplicitlyDefined="true" clrType="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<serializedValue>BasicHttpBinding_IPushService</serializedValue>
</property>
<property path="/contract" isComplexType="false" isExplicitlyDefined="true" clrType="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<serializedValue>Services.IPushService</serializedValue>
</property>
<property path="/headers" isComplexType="true" isExplicitlyDefined="false" clrType="System.ServiceModel.Configuration.AddressHeaderCollectionElement, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<serializedValue>System.ServiceModel.Configuration.AddressHeaderCollectionElement</serializedValue>
</property>
<property path="/headers/headers" isComplexType="false" isExplicitlyDefined="true" clrType="System.ServiceModel.Channels.AddressHeaderCollection, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<serializedValue>&lt;Header /&gt;</serializedValue>
</property>
<property path="/identity" isComplexType="true" isExplicitlyDefined="false" clrType="System.ServiceModel.Configuration.IdentityElement, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<serializedValue>System.ServiceModel.Configuration.IdentityElement</serializedValue>
</property>
<property path="/identity/userPrincipalName" isComplexType="true" isExplicitlyDefined="false" clrType="System.ServiceModel.Configuration.UserPrincipalNameElement, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<serializedValue>System.ServiceModel.Configuration.UserPrincipalNameElement</serializedValue>
</property>
<property path="/identity/userPrincipalName/value" isComplexType="false" isExplicitlyDefined="false" clrType="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<serializedValue />
</property>
<property path="/identity/servicePrincipalName" isComplexType="true" isExplicitlyDefined="false" clrType="System.ServiceModel.Configuration.ServicePrincipalNameElement, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<serializedValue>System.ServiceModel.Configuration.ServicePrincipalNameElement</serializedValue>
</property>
<property path="/identity/servicePrincipalName/value" isComplexType="false" isExplicitlyDefined="false" clrType="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<serializedValue />
</property>
<property path="/identity/dns" isComplexType="true" isExplicitlyDefined="false" clrType="System.ServiceModel.Configuration.DnsElement, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<serializedValue>System.ServiceModel.Configuration.DnsElement</serializedValue>
</property>
<property path="/identity/dns/value" isComplexType="false" isExplicitlyDefined="false" clrType="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<serializedValue />
</property>
<property path="/identity/rsa" isComplexType="true" isExplicitlyDefined="false" clrType="System.ServiceModel.Configuration.RsaElement, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<serializedValue>System.ServiceModel.Configuration.RsaElement</serializedValue>
</property>
<property path="/identity/rsa/value" isComplexType="false" isExplicitlyDefined="false" clrType="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<serializedValue />
</property>
<property path="/identity/certificate" isComplexType="true" isExplicitlyDefined="false" clrType="System.ServiceModel.Configuration.CertificateElement, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<serializedValue>System.ServiceModel.Configuration.CertificateElement</serializedValue>
</property>
<property path="/identity/certificate/encodedValue" isComplexType="false" isExplicitlyDefined="false" clrType="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<serializedValue />
</property>
<property path="/identity/certificateReference" isComplexType="true" isExplicitlyDefined="false" clrType="System.ServiceModel.Configuration.CertificateReferenceElement, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<serializedValue>System.ServiceModel.Configuration.CertificateReferenceElement</serializedValue>
</property>
<property path="/identity/certificateReference/storeName" isComplexType="false" isExplicitlyDefined="false" clrType="System.Security.Cryptography.X509Certificates.StoreName, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<serializedValue>My</serializedValue>
</property>
<property path="/identity/certificateReference/storeLocation" isComplexType="false" isExplicitlyDefined="false" clrType="System.Security.Cryptography.X509Certificates.StoreLocation, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<serializedValue>LocalMachine</serializedValue>
</property>
<property path="/identity/certificateReference/x509FindType" isComplexType="false" isExplicitlyDefined="false" clrType="System.Security.Cryptography.X509Certificates.X509FindType, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<serializedValue>FindBySubjectDistinguishedName</serializedValue>
</property>
<property path="/identity/certificateReference/findValue" isComplexType="false" isExplicitlyDefined="false" clrType="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<serializedValue />
</property>
<property path="/identity/certificateReference/isChainIncluded" isComplexType="false" isExplicitlyDefined="false" clrType="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<serializedValue>False</serializedValue>
</property>
<property path="/name" isComplexType="false" isExplicitlyDefined="true" clrType="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<serializedValue>BasicHttpBinding_IPushService</serializedValue>
</property>
<property path="/kind" isComplexType="false" isExplicitlyDefined="false" clrType="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<serializedValue />
</property>
<property path="/endpointConfiguration" isComplexType="false" isExplicitlyDefined="false" clrType="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<serializedValue />
</property>
</properties>
</endpoint>
</endpoints>
</SavedWcfConfigurationInformation>
@@ -0,0 +1,77 @@
<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy" xmlns:wsa10="http://www.w3.org/2005/08/addressing" xmlns:tns="http://tempuri.org/" xmlns:msc="http://schemas.microsoft.com/ws/2005/12/wsdl/contract" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="PushService" targetNamespace="http://tempuri.org/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<xsd:schema targetNamespace="http://tempuri.org/Imports">
<xsd:import namespace="http://tempuri.org/" />
<xsd:import namespace="http://schemas.microsoft.com/2003/10/Serialization/" />
<xsd:import namespace="http://schemas.datacontract.org/2004/07/WindowsPhone.Recipes.Push.Server.Models" />
</xsd:schema>
</wsdl:types>
<wsdl:message name="IPushService_Register_InputMessage">
<wsdl:part name="parameters" element="tns:Register" />
</wsdl:message>
<wsdl:message name="IPushService_Register_OutputMessage">
<wsdl:part name="parameters" element="tns:RegisterResponse" />
</wsdl:message>
<wsdl:message name="IPushService_GetServerInfo_InputMessage">
<wsdl:part name="parameters" element="tns:GetServerInfo" />
</wsdl:message>
<wsdl:message name="IPushService_GetServerInfo_OutputMessage">
<wsdl:part name="parameters" element="tns:GetServerInfoResponse" />
</wsdl:message>
<wsdl:message name="IPushService_UpdateTile_InputMessage">
<wsdl:part name="parameters" element="tns:UpdateTile" />
</wsdl:message>
<wsdl:message name="IPushService_UpdateTile_OutputMessage">
<wsdl:part name="parameters" element="tns:UpdateTileResponse" />
</wsdl:message>
<wsdl:portType name="IPushService">
<wsdl:operation name="Register">
<wsdl:input wsaw:Action="http://tempuri.org/IPushService/Register" message="tns:IPushService_Register_InputMessage" />
<wsdl:output wsaw:Action="http://tempuri.org/IPushService/RegisterResponse" message="tns:IPushService_Register_OutputMessage" />
</wsdl:operation>
<wsdl:operation name="GetServerInfo">
<wsdl:input wsaw:Action="http://tempuri.org/IPushService/GetServerInfo" message="tns:IPushService_GetServerInfo_InputMessage" />
<wsdl:output wsaw:Action="http://tempuri.org/IPushService/GetServerInfoResponse" message="tns:IPushService_GetServerInfo_OutputMessage" />
</wsdl:operation>
<wsdl:operation name="UpdateTile">
<wsdl:input wsaw:Action="http://tempuri.org/IPushService/UpdateTile" message="tns:IPushService_UpdateTile_InputMessage" />
<wsdl:output wsaw:Action="http://tempuri.org/IPushService/UpdateTileResponse" message="tns:IPushService_UpdateTile_OutputMessage" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="BasicHttpBinding_IPushService" type="tns:IPushService">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="Register">
<soap:operation soapAction="http://tempuri.org/IPushService/Register" style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="GetServerInfo">
<soap:operation soapAction="http://tempuri.org/IPushService/GetServerInfo" style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="UpdateTile">
<soap:operation soapAction="http://tempuri.org/IPushService/UpdateTile" style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="PushService">
<wsdl:port name="BasicHttpBinding_IPushService" binding="tns:BasicHttpBinding_IPushService">
<soap:address location="http://localhost:8000/PushService/" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:tns="http://tempuri.org/" elementFormDefault="qualified" targetNamespace="http://tempuri.org/" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:import namespace="http://schemas.datacontract.org/2004/07/WindowsPhone.Recipes.Push.Server.Models" />
<xs:element name="Register">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="userName" nillable="true" type="xs:string" />
<xs:element minOccurs="0" name="channelUri" nillable="true" type="xs:anyURI" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="RegisterResponse">
<xs:complexType>
<xs:sequence />
</xs:complexType>
</xs:element>
<xs:element name="GetServerInfo">
<xs:complexType>
<xs:sequence />
</xs:complexType>
</xs:element>
<xs:element name="GetServerInfoResponse">
<xs:complexType>
<xs:sequence>
<xs:element xmlns:q1="http://schemas.datacontract.org/2004/07/WindowsPhone.Recipes.Push.Server.Models" minOccurs="0" name="GetServerInfoResult" nillable="true" type="q1:ServerInfo" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="UpdateTile">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="channelUri" nillable="true" type="xs:anyURI" />
<xs:element minOccurs="0" name="parameter" nillable="true" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="UpdateTileResponse">
<xs:complexType>
<xs:sequence />
</xs:complexType>
</xs:element>
</xs:schema>
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:tns="http://schemas.microsoft.com/2003/10/Serialization/" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://schemas.microsoft.com/2003/10/Serialization/" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="anyType" nillable="true" type="xs:anyType" />
<xs:element name="anyURI" nillable="true" type="xs:anyURI" />
<xs:element name="base64Binary" nillable="true" type="xs:base64Binary" />
<xs:element name="boolean" nillable="true" type="xs:boolean" />
<xs:element name="byte" nillable="true" type="xs:byte" />
<xs:element name="dateTime" nillable="true" type="xs:dateTime" />
<xs:element name="decimal" nillable="true" type="xs:decimal" />
<xs:element name="double" nillable="true" type="xs:double" />
<xs:element name="float" nillable="true" type="xs:float" />
<xs:element name="int" nillable="true" type="xs:int" />
<xs:element name="long" nillable="true" type="xs:long" />
<xs:element name="QName" nillable="true" type="xs:QName" />
<xs:element name="short" nillable="true" type="xs:short" />
<xs:element name="string" nillable="true" type="xs:string" />
<xs:element name="unsignedByte" nillable="true" type="xs:unsignedByte" />
<xs:element name="unsignedInt" nillable="true" type="xs:unsignedInt" />
<xs:element name="unsignedLong" nillable="true" type="xs:unsignedLong" />
<xs:element name="unsignedShort" nillable="true" type="xs:unsignedShort" />
<xs:element name="char" nillable="true" type="tns:char" />
<xs:simpleType name="char">
<xs:restriction base="xs:int" />
</xs:simpleType>
<xs:element name="duration" nillable="true" type="tns:duration" />
<xs:simpleType name="duration">
<xs:restriction base="xs:duration">
<xs:pattern value="\-?P(\d*D)?(T(\d*H)?(\d*M)?(\d*(\.\d*)?S)?)?" />
<xs:minInclusive value="-P10675199DT2H48M5.4775808S" />
<xs:maxInclusive value="P10675199DT2H48M5.4775807S" />
</xs:restriction>
</xs:simpleType>
<xs:element name="guid" nillable="true" type="tns:guid" />
<xs:simpleType name="guid">
<xs:restriction base="xs:string">
<xs:pattern value="[\da-fA-F]{8}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{12}" />
</xs:restriction>
</xs:simpleType>
<xs:attribute name="FactoryType" type="xs:QName" />
<xs:attribute name="Id" type="xs:ID" />
<xs:attribute name="Ref" type="xs:IDREF" />
</xs:schema>
@@ -0,0 +1,17 @@
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IPushService" maxBufferSize="2147483647"
maxReceivedMessageSize="2147483647">
<security mode="None" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:8000/PushService/" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IPushService" contract="Services.IPushService"
name="BasicHttpBinding_IPushService" />
</client>
</system.serviceModel>
</configuration>
Binary file not shown.

After

Width:  |  Height:  |  Size: 9.2 KiB

@@ -0,0 +1,79 @@
<UserControl x:Class="WindowsPhone.Recipes.Push.Client.Views.InboxView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:tk="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
d:DesignHeight="480" d:DesignWidth="480">
<Grid x:Name="LayoutRoot" Background="{StaticResource PhoneChromeBrush}">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="Views">
<VisualState x:Name="NormalView" />
<VisualState x:Name="ScheduleView">
<Storyboard>
<ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetName="TileScheduleView" Storyboard.TargetProperty="Visibility">
<DiscreteObjectKeyFrame KeyTime="0" Value="Visible" />
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Grid.RowDefinitions>
<RowDefinition Height="120"/>
<RowDefinition Height="120"/>
<RowDefinition Height="60"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<StackPanel d:LayoutOverrides="Height">
<TextBlock Margin="12,12,0,0" Text="Active Push Pattern" FontSize="24" />
<ListBox ItemsSource="{Binding PushPatterns}"
IsHitTestVisible="False"
SelectedItem="{Binding PushPattern, Mode=TwoWay}"
ItemsPanel="{StaticResource ItemsPanelTemplate}"
ItemContainerStyle="{StaticResource PatternListBoxItemStyle}"
HorizontalAlignment="Center">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding}"
TextWrapping="Wrap"
VerticalAlignment="Center"
HorizontalAlignment="Center"
TextAlignment="Center" />
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</StackPanel>
<StackPanel Grid.Row="1" d:LayoutOverrides="Height">
<TextBlock Margin="12,12,0,0" Text="Counter (if relevant)" FontSize="24" />
<TextBlock Margin="12,12,0,0" Text="{Binding Counter}" Foreground="LightBlue" />
</StackPanel>
<TextBlock Margin="12,12,0,17" Text="Raw Messages (last on top)" Grid.Row="2" d:LayoutOverrides="Height" FontSize="24" />
<ListBox ItemsSource="{Binding RawMessages}" Grid.Row="4" Margin="12,0,12,80"/>
<Border x:Name="TileScheduleView"
Grid.Row="1" Grid.RowSpan="3"
Visibility="Collapsed"
Background="{StaticResource PhoneChromeBrush}">
<StackPanel>
<TextBlock Margin="12,12,0,17" Text="Tile Image (located on server)" Grid.Row="2" d:LayoutOverrides="Height" FontSize="24" />
<ListBox ItemsSource="{Binding ServerImages}"
SelectedItem="{Binding SelectedServerImage, Mode=TwoWay}"
Margin="12,0,12,0" />
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Button Content="Schedule" Click="ButtonSchedule_Click" />
<Button Content="Test Now" Click="ButtonTestNow_Click" Grid.Column="1" />
</Grid>
</StackPanel>
</Border>
</Grid>
</UserControl>
@@ -0,0 +1,275 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.IO;
using System.Collections.ObjectModel;
using System.Threading;
using Microsoft.Phone.Shell;
using Microsoft.Phone.Notification;
using WindowsPhone.Recipes.Push.Client.Services;
using WindowsPhone.Recipes.Push.Client.Controls;
namespace WindowsPhone.Recipes.Push.Client.Views
{
public partial class InboxView : UserControl
{
#region Fields
/// <value>Url of the GetTileImage REST service.</value>
private static readonly string GetTileImageService = App.ServerAddress + "/ImageService/GetTileImage?uri={0}";
private readonly ObservableCollection<string> _rawMessages = new ObservableCollection<string>();
private ShellTileSchedule _tileSchedule;
#endregion
#region Properties
public ObservableCollection<string> RawMessages
{
get { return _rawMessages; }
}
public IEnumerable<string> ServerImages
{
get
{
return new string[]
{
"number0.png",
"number1.png",
"number2.png",
"number3.png",
"number4.png",
"number5.png",
"number6.png",
"number7.png",
"number8.png",
"number9.png"
};
}
}
public string SelectedServerImage
{
get { return (string)GetValue(SelectedServerImageProperty); }
set { SetValue(SelectedServerImageProperty, value); }
}
// Using a DependencyProperty as the backing store for SelectedServerImage. This enables animation, styling, binding, etc...
public static readonly DependencyProperty SelectedServerImageProperty =
DependencyProperty.Register(
"SelectedServerImage",
typeof(string),
typeof(InboxView),
new PropertyMetadata("number0.png"));
public IEnumerable<string> PushPatterns
{
get { return new string[] { "One Time", "Counter", "Ask to Pin", "Custom Tile", "Tile Schedule" }; }
}
public string PushPattern
{
get { return (string)GetValue(PushPatternProperty); }
set { SetValue(PushPatternProperty, value); }
}
// Using a DependencyProperty as the backing store for PushPattern. This enables animation, styling, binding, etc...
public static readonly DependencyProperty PushPatternProperty =
DependencyProperty.Register(
"PushPattern",
typeof(string),
typeof(InboxView),
new PropertyMetadata(null, PushPatternChanged));
private static void PushPatternChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var view = d as InboxView;
if ("Tile Schedule".CompareTo(e.NewValue) == 0)
{
VisualStateManager.GoToState(view, "ScheduleView", false);
}
else
{
VisualStateManager.GoToState(view, "NormalView", false);
}
}
public int Counter
{
get { return (int)GetValue(CounterProperty); }
set { SetValue(CounterProperty, value); }
}
// Using a DependencyProperty as the backing store for Counter. This enables animation, styling, binding, etc...
public static readonly DependencyProperty CounterProperty =
DependencyProperty.Register(
"Counter",
typeof(int),
typeof(InboxView),
new PropertyMetadata(0));
public string TileScheduleParameter
{
get { return (string)GetValue(TileScheduleParameterProperty); }
set { SetValue(TileScheduleParameterProperty, value); }
}
// Using a DependencyProperty as the backing store for TileScheduleParameter. This enables animation, styling, binding, etc...
public static readonly DependencyProperty TileScheduleParameterProperty =
DependencyProperty.Register(
"TileScheduleParameter",
typeof(string),
typeof(InboxView),
new PropertyMetadata("number0.png"));
#endregion
public InboxView()
{
DataContext = this;
InitializeComponent();
Loaded += InboxView_Loaded;
Unloaded += InboxView_Unloaded;
UpdateServerInfo();
}
private void InboxView_Unloaded(object sender, RoutedEventArgs e)
{
UnregisterRawNotification();
}
private void InboxView_Loaded(object sender, RoutedEventArgs e)
{
RegisterRawNotification();
}
private void UpdateServerInfo()
{
try
{
var pushService = new PushServiceClient();
pushService.GetServerInfoCompleted += (s1, e1) =>
{
try
{
pushService.CloseAsync();
if (e1.Result != null)
{
Dispatcher.BeginInvoke(() =>
{
PushPattern = e1.Result.PushPattern;
Counter = e1.Result.Counter;
});
}
}
catch (Exception ex)
{
ex.Show();
}
};
pushService.GetServerInfoAsync();
}
catch (Exception ex)
{
ex.Show();
}
}
private void RegisterRawNotification()
{
var context = PushContext.Current;
if (context != null)
{
context.RawNotification += context_RawNotification;
}
}
private void UnregisterRawNotification()
{
var context = PushContext.Current;
if (context != null)
{
context.RawNotification -= context_RawNotification;
}
}
private void context_RawNotification(object sender, HttpNotificationEventArgs e)
{
try
{
using (var stream = new StreamReader(e.Notification.Body))
{
var rawMessage = stream.ReadToEnd();
_rawMessages.Insert(0, rawMessage);
if ("AskToPin".CompareTo(rawMessage) == 0)
{
AskToPin();
}
UpdateServerInfo();
}
}
catch (Exception ex)
{
ex.Show();
}
}
private void AskToPin()
{
NotificationBox.Show("Important", "Please pin your application to Start Screen so this application can work properly.");
}
private void ButtonSchedule_Click(object sender, RoutedEventArgs e)
{
_tileSchedule = new ShellTileSchedule();
_tileSchedule.Recurrence = UpdateRecurrence.Interval;
_tileSchedule.StartTime = DateTime.Now;
_tileSchedule.Interval = UpdateInterval.EveryHour;
_tileSchedule.RemoteImageUri = new Uri(string.Format(GetTileImageService, TileScheduleParameter));
_tileSchedule.Start();
}
private void ButtonTestNow_Click(object sender, RoutedEventArgs e)
{
try
{
var pushService = new PushServiceClient();
pushService.UpdateTileCompleted += (s1, e1) =>
{
try
{
pushService.CloseAsync();
}
catch (Exception ex)
{
ex.Show();
}
};
pushService.UpdateTileAsync(PushContext.Current.NotificationChannel.ChannelUri, SelectedServerImage);
}
catch (Exception ex)
{
ex.Show();
}
}
}
}
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace WindowsPhone.Recipes.Push.Client.Views
{
public class LoginEventArgs : EventArgs
{
public Exception Exception { get; private set; }
public LoginEventArgs(Exception exception = null)
{
Exception = exception;
}
}
}
@@ -0,0 +1,16 @@
<UserControl x:Class="WindowsPhone.Recipes.Push.Client.Views.PushSettingsView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:my="clr-namespace:WindowsPhone.Recipes.Push.Client.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
d:DesignHeight="628" d:DesignWidth="480">
<Grid x:Name="LayoutRoot" Background="{StaticResource PhoneChromeBrush}">
<my:PushSettingsControl x:Name="settingsControl" />
</Grid>
</UserControl>
@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
namespace WindowsPhone.Recipes.Push.Client.Views
{
public partial class PushSettingsView : UserControl
{
public PushSettingsView()
{
InitializeComponent();
}
}
}
@@ -0,0 +1,26 @@
<UserControl x:Class="WindowsPhone.Recipes.Push.Client.Views.UserLoginView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
xmlns:my="clr-namespace:WindowsPhone.Recipes.Push.Client.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
d:DesignHeight="480" d:DesignWidth="480">
<!--ContentPanel - place additional content here-->
<Grid x:Name="LayoutRoot">
<my:ProgressBarWithText x:Name="progress" Margin="0,-40,0,0" Text="Login..." FontSize="24" ShowProgress="True" Visibility="Collapsed" />
<StackPanel x:Name="login" Visibility="Collapsed">
<StackPanel>
<TextBlock Text="User Name" />
<TextBox x:Name="textBoxUserName" Text="{Binding UserName, Mode=TwoWay}" />
</StackPanel>
<Button x:Name="buttonLogin" Content="Login" Click="ButtonLogin_Click" />
</StackPanel>
</Grid>
</UserControl>
@@ -0,0 +1,115 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.IO.IsolatedStorage;
using WindowsPhone.Recipes.Push.Client.Services;
using System.Threading;
namespace WindowsPhone.Recipes.Push.Client.Views
{
public partial class UserLoginView : UserControl
{
#region Fields
private readonly IsolatedStorageSettings Settings = IsolatedStorageSettings.ApplicationSettings;
#endregion
#region Properties
public string UserName { get; set; }
#endregion
#region Events
public event EventHandler<LoginEventArgs> Login;
#endregion
public UserLoginView()
{
DataContext = this;
InitializeComponent();
Loaded += UserLoginView_Loaded;
}
private void UserLoginView_Loaded(object sender, RoutedEventArgs e)
{
string userName;
if (!Settings.TryGetValue("LoginPage.UserName", out userName))
{
login.Visibility = Visibility.Visible;
}
else
{
UserName = userName;
InternalLogin();
}
}
private void ButtonLogin_Click(object sender, RoutedEventArgs args)
{
Settings["LoginPage.UserName"] = UserName;
login.Visibility = Visibility.Collapsed;
InternalLogin();
}
private void OnLogin(LoginEventArgs args)
{
if (Login != null)
{
Login(this, args);
}
}
private void InternalLogin()
{
login.Visibility = Visibility.Collapsed;
progress.Visibility = Visibility.Visible;
var pushContext = PushContext.Current;
pushContext.Connect(c => RegisterClient(c.ChannelUri));
}
private void RegisterClient(Uri channelUri)
{
// Register the URI with 3rd party web service.
try
{
var pushService = new PushServiceClient();
pushService.RegisterCompleted += (s, e) =>
{
pushService.CloseAsync();
Completed(e.Error);
};
pushService.RegisterAsync(UserName, channelUri);
}
catch (Exception ex)
{
Completed(ex);
}
}
private void Completed(Exception ex)
{
login.Visibility = Visibility.Visible;
progress.Visibility = Visibility.Collapsed;
Dispatcher.BeginInvoke(() => OnLogin(new LoginEventArgs(ex)));
}
}
}
@@ -0,0 +1,196 @@
<?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)' == '' ">AnyCPU</Platform>
<ProductVersion>10.0.20506</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{DD28493E-0C20-4175-AEB0-E76D94EC92D3}</ProjectGuid>
<ProjectTypeGuids>{C089C8C0-30E0-4E22-80C0-CE093F111A43};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>WindowsPhone.Recipes.Push.Client</RootNamespace>
<AssemblyName>PushClient</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<SilverlightVersion>$(TargetFrameworkVersion)</SilverlightVersion>
<TargetFrameworkProfile>WindowsPhone</TargetFrameworkProfile>
<TargetFrameworkIdentifier>Silverlight</TargetFrameworkIdentifier>
<SilverlightApplication>true</SilverlightApplication>
<SupportedCultures>
</SupportedCultures>
<XapOutputs>true</XapOutputs>
<GenerateSilverlightManifest>true</GenerateSilverlightManifest>
<XapFilename>PushClient.xap</XapFilename>
<SilverlightManifestTemplate>Properties\AppManifest.xml</SilverlightManifestTemplate>
<SilverlightAppEntry>WindowsPhone.Recipes.Push.Client.App</SilverlightAppEntry>
<ValidateXaml>true</ValidateXaml>
<ThrowErrorsInValidation>true</ThrowErrorsInValidation>
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>Bin\Debug</OutputPath>
<DefineConstants>DEBUG;TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
<NoStdLib>true</NoStdLib>
<NoConfig>true</NoConfig>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>Bin\Release</OutputPath>
<DefineConstants>TRACE;SILVERLIGHT;WINDOWS_PHONE</DefineConstants>
<NoStdLib>true</NoStdLib>
<NoConfig>true</NoConfig>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Phone" />
<Reference Include="Microsoft.Phone.Controls, Version=7.0.0.0, Culture=neutral, PublicKeyToken=24eec0d8c86cda1e, processorArchitecture=MSIL" />
<Reference Include="Microsoft.Phone.Controls.Toolkit, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b772ad94eb9ca604, processorArchitecture=MSIL" />
<Reference Include="Microsoft.Phone.Interop" />
<Reference Include="System.Net" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Servicemodel" />
<Reference Include="System.Servicemodel.Web" />
<Reference Include="System.Windows" />
<Reference Include="system" />
<Reference Include="System.Core" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
</ItemGroup>
<ItemGroup>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
</Compile>
<Compile Include="Controls\NotificationBox.xaml.cs">
<DependentUpon>NotificationBox.xaml</DependentUpon>
</Compile>
<Compile Include="Controls\ViewTransitions.cs" />
<Compile Include="Converters\BoolBrushConverter.cs" />
<Compile Include="ExceptionExtensions.cs" />
<Compile Include="MainPage.xaml.cs">
<DependentUpon>MainPage.xaml</DependentUpon>
</Compile>
<Compile Include="Controls\ProgressBar\BooleanToVisibilityConverter.cs" />
<Compile Include="Controls\ProgressBar\ProgressBarWithText.xaml.cs">
<DependentUpon>ProgressBarWithText.xaml</DependentUpon>
</Compile>
<Compile Include="Controls\ProgressBar\RelativeAnimatingContentControl.cs" />
<Compile Include="PushContextErrorEventArgs.cs" />
<Compile Include="PushContextEventArgs.cs" />
<Compile Include="PushContext.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Controls\PushSettingsControl.xaml.cs">
<DependentUpon>PushSettingsControl.xaml</DependentUpon>
</Compile>
<Compile Include="Service References\Services\Reference.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Reference.svcmap</DependentUpon>
</Compile>
<Compile Include="Views\InboxView.xaml.cs">
<DependentUpon>InboxView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\LoginEventArgs.cs" />
<Compile Include="Views\PushSettingsView.xaml.cs">
<DependentUpon>PushSettingsView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\UserLoginView.xaml.cs">
<DependentUpon>UserLoginView.xaml</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</ApplicationDefinition>
<Page Include="Controls\NotificationBox.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="MainPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Controls\PushSettingsControl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Controls\ProgressBar\ProgressBarWithText.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Views\InboxView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\PushSettingsView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\UserLoginView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<None Include="Properties\AppManifest.xml" />
<None Include="Properties\WMAppManifest.xml" />
<None Include="Service References\Services\service.wsdl" />
<None Include="Service References\Services\service.xsd">
<SubType>Designer</SubType>
</None>
<None Include="Service References\Services\service1.xsd">
<SubType>Designer</SubType>
</None>
<None Include="Service References\Services\WindowsPhone.Recipes.Push.Client.Services.ServerInfo1.datasource">
<DependentUpon>Reference.svcmap</DependentUpon>
</None>
<None Include="Service References\Services\WindowsPhone.Recipes.Push.Server.Models.xsd">
<SubType>Designer</SubType>
</None>
<Content Include="ServiceReferences.ClientConfig" />
</ItemGroup>
<ItemGroup>
<Content Include="ApplicationIcon.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Background.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Resources\TileImages\TileBackground1.jpg" />
<Content Include="Resources\TileImages\TileBackground2.jpg" />
<Content Include="Resources\TileImages\TileBackground3.jpg" />
<None Include="Service References\Services\configuration91.svcinfo" />
<None Include="Service References\Services\configuration.svcinfo" />
<None Include="Service References\Services\Reference.svcmap">
<Generator>WCF Proxy Generator</Generator>
<LastGenOutput>Reference.cs</LastGenOutput>
</None>
<Content Include="SplashScreenImage.jpg" />
</ItemGroup>
<ItemGroup>
<WCFMetadata Include="Service References\" />
</ItemGroup>
<ItemGroup>
<WCFMetadataStorage Include="Service References\Services\" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Microsoft\Silverlight for Phone\$(TargetFrameworkVersion)\Microsoft.Silverlight.$(TargetFrameworkProfile).Overrides.targets" />
<Import Project="$(MSBuildExtensionsPath)\Microsoft\Silverlight for Phone\$(TargetFrameworkVersion)\Microsoft.Silverlight.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>
-->
<ProjectExtensions />
</Project>
@@ -0,0 +1,139 @@
<?xml version="1.0" encoding="utf-8"?>
<ClassDiagram MajorVersion="1" MinorVersion="1">
<Class Name="WindowsPhone.Recipes.Push.Messasges.Guard" Collapsed="true">
<Position X="10.75" Y="3" Width="1.5" />
<TypeIdentifier>
<HashCode>AAEAAIAAAAAAAAAAAAAAQAAAAAAAAAAAACAAAAAAAAA=</HashCode>
<FileName>Guard.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="WindowsPhone.Recipes.Push.Messasges.HttpWebResponseExtensions">
<Position X="10.75" Y="0.5" Width="2.25" />
<Members>
<Method Name="GetStatus" Hidden="true" />
</Members>
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAAAAAAEAAAAEAgAQAAAAAAAAAA=</HashCode>
<FileName>HttpWebResponseExtensions.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="WindowsPhone.Recipes.Push.Messasges.MessageSendException">
<Position X="0.5" Y="3.25" Width="2" />
<Members>
<Method Name="MessageSendException" Hidden="true" />
</Members>
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>MessageSendException.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="WindowsPhone.Recipes.Push.Messasges.MessageSendResult">
<Position X="0.5" Y="0.5" Width="2" />
<Members>
<Method Name="InitializeStatusCodes" Hidden="true" />
<Method Name="MessageSendResult" Hidden="true" />
</Members>
<TypeIdentifier>
<HashCode>FAAAAAAAAQCAAAAgAAACAAAAAAgAAAAAIABAAAAAAAA=</HashCode>
<FileName>MessageSendResult.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="WindowsPhone.Recipes.Push.Messasges.PushNotificationMessage">
<Position X="3.25" Y="0.5" Width="2.25" />
<Members>
<Field Name="_payload" Hidden="true" />
<Field Name="_sendPriority" Hidden="true" />
<Field Name="_sync" Hidden="true" />
<Method Name="DebugOutput" Hidden="true" />
<Method Name="GetOrCreatePayload" Hidden="true" />
</Members>
<Compartments>
<Compartment Name="Fields" Collapsed="true" />
</Compartments>
<NestedTypes>
<Class Name="WindowsPhone.Recipes.Push.Messasges.PushNotificationMessage.Headers" Collapsed="true">
<TypeIdentifier>
<NewMemberFileName>PushNotificationMessage.cs</NewMemberFileName>
</TypeIdentifier>
</Class>
</NestedTypes>
<TypeIdentifier>
<HashCode>CBBCAAAAAAIAAIgAAEAQgAAggABAQAAAAAKRAAAAEIA=</HashCode>
<FileName>PushNotificationMessage.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="WindowsPhone.Recipes.Push.Messasges.RawPushNotificationMessage">
<Position X="0.5" Y="5.75" Width="2.5" />
<TypeIdentifier>
<HashCode>AAAAAAAIAAAAAAgAAABAAAAAAAAAQAAAAAACAAAAAAA=</HashCode>
<FileName>RawPushNotificationMessage.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="WindowsPhone.Recipes.Push.Messasges.TilePushNotificationMessage">
<Position X="3.25" Y="5.75" Width="2.25" />
<Members>
<Field Name="_backgroundImageUri" Hidden="true" />
<Field Name="_count" Hidden="true" />
<Field Name="_title" Hidden="true" />
<Field Name="MaxCount" Hidden="true" />
<Field Name="MinCount" Hidden="true" />
<Field Name="PayloadString" Hidden="true" />
<Field Name="WindowsPhoneTarget" Hidden="true" />
</Members>
<TypeIdentifier>
<HashCode>ARAAAAABAIAAAEgAAARACAQCAAAAQAAgAACAAAAAAKA=</HashCode>
<FileName>TilePushNotificationMessage.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="WindowsPhone.Recipes.Push.Messasges.ToastPushNotificationMessage">
<Position X="5.75" Y="5.75" Width="2.5" />
<Members>
<Field Name="_subTitle" Hidden="true" />
<Field Name="_title" Hidden="true" />
<Field Name="PayloadString" Hidden="true" />
<Field Name="WindowsPhoneTarget" Hidden="true" />
</Members>
<Compartments>
<Compartment Name="Fields" Collapsed="true" />
</Compartments>
<TypeIdentifier>
<HashCode>ABAAAAAAAIAAAEgAAARAAEAABgAAQAAAAAAAAAAAAKA=</HashCode>
<FileName>ToastPushNotificationMessage.cs</FileName>
</TypeIdentifier>
</Class>
<Class Name="WindowsPhone.Recipes.Push.Messasges.Properties.Resources" Collapsed="true">
<Position X="10.75" Y="2.25" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAACAAAAAAACgBEABAQQAAAAAAAAAAAJACAIA=</HashCode>
</TypeIdentifier>
</Class>
<Enum Name="WindowsPhone.Recipes.Push.Messasges.DeviceConnectionStatus">
<Position X="8.5" Y="4" Width="2" />
<TypeIdentifier>
<HashCode>ABIACAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>DeviceConnectionStatus.cs</FileName>
</TypeIdentifier>
</Enum>
<Enum Name="WindowsPhone.Recipes.Push.Messasges.MessageSendPriority">
<Position X="8.5" Y="5.75" Width="2" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAAAAAgAAAAAAAAgIAAAAAAAAAAAAAAA=</HashCode>
<FileName>MessageSendPriority.cs</FileName>
</TypeIdentifier>
</Enum>
<Enum Name="WindowsPhone.Recipes.Push.Messasges.NotificationStatus">
<Position X="8.5" Y="2" Width="2" />
<TypeIdentifier>
<HashCode>AAIAAECBAAAAAAAAAAAAAAABAAAAAAAAAAAAAAAAAAA=</HashCode>
<FileName>NotificationStatus.cs</FileName>
</TypeIdentifier>
</Enum>
<Enum Name="WindowsPhone.Recipes.Push.Messasges.SubscriptionStatus">
<Position X="8.5" Y="0.5" Width="2" />
<TypeIdentifier>
<HashCode>AAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAhAAAAAAAAAAA=</HashCode>
<FileName>SubscriptionStatus.cs</FileName>
</TypeIdentifier>
</Enum>
<Font Name="Calibri" Size="10" />
</ClassDiagram>
@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace WindowsPhone.Recipes.Push.Messasges
{
/// <summary>
/// Windows Phone Device connection status.
/// </summary>
public enum DeviceConnectionStatus
{
/// <value>The request is not applicable.</value>
NotApplicable,
/// <value>The device is connected.</value>
Connected,
/// <value>The device is temporarily disconnected.</value>
TempDisconnected,
/// <value>The device is in an inactive state.</value>
Inactive
}
}
@@ -0,0 +1,132 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using WindowsPhone.Recipes.Push.Messasges.Properties;
namespace WindowsPhone.Recipes.Push.Messasges
{
/// <summary>
/// A static helper class that includes various parameter checking routines.
/// </summary>
public static partial class Guard
{
/// <summary>
/// Throws <see cref="ArgumentNullException"/> if the given argument is null.
/// </summary>
/// <exception cref="ArgumentNullException"> if tested value if null.</exception>
/// <param name="argumentValue">Argument value to test.</param>
/// <param name="argumentName">Name of the argument being tested.</param>
public static void ArgumentNotNull(object argumentValue,
string argumentName)
{
if (argumentValue == null)
{
throw new ArgumentNullException(argumentName);
}
}
/// <summary>
/// Throws an exception if the tested string argument is null or the empty string.
/// </summary>
/// <exception cref="ArgumentNullException">Thrown if string value is null.</exception>
/// <exception cref="ArgumentException">Thrown if the string is empty</exception>
/// <param name="argumentValue">Argument value to check.</param>
/// <param name="argumentName">Name of argument being checked.</param>
public static void ArgumentNotNullOrEmpty(string argumentValue,
string argumentName)
{
if (argumentValue == null)
{
throw new ArgumentNullException(argumentName);
}
if (argumentValue.Length == 0)
{
throw new ArgumentException(Resources.ArgumentMustNotBeEmpty, argumentName);
}
}
/// <summary>
/// Verifies that an argument type is assignable from the provided type (meaning
/// interfaces are implemented, or classes exist in the base class hierarchy).
/// </summary>
/// <param name="assignmentTargetType">The argument type that will be assigned to.</param>
/// <param name="assignmentValueType">The type of the value being assigned.</param>
/// <param name="argumentName">Argument name.</param>
public static void TypeIsAssignable(Type assignmentTargetType, Type assignmentValueType, string argumentName)
{
if (assignmentTargetType == null)
{
throw new ArgumentNullException("assignmentTargetType");
}
if (assignmentValueType == null)
{
throw new ArgumentNullException("assignmentValueType");
}
if (!assignmentTargetType.IsAssignableFrom(assignmentValueType))
{
throw new ArgumentException(string.Format(
CultureInfo.CurrentCulture,
Resources.TypesAreNotAssignable,
assignmentTargetType,
assignmentValueType),
argumentName);
}
}
/// <summary>
/// Verifies that an argument instance is assignable from the provided type (meaning
/// interfaces are implemented, or classes exist in the base class hierarchy, or instance can be
/// assigned through a runtime wrapper, as is the case for COM Objects).
/// </summary>
/// <param name="assignmentTargetType">The argument type that will be assigned to.</param>
/// <param name="assignmentInstance">The instance that will be assigned.</param>
/// <param name="argumentName">Argument name.</param>
[SuppressMessage(
"Microsoft.Design",
"CA1031:DoNotCatchGeneralExceptionTypes",
Justification = "GetType() invoked for diagnostics purposes")]
public static void InstanceIsAssignable(Type assignmentTargetType, object assignmentInstance, string argumentName)
{
if (assignmentTargetType == null)
{
throw new ArgumentNullException("assignmentTargetType");
}
if (assignmentInstance == null)
{
throw new ArgumentNullException("assignmentInstance");
}
if (!assignmentTargetType.IsInstanceOfType(assignmentInstance))
{
throw new ArgumentException(
string.Format(
CultureInfo.CurrentCulture,
Resources.TypesAreNotAssignable,
assignmentTargetType,
GetTypeName(assignmentInstance)),
argumentName);
}
}
[SuppressMessage("Microsoft.Design", "CA1031:DoNotCatchGeneralExceptionTypes",
Justification = "Need to use exception as flow control here, no other choice")]
private static string GetTypeName(object assignmentInstance)
{
string assignmentInstanceType;
try
{
assignmentInstanceType = assignmentInstance.GetType().FullName;
}
catch (Exception)
{
assignmentInstanceType = Resources.UnknownType;
}
return assignmentInstanceType;
}
}
}
@@ -0,0 +1,58 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
namespace WindowsPhone.Recipes.Push.Messasges
{
/// <summary>
/// Extends the <see cref="HttpWebResponse"/> type with methods for translating push notification specific status codes strings to strong typed enumeration.
/// </summary>
internal static class HttpWebResponseExtensions
{
/// <summary>
/// Gets the Notification Status code as <see cref="NotificationStatus"/> enumeration.
/// </summary>
/// <param name="response">The http web response instance.</param>
/// <returns>Correlate enumeration value.</returns>
public static NotificationStatus GetNotificationStatus(this HttpWebResponse response)
{
return response.GetStatus(
NotificationStatus.NotApplicable,
PushNotificationMessage.Headers.NotificationStatus);
}
/// <summary>
/// Gets the Device Connection Status code as <see cref="NotificationStatus"/> enumeration.
/// </summary>
/// <param name="response">The http web response instance.</param>
/// <returns>Correlate enumeration value.</returns>
public static DeviceConnectionStatus GetDeviceConnectionStatus(this HttpWebResponse response)
{
return response.GetStatus(
DeviceConnectionStatus.NotApplicable,
PushNotificationMessage.Headers.DeviceConnectionStatus);
}
/// <summary>
/// Gets the Subscription Status code as <see cref="NotificationStatus"/> enumeration.
/// </summary>
/// <param name="response">The http web response instance.</param>
/// <returns>Correlate enumeration value.</returns>
public static SubscriptionStatus GetSubscriptionStatus(this HttpWebResponse response)
{
return response.GetStatus(
SubscriptionStatus.NotApplicable,
PushNotificationMessage.Headers.SubscriptionStatus);
}
private static T GetStatus<T>(this HttpWebResponse response, T def, string header) where T : struct
{
string statusString = response.Headers[header];
T status = def;
Enum.TryParse<T>(statusString, out status);
return status;
}
}
}
@@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using WindowsPhone.Recipes.Push.Messasges.Properties;
namespace WindowsPhone.Recipes.Push.Messasges
{
/// <summary>
/// Represents errors that occur during push notification message send operation.
/// </summary>
public class MessageSendException : Exception
{
/// <summary>
/// Gets the message send result.
/// </summary>
public MessageSendResult Result { get; private set; }
/// <summary>
/// Initializes a new instance of this type.
/// </summary>
/// <param name="result">The send operation result.</param>
/// <param name="innerException">An inner exception causes this error.</param>
internal MessageSendException(MessageSendResult result, Exception innerException)
: base(Resources.FailedToSendMessage, innerException)
{
Result = result;
}
}
}
@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace WindowsPhone.Recipes.Push.Messasges
{
/// <summary>
/// Represents the priorities of which the Push Notification Service sends the message.
/// </summary>
public enum MessageSendPriority
{
/// <value>The message should be delivered by the Push Notification Service immediately.</value>
High = 0,
/// <value>The message should be delivered by the Push Notification Service within 450 seconds.</value>
Normal = 1,
/// <value>The message should be delivered by the Push Notification Service within 900 seconds.</value>
Low = 2
}
}
@@ -0,0 +1,115 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Runtime.Serialization;
namespace WindowsPhone.Recipes.Push.Messasges
{
/// <summary>
/// Push notification message send operation result.
/// </summary>
public class MessageSendResult
{
#region Properties
/// <summary>
/// Gets the original exception or null.
/// </summary>
public Exception Exception { get; private set; }
/// <summary>
/// Gets the response time offset.
/// </summary>
public DateTimeOffset Timestamp { get; private set; }
/// <summary>
/// Gets the associated message.
/// </summary>
public PushNotificationMessage AssociatedMessage { get; private set; }
/// <summary>
/// Gets the channel URI.
/// </summary>
public Uri ChannelUri { get; private set; }
/// <summary>
/// Gets the web request status.
/// </summary>
public HttpStatusCode StatusCode { get; private set; }
/// <summary>
/// Gets the push 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; }
#endregion
#region Ctor
/// <summary>
/// Initializes a new instance of this type.
/// </summary>
internal MessageSendResult(PushNotificationMessage associatedMessage, Uri channelUri, WebResponse response)
{
Timestamp = DateTimeOffset.Now;
AssociatedMessage = associatedMessage;
ChannelUri = channelUri;
InitializeStatusCodes(response as HttpWebResponse);
}
/// <summary>
/// Initializes a new instance of this type.
/// </summary>
internal MessageSendResult(PushNotificationMessage associatedMessage, Uri channelUri, WebException exception)
: this(associatedMessage, channelUri, response: exception.Response)
{
Exception = exception;
}
/// <summary>
/// Initializes a new instance of this type.
/// </summary>
internal MessageSendResult(PushNotificationMessage associatedMessage, Uri channelUri, Exception exception)
: this(associatedMessage, channelUri, response: null)
{
Exception = exception;
}
#endregion
#region Privates
private void InitializeStatusCodes(HttpWebResponse response)
{
if (response == null)
{
StatusCode = HttpStatusCode.InternalServerError;
NotificationStatus = NotificationStatus.NotApplicable;
DeviceConnectionStatus = DeviceConnectionStatus.NotApplicable;
SubscriptionStatus = SubscriptionStatus.NotApplicable;
}
else
{
StatusCode = response.StatusCode;
NotificationStatus = response.GetNotificationStatus();
DeviceConnectionStatus = response.GetDeviceConnectionStatus();
SubscriptionStatus = response.GetSubscriptionStatus();
}
}
#endregion
}
}
@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace WindowsPhone.Recipes.Push.Messasges
{
/// <summary>
/// Microsoft Push Notification Service notification request status.
/// </summary>
public enum NotificationStatus
{
/// <value>The request is not applicable.</value>
NotApplicable,
/// <value>The notification request was accepted.</value>
Received,
/// <value>Queue overflow. The Push Notification Service should re-send the notification later.</value>
QueueFull,
/// <value>The push notification was suppressed by the Push Notification Service.</value>
Suppressed,
/// <value>The push notification was dropped by the Push Notification Service.</value>
Dropped,
}
}
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 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("NotificationSenderUtility")]
[assembly: AssemblyDescription("Class Library to communicate with the Push Notification Service")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft Corp.")]
[assembly: AssemblyProduct("Using Push Notifications Hands-on Lab")]
[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)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("4cb73b37-8cd0-456a-8c69-ea3e6622582b")]
// 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,135 @@
//------------------------------------------------------------------------------
// <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.Messasges.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.Messasges.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;
}
}
/// <summary>
/// Looks up a localized string similar to The provided string argument must not be empty..
/// </summary>
internal static string ArgumentMustNotBeEmpty {
get {
return ResourceManager.GetString("ArgumentMustNotBeEmpty", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Count value {0} is not valid. Count value must not be lower than {1} or greater than {2}..
/// </summary>
internal static string CountValueIsNotValid {
get {
return ResourceManager.GetString("CountValueIsNotValid", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Failed to send push notification message..
/// </summary>
internal static string FailedToSendMessage {
get {
return ResourceManager.GetString("FailedToSendMessage", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to The provided payload must not be null..
/// </summary>
internal static string PayloadMustNotBeNull {
get {
return ResourceManager.GetString("PayloadMustNotBeNull", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Payload size is too big. Maximum payload size shouldn&apos;t exceed {0} bytes..
/// </summary>
internal static string PayloadSizeIsTooBig {
get {
return ResourceManager.GetString("PayloadSizeIsTooBig", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Server returned error status code:{0}..
/// </summary>
internal static string ServerErrorStatusCode {
get {
return ResourceManager.GetString("ServerErrorStatusCode", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to The type {1} cannot be assigned to variables of type {0}..
/// </summary>
internal static string TypesAreNotAssignable {
get {
return ResourceManager.GetString("TypesAreNotAssignable", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to &lt;unknown&gt;.
/// </summary>
internal static string UnknownType {
get {
return ResourceManager.GetString("UnknownType", resourceCulture);
}
}
}
}
@@ -0,0 +1,144 @@
<?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.Runtime.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:import namespace="http://www.w3.org/XML/1998/namespace" />
<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" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</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" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</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=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="ArgumentMustNotBeEmpty" xml:space="preserve">
<value>The provided string argument must not be empty.</value>
</data>
<data name="CountValueIsNotValid" xml:space="preserve">
<value>Count value {0} is not valid. Count value must not be lower than {1} or greater than {2}.</value>
</data>
<data name="FailedToSendMessage" xml:space="preserve">
<value>Failed to send push notification message.</value>
</data>
<data name="PayloadMustNotBeNull" xml:space="preserve">
<value>The provided payload must not be null.</value>
</data>
<data name="PayloadSizeIsTooBig" xml:space="preserve">
<value>Payload size is too big. Maximum payload size shouldn't exceed {0} bytes.</value>
</data>
<data name="ServerErrorStatusCode" xml:space="preserve">
<value>Server returned error status code:{0}.</value>
</data>
<data name="TypesAreNotAssignable" xml:space="preserve">
<value>The type {1} cannot be assigned to variables of type {0}.</value>
</data>
<data name="UnknownType" xml:space="preserve">
<value>&lt;unknown&gt;</value>
</data>
</root>
@@ -0,0 +1,388 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Diagnostics;
using System.Threading;
using WindowsPhone.Recipes.Push.Messasges.Properties;
namespace WindowsPhone.Recipes.Push.Messasges
{
/// <summary>
/// Represents a base class for push notification messages.
/// </summary>
/// <remarks>
/// This class members are thread safe.
/// </remarks>
public abstract class PushNotificationMessage
{
#region Constants
/// <value>Push notification maximum message size including headers and payload.</value>
protected const int MaxMessageSize = 1024;
/// <summary>
/// Well known push notification message web request headers.
/// </summary>
internal static class Headers
{
public const string MessageId = "X-MessageID";
public const string BatchingInterval = "X-NotificationClass";
public const string NotificationStatus = "X-NotificationStatus";
public const string DeviceConnectionStatus = "X-DeviceConnectionStatus";
public const string SubscriptionStatus = "X-SubscriptionStatus";
public const string WindowsPhoneTarget = "X-WindowsPhone-Target";
}
#endregion
#region Fields
/// <value>Synchronizes payload manipulations.</value>
private readonly object _sync = new object();
/// <value>The payload raw bytes of this message.</value>
private byte[] _payload;
private MessageSendPriority _sendPriority;
#endregion
#region Properties
/// <summary>
/// Gets this message unique ID.
/// </summary>
public Guid Id { get; private set; }
/// <summary>
/// Gets or sets the send priority of this message in the MPNS.
/// </summary>
public MessageSendPriority SendPriority
{
get
{
return _sendPriority;
}
set
{
SafeSet(ref _sendPriority, value);
}
}
/// <summary>
/// Gets or sets the message payload.
/// </summary>
protected byte[] Payload
{
get
{
return _payload;
}
set
{
SafeSet(ref _payload, value);
}
}
protected abstract int NotificationClassId
{
get;
}
/// <summary>
/// Gets or sets the flag indicating that one of the message properties
/// has changed, thus the payload should be rebuilt.
/// </summary>
private bool IsDirty { get; set; }
#endregion
#region Ctor
/// <summary>
/// Initializes a new instance of this type with <see cref="WindowsPhone.Recipes.Push.Messasges.MessageSendPriority.Normal"/> send priority.
/// </summary>
protected PushNotificationMessage(MessageSendPriority sendPriority = MessageSendPriority.Normal)
{
Id = Guid.NewGuid();
SendPriority = sendPriority;
IsDirty = true;
}
#endregion
#region Operations
/// <summary>
/// Synchronously send this messasge to the destination address.
/// </summary>
/// <remarks>
/// Note that properties of this instance may be changed by different threads while
/// sending, but once the payload created, it won't be changed until the next send.
/// </remarks>
/// <param name="uri">Destination address uri.</param>
/// <exception cref="ArgumentNullException">One of the arguments is null.</exception>
/// <exception cref="ArgumentOutOfRangeException">Payload size is out of range. For maximum allowed message size see <see cref="PushNotificationMessage.MaxPayloadSize"/></exception>
/// <exception cref="MessageSendException">Failed to send message for any reason.</exception>
/// <returns>The result instance with relevant information for this send operation.</returns>
public MessageSendResult Send(Uri uri)
{
Guard.ArgumentNotNull(uri, "uri");
// Create payload or reuse cached one.
var payload = GetOrCreatePayload();
// Create and initialize the request object.
var request = CreateWebRequest(uri, payload);
var result = SendSynchronously(payload, uri, request);
return result;
}
/// <summary>
/// Asynchronously send this messasge to the destination address.
/// </summary>
/// <remarks>
/// This method uses the .NET Thread Pool. Use this method to send one or few
/// messages asynchronously. If you have many messages to send, please consider
/// of using the synchronous method with custom (external) queue-thread solution.
///
/// Note that properties of this instance may be changed by different threads while
/// sending, but once the payload created, it won't be changed until the next send.
/// </remarks>
/// <param name="uri">Destination address uri.</param>
/// <param name="messageSent">Message sent callback.</param>
/// <param name="messageError">Message send error callback.</param>
/// <exception cref="ArgumentNullException">One of the arguments is null.</exception>
/// <exception cref="ArgumentOutOfRangeException">Payload size is out of range. For maximum allowed message size see <see cref="PushNotificationMessage.MaxPayloadSize"/></exception>
public void SendAsync(Uri uri, Action<MessageSendResult> messageSent = null, Action<MessageSendResult> messageError = null)
{
Guard.ArgumentNotNull(uri, "uri");
// Create payload or reuse cached one.
var payload = GetOrCreatePayload();
// Create and initialize the request object.
var request = CreateWebRequest(uri, payload);
SendAsynchronously(
payload,
uri,
request,
messageSent ?? (result => { }),
messageError ?? (result => { }));
}
#endregion
#region Protected & Virtuals
/// <summary>
/// Override to create the message payload.
/// </summary>
/// <returns>The messasge payload bytes.</returns>
protected virtual byte[] OnCreatePayload()
{
return _payload;
}
/// <summary>
/// Override to initialize the message web request with custom headers.
/// </summary>
/// <param name="request">The message web request.</param>
protected virtual void OnInitializeRequest(HttpWebRequest request)
{
}
/// <summary>
/// Check the size of the payload and reject it if too big.
/// </summary>
/// <param name="payload">Payload raw bytes.</param>
protected abstract void VerifyPayloadSize(byte[] payload);
/// <summary>
/// Safely set oldValue with newValue in case that are different, and raise the dirty flag.
/// </summary>
/// <typeparam name="T">The type of the value.</typeparam>
/// <param name="oldValue">The old value.</param>
/// <param name="newValue">The new value.</param>
protected void SafeSet<T>(ref T oldValue, T newValue)
{
lock (_sync)
{
if (!object.Equals(oldValue, newValue))
{
oldValue = newValue;
IsDirty = true;
}
}
}
#endregion
#region Privates
/// <summary>
/// Synchronously send this message to the destination uri.
/// </summary>
/// <param name="payload">The message payload bytes.</param>
/// <param name="uri">The message destination uri.</param>
/// <param name="payload">Initialized Web request instance.</param>
/// <returns>The result instance with relevant information for this send operation.</returns>
private MessageSendResult SendSynchronously(byte[] payload, Uri uri, HttpWebRequest request)
{
try
{
// Get the request stream.
using (var requestStream = request.GetRequestStream())
{
// Start to write the payload to the stream.
requestStream.Write(payload, 0, payload.Length);
// Switch to receiving the response from MPNS.
using (var response = (HttpWebResponse)request.GetResponse())
{
var result = new MessageSendResult(this, uri, response);
if (response.StatusCode != HttpStatusCode.OK)
{
throw new InvalidOperationException(string.Format(Resources.ServerErrorStatusCode, response.StatusCode));
}
return result;
}
}
}
catch (WebException ex)
{
var result = new MessageSendResult(this, uri, ex);
throw new MessageSendException(result, ex);
}
catch (Exception ex)
{
var result = new MessageSendResult(this, uri, ex);
throw new MessageSendException(result, ex);
}
}
/// <summary>
/// Asynchronously send this message to the destination uri using the HttpWebRequest context.
/// </summary>
/// <param name="payload">The message payload bytes.</param>
/// <param name="uri">The message destination uri.</param>
/// <param name="payload">Initialized Web request instance.</param>
/// <param name="sent">Message sent callback.</param>
/// <param name="error">Message send error callback.</param>
/// <returns>The result instance with relevant information for this send operation.</returns>
private void SendAsynchronously(byte[] payload, Uri uri, HttpWebRequest request, Action<MessageSendResult> sent, Action<MessageSendResult> error)
{
try
{
// Get the request stream asynchronously.
request.BeginGetRequestStream(requestAsyncResult =>
{
try
{
using (var requestStream = request.EndGetRequestStream(requestAsyncResult))
{
// Start writing the payload to the stream.
requestStream.Write(payload, 0, payload.Length);
}
// Switch to receiving the response from MPNS asynchronously.
request.BeginGetResponse(responseAsyncResult =>
{
try
{
using (var response = (HttpWebResponse)request.EndGetResponse(responseAsyncResult))
{
var result = new MessageSendResult(this, uri, response);
if (response.StatusCode == HttpStatusCode.OK)
{
sent(result);
}
else
{
error(result);
}
}
}
catch (Exception ex3)
{
error(new MessageSendResult(this, uri, ex3));
}
}, null);
}
catch (Exception ex2)
{
error(new MessageSendResult(this, uri, ex2));
}
}, null);
}
catch (Exception ex1)
{
error(new MessageSendResult(this, uri, ex1));
}
}
/// <summary>
/// Create a payload and verify its size.
/// </summary>
/// <returns>Payload raw bytes.</returns>
private byte[] GetOrCreatePayload()
{
if (IsDirty)
{
lock (_sync)
{
if (IsDirty)
{
var payload = OnCreatePayload() ?? new byte[0];
DebugOutput(payload);
VerifyPayloadSize(payload);
_payload = payload;
IsDirty = false;
}
}
}
return _payload;
}
private HttpWebRequest CreateWebRequest(Uri uri, byte[] payload)
{
var request = (HttpWebRequest)WebRequest.Create(uri);
request.Method = WebRequestMethods.Http.Post;
request.ContentType = "text/xml; charset=utf-8";
request.ContentLength = payload.Length;
request.Headers[Headers.MessageId] = Id.ToString();
// Batching interval is composed of the message priority and the message class id.
int batchingInterval = ((int)SendPriority * 10) + NotificationClassId;
request.Headers[Headers.BatchingInterval] = batchingInterval.ToString();
OnInitializeRequest(request);
return request;
}
#endregion
#region Diagnostics
[Conditional("DEBUG")]
private static void DebugOutput(byte[] payload)
{
string payloadString = Encoding.ASCII.GetString(payload);
Debug.WriteLine(payloadString);
}
#endregion
}
}
@@ -0,0 +1,87 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using WindowsPhone.Recipes.Push.Messasges.Properties;
namespace WindowsPhone.Recipes.Push.Messasges
{
/// <summary>
/// Represents a raw push notification message.
/// </summary>
/// <remarks>
/// If you do not wish to update the tile or send a toast notification, you can instead
/// send raw information to your application using a raw notification. If your application
/// is not currently running, the raw notification is discarded on the Microsoft Push
/// Notification Service and is not delivered to the device.
///
/// This class members are thread safe.
/// </remarks>
public sealed class RawPushNotificationMessage : PushNotificationMessage
{
#region Constants
/// <value>Calculated raw message headers size.</value>
/// <remarks>This should ne updated if changing the protocol.</remarks>
private const int RawMessageHeadersSize = 116;
/// <value>Raw push notification message maximum payload size.</value>
public const int MaxPayloadSize = MaxMessageSize - RawMessageHeadersSize;
#endregion
#region Properties
/// <summary>
/// Gets or sets the message raw data bytes.
/// </summary>
public byte[] RawData
{
get
{
return Payload;
}
set
{
Payload = value;
}
}
/// <summary>
/// Raw push notification message class id.
/// </summary>
protected override int NotificationClassId
{
get { return 3; }
}
#endregion
#region Ctor
/// <summary>
/// Initializes a new instance of this type.
/// </summary>
/// <param name="sendPriority">The send priority of this message in the MPNS.</param>
public RawPushNotificationMessage(MessageSendPriority sendPriority = MessageSendPriority.Normal)
: base(sendPriority)
{
}
#endregion
#region Overrides
protected override void VerifyPayloadSize(byte[] payload)
{
if (payload.Length > MaxPayloadSize)
{
throw new ArgumentOutOfRangeException(string.Format(Resources.PayloadSizeIsTooBig, MaxPayloadSize));
}
}
#endregion
}
}
@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace WindowsPhone.Recipes.Push.Messasges
{
/// <summary>
/// Push notification channel subscription status.
/// </summary>
public enum SubscriptionStatus
{
/// <value>The request is not applicable.</value>
NotApplicable,
/// <value>The subscription is active.</value>
Active,
/// <value>The subscription has expired.</value>
Expired
}
}
@@ -0,0 +1,182 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WindowsPhone.Recipes.Push.Messasges.Properties;
namespace WindowsPhone.Recipes.Push.Messasges
{
/// <summary>
/// Represents a tile push notification message.
/// </summary>
/// <remarks>
/// Every phone application has one assigned 'tile' a visual, dynamic
/// representation of the application or its content. A tile displays in
/// the Start screen if the end user has pinned it.
///
/// This class members are thread safe.
/// </remarks>
public sealed class TilePushNotificationMessage : PushNotificationMessage
{
#region Constants
/// <value>Calculated tile message headers size.</value>
/// <remarks>This should ne updated if changing the protocol.</remarks>
private const int TileMessageHeadersSize = 146;
/// <value>Tile push notification message maximum payload size.</value>
public const int MaxPayloadSize = MaxMessageSize - TileMessageHeadersSize;
/// <value>The minimum <see cref="TilePushNotificationMessage.Count"/> value.</value>
public const int MinCount = 0;
/// <value>The maximum <see cref="TilePushNotificationMessage.Count"/> value.</value>
public const int MaxCount = 99;
/// <value>Windows phone target.</value>
private const string WindowsPhoneTarget = "token";
/// <value>A well formed structure of the tile notification message.</value>
private const string PayloadString =
"<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
"<wp:Notification xmlns:wp=\"WPNotification\">" +
"<wp:Tile>" +
"<wp:BackgroundImage>{0}</wp:BackgroundImage>" +
"<wp:Count>{1}</wp:Count>" +
"<wp:Title>{2}</wp:Title>" +
"</wp:Tile>" +
"</wp:Notification>";
#endregion
#region Fields
/// <value>The phone's local path, or a remote path for the background image.</value>
private Uri _backgroundImageUri;
/// <value>An integer value to be displayed in the tile.</value>
private int _count = MinCount;
/// <value>The title text should be displayed in the tile.</value>
private string _title;
#endregion
#region Properties
/// <summary>
/// Gets or sets the phone's local path, or a remote path for the background image.
/// </summary>
/// <remarks>
/// If the uri references a remote resource, the maximum allowed size of the tile
/// image is 80 KB, with a maximum download time of 15 seconds.
/// </remarks>
public Uri BackgroundImageUri
{
get
{
return _backgroundImageUri;
}
set
{
SafeSet(ref _backgroundImageUri, value);
}
}
/// <summary>
/// Gets or sets an integer value from 1 to 99 to be displayed in the tile, or 0 to clear count.
/// </summary>
public int Count
{
get
{
return _count;
}
set
{
if (value < MinCount || value > MaxCount)
{
throw new ArgumentOutOfRangeException(string.Format(Resources.CountValueIsNotValid, value, MinCount, MaxCount));
}
SafeSet(ref _count, value);
}
}
/// <summary>
/// Gets or sets the title text should be displayed in the tile. Null keeps the existing title.
/// </summary>
/// <remarks>
/// The Title must fit a single line of text and should not be wider than the actual tile.
/// Imperatively a good number of letters would be 18-20 characters long.
/// </remarks>
public string Title
{
get
{
return _title;
}
set
{
SafeSet(ref _title, value);
}
}
/// <summary>
/// Tile push notification message class id.
/// </summary>
protected override int NotificationClassId
{
get { return 1; }
}
#endregion
#region Ctor
/// <summary>
/// Initializes a new instance of this type.
/// </summary>
/// <param name="sendPriority">The send priority of this message in the MPNS.</param>
public TilePushNotificationMessage(MessageSendPriority sendPriority = MessageSendPriority.Normal)
: base(sendPriority)
{
}
#endregion
#region Overrides
/// <summary>
/// Create the tile message payload.
/// </summary>
/// <returns>The message payload bytes.</returns>
protected override byte[] OnCreatePayload()
{
var payloadString = string.Format(PayloadString, BackgroundImageUri, Count, Title);
return Encoding.ASCII.GetBytes(payloadString);
}
/// <summary>
/// Initialize the request with tile specific headers.
/// </summary>
/// <param name="request">The message request.</param>
protected override void OnInitializeRequest(System.Net.HttpWebRequest request)
{
request.Headers[Headers.WindowsPhoneTarget] = WindowsPhoneTarget;
}
protected override void VerifyPayloadSize(byte[] payload)
{
if (payload.Length > MaxPayloadSize)
{
throw new ArgumentOutOfRangeException(string.Format(Resources.PayloadSizeIsTooBig, MaxPayloadSize));
}
}
#endregion
}
}
@@ -0,0 +1,146 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using WindowsPhone.Recipes.Push.Messasges.Properties;
namespace WindowsPhone.Recipes.Push.Messasges
{
/// <summary>
/// Represents a toast push notification message.
/// </summary>
/// <remarks>
/// Toast notifications are system-wide notifications that do not disrupt
/// the user workflow or require intervention to resolve. They are displayed
/// at the top of the screen for ten seconds before disappearing. If the toast
/// notification is tapped, the application that sent the toast notification
/// will launch. A toast notification can be dismissed with a flick.
///
/// This class members are thread safe.
/// </remarks>
public sealed class ToastPushNotificationMessage : PushNotificationMessage
{
#region Constants
/// <value>Calculated toast message headers size.</value>
/// <remarks>This should ne updated if changing the protocol.</remarks>
private const int ToastMessageHeadersSize = 146;
/// <value>Toast push notification message maximum payload size.</value>
public const int MaxPayloadSize = MaxMessageSize - ToastMessageHeadersSize;
/// <value>Windows phone target.</value>
private const string WindowsPhoneTarget = "toast";
/// <value>A well formed structure of the toast notification message.</value>
private const string PayloadString =
"<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
"<wp:Notification xmlns:wp=\"WPNotification\">" +
"<wp:Toast>" +
"<wp:Text1>{0}</wp:Text1>" +
"<wp:Text2>{1}</wp:Text2>" +
"</wp:Toast>" +
"</wp:Notification>";
#endregion
#region Fields
/// <value>The bolded string that should be displayed immediately after the application icon.</value>
private string _title;
/// <value>The non-bolded string that should be displayed immediately after the Title.</value>
private string _subTitle;
#endregion
#region Properties
/// <summary>
/// Gets or sets a bolded string that should be displayed immediately after the application icon.
/// </summary>
public string Title
{
get
{
return _title;
}
set
{
SafeSet(ref _title, value);
}
}
/// <summary>
/// Gets or sets a non-bolded string that should be displayed immediately after the Title.
/// </summary>
public string SubTitle
{
get
{
return _subTitle;
}
set
{
SafeSet(ref _subTitle, value);
}
}
/// <summary>
/// Toast push notification message class id.
/// </summary>
protected override int NotificationClassId
{
get { return 2; }
}
#endregion
#region Ctor
/// <summary>
/// Initializes a new instance of this type.
/// </summary>
/// <param name="sendPriority">The send priority of this message in the MPNS.</param>
public ToastPushNotificationMessage(MessageSendPriority sendPriority = MessageSendPriority.Normal)
: base(sendPriority)
{
}
#endregion
#region Overrides
/// <summary>
/// Create the toast message payload.
/// </summary>
/// <returns>The message payload bytes.</returns>
protected override byte[] OnCreatePayload()
{
var payloadString = string.Format(PayloadString, Title, SubTitle);
return Encoding.ASCII.GetBytes(payloadString);
}
/// <summary>
/// Initialize the request with toast specific headers.
/// </summary>
/// <param name="request">The message request.</param>
protected override void OnInitializeRequest(HttpWebRequest request)
{
request.Headers[Headers.WindowsPhoneTarget] = WindowsPhoneTarget;
}
protected override void VerifyPayloadSize(byte[] payload)
{
if (payload.Length > MaxPayloadSize)
{
throw new ArgumentOutOfRangeException(string.Format(Resources.PayloadSizeIsTooBig, MaxPayloadSize));
}
}
#endregion
}
}
@@ -0,0 +1,84 @@
<?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)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{E4691236-9F54-4250-BDBE-916BBB07A378}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>WindowsPhone.Recipes.Push.Messasges</RootNamespace>
<AssemblyName>WindowsPhone.Recipes.Push.Messasges</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<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|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="DeviceConnectionStatus.cs" />
<Compile Include="Guard.cs" />
<Compile Include="HttpWebResponseExtensions.cs" />
<Compile Include="MessageSendPriority.cs" />
<Compile Include="NotificationStatus.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="MessageSendException.cs" />
<Compile Include="MessageSendResult.cs" />
<Compile Include="PushNotificationMessage.cs" />
<Compile Include="RawPushNotificationMessage.cs" />
<Compile Include="SubscriptionStatus.cs" />
<Compile Include="TilePushNotificationMessage.cs" />
<Compile Include="ToastPushNotificationMessage.cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Include="ClassDiagram.cd" />
</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,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

Some files were not shown because too many files have changed in this diff Show More