This commit is contained in:
SpartyGuy 2017-08-04 13:24:23 -05:00
Родитель c6390479e0
Коммит 8a76b865ca
21 изменённых файлов: 932 добавлений и 32 удалений

63
.gitattributes поставляемый Normal file
Просмотреть файл

@ -0,0 +1,63 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto
###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp
###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary
###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary
###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain

37
.gitignore поставляемый
Просмотреть файл

@ -1,7 +1,5 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
# User-specific files
*.suo
@ -42,11 +40,10 @@ TestResult.xml
[Rr]eleasePS/
dlldata.c
# .NET Core
# DNX
project.lock.json
project.fragment.lock.json
artifacts/
**/Properties/launchSettings.json
*_i.c
*_p.c
@ -113,10 +110,6 @@ _TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# Visual Studio code coverage results
*.coverage
*.coveragexml
# NCrunch
_NCrunch_*
.*crunch*.local.xml
@ -150,7 +143,7 @@ publish/
*.azurePubxml
# TODO: Comment the next line if you want to checkin your web deploy settings
# but database connection strings (with potential passwords) will be unencrypted
*.pubxml
#*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
@ -166,7 +159,7 @@ PublishScripts/
!**/packages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config
# NuGet v3's project.json files produces more ignorable files
# NuGet v3's project.json files produces more ignoreable files
*.nuget.props
*.nuget.targets
@ -199,6 +192,7 @@ ClientBin/
*.jfm
*.pfx
*.publishsettings
node_modules/
orleans.codegen.cs
# Since there are multiple workflows, uncomment next line to ignore bower_components
@ -219,7 +213,6 @@ UpgradeLog*.htm
# SQL Server files
*.mdf
*.ldf
*.ndf
# Business Intelligence projects
*.rdl.data
@ -234,10 +227,6 @@ FakesAssemblies/
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
node_modules/
# Typescript v1 declaration files
typings/
# Visual Studio 6 build log
*.plg
@ -245,9 +234,6 @@ typings/
# Visual Studio 6 workspace options file
*.opt
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
*.vbw
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
@ -272,17 +258,4 @@ paket-files/
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
# Cake - Uncomment if you are using it
# tools/**
# !tools/packages.config
# Telerik's JustMock configuration file
*.jmconfig
# BizTalk build output
*.btp.cs
*.btm.cs
*.odx.cs
*.xsd.cs
*.pyc

40
AMP.sln Normal file
Просмотреть файл

@ -0,0 +1,40 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26430.16
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AMP", "AMP\AMP.csproj", "{3381EB7B-7266-440E-AE0F-E8CAD7376281}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|ARM = Debug|ARM
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|ARM = Release|ARM
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{3381EB7B-7266-440E-AE0F-E8CAD7376281}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3381EB7B-7266-440E-AE0F-E8CAD7376281}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3381EB7B-7266-440E-AE0F-E8CAD7376281}.Debug|ARM.ActiveCfg = Debug|ARM
{3381EB7B-7266-440E-AE0F-E8CAD7376281}.Debug|ARM.Build.0 = Debug|ARM
{3381EB7B-7266-440E-AE0F-E8CAD7376281}.Debug|x64.ActiveCfg = Debug|x64
{3381EB7B-7266-440E-AE0F-E8CAD7376281}.Debug|x64.Build.0 = Debug|x64
{3381EB7B-7266-440E-AE0F-E8CAD7376281}.Debug|x86.ActiveCfg = Debug|x86
{3381EB7B-7266-440E-AE0F-E8CAD7376281}.Debug|x86.Build.0 = Debug|x86
{3381EB7B-7266-440E-AE0F-E8CAD7376281}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3381EB7B-7266-440E-AE0F-E8CAD7376281}.Release|Any CPU.Build.0 = Release|Any CPU
{3381EB7B-7266-440E-AE0F-E8CAD7376281}.Release|ARM.ActiveCfg = Release|ARM
{3381EB7B-7266-440E-AE0F-E8CAD7376281}.Release|ARM.Build.0 = Release|ARM
{3381EB7B-7266-440E-AE0F-E8CAD7376281}.Release|x64.ActiveCfg = Release|x64
{3381EB7B-7266-440E-AE0F-E8CAD7376281}.Release|x64.Build.0 = Release|x64
{3381EB7B-7266-440E-AE0F-E8CAD7376281}.Release|x86.ActiveCfg = Release|x86
{3381EB7B-7266-440E-AE0F-E8CAD7376281}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

