Skip to content

Commit

Permalink
WindowsStore: Now bootstrapping the application using TinyIoC (no Nav…
Browse files Browse the repository at this point in the history
…igationManager yet). This means TinyIoC PCL works fine under WindowsStore!

Related to issue #423.
  • Loading branch information
ycastonguay committed Sep 14, 2013
1 parent 09e0543 commit e8e5603
Show file tree
Hide file tree
Showing 7 changed files with 372 additions and 4 deletions.
4 changes: 3 additions & 1 deletion MPfm/MPfm.Library/Objects/SyncDevice.cs
Expand Up @@ -41,6 +41,8 @@ public enum SyncDeviceType
OSX = 2,
Windows = 3,
iOS = 4,
Android = 5
Android = 5,
WindowsPhone = 6,
WindowsStore = 7
}
}
3 changes: 2 additions & 1 deletion MPfm/MPfm.WindowsStore/App.xaml
Expand Up @@ -3,7 +3,8 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:MPfm.WindowsStore"
xmlns:localData="using:MPfm.WindowsStore.Data">
xmlns:localData="using:MPfm.WindowsStore.Data"
RequestedTheme="Light">

<Application.Resources>
<ResourceDictionary>
Expand Down
61 changes: 59 additions & 2 deletions MPfm/MPfm.WindowsStore/App.xaml.cs
@@ -1,4 +1,26 @@
using System.Diagnostics;
// Copyright © 2011-2013 Yanick Castonguay
//
// This file is part of MPfm.
//
// MPfm is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// MPfm is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with MPfm. If not, see <http://www.gnu.org/licenses/>.

using System.Diagnostics;
using MPfm.Library;
using MPfm.MVP.Bootstrap;
using MPfm.MVP.Navigation;
using MPfm.MVP.Views;
using MPfm.WindowsStore.Classes;
using MPfm.WindowsStore.Common;

using System;
Expand All @@ -16,6 +38,7 @@
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;
using TinyIoC;

// The Split App template is documented at http://go.microsoft.com/fwlink/?LinkId=234228

Expand Down Expand Up @@ -53,6 +76,8 @@ protected override async void OnLaunched(LaunchActivatedEventArgs args)

if (rootFrame == null)
{
BootstrapApp();

// Create a Frame to act as the navigation context and navigate to the first page
rootFrame = new Frame();
//Associate the frame with a SuspensionManager key
Expand Down Expand Up @@ -82,7 +107,8 @@ protected override async void OnLaunched(LaunchActivatedEventArgs args)
// configuring the new page by passing required information as a navigation
// parameter
Debug.WriteLine("RootFrame.Content == null; trying to navigate to ItemsPage");
if (!rootFrame.Navigate(typeof(ItemsPage), "AllGroups"))
//if (!rootFrame.Navigate(typeof(ItemsPage), "AllGroups"))
if(!rootFrame.Navigate(typeof(Main), args.Arguments))
{
throw new Exception("Failed to create initial page");
}
Expand All @@ -105,5 +131,36 @@ private async void OnSuspending(object sender, SuspendingEventArgs e)
await SuspensionManager.SaveAsync();
deferral.Complete();
}

private void BootstrapApp()
{
TinyIoCContainer container = Bootstrapper.GetContainer();
container.Register<ISyncDeviceSpecifications, WindowsStoreSyncDeviceSpecifications>().AsSingleton();
//container.Register<MobileNavigationManager, AndroidNavigationManager>().AsSingleton();
//container.Register<IMobileOptionsMenuView, MainActivity>().AsMultiInstance();
//container.Register<ISplashView, SplashFragment>().AsMultiInstance();
//container.Register<IPlayerView, PlayerActivity>().AsMultiInstance();
//container.Register<IPlayerMetadataView, PlayerMetadataFragment>().AsMultiInstance();
//container.Register<IMarkersView, MarkersFragment>().AsMultiInstance();
//container.Register<IMarkerDetailsView, MarkerDetailsActivity>().AsMultiInstance();
//container.Register<ILoopsView, LoopsFragment>().AsMultiInstance();
//container.Register<ITimeShiftingView, TimeShiftingFragment>().AsMultiInstance();
//container.Register<IPitchShiftingView, PitchShiftingFragment>().AsMultiInstance();
//container.Register<IUpdateLibraryView, UpdateLibraryFragment>().AsMultiInstance();
//container.Register<IMobileLibraryBrowserView, MobileLibraryBrowserFragment>().AsMultiInstance();
//container.Register<IPlaylistView, PlaylistActivity>().AsMultiInstance();
//container.Register<ISyncView, SyncActivity>().AsMultiInstance();
//container.Register<ISyncDownloadView, SyncDownloadActivity>().AsMultiInstance();
//container.Register<ISyncMenuView, SyncMenuActivity>().AsMultiInstance();
//container.Register<ISyncWebBrowserView, SyncWebBrowserActivity>().AsMultiInstance();
//container.Register<IEqualizerPresetsView, EqualizerPresetsActivity>().AsMultiInstance();
//container.Register<IEqualizerPresetDetailsView, EqualizerPresetDetailsActivity>().AsMultiInstance();
//container.Register<IPreferencesView, PreferencesActivity>().AsMultiInstance();
//container.Register<IAudioPreferencesView, AudioPreferencesFragment>().AsMultiInstance();
//container.Register<IGeneralPreferencesView, GeneralPreferencesFragment>().AsMultiInstance();
//container.Register<ILibraryPreferencesView, LibraryPreferencesFragment>().AsMultiInstance();
//container.Register<IAboutView, AboutActivity>().AsMultiInstance();

}
}
}
@@ -0,0 +1,57 @@
// Copyright © 2011-2013 Yanick Castonguay
//
// This file is part of MPfm.
//
// MPfm is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// MPfm is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with MPfm. If not, see <http://www.gnu.org/licenses/>.

