Skip to content

Commit

Permalink
[WP7] port to WP7 using @kenegozi unofficial client
Browse files Browse the repository at this point in the history
 unofficial client

Apologies in advance for the worst WP7 code ever... it's just a
demo/hack
  • Loading branch information
conceptdev committed Sep 13, 2012
1 parent 93d39d1 commit 856a6cf
Show file tree
Hide file tree
Showing 30 changed files with 951 additions and 22 deletions.
43 changes: 22 additions & 21 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@

*.pidb
*.userprefs
*.swp
*.DS_Store
*.nib
*.suo
Thumbs.db

*/bin/*
*/obj/*
*/*/bin/*
*/*/obj/*

bin/*
obj/*
bin/*
obj/*

*/Resource.designer.cs
*/*/Resource.designer.cs

*.pidb
*.userprefs
*.swp
*.DS_Store
*.nib
*.user
*.suo
Thumbs.db

*/bin/*
*/obj/*
*/*/bin/*
*/*/obj/*

bin/*
obj/*
bin/*
obj/*

*/Resource.designer.cs
*/*/Resource.designer.cs
*/*/*/Resource.designer.cs
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
11 changes: 10 additions & 1 deletion Azure/README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
TaskyAzure for iOS & Android
============================
There are two sample projects using the same Azure Mobile Services instance:
There are a number of sample projects using the same Azure Mobile Services instance:

* iOS with MonoTouch

* Android for Mono for Android

* Windows Phone 7

* Mac-OSX with MonoMac

* Windows 8 sample provided by Microsoft


![screenshot](https://raw.github.com/conceptdev/TaskCloud/master/Azure/Screenshots/Screenshots_sml.png)

This sample has a very basic implementation of Microsoft's new (Sep-2012) Azure Mobile Services API.

It is loosely based on this article (ie the syntax for the REST requests)
[chrisrisner.com/Windows-Azure-Mobile-Services-and-](http://chrisrisner.com/Windows-Azure-Mobile-Services-and-iOS) however the Mono-for-Android application code is based on the existing Tasky samples (and uses MonoTouch.Dialog).

The Windows Phone 7 version uses the 'unofficial' [Azure Mobile Services Client](https://github.com/kenegozi/azure-mobile-csharp-sdk}

Use the [Azure Getting Started](https://www.windowsazure.com/en-us/develop/mobile/tutorials/get-started/) code to first set-up the Windows 8 sample app. The iOS, Android and Windows 8 apps will then read/write to the same TodoList !
Binary file added Azure/Screenshots/WP7Task.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Azure/Screenshots/WP7TaskList.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions Azure/WP7/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<Application
x:Class="TaskyWP7.App"
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">

<!--Application Resources-->
<Application.Resources>
</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>
158 changes: 158 additions & 0 deletions Azure/WP7/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
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;

using MobileServices.Sdk;

namespace TaskyWP7 {
public partial class App : Application {

public static readonly MobileServiceClient MobileServiceClient;
//public static User CurrentUser;

static App()
{
// Get this data from the management portal's quickstart page
// in the 'connect to existing apps' section
MobileServiceClient = new MobileServiceClient(
"https://XXXXXX.azure-mobile.net/",
"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
);
}






/// <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;

// Standard Silverlight initialization
InitializeComponent();

// Phone-specific initialization
InitializePhoneApplication();

// 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 handed off to GPU with a colored overlay.
//Application.Current.Host.Settings.EnableCacheVisualization = true;

// Disable the application idle detection by setting the UserIdleDetectionMode property of the
// application's PhoneApplicationService object to Disabled.
// Caution:- Use this under debug mode only. Application that disables user idle detection will continue to run
// and consume battery power when the user is not using the phone.
PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;
}

}

// 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 added Azure/WP7/ApplicationIcon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Azure/WP7/Background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
71 changes: 71 additions & 0 deletions Azure/WP7/MainPage.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<phone:PhoneApplicationPage
x:Class="TaskyWP7.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"
xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="696"
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="TASKY" Style="{StaticResource PhoneTextNormalStyle}"/>
<TextBlock x:Name="PageTitle" Text="task list" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
</StackPanel>

<ListBox Grid.Row="1"
ItemsSource="{Binding Items}"
Visibility="{Binding ListVisibility}">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid
Margin="{Binding Margin}"
toolkit:TiltEffect.IsTiltEnabled="True"
Width="400"
Tap="HandleTaskTap">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>

<TextBlock
Grid.Row="0"
Grid.Column="0"
Foreground="White"
Style="{StaticResource PhoneTextLargeStyle}"
Margin="0,0,0,0"
Text="{Binding Text}" />
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</Grid>

<phone:PhoneApplicationPage.ApplicationBar>
<shell:ApplicationBar Opacity="1" IsVisible="True" IsMenuEnabled="True">

<shell:ApplicationBarIconButton
IconUri="/Images/appbar.add.rest.jpg"
Text="add"
Click="HandleAdd"/>

</shell:ApplicationBar>

</phone:PhoneApplicationPage.ApplicationBar>


</phone:PhoneApplicationPage>
46 changes: 46 additions & 0 deletions Azure/WP7/MainPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
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 Microsoft.Phone.Controls;

using MobileServices.Sdk;

namespace TaskyWP7 {
public partial class MainPage : PhoneApplicationPage {
// Constructor
public MainPage()
{
InitializeComponent();

DataContext = new TaskListViewModel();
Loaded += new RoutedEventHandler(MainPage_Loaded);
}

void MainPage_Loaded(object sender, RoutedEventArgs e)
{
((TaskListViewModel)DataContext).BeginUpdate(Dispatcher);
}

private void HandleAdd(object sender, EventArgs e)
{
NavigationService.Navigate(new Uri("/TaskDetailsPage.xaml?id=-1", UriKind.RelativeOrAbsolute));
}

private void HandleTaskTap(object sender, System.Windows.Input.GestureEventArgs e)
{
var item = ((Grid)sender).DataContext as TaskViewModel;

if (item != null) {
NavigationService.Navigate(new Uri("/TaskDetailsPage.xaml?id=" + item.Id, UriKind.RelativeOrAbsolute));
}
}
}
}
6 changes: 6 additions & 0 deletions Azure/WP7/Properties/AppManifest.xml
Original file line number Diff line number Diff line change
@@ -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>
Loading

0 comments on commit 856a6cf

Please sign in to comment.