151
AMP/AMP.csproj Normal file
Просмотреть файл

@ -0,0 +1,151 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{3381EB7B-7266-440E-AE0F-E8CAD7376281}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>AMP</RootNamespace>
<AssemblyName>AMP</AssemblyName>
<DefaultLanguage>en-US</DefaultLanguage>
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
<TargetPlatformVersion Condition=" '$(TargetPlatformVersion)' == '' ">10.0.15063.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.10586.0</TargetPlatformMinVersion>
<MinimumVisualStudioVersion>14</MinimumVisualStudioVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<PlatformTarget>x86</PlatformTarget>
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<Optimize>true</Optimize>
<NoWarn>;2008</NoWarn>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM'">
<PlatformTarget>ARM</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\ARM\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType>
<PlatformTarget>ARM</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM'">
<PlatformTarget>ARM</PlatformTarget>
<OutputPath>bin\ARM\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<Optimize>true</Optimize>
<NoWarn>;2008</NoWarn>
<DebugType>pdbonly</DebugType>
<PlatformTarget>ARM</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<PlatformTarget>x64</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<NoWarn>;2008</NoWarn>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<PlatformTarget>x64</PlatformTarget>
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
<Optimize>true</Optimize>
<NoWarn>;2008</NoWarn>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<UseVSHostingProcess>false</UseVSHostingProcess>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup>
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
</PropertyGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Services\IAsyncInitialization.cs" />
<Compile Include="UX\Services\FrameNavigationService.cs" />
<Compile Include="UX\Services\FrameViewInfo.cs" />
<Compile Include="UX\Services\INavigationServiceEx.cs" />
<Compile Include="ViewModels\AsyncViewModel.cs" />
<Compile Include="ViewModels\INavAware.cs" />
<Compile Include="ViewModels\IVisualState.cs" />
<Compile Include="ViewModels\NavAwareViewModel.cs" />
<Compile Include="Views\AsyncUserControl.cs" />
<Compile Include="Views\Commands\ItemClickCommand.cs" />
<Compile Include="Views\Converters\BoolToVisibilityConverter.cs" />
<Compile Include="Views\Converters\InverseBoolToVisibilityConverter.cs" />
<Compile Include="Views\NavAwarePage.cs" />
<Compile Include="Views\Triggers\VisualStateTrigger.cs" />
<EmbeddedResource Include="Properties\AMP.rd.xml" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
<Version>5.2.3</Version>
</PackageReference>
<PackageReference Include="MvvmLight">
<Version>5.3.0</Version>
</PackageReference>
<PackageReference Include="Newtonsoft.Json">
<Version>10.0.3</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
<None Include="README.md" />
</ItemGroup>
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '14.0' ">
<VisualStudioVersion>14.0</VisualStudioVersion>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

33
AMP/Properties/AMP.rd.xml Normal file
Просмотреть файл

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
This file contains Runtime Directives, specifications about types your application accesses
through reflection and other dynamic code patterns. Runtime Directives are used to control the
.NET Native optimizer and ensure that it does not remove code accessed by your library. If your
library does not do any reflection, then you generally do not need to edit this file. However,
if your library reflects over types, especially types passed to it or derived from its types,
then you should write Runtime Directives.
The most common use of reflection in libraries is to discover information about types passed
to the library. Runtime Directives have three ways to express requirements on types passed to
your library.
1. Parameter, GenericParameter, TypeParameter, TypeEnumerableParameter
Use these directives to reflect over types passed as a parameter.
2. SubTypes
Use a SubTypes directive to reflect over types derived from another type.
3. AttributeImplies
Use an AttributeImplies directive to indicate that your library needs to reflect over
types or methods decorated with an attribute.
For more information on writing Runtime Directives for libraries, please visit
https://go.microsoft.com/fwlink/?LinkID=391919
-->
<Directives xmlns="http://schemas.microsoft.com/netfx/2013/01/metadata">
<Library Name="AMP">
<!-- add directives for your library here -->
</Library>
</Directives>

Просмотреть файл