using System;
using MPfm.Library;
using MPfm.Library.Objects;

namespace MPfm.WindowsStore.Classes
{
public class WindowsStoreSyncDeviceSpecifications : ISyncDeviceSpecifications
{
public event NetworkStateChanged OnNetworkStateChanged;

public SyncDeviceType GetDeviceType()
{
return SyncDeviceType.WindowsStore;
}

public string GetDeviceName()
{
return "WindowsStore Generic Device";
}

public long GetFreeSpace()
{
return 0;
}

public string GetIPAddress()
{
return string.Empty;
}

public string GetMusicFolderPath()
{
return string.Empty;
}

public void ReportNetworkStateChange(NetworkState networkState)
{
}
}
}
8 changes: 8 additions & 0 deletions MPfm/MPfm.WindowsStore/MPfm.WindowsStore.csproj
Expand Up @@ -126,9 +126,13 @@
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
</Compile>
<Compile Include="Classes\WindowsStoreSyncDeviceSpecifications.cs" />
<Compile Include="ItemsPage.xaml.cs">
<DependentUpon>ItemsPage.xaml</DependentUpon>
</Compile>
<Compile Include="Main.xaml.cs">
<DependentUpon>Main.xaml</DependentUpon>
</Compile>
<Compile Include="SplitPage.xaml.cs">
<DependentUpon>SplitPage.xaml</DependentUpon>
</Compile>
Expand Down Expand Up @@ -170,6 +174,10 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Main.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="SplitPage.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
Expand Down
178 changes: 178 additions & 0 deletions MPfm/MPfm.WindowsStore/Main.xaml
@@ -0,0 +1,178 @@
<common:LayoutAwarePage
x:Name="pageRoot"
x:Class="MPfm.WindowsStore.Main"
DataContext="{Binding DefaultViewModel, RelativeSource={RelativeSource Self}}"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:MPfm.WindowsStore"
xmlns:common="using:MPfm.WindowsStore.Common"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">

<Page.Resources>

<!--
Collection of grouped items displayed by this page, bound to a subset
of the complete item list because items in groups cannot be virtualized
-->
<CollectionViewSource
x:Name="groupedItemsViewSource"
Source="{Binding Groups}"
IsSourceGrouped="true"
ItemsPath="TopItems"/>

<!-- TODO: Delete this line if the key AppName is declared in App.xaml -->
<x:String x:Key="AppName">Sessions</x:String>
</Page.Resources>

<!--
This grid acts as a root panel for the page that defines two rows:
* Row 0 contains the back button and page title
* Row 1 contains the rest of the page layout
-->
<Grid Style="{StaticResource LayoutRootStyle}">
<Grid.RowDefinitions>
<RowDefinition Height="140"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>

<!-- Horizontal scrolling grid used in most view states -->
<GridView
x:Name="itemGridView"
AutomationProperties.AutomationId="ItemGridView"
AutomationProperties.Name="Grouped Items"
Grid.RowSpan="2"
Padding="116,137,40,46"
ItemsSource="{Binding Source={StaticResource groupedItemsViewSource}}"
ItemTemplate="{StaticResource Standard250x250ItemTemplate}"
SelectionMode="None"
IsSwipeEnabled="false">

<GridView.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
</GridView.ItemsPanel>
<GridView.GroupStyle>
<GroupStyle>
<GroupStyle.HeaderTemplate>
<DataTemplate>
<Grid Margin="1,0,0,6">
<Button
AutomationProperties.Name="Group Title"
Style="{StaticResource TextPrimaryButtonStyle}">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Title}" Margin="3,-7,10,10" Style="{StaticResource GroupHeaderTextStyle}" />
<TextBlock Text="{StaticResource ChevronGlyph}" FontFamily="Segoe UI Symbol" Margin="0,-7,0,10" Style="{StaticResource GroupHeaderTextStyle}"/>
</StackPanel>
</Button>
</Grid>
</DataTemplate>
</GroupStyle.HeaderTemplate>
<GroupStyle.Panel>
<ItemsPanelTemplate>
<VariableSizedWrapGrid Orientation="Vertical" Margin="0,0,80,0"/>
</ItemsPanelTemplate>
</GroupStyle.Panel>
</GroupStyle>
</GridView.GroupStyle>
</GridView>

<!-- Vertical scrolling list only used when snapped -->
<ListView
x:Name="itemListView"
AutomationProperties.AutomationId="ItemListView"
AutomationProperties.Name="Grouped Items"
Grid.Row="1"
Visibility="Collapsed"
Margin="0,-10,0,0"
Padding="10,0,0,60"
ItemsSource="{Binding Source={StaticResource groupedItemsViewSource}}"
ItemTemplate="{StaticResource Standard80ItemTemplate}"
SelectionMode="None"
IsSwipeEnabled="false">

<ListView.GroupStyle>
<GroupStyle>
<GroupStyle.HeaderTemplate>
<DataTemplate>
<Grid Margin="7,7,0,0">
<Button
AutomationProperties.Name="Group Title"
Style="{StaticResource TextPrimaryButtonStyle}">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Title}" Margin="3,-7,10,10" Style="{StaticResource GroupHeaderTextStyle}" />
<TextBlock Text="{StaticResource ChevronGlyph}" FontFamily="Segoe UI Symbol" Margin="0,-7,0,10" Style="{StaticResource GroupHeaderTextStyle}"/>
</StackPanel>
</Button>
</Grid>
</DataTemplate>
</GroupStyle.HeaderTemplate>
</GroupStyle>
</ListView.GroupStyle>
</ListView>

<!-- Back button and page title -->
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Button x:Name="backButton" Click="GoBack" IsEnabled="{Binding Frame.CanGoBack, ElementName=pageRoot}" Style="{StaticResource BackButtonStyle}"/>
<TextBlock x:Name="pageTitle" Text="{StaticResource AppName}" Grid.Column="1" IsHitTestVisible="false" Style="{StaticResource PageHeaderTextStyle}"/>
</Grid>
<StackPanel Grid.Row="1" Margin="120,30,0,0">
<TextBlock Text="What's your name?"/>
<StackPanel Orientation="Horizontal" Margin="0,20,0,20">
<TextBox x:Name="nameInput" Width="300" HorizontalAlignment="Left"/>
<Button Content="Say &quot;Hello&quot;" Click="Button_Click"/>
</StackPanel>
<TextBlock x:Name="greetingOutput"/>
</StackPanel>

<VisualStateManager.VisualStateGroups>

<!-- Visual states reflect the application's view state -->
<VisualStateGroup x:Name="ApplicationViewStates">
<VisualState x:Name="FullScreenLandscape"/>
<VisualState x:Name="Filled"/>

<!-- The entire page respects the narrower 100-pixel margin convention for portrait -->
<VisualState x:Name="FullScreenPortrait">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Style">
<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PortraitBackButtonStyle}"/>
</ObjectAnimationUsingKeyFrames>

<ObjectAnimationUsingKeyFrames Storyboard.TargetName="itemGridView" Storyboard.TargetProperty="Padding">
<DiscreteObjectKeyFrame KeyTime="0" Value="96,137,10,56"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>

<!--
The back button and title have different styles when snapped, and the list representation is substituted
for the grid displayed in all other view states
-->
<VisualState x:Name="Snapped">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Style">
<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SnappedBackButtonStyle}"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="pageTitle" Storyboard.TargetProperty="Style">
<DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SnappedPageHeaderTextStyle}"/>
</ObjectAnimationUsingKeyFrames>

<ObjectAnimationUsingKeyFrames Storyboard.TargetName="itemListView" Storyboard.TargetProperty="Visibility">
<DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
</ObjectAnimationUsingKeyFrames>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="itemGridView" Storyboard.TargetProperty="Visibility">
<DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Grid>
</common:LayoutAwarePage>

0 comments on commit e8e5603

Please sign in to comment.