From 5dadddefbc78731100aa82ae6b70aba2c7df3537 Mon Sep 17 00:00:00 2001 From: aki_lua87 Date: Tue, 22 Nov 2016 10:00:43 +0900 Subject: [PATCH 01/14] =?UTF-8?q?Views=E3=83=95=E3=82=A9=E3=83=AB=E3=83=80?= =?UTF-8?q?=E4=BD=9C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SimpleLifeCounter/SimpleLifeCounter/App.cs | 26 +++++++------------ .../SimpleLifeCounter.csproj | 16 +++++++++--- .../{ => Views}/LifePage.xaml | 0 .../{ => Views}/LifePage.xaml.cs | 0 .../{ => Views}/MenuPage.xaml | 0 .../{ => Views}/MenuPage.xaml.cs | 0 .../SimpleLifeCounter/packages.config | 2 ++ 7 files changed, 23 insertions(+), 21 deletions(-) rename SimpleLifeCounter/SimpleLifeCounter/{ => Views}/LifePage.xaml (100%) rename SimpleLifeCounter/SimpleLifeCounter/{ => Views}/LifePage.xaml.cs (100%) rename SimpleLifeCounter/SimpleLifeCounter/{ => Views}/MenuPage.xaml (100%) rename SimpleLifeCounter/SimpleLifeCounter/{ => Views}/MenuPage.xaml.cs (100%) diff --git a/SimpleLifeCounter/SimpleLifeCounter/App.cs b/SimpleLifeCounter/SimpleLifeCounter/App.cs index f430ea5..cfaa319 100644 --- a/SimpleLifeCounter/SimpleLifeCounter/App.cs +++ b/SimpleLifeCounter/SimpleLifeCounter/App.cs @@ -2,34 +2,26 @@ using System.Collections.Generic; using System.Linq; using System.Text; - +using Prism; +using Prism.Unity; using Xamarin.Forms; using Xamarin.Forms.Xaml; [assembly: XamlCompilation(XamlCompilationOptions.Compile)] namespace SimpleLifeCounter { - public class App : Application + public class App : PrismApplication { - public App() - { - // The root page of your application - MainPage = new NavigationPage(new LifePage()); - } - - protected override void OnStart() - { - // Handle when your app starts - } - - protected override void OnSleep() + protected override void RegisterTypes() { - // Handle when your app sleeps + Container.RegisterTypeForNavigation(); + Container.RegisterTypeForNavigation(); + Container.RegisterTypeForNavigation(); } - protected override void OnResume() + protected override void OnInitialized() { - // Handle when your app resumes + NavigationService.NavigateAsync("NavigationPage/LifePage"); } } diff --git a/SimpleLifeCounter/SimpleLifeCounter/SimpleLifeCounter.csproj b/SimpleLifeCounter/SimpleLifeCounter/SimpleLifeCounter.csproj index afdb017..3aa5bab 100644 --- a/SimpleLifeCounter/SimpleLifeCounter/SimpleLifeCounter.csproj +++ b/SimpleLifeCounter/SimpleLifeCounter/SimpleLifeCounter.csproj @@ -37,10 +37,10 @@ - + LifePage.xaml - + MenuPage.xaml @@ -59,7 +59,7 @@ - + MSBuild:UpdateDesignTimeXaml Designer @@ -73,6 +73,10 @@ ..\..\packages\CommonServiceLocator.1.3\lib\portable-net4+sl5+netcore45+wpa81+wp8\Microsoft.Practices.ServiceLocation.dll True + + ..\..\packages\Unity.4.0.1\lib\portable-net45+wp80+win8+wpa81+MonoAndroid10+MonoTouch10\Microsoft.Practices.Unity.dll + True + ..\..\packages\Newtonsoft.Json.9.0.1\lib\portable-net45+wp80+win8+wpa81\Newtonsoft.Json.dll True @@ -85,6 +89,10 @@ ..\..\packages\Prism.Forms.6.2.0\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Prism.Forms.dll True + + ..\..\packages\Prism.Unity.Forms.6.2.0\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Prism.Unity.Forms.dll + True + C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETCore\v4.5.1\System.ServiceModel.Primitives.dll @@ -102,7 +110,7 @@ - + MSBuild:UpdateDesignTimeXaml Designer diff --git a/SimpleLifeCounter/SimpleLifeCounter/LifePage.xaml b/SimpleLifeCounter/SimpleLifeCounter/Views/LifePage.xaml similarity index 100% rename from SimpleLifeCounter/SimpleLifeCounter/LifePage.xaml rename to SimpleLifeCounter/SimpleLifeCounter/Views/LifePage.xaml diff --git a/SimpleLifeCounter/SimpleLifeCounter/LifePage.xaml.cs b/SimpleLifeCounter/SimpleLifeCounter/Views/LifePage.xaml.cs similarity index 100% rename from SimpleLifeCounter/SimpleLifeCounter/LifePage.xaml.cs rename to SimpleLifeCounter/SimpleLifeCounter/Views/LifePage.xaml.cs diff --git a/SimpleLifeCounter/SimpleLifeCounter/MenuPage.xaml b/SimpleLifeCounter/SimpleLifeCounter/Views/MenuPage.xaml similarity index 100% rename from SimpleLifeCounter/SimpleLifeCounter/MenuPage.xaml rename to SimpleLifeCounter/SimpleLifeCounter/Views/MenuPage.xaml diff --git a/SimpleLifeCounter/SimpleLifeCounter/MenuPage.xaml.cs b/SimpleLifeCounter/SimpleLifeCounter/Views/MenuPage.xaml.cs similarity index 100% rename from SimpleLifeCounter/SimpleLifeCounter/MenuPage.xaml.cs rename to SimpleLifeCounter/SimpleLifeCounter/Views/MenuPage.xaml.cs diff --git a/SimpleLifeCounter/SimpleLifeCounter/packages.config b/SimpleLifeCounter/SimpleLifeCounter/packages.config index bdab753..c19a4b7 100644 --- a/SimpleLifeCounter/SimpleLifeCounter/packages.config +++ b/SimpleLifeCounter/SimpleLifeCounter/packages.config @@ -4,5 +4,7 @@ + + \ No newline at end of file From b69316fc3337a1d50191f9bf6c531b6afc47f773 Mon Sep 17 00:00:00 2001 From: aki_lua87 Date: Tue, 22 Nov 2016 11:45:39 +0900 Subject: [PATCH 02/14] =?UTF-8?q?=E5=8B=95=E3=81=8B=E3=82=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SimpleLifeCounter.sln | 4 +- .../SimpleLifeCounter.Droid/MainActivity.cs | 12 +- .../SimpleLifeCounter.Droid.csproj | 8 ++ .../SimpleLifeCounter.Droid/packages.config | 2 + .../SimpleLifeCounter.iOS.csproj | 20 ++++ .../SimpleLifeCounter.iOS/packages.config | 5 + SimpleLifeCounter/SimpleLifeCounter/App.cs | 24 ++-- .../SimpleLifeCounter/Models/AllPageModel.cs | 1 - .../ViewModels/LifePageViewModel.cs | 33 +++++- .../ViewModels/MenuPageViewModel.cs | 3 +- .../SimpleLifeCounter/Views/LifePage.xaml | 6 +- .../SimpleLifeCounter/Views/LifePage.xaml.cs | 105 ++++++++---------- .../SimpleLifeCounter/Views/MenuPage.xaml | 5 +- .../SimpleLifeCounter/Views/MenuPage.xaml.cs | 13 +-- .../SimpleLifeCounter.LifePage.xaml.g.cs | 68 ------------ .../SimpleLifeCounter.MenuPage.xaml.g.cs | 76 ------------- ...pleLifeCounter.csproj.FileListAbsolute.txt | 10 +- UITest1/AppInitializer.cs | 26 +++++ UITest1/LifePageViewModelTest.cs | 17 +++ UITest1/SimpleLifeCounter.Tests.csproj | 66 +++++++++++ UITest1/Tests.cs | 35 ++++++ UITest1/packages.config | 6 + 22 files changed, 305 insertions(+), 240 deletions(-) delete mode 100644 SimpleLifeCounter/SimpleLifeCounter/obj/Debug/SimpleLifeCounter.LifePage.xaml.g.cs delete mode 100644 SimpleLifeCounter/SimpleLifeCounter/obj/Debug/SimpleLifeCounter.MenuPage.xaml.g.cs create mode 100644 UITest1/AppInitializer.cs create mode 100644 UITest1/LifePageViewModelTest.cs create mode 100644 UITest1/SimpleLifeCounter.Tests.csproj create mode 100644 UITest1/Tests.cs create mode 100644 UITest1/packages.config diff --git a/SimpleLifeCounter.sln b/SimpleLifeCounter.sln index c1f493e..31dd28c 100644 --- a/SimpleLifeCounter.sln +++ b/SimpleLifeCounter.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.25420.1 +# Visual Studio 15 +VisualStudioVersion = 15.0.25920.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleLifeCounter.Droid", "SimpleLifeCounter\SimpleLifeCounter.Droid\SimpleLifeCounter.Droid.csproj", "{A36FD8A8-8D78-4EF1-AD8E-F03492223173}" EndProject diff --git a/SimpleLifeCounter/SimpleLifeCounter.Droid/MainActivity.cs b/SimpleLifeCounter/SimpleLifeCounter.Droid/MainActivity.cs index 6755d3b..4c1f030 100644 --- a/SimpleLifeCounter/SimpleLifeCounter.Droid/MainActivity.cs +++ b/SimpleLifeCounter/SimpleLifeCounter.Droid/MainActivity.cs @@ -6,6 +6,8 @@ using Android.Views; using Android.Widget; using Android.OS; +using Prism.Unity; +using Microsoft.Practices.Unity; namespace SimpleLifeCounter.Droid { @@ -23,7 +25,15 @@ protected override void OnCreate(Bundle bundle) this.Window.SetFlags(WindowManagerFlags.KeepScreenOn, WindowManagerFlags.KeepScreenOn); global::Xamarin.Forms.Forms.Init(this, bundle); - LoadApplication(new App()); + //LoadApplication(new App()); + LoadApplication(new App(new AndroidInitializer())); + } + } + public class AndroidInitializer : IPlatformInitializer + { + public void RegisterTypes(IUnityContainer container) + { + } } } diff --git a/SimpleLifeCounter/SimpleLifeCounter.Droid/SimpleLifeCounter.Droid.csproj b/SimpleLifeCounter/SimpleLifeCounter.Droid/SimpleLifeCounter.Droid.csproj index 4607fcd..de8c149 100644 --- a/SimpleLifeCounter/SimpleLifeCounter.Droid/SimpleLifeCounter.Droid.csproj +++ b/SimpleLifeCounter/SimpleLifeCounter.Droid/SimpleLifeCounter.Droid.csproj @@ -64,6 +64,10 @@ ..\..\packages\CommonServiceLocator.1.3\lib\portable-net4+sl5+netcore45+wpa81+wp8\Microsoft.Practices.ServiceLocation.dll True + + ..\..\packages\Unity.4.0.1\lib\portable-net45+wp80+win8+wpa81+MonoAndroid10+MonoTouch10\Microsoft.Practices.Unity.dll + True + @@ -74,6 +78,10 @@ ..\..\packages\Prism.Forms.6.2.0\lib\MonoAndroid1.0\Prism.Forms.dll True + + ..\..\packages\Prism.Unity.Forms.6.2.0\lib\MonoAndroid1.0\Prism.Unity.Forms.dll + True + diff --git a/SimpleLifeCounter/SimpleLifeCounter.Droid/packages.config b/SimpleLifeCounter/SimpleLifeCounter.Droid/packages.config index 9acc0f8..a8cba73 100644 --- a/SimpleLifeCounter/SimpleLifeCounter.Droid/packages.config +++ b/SimpleLifeCounter/SimpleLifeCounter.Droid/packages.config @@ -3,6 +3,8 @@ + + diff --git a/SimpleLifeCounter/SimpleLifeCounter.iOS/SimpleLifeCounter.iOS.csproj b/SimpleLifeCounter/SimpleLifeCounter.iOS/SimpleLifeCounter.iOS.csproj index d44d7bc..1f699ac 100644 --- a/SimpleLifeCounter/SimpleLifeCounter.iOS/SimpleLifeCounter.iOS.csproj +++ b/SimpleLifeCounter/SimpleLifeCounter.iOS/SimpleLifeCounter.iOS.csproj @@ -124,6 +124,26 @@ + + ..\..\packages\CommonServiceLocator.1.3\lib\portable-net4+sl5+netcore45+wpa81+wp8\Microsoft.Practices.ServiceLocation.dll + True + + + ..\..\packages\Unity.4.0.1\lib\portable-net45+wp80+win8+wpa81+MonoAndroid10+MonoTouch10\Microsoft.Practices.Unity.dll + True + + + ..\..\packages\Prism.Core.6.2.0\lib\Xamarin.iOS10\Prism.dll + True + + + ..\..\packages\Prism.Forms.6.2.0\lib\Xamarin.iOS1.0\Prism.Forms.dll + True + + + ..\..\packages\Prism.Unity.Forms.6.2.0\lib\Xamarin.iOS1.0\Prism.Unity.Forms.dll + True + diff --git a/SimpleLifeCounter/SimpleLifeCounter.iOS/packages.config b/SimpleLifeCounter/SimpleLifeCounter.iOS/packages.config index 14f9162..f3243de 100644 --- a/SimpleLifeCounter/SimpleLifeCounter.iOS/packages.config +++ b/SimpleLifeCounter/SimpleLifeCounter.iOS/packages.config @@ -1,5 +1,10 @@  + + + + + \ No newline at end of file diff --git a/SimpleLifeCounter/SimpleLifeCounter/App.cs b/SimpleLifeCounter/SimpleLifeCounter/App.cs index cfaa319..e97a1c6 100644 --- a/SimpleLifeCounter/SimpleLifeCounter/App.cs +++ b/SimpleLifeCounter/SimpleLifeCounter/App.cs @@ -1,28 +1,26 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Prism; -using Prism.Unity; +using Prism.Unity; using Xamarin.Forms; using Xamarin.Forms.Xaml; +using SimpleLifeCounter.Models; +using SimpleLifeCounter.Views; +using Microsoft.Practices.Unity; -[assembly: XamlCompilation(XamlCompilationOptions.Compile)] namespace SimpleLifeCounter { public class App : PrismApplication { + public App(IPlatformInitializer initializer = null) : base(initializer) { } + + protected override void OnInitialized() + { + NavigationService.NavigateAsync("/NavigationPage/LifePage"); + } + protected override void RegisterTypes() { Container.RegisterTypeForNavigation(); Container.RegisterTypeForNavigation(); Container.RegisterTypeForNavigation(); } - - protected override void OnInitialized() - { - NavigationService.NavigateAsync("NavigationPage/LifePage"); - } - } } diff --git a/SimpleLifeCounter/SimpleLifeCounter/Models/AllPageModel.cs b/SimpleLifeCounter/SimpleLifeCounter/Models/AllPageModel.cs index 3c6f100..0d5bc2e 100644 --- a/SimpleLifeCounter/SimpleLifeCounter/Models/AllPageModel.cs +++ b/SimpleLifeCounter/SimpleLifeCounter/Models/AllPageModel.cs @@ -82,7 +82,6 @@ public string Message } - public void DoNotBindingSetVM(string lifePoint, string fontColor, string backgroundColor) { // データバインドできない部分をViewModelに手書き diff --git a/SimpleLifeCounter/SimpleLifeCounter/ViewModels/LifePageViewModel.cs b/SimpleLifeCounter/SimpleLifeCounter/ViewModels/LifePageViewModel.cs index 1b9edd6..17f30eb 100644 --- a/SimpleLifeCounter/SimpleLifeCounter/ViewModels/LifePageViewModel.cs +++ b/SimpleLifeCounter/SimpleLifeCounter/ViewModels/LifePageViewModel.cs @@ -5,11 +5,12 @@ using System.Linq; using System.Text; using System.Threading.Tasks; - -using Xamarin.Forms; using Newtonsoft.Json; using Prism.Commands; using Prism.Mvvm; +using Prism.Navigation; +using Prism.Services; +using DependencyService = Xamarin.Forms.DependencyService; namespace SimpleLifeCounter.ViewModels { @@ -17,6 +18,8 @@ class LifePageViewModel : BindableBase { //private AllPageModel Model { get; } = new AllPageModel(); private AllPageModel Model = new AllPageModel(); + private readonly INavigationService _navigationService; + private readonly IPageDialogService _pageDialogService; //LifePage Bainding private string _backgroundColor; @@ -88,19 +91,28 @@ public string Message public DelegateCommand ResetLifeCommand { get; private set; } public DelegateCommand CoinTossCommand { get; private set; } public DelegateCommand DiceCollCommand { get; private set; } + public DelegateCommand NavigationCommand { get; private set; } + + private void Navigate() + { + _navigationService.NavigateAsync("MenuPage"); + } /// /// コンストラクタ /// - public LifePageViewModel() + public LifePageViewModel(INavigationService navigationService, IPageDialogService pageDialogService) { - // this.Model.PropertyChanged += ModelPropertyChanged; //これが反映されない + _navigationService = navigationService; + _pageDialogService = pageDialogService; + Load(); this.RightUpCommand = new DelegateCommand(() => RightLifePoint = (int.Parse(RightLifePoint) + 1).ToString()); this.RightDownCommand = new DelegateCommand(() => RightLifePoint = (int.Parse(RightLifePoint) - 1).ToString()); this.LeftUpCommand = new DelegateCommand(() => LeftLifePoint = (int.Parse(LeftLifePoint) + 1).ToString()); this.LeftDownCommand = new DelegateCommand(() => LeftLifePoint = (int.Parse(LeftLifePoint) - 1).ToString()); + this.NavigationCommand = new DelegateCommand(Navigate); setLifePoint(); } @@ -149,5 +161,18 @@ public void setLifePoint() LeftLifePoint = DefaultLifePoint.ToString(); RightLifePoint = DefaultLifePoint.ToString(); } + + public void OnNavigatedFrom(NavigationParameters parameters) + { + } + + public void OnNavigatedTo(NavigationParameters parameters) + { + } + + public Task CanNavigateAsync(NavigationParameters parameters) + { + throw new NotImplementedException(); + } } } diff --git a/SimpleLifeCounter/SimpleLifeCounter/ViewModels/MenuPageViewModel.cs b/SimpleLifeCounter/SimpleLifeCounter/ViewModels/MenuPageViewModel.cs index 9f88117..7dce2f1 100644 --- a/SimpleLifeCounter/SimpleLifeCounter/ViewModels/MenuPageViewModel.cs +++ b/SimpleLifeCounter/SimpleLifeCounter/ViewModels/MenuPageViewModel.cs @@ -5,7 +5,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; - +using System.Windows.Input; using Xamarin.Forms; using Newtonsoft.Json; using Prism.Commands; @@ -15,6 +15,7 @@ namespace SimpleLifeCounter.ViewModels { class MenuPageViewModel : BindableBase { + private AllPageModel Model = new AllPageModel(); // MenuPage Binding diff --git a/SimpleLifeCounter/SimpleLifeCounter/Views/LifePage.xaml b/SimpleLifeCounter/SimpleLifeCounter/Views/LifePage.xaml index 5cdf594..835f942 100644 --- a/SimpleLifeCounter/SimpleLifeCounter/Views/LifePage.xaml +++ b/SimpleLifeCounter/SimpleLifeCounter/Views/LifePage.xaml @@ -1,7 +1,10 @@  @@ -69,6 +72,7 @@