@ -0,0 +1,29 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("AMP")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AMP")]
[assembly: AssemblyCopyright("Copyright © 2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: ComVisible(false)]

Просмотреть файл

Просмотреть файл

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AMP.Services
{
public interface IAsyncInitialization
{
Task Initialization { get; }
}
}

Просмотреть файл

@ -0,0 +1,224 @@
// ****************************************************************************
// <copyright file="NavigationService.cs" company="GalaSoft Laurent Bugnion">
// Copyright © GalaSoft Laurent Bugnion 2009-2016
// </copyright>
// ****************************************************************************
// <author>Laurent Bugnion</author>
// <email>laurent@galasoft.ch</email>
// <date>02.10.2014</date>
// <project>GalaSoft.MvvmLight</project>
// <web>http://www.mvvmlight.net</web>
// <license>
// See license.txt in this solution or http://www.galasoft.ch/license_MIT.txt
// </license>
// ****************************************************************************
using GalaSoft.MvvmLight.Views;
using System;
using System.Collections.Generic;
using System.Linq;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
namespace AMP.UX.Services
{
/// <summary>
/// Windows 8 and Windows Phone Application 8.1 implementation of <see cref="INavigationService"/>.
/// </summary>
public class FrameNavigationService : INavigationService, INavigationServiceEx
{
ViewTarget _lastTarget;
Frame _subFrame;
/// <summary>
/// The key that is returned by the <see cref="CurrentPageKey"/> property
/// when the current Page is the root page.
/// </summary>
public const string RootPageKey = "-- ROOT --";
/// <summary>
/// The key that is returned by the <see cref="CurrentPageKey"/> property
/// when the current Page is not found.
/// This can be the case when the navigation wasn't managed by this NavigationService,
/// for example when it is directly triggered in the code behind, and the
/// NavigationService was not configured for this page type.
/// </summary>
public const string UnknownPageKey = "-- UNKNOWN --";
private readonly Dictionary<string, ViewInfo> _pagesByKey = new Dictionary<string, ViewInfo>();
/// <summary>
/// The key corresponding to the currently displayed page.
/// </summary>
public string CurrentPageKey
{
get
{
lock (_pagesByKey)
{
var frame = GetCurrentFrame();
if (frame.BackStackDepth == 0)
{
return RootPageKey;
}
if (frame.Content == null)
{
return UnknownPageKey;
}
var currentType = frame.Content.GetType();
if (_pagesByKey.All(p => p.Value.View != currentType))
{
return UnknownPageKey;
}
var item = _pagesByKey.FirstOrDefault(
i => i.Value.View == currentType);
return item.Key;
}
}
}
public Frame SubFrame
{
get { return _subFrame; }
set { _subFrame = value; }
}
public bool CanGoBack
{
get
{
var frame = this.GetCurrentFrame();
if (frame != null)
return frame.CanGoBack;
return false;
}
}
public bool RemoveBackEntry()
{
var frame = this.GetCurrentFrame();
if (frame.CanGoBack)
{
frame.BackStack.RemoveAt(frame.BackStackDepth - 1);
return true;
}
return false;
}
private Frame GetCurrentFrame()
{
if (_lastTarget == ViewTarget.MainFrame)
return (Frame)Window.Current.Content;
return _subFrame;
}
private Frame GetTargetFrame(ViewTarget target)
{
_lastTarget = target;
if (target == ViewTarget.MainFrame)
return (Frame)Window.Current.Content;
return _subFrame;
}
/// <summary>
/// Displays a new page corresponding to the given key.
/// Make sure to call the <see cref="Configure"/>
/// method first.
/// </summary>
/// <param name="pageKey">The key corresponding to the page
/// that should be displayed.</param>
/// <exception cref="ArgumentException">When this method is called for
/// a key that has not been configured earlier.</exception>
public void NavigateTo(string pageKey)
{
NavigateTo(pageKey, null);
}
/// <summary>
/// Displays a new page corresponding to the given key,
/// and passes a parameter to the new page.
/// Make sure to call the <see cref="Configure"/>
/// method first.
/// </summary>
/// <param name="pageKey">The key corresponding to the page
/// that should be displayed.</param>
/// <param name="parameter">The parameter that should be passed
/// to the new page.</param>
/// <exception cref="ArgumentException">When this method is called for
/// a key that has not been configured earlier.</exception>
public virtual void NavigateTo(string pageKey, object parameter)
{
lock (_pagesByKey)
{
if (!_pagesByKey.ContainsKey(pageKey))
{
throw new ArgumentException(
string.Format(
"No such page: {0}. Did you forget to call NavigationService.Configure?",
pageKey),
"pageKey");
}
var frame = GetTargetFrame(_pagesByKey[pageKey].Target);
frame.Navigate(_pagesByKey[pageKey].View, parameter);
}
}
/// <summary>
/// Adds a key/page pair to the navigation service.
/// </summary>
/// <param name="key">The key that will be used later
/// in the <see cref="NavigateTo(string)"/> or <see cref="NavigateTo(string, object)"/> methods.</param>
/// <param name="viewInfo">The type of the page corresponding to the key.</param>
public void Configure(string key, ViewInfo viewInfo)
{
lock (_pagesByKey)
{
if (_pagesByKey.ContainsKey(key))
{
throw new ArgumentException("This key is already used: " + key);
}
if (_pagesByKey.Any(p => p.Value.View == viewInfo.View))
{
throw new ArgumentException(
"This type is already configured with key " + _pagesByKey.First(p => p.Value.View == viewInfo.View).Key);
}
_pagesByKey.Add(
key,
viewInfo);
}
}
public void GoBack()
{
var frame = GetCurrentFrame();
if (frame.CanGoBack)
{
frame.GoBack();
}
}
}
}

Просмотреть файл

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AMP.UX.Services
{
public enum ViewTarget
{
MainFrame,
SubFrame
}
public class ViewInfo
{
public Type View { get; set; }
public ViewTarget Target { get; set; }
}
}

Просмотреть файл

@ -0,0 +1,18 @@
using GalaSoft.MvvmLight.Views;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.UI.Xaml.Controls;
namespace AMP.UX.Services
{
public interface INavigationServiceEx : INavigationService
{
Frame SubFrame { get; set; }
bool CanGoBack { get; }
bool RemoveBackEntry();
}
}

Просмотреть файл

@ -0,0 +1,37 @@
using GalaSoft.MvvmLight;
using AMP.Services;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.UI.Core;
namespace AMP.ViewModels
{
public abstract class AsyncViewModel : ViewModelBase, IAsyncInitialization, INavAware
{
private static CoreDispatcher _dispatcher;
public Task Initialization { get { return InitializeAsync(); } }
protected AsyncViewModel() :base()
{
Debug.WriteLine("AsyncViewModel ctor");
if (_dispatcher == null)
_dispatcher = Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher;
}
protected Task RunAsync(Action a) {
return _dispatcher.RunAsync(CoreDispatcherPriority.Normal, ()=> { a.Invoke(); }).AsTask();
}
protected virtual async Task InitializeAsync() { }
public virtual void Activate(object parameter) { }
public virtual void Deactivate(object parameter) { }
}
}

Просмотреть файл

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AMP.ViewModels
{
public interface INavAware
{
void Activate(object parameter);
void Deactivate(object parameter);
}
}

Просмотреть файл

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AMP.ViewModels
{
public class VisualStateEventArgs : EventArgs
{
public string NewState { get; set; }
public VisualStateEventArgs()
{
}
public VisualStateEventArgs(string newState)
{
NewState = newState;
}
}
public interface IVisualState
{
event EventHandler<VisualStateEventArgs> VisualStateChanged;
}
}

Просмотреть файл

@ -0,0 +1,18 @@

using GalaSoft.MvvmLight;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AMP.ViewModels
{
public abstract class NavAwareViewModel : ViewModelBase, INavAware
{
public abstract void Activate(object parameter);
public abstract void Deactivate(object parameter);
}
}

Просмотреть файл

@ -0,0 +1,27 @@
using AMP.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.UI.Xaml.Controls;
namespace AMP.Views
{
public class AsyncUserControl : UserControl
{
public AsyncUserControl() : base()
{
this.Loaded += AsyncUserControl_Loaded;
}
private async void AsyncUserControl_Loaded(object sender, Windows.UI.Xaml.RoutedEventArgs e)
{
var vm = this.DataContext;
if (vm is AsyncViewModel)
{
await (vm as AsyncViewModel).Initialization;
}
}
}
}

Просмотреть файл

@ -0,0 +1,57 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
namespace AMP.Views.Commands
{
public static class ItemClickCommand
{
public static readonly DependencyProperty CommandProperty =
DependencyProperty.RegisterAttached("Command", typeof(ICommand),
typeof(ItemClickCommand), new PropertyMetadata(null, OnCommandPropertyChanged));
public static void SetCommand(DependencyObject d, ICommand value)
{
d.SetValue(CommandProperty, value);
}
public static ICommand GetCommand(DependencyObject d)
{
return (ICommand)d.GetValue(CommandProperty);
}
private static void OnCommandPropertyChanged(DependencyObject d,
DependencyPropertyChangedEventArgs e)
{
var control = d as ListViewBase;
if (control != null)
control.ItemClick += OnItemClick;
}
// Using a DependencyProperty as the backing store for CommandParameter. This enables animation, styling, binding, etc...
private static void OnItemClick(object sender, ItemClickEventArgs e)
{
Type castType;
var control = sender as ListViewBase;
var command = GetCommand(control);
var generics = command.GetType().GetGenericArguments();
if (generics.Length > 0)
castType = generics[0];
if (command != null && command.CanExecute(e.ClickedItem))
command.Execute(e.ClickedItem);
}
}
}

Просмотреть файл

@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Data;
namespace AMP.Views.Converters
{
public class BoolToVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language)
{
return ((bool)value) ? Visibility.Visible : Visibility.Collapsed;
}
public object ConvertBack(object value, Type targetType, object parameter, string language)
{
throw new NotImplementedException();
}
}
}

Просмотреть файл

@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Data;
namespace AMP.Views.Converters
{
public class InverseBoolToVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language)
{
return ((bool)value) ? Visibility.Collapsed : Visibility.Visible;
}
public object ConvertBack(object value, Type targetType, object parameter, string language)
{
throw new NotImplementedException();
}
}
}

52
AMP/Views/NavAwarePage.cs Normal file
Просмотреть файл

@ -0,0 +1,52 @@
using AMP.ViewModels;
using AMP.Services;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation;
namespace AMP.Views
{
public class NavAwarePage : Page
{
public NavAwarePage() : base()
{
this.Loaded += NavAwarePage_Loaded;
}
private void NavAwarePage_Loaded(object sender, Windows.UI.Xaml.RoutedEventArgs e)
{
Debug.WriteLine("loaded");
}
protected async override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
var navigableViewModel = this.DataContext as INavAware;
if (navigableViewModel != null)
navigableViewModel.Activate(e.Parameter);
var asyncViewModel = this.DataContext as IAsyncInitialization;
if (asyncViewModel != null)
await asyncViewModel.Initialization;
}
protected override void OnNavigatedFrom(NavigationEventArgs e)
{
base.OnNavigatedFrom(e);
var navigableViewModel = this.DataContext as INavAware;
if (navigableViewModel != null)
navigableViewModel.Deactivate(e.Parameter);
}
}
}

Просмотреть файл

@ -0,0 +1,58 @@
using AMP.ViewModels;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.UI.Xaml;
namespace AMP.Views.Triggers
{
public class VisualStateTrigger : StateTriggerBase
{
string _guid;
public VisualStateTrigger()
{
_guid = Guid.NewGuid().ToString();
}
public IVisualState ViewModel
{
get { return (IVisualState)GetValue(ViewModelProperty); }
set { SetValue(ViewModelProperty, value); }
}
// Using a DependencyProperty as the backing store for ViewModel. This enables animation, styling, binding, etc...
public static readonly DependencyProperty ViewModelProperty =
DependencyProperty.Register("ViewModel", typeof(IVisualState), typeof(VisualStateTrigger), new PropertyMetadata(null, OnViewModelChanged));
private static void OnViewModelChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var model = e.NewValue as IVisualState;
var me = d as VisualStateTrigger;
if (model != null)
model.VisualStateChanged += me.Model_StateChanged;
}
public string TargetState { get; set; }
private async void Model_StateChanged(object model, VisualStateEventArgs args)
{
var me = model as VisualStateTrigger;
var isActive = args.NewState.ToString().Equals(TargetState);
Debug.WriteLine($"VisualStateTrigger {_guid}: target = {TargetState} new: {args.NewState.ToString()} result={isActive}");
await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.High, () =>
{
SetActive(isActive);
});
}
}
}