Skip to content

Commit 6a8fa8b

Browse files
committed
WP7 Tested, Sample Added
Added a Client sample for Windows Phone 7 (very easy code, no client lib needed), and also did some testing of WP7 Toasts.
1 parent fd4c35b commit 6a8fa8b

24 files changed

+696
-24
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
<Properties>
22
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
3-
<MonoDevelop.Ide.Workbench ActiveDocument="PushSharp.ClientSample.MonoForAndroid\Properties\AndroidManifest.xml">
3+
<MonoDevelop.Ide.Workbench ActiveDocument="..\..\PushSharp.Client\PushSharp.Client.MonoForAndroid\C2dmService.cs">
44
<Files>
55
<File FileName="..\..\PushSharp.Client\PushSharp.Client.MonoForAndroid\C2dmBroadcastReceiver.cs" Line="14" Column="42" />
66
<File FileName="..\..\PushSharp.Client\PushSharp.Client.MonoForAndroid\C2dmClient.cs" Line="14" Column="42" />
77
<File FileName="..\..\PushSharp.Client\PushSharp.Client.MonoForAndroid\C2dmExceptions.cs" Line="14" Column="27" />
8-
<File FileName="..\..\PushSharp.Client\PushSharp.Client.MonoForAndroid\C2dmService.cs" Line="14" Column="27" />
9-
<File FileName="PushSharp.ClientSample.MonoForAndroid\PushService.cs" Line="25" Column="74" />
10-
<File FileName="PushSharp.ClientSample.MonoForAndroid\Properties\AndroidManifest.xml" Line="6" Column="64" />
8+
<File FileName="..\..\PushSharp.Client\PushSharp.Client.MonoForAndroid\C2dmService.cs" Line="24" Column="4" />
9+
<File FileName="PushSharp.ClientSample.MonoForAndroid\PushService.cs" Line="13" Column="20" />
10+
<File FileName="PushSharp.ClientSample.MonoForAndroid\DefaultActivity.cs" Line="77" Column="45" />
1111
</Files>
1212
</MonoDevelop.Ide.Workbench>
1313
<MonoDevelop.Ide.DebuggingService.Breakpoints>
1414
<BreakpointStore />
1515
</MonoDevelop.Ide.DebuggingService.Breakpoints>
1616
<MonoDevelop.Ide.DebuggingService.PinnedWatches />
17+
<MonoDevelop.Ide.ItemProperties.PushSharp.ClientSample.MonoForAndroid MonoForAntroid.PreferredDevice="3.7in WVGA (Nexus One)" AndroidDeviceId-Debug="383096100C4700EC" />
1718
</Properties>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 11.00
3+
# Visual Studio 2010
4+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PushSharp.ClientSample.WindowsPhone", "PushSharp.ClientSample.WindowsPhone\PushSharp.ClientSample.WindowsPhone.csproj", "{03FB674A-89FA-4E76-9CA0-6F3869D57336}"
5+
EndProject
6+
Global
7+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
8+
Debug|Any CPU = Debug|Any CPU
9+
Release|Any CPU = Release|Any CPU
10+
EndGlobalSection
11+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
12+
{03FB674A-89FA-4E76-9CA0-6F3869D57336}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
13+
{03FB674A-89FA-4E76-9CA0-6F3869D57336}.Debug|Any CPU.Build.0 = Debug|Any CPU
14+
{03FB674A-89FA-4E76-9CA0-6F3869D57336}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
15+
{03FB674A-89FA-4E76-9CA0-6F3869D57336}.Release|Any CPU.ActiveCfg = Release|Any CPU
16+
{03FB674A-89FA-4E76-9CA0-6F3869D57336}.Release|Any CPU.Build.0 = Release|Any CPU
17+
{03FB674A-89FA-4E76-9CA0-6F3869D57336}.Release|Any CPU.Deploy.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
EndGlobal
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<Application
2+
x:Class="PushSharp.ClientSample.WindowsPhone.App"
3+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5+
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
6+
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone">
7+
8+
<!--Application Resources-->
9+
<Application.Resources>
10+
</Application.Resources>
11+
12+
<Application.ApplicationLifetimeObjects>
13+
<!--Required object that handles lifetime events for the application-->
14+
<shell:PhoneApplicationService
15+
Launching="Application_Launching" Closing="Application_Closing"
16+
Activated="Application_Activated" Deactivated="Application_Deactivated"/>
17+
</Application.ApplicationLifetimeObjects>
18+
19+
</Application>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Net;
5+
using System.Windows;
6+
using System.Windows.Controls;
7+
using System.Windows.Documents;
8+
using System.Windows.Input;
9+
using System.Windows.Media;
10+
using System.Windows.Media.Animation;
11+
using System.Windows.Navigation;
12+
using System.Windows.Shapes;
13+
using Microsoft.Phone.Controls;
14+
using Microsoft.Phone.Shell;
15+
16+
namespace PushSharp.ClientSample.WindowsPhone
17+
{
18+
public partial class App : Application
19+
{
20+
/// <summary>
21+
/// Provides easy access to the root frame of the Phone Application.
22+
/// </summary>
23+
/// <returns>The root frame of the Phone Application.</returns>
24+
public PhoneApplicationFrame RootFrame { get; private set; }
25+
26+
/// <summary>
27+
/// Constructor for the Application object.
28+
/// </summary>
29+
public App()
30+
{
31+
// Global handler for uncaught exceptions.
32+
UnhandledException += Application_UnhandledException;
33+
34+
// Standard Silverlight initialization
35+
InitializeComponent();
36+
37+
// Phone-specific initialization
38+
InitializePhoneApplication();
39+
40+
// Show graphics profiling information while debugging.
41+
if (System.Diagnostics.Debugger.IsAttached)
42+
{
43+
// Display the current frame rate counters.
44+
Application.Current.Host.Settings.EnableFrameRateCounter = true;
45+
46+
// Show the areas of the app that are being redrawn in each frame.
47+
//Application.Current.Host.Settings.EnableRedrawRegions = true;
48+
49+
// Enable non-production analysis visualization mode,
50+
// which shows areas of a page that are handed off to GPU with a colored overlay.
51+
//Application.Current.Host.Settings.EnableCacheVisualization = true;
52+
53+
// Disable the application idle detection by setting the UserIdleDetectionMode property of the
54+
// application's PhoneApplicationService object to Disabled.
55+
// Caution:- Use this under debug mode only. Application that disables user idle detection will continue to run
56+
// and consume battery power when the user is not using the phone.
57+
PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;
58+
}
59+
60+
}
61+
62+
// Code to execute when the application is launching (eg, from Start)
63+
// This code will not execute when the application is reactivated
64+
private void Application_Launching(object sender, LaunchingEventArgs e)
65+
{
66+
}
67+
68+
// Code to execute when the application is activated (brought to foreground)
69+
// This code will not execute when the application is first launched
70+
private void Application_Activated(object sender, ActivatedEventArgs e)
71+
{
72+
}
73+
74+
// Code to execute when the application is deactivated (sent to background)
75+
// This code will not execute when the application is closing
76+
private void Application_Deactivated(object sender, DeactivatedEventArgs e)
77+
{
78+
}
79+
80+
// Code to execute when the application is closing (eg, user hit Back)
81+
// This code will not execute when the application is deactivated
82+
private void Application_Closing(object sender, ClosingEventArgs e)
83+
{
84+
}
85+
86+
// Code to execute if a navigation fails
87+
private void RootFrame_NavigationFailed(object sender, NavigationFailedEventArgs e)
88+
{
89+
if (System.Diagnostics.Debugger.IsAttached)
90+
{
91+
// A navigation has failed; break into the debugger
92+
System.Diagnostics.Debugger.Break();
93+
}
94+
}
95+
96+
// Code to execute on Unhandled Exceptions
97+
private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
98+
{
99+
if (System.Diagnostics.Debugger.IsAttached)
100+
{
101+
// An unhandled exception has occurred; break into the debugger
102+
System.Diagnostics.Debugger.Break();
103+
}
104+
}
105+
106+
#region Phone application initialization
107+
108+
// Avoid double-initialization
109+
private bool phoneApplicationInitialized = false;
110+
111+
// Do not add any additional code to this method
112+
private void InitializePhoneApplication()
113+
{
114+
if (phoneApplicationInitialized)
115+
return;
116+
117+
// Create the frame but don't set it as RootVisual yet; this allows the splash
118+
// screen to remain active until the application is ready to render.
119+
RootFrame = new PhoneApplicationFrame();
120+
RootFrame.Navigated += CompleteInitializePhoneApplication;
121+
122+
// Handle navigation failures
123+
RootFrame.NavigationFailed += RootFrame_NavigationFailed;
124+
125+
// Ensure we don't initialize again
126+
phoneApplicationInitialized = true;
127+
}
128+
129+
// Do not add any additional code to this method
130+
private void CompleteInitializePhoneApplication(object sender, NavigationEventArgs e)
131+
{
132+
// Set the root visual to allow the application to render
133+
if (RootVisual != RootFrame)
134+
RootVisual = RootFrame;
135+
136+
// Remove this handler since it is no longer needed
137+
RootFrame.Navigated -= CompleteInitializePhoneApplication;
138+
}
139+
140+
#endregion
141+
}
142+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<phone:PhoneApplicationPage
2+
x:Class="PushSharp.ClientSample.WindowsPhone.MainPage"
3+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5+
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
6+
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
7+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
8+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
9+
mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
10+
FontFamily="{StaticResource PhoneFontFamilyNormal}"
11+
FontSize="{StaticResource PhoneFontSizeNormal}"
12+
Foreground="{StaticResource PhoneForegroundBrush}"
13+
SupportedOrientations="Portrait" Orientation="Portrait"
14+
shell:SystemTray.IsVisible="True">
15+
16+
<!--LayoutRoot is the root grid where all page content is placed-->
17+
<Grid x:Name="LayoutRoot" Background="Transparent">
18+
<Grid.RowDefinitions>
19+
<RowDefinition Height="Auto"/>
20+
<RowDefinition Height="*"/>
21+
</Grid.RowDefinitions>
22+
23+
<!--TitlePanel contains the name of the application and page title-->
24+
<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
25+
<TextBlock x:Name="ApplicationTitle" Text="PUSHSHARP SAMPLE" Style="{StaticResource PhoneTextNormalStyle}"/>
26+
<TextBlock x:Name="PageTitle" Text="PushSharp" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
27+
</StackPanel>
28+
29+
<!--ContentPanel - place additional content here-->
30+
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0"></Grid>
31+
</Grid>
32+
33+
<!--Sample code showing usage of ApplicationBar-->
34+
<!--<phone:PhoneApplicationPage.ApplicationBar>
35+
<shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
36+
<shell:ApplicationBarIconButton IconUri="/Images/appbar_button1.png" Text="Button 1"/>
37+
<shell:ApplicationBarIconButton IconUri="/Images/appbar_button2.png" Text="Button 2"/>
38+
<shell:ApplicationBar.MenuItems>
39+
<shell:ApplicationBarMenuItem Text="MenuItem 1"/>
40+
<shell:ApplicationBarMenuItem Text="MenuItem 2"/>
41+
</shell:ApplicationBar.MenuItems>
42+
</shell:ApplicationBar>
43+
</phone:PhoneApplicationPage.ApplicationBar>-->
44+
45+
</phone:PhoneApplicationPage>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Net;
5+
using System.Windows;
6+
using System.Windows.Controls;
7+
using System.Windows.Documents;
8+
using System.Windows.Input;
9+
using System.Windows.Media;
10+
using System.Windows.Media.Animation;
11+
using System.Windows.Shapes;
12+
using Microsoft.Phone.Controls;
13+
14+
namespace PushSharp.ClientSample.WindowsPhone
15+
{
16+
public partial class MainPage : PhoneApplicationPage
17+
{
18+
PushSharpClient client;
19+
20+
// Constructor
21+
public MainPage()
22+
{
23+
InitializeComponent();
24+
25+
client = new PushSharpClient();
26+
client.RegisterForToast();
27+
}
28+
}
29+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<Deployment xmlns="http://schemas.microsoft.com/client/2007/deployment"
2+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
3+
>
4+
<Deployment.Parts>
5+
</Deployment.Parts>
6+
</Deployment>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
using System.Resources;
5+
6+
// General Information about an assembly is controlled through the following
7+
// set of attributes. Change these attribute values to modify the information
8+
// associated with an assembly.
9+
[assembly: AssemblyTitle("PushSharp.ClientSample.WindowsPhone")]
10+
[assembly: AssemblyDescription("")]
11+
[assembly: AssemblyConfiguration("")]
12+
[assembly: AssemblyCompany("")]
13+
[assembly: AssemblyProduct("PushSharp.ClientSample.WindowsPhone")]
14+
[assembly: AssemblyCopyright("Copyright © 2012")]
15+
[assembly: AssemblyTrademark("")]
16+
[assembly: AssemblyCulture("")]
17+
18+
// Setting ComVisible to false makes the types in this assembly not visible
19+
// to COM components. If you need to access a type in this assembly from
20+
// COM, set the ComVisible attribute to true on that type.
21+
[assembly: ComVisible(false)]
22+
23+
// The following GUID is for the ID of the typelib if this project is exposed to COM
24+
[assembly: Guid("d241dff8-4f80-43b7-b396-c0cf57e4be5f")]
25+
26+
// Version information for an assembly consists of the following four values:
27+
//
28+
// Major Version
29+
// Minor Version
30+
// Build Number
31+
// Revision
32+
//
33+
// You can specify all the values or you can default the Revision and Build Numbers
34+
// by using the '*' as shown below:
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]
37+
[assembly: NeutralResourcesLanguageAttribute("en-US")]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
3+
<Deployment xmlns="http://schemas.microsoft.com/windowsphone/2009/deployment" AppPlatformVersion="7.1">
4+
<App xmlns="" ProductID="{21fc5b7c-203c-4017-b926-11adcb1b79d5}" Title="PushSharp.ClientSample.WindowsPhone" RuntimeType="Silverlight" Version="1.0.0.0" Genre="apps.normal" Author="PushSharp.ClientSample.WindowsPhone author" Description="Sample description" Publisher="PushSharp.ClientSample.WindowsPhone">
5+
<IconPath IsRelative="true" IsResource="false">ApplicationIcon.png</IconPath>
6+
<Capabilities>
7+
<Capability Name="ID_CAP_GAMERSERVICES"/>
8+
<Capability Name="ID_CAP_IDENTITY_DEVICE"/>
9+
<Capability Name="ID_CAP_IDENTITY_USER"/>
10+
<Capability Name="ID_CAP_LOCATION"/>
11+
<Capability Name="ID_CAP_MEDIALIB"/>
12+
<Capability Name="ID_CAP_MICROPHONE"/>
13+
<Capability Name="ID_CAP_NETWORKING"/>
14+
<Capability Name="ID_CAP_PHONEDIALER"/>
15+
<Capability Name="ID_CAP_PUSH_NOTIFICATION"/>
16+
<Capability Name="ID_CAP_SENSORS"/>
17+
<Capability Name="ID_CAP_WEBBROWSERCOMPONENT"/>
18+
<Capability Name="ID_CAP_ISV_CAMERA"/>
19+
<Capability Name="ID_CAP_CONTACTS"/>
20+
<Capability Name="ID_CAP_APPOINTMENTS"/>
21+
</Capabilities>
22+
<Tasks>
23+
<DefaultTask Name ="_default" NavigationPage="MainPage.xaml"/>
24+
</Tasks>
25+
<Tokens>
26+
<PrimaryToken TokenID="PushSharp.ClientSample.WindowsPhoneToken" TaskName="_default">
27+
<TemplateType5>
28+
<BackgroundImageURI IsRelative="true" IsResource="false">Background.png</BackgroundImageURI>
29+
<Count>0</Count>
30+
<Title>PushSharp.ClientSample.WindowsPhone</Title>
31+
</TemplateType5>
32+
</PrimaryToken>
33+
</Tokens>
34+
</App>
35+
</Deployment>

0 commit comments

Comments
 (0)