Skip to content

Commit

Permalink
Merge branch 'auto-suspendify'
Browse files Browse the repository at this point in the history
  • Loading branch information
anaisbetts committed Feb 10, 2013
2 parents 2ce26ab + a4dabd5 commit 7897b10
Show file tree
Hide file tree
Showing 13 changed files with 6,432 additions and 64 deletions.
7 changes: 4 additions & 3 deletions MobileSample-WP8/App.xaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<Application
<mobile:AutoSuspendApplication
x:Class="MobileSample_WP8.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">
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:mobile="clr-namespace:ReactiveUI.Mobile;assembly=ReactiveUI.Mobile_WP8">

<!--Application Resources-->
<Application.Resources>
Expand All @@ -15,4 +16,4 @@
<shell:PhoneApplicationService />
</Application.ApplicationLifetimeObjects>

</Application>
</mobile:AutoSuspendApplication>
23 changes: 10 additions & 13 deletions MobileSample-WP8/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,22 @@
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using MobileSample_WP8.Resources;
using MobileSample_WP8.ViewModels;
using ReactiveUI;
using ReactiveUI.Mobile;

namespace MobileSample_WP8
{
public partial class App : Application
public partial class App : AutoSuspendApplication
{
/// <summary>
/// Provides easy access to the root frame of the Phone Application.
/// </summary>
/// <returns>The root frame of the Phone Application.</returns>
public static PhoneApplicationFrame RootFrame { get; private set; }

/// <summary>
/// Constructor for the Application object.
/// </summary>
public App()
{
// Global handler for uncaught exceptions.
UnhandledException += Application_UnhandledException;

// Standard XAML initialization
InitializeComponent();

// Phone-specific initialization
InitializePhoneApplication();

// Language display initialization
InitializeLanguage();

Expand All @@ -55,6 +46,10 @@ public App()
PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;
}

RxApp.Register(typeof (AppBootstrapper), typeof (IApplicationRootState));

var host = RxApp.GetService<ISuspensionHost>();
host.SetupDefaultSuspendResume();
}

// Code to execute when the application is launching (eg, from Start)
Expand Down Expand Up @@ -102,6 +97,7 @@ private void Application_UnhandledException(object sender, ApplicationUnhandledE
}

#region Phone application initialization
#if FALSE

// Avoid double-initialization
private bool phoneApplicationInitialized = false;
Expand Down Expand Up @@ -162,6 +158,7 @@ private void ClearBackStackAfterReset(object sender, NavigationEventArgs e)
}
}

#endif
#endregion

// Initialize the app's font and flow direction as defined in its localized resource strings.
Expand Down
49 changes: 2 additions & 47 deletions MobileSample-WP8/MainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,57 +6,12 @@
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:routing="clr-namespace:ReactiveUI.Routing;assembly=ReactiveUI.Routing_WP8"
mc:Ignorable="d"
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>

<!-- LOCALIZATION NOTE:
To localize the displayed strings copy their values to appropriately named
keys in the app's neutral language resource file (AppResources.resx) then
replace the hard-coded text value between the attributes' quotation marks
with the binding clause whose path points to that string name.
For example:
Text="{Binding Path=LocalizedResources.ApplicationTitle, Source={StaticResource LocalizedStrings}}"
This binding points to the template's string resource named "ApplicationTitle".
Adding supported languages in the Project Properties tab will create a
new resx file per language that can carry the translated values of your
UI strings. The binding in these examples will cause the value of the
attributes to be drawn from the .resx file that matches the
CurrentUICulture of the app at run time.
-->

<!--TitlePanel contains the name of the application and page title-->
<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
<TextBlock Text="MY APPLICATION" Style="{StaticResource PhoneTextNormalStyle}" Margin="12,0"/>
<TextBlock Text="page name" 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">

</Grid>

<!--Uncomment to see an alignment grid to help ensure your controls are
aligned on common boundaries. The image has a top margin of -32px to
account for the System Tray. Set this to 0 (or remove the margin altogether)
if the System Tray is hidden.
Before shipping remove this XAML and the image itself.-->
<!--<Image Source="/Assets/AlignmentGrid.png" VerticalAlignment="Top" Height="800" Width="480" Margin="0,-32,0,0" Grid.Row="0" Grid.RowSpan="2" IsHitTestVisible="False" />-->
</Grid>

<routing:RoutedViewHost x:Name="Router" />
</phone:PhoneApplicationPage>
24 changes: 23 additions & 1 deletion MobileSample-WP8/MainPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Net;
using System.Windows;
Expand All @@ -8,20 +9,41 @@
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using MobileSample_WP8.Resources;
using MobileSample_WP8.ViewModels;
using ReactiveUI;

namespace MobileSample_WP8
{
public partial class MainPage : PhoneApplicationPage
public partial class MainPage : PhoneApplicationPage, IViewFor<AppBootstrapper>
{
// Constructor
public MainPage()
{
InitializeComponent();

this.OneWayBind(ViewModel, x => x.Router, x => x.Router.Router);

this.Tap += (o, e) =>
{
Console.WriteLine("Foo");
};

// Sample code to localize the ApplicationBar
//BuildLocalizedApplicationBar();
}

public AppBootstrapper ViewModel {
get { return (AppBootstrapper)GetValue(ViewModelProperty); }
set { SetValue(ViewModelProperty, value); }
}
public static readonly DependencyProperty ViewModelProperty =
DependencyProperty.Register("ViewModel", typeof(AppBootstrapper), typeof(MainPage), new PropertyMetadata(null));

object IViewFor.ViewModel {
get { return ViewModel; }
set { ViewModel = (AppBootstrapper)value; }
}

// Sample code for building a localized ApplicationBar
//private void BuildLocalizedApplicationBar()
//{
Expand Down
26 changes: 26 additions & 0 deletions MobileSample-WP8/MobileSample-WP8.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@
<DesignTime>True</DesignTime>
<DependentUpon>AppResources.resx</DependentUpon>
</Compile>
<Compile Include="ViewModels\AppBootstrapper.cs" />
<Compile Include="ViewModels\TestPage1ViewModel.cs" />
<Compile Include="Views\TestPage1View.xaml.cs">
<DependentUpon>TestPage1View.xaml</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
Expand All @@ -115,8 +120,14 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\TestPage1View.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
<None Include="Properties\AppManifest.xml" />
<None Include="Properties\WMAppManifest.xml">
<SubType>Designer</SubType>
Expand Down Expand Up @@ -172,9 +183,24 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Reference Include="Microsoft.Threading.Tasks">
<HintPath>..\packages\Microsoft.Bcl.Async.1.0.14-rc\lib\wp8\Microsoft.Threading.Tasks.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Threading.Tasks.Extensions">
<HintPath>..\packages\Microsoft.Bcl.Async.1.0.14-rc\lib\wp8\Microsoft.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Threading.Tasks.Extensions.Phone">
<HintPath>..\packages\Microsoft.Bcl.Async.1.0.14-rc\lib\wp8\Microsoft.Threading.Tasks.Extensions.Phone.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json">
<HintPath>..\ext\WP80\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="Ninject.Common">
<HintPath>.\Ninject.Common.dll</HintPath>
</Reference>
<Reference Include="Ninject.WP">
<HintPath>.\Ninject.WP.dll</HintPath>
</Reference>
<Reference Include="System.Reactive.Core">
<HintPath>..\ext\WP80\System.Reactive.Core.dll</HintPath>
</Reference>
Expand Down
Binary file added MobileSample-WP8/Ninject.Common.dll
Binary file not shown.
Loading

0 comments on commit 7897b10

Please sign in to comment.