Skip to content

Commit

Permalink
Merge pull request #8 from Windows-XAML/master
Browse files Browse the repository at this point in the history
Pull from origin
  • Loading branch information
artfuldev committed Feb 15, 2016
2 parents d9b4f9b + 2c44f14 commit b3e6d29
Show file tree
Hide file tree
Showing 70 changed files with 831 additions and 319 deletions.
4 changes: 2 additions & 2 deletions Samples/Cortana/App.xaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<common:BootStrapper x:Class="Messaging.App"
<common:BootStrapper x:Class="Sample.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:common="using:Template10.Common"
xmlns:controls="using:Template10.Controls" xmlns:local="using:Messaging" />
xmlns:controls="using:Template10.Controls" xmlns:local="using:Sample" />
16 changes: 10 additions & 6 deletions Samples/Cortana/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using Windows.ApplicationModel.VoiceCommands;
using Windows.Storage;

namespace Messaging
namespace Sample
{
sealed partial class App : Template10.Common.BootStrapper
{
Expand All @@ -23,9 +23,10 @@ public override async Task OnInitializeAsync(IActivatedEventArgs args)

public override Task OnStartAsync(StartKind startKind, IActivatedEventArgs args)
{
if (args.Kind == ActivationKind.VoiceCommand)
var e = args as VoiceCommandActivatedEventArgs;
if (e != null)
{
var result = (args as VoiceCommandActivatedEventArgs).Result;
var result = e.Result;
var properties = result.SemanticInterpretation.Properties
.ToDictionary(x => x.Key, x => x.Value);

Expand All @@ -41,15 +42,18 @@ public override Task OnStartAsync(StartKind startKind, IActivatedEventArgs args)
else { /* not okay to speak */ }

// update value
ViewModels.MainPageViewModel.Instance.Value = text;
if (ViewModels.MainPageViewModel.Instance == null)
NavigationService.Navigate(typeof(Views.MainPage), text);
else
ViewModels.MainPageViewModel.Instance.Value = text;
}
else { /* unexpected command */ }
}
else
{
NavigationService.Navigate(typeof(Views.MainPage));
}
return Task.CompletedTask;
}
return Task.CompletedTask;
}
}
}
7 changes: 7 additions & 0 deletions Samples/Cortana/Cortana (and Speech).csproj
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@
<Compile Include="Views\MainPage.xaml.cs">
<DependentUpon>MainPage.xaml</DependentUpon>
</Compile>
<Compile Include="Views\SettingsPage.xaml.cs">
<DependentUpon>SettingsPage.xaml</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="Blank_TemporaryKey.pfx" />
Expand All @@ -129,6 +132,10 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Views\SettingsPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Template10 %28Library%29\Template10 %28Library%29.csproj">
Expand Down
3 changes: 3 additions & 0 deletions Samples/Cortana/Cortana.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?xml version="1.0" encoding="utf-8" ?>
<VoiceCommands xmlns="http://schemas.microsoft.com/voicecommands/1.2">

<CommandSet xml:lang="en-us" Name="FreeText_en-us">

<CommandPrefix> TemplateTen </CommandPrefix>
<Example> Handle my text with Template 10. </Example>

Expand All @@ -14,4 +16,5 @@
<PhraseTopic Label="textPhrase" Scenario="Natural Language" />

</CommandSet>

</VoiceCommands>
15 changes: 8 additions & 7 deletions Samples/Cortana/Services/SpeechService/SpeechService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using Windows.Media.SpeechSynthesis;
using Windows.UI.Xaml.Controls;

namespace Messaging.Services.SpeechService
namespace Sample.Services.SpeechService
{
class SpeechService : IDisposable
{
Expand Down Expand Up @@ -39,14 +39,15 @@ public async Task<string> ListenAsync(string prompt, string example)
_SpeechRecognizer.UIOptions.AudiblePrompt = prompt;
_SpeechRecognizer.UIOptions.ExampleText = example;
var result = await _SpeechRecognizer.RecognizeWithUIAsync();
if (result.Status == SpeechRecognitionResultStatus.Success)
switch (result.Status)
{
return result.Text;
case SpeechRecognitionResultStatus.Success:
return result.Text;
case SpeechRecognitionResultStatus.UserCanceled:
return string.Empty;
default:
throw new Exception("Speech recognition failed. Status: " + result.Status.ToString());
}
else
{
throw new Exception("Speech recognition failed. Status: " + result.Status.ToString());
}
}
catch (TaskCanceledException e) { throw new Exception("Cancelled", e); }
catch (Exception e) when (e.HResult.Equals(0x80045509)) { throw new Exception("Disabled in settings", e); }
Expand Down
37 changes: 21 additions & 16 deletions Samples/Cortana/ViewModels/MainPageViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Navigation;

namespace Messaging.ViewModels
namespace Sample.ViewModels
{
public class MainPageViewModel : Template10.Mvvm.ViewModelBase
{
Expand Down Expand Up @@ -40,8 +40,8 @@ public override async Task OnNavigatedToAsync(object parameter, NavigationMode m
public override Task OnNavigatedFromAsync(IDictionary<string, object> state, bool suspending)
{
_SpeechService.Dispose();
return Task.CompletedTask;
}
return Task.CompletedTask;
}

private string _Value;
public string Value
Expand All @@ -61,23 +61,28 @@ public string Value

private async void ListenExecute()
{
try
{
Value = await _SpeechService.ListenAsync("Cortana Sample", "Try saying, 'The quick brown fox jumps over the lazy dog.'");
}
catch(Exception ex)
{
var messageDialog = new Windows.UI.Popups.MessageDialog
("Failed to start speech recognition." +
Environment.NewLine + Environment.NewLine + "Message: " + ex.Message,
"Speech recognition failed");
await messageDialog.ShowAsync();
}
}
try
{
Value = await _SpeechService.ListenAsync("Cortana Sample", "Try saying, 'The quick brown fox jumps over the lazy dog.'");
}
catch (Exception ex)
{
var messageDialog = new Windows.UI.Popups.MessageDialog
("Failed to start speech recognition." +
Environment.NewLine + Environment.NewLine + "Message: " + ex.Message,
"Speech recognition failed");
await messageDialog.ShowAsync();
}
}

public async Task Speak()
{
await _SpeechService.SpeakAsync(Value);
}

public void GotoSettings()
{
NavigationService.Navigate(typeof(Views.SettingsPage));
}
}
}
17 changes: 10 additions & 7 deletions Samples/Cortana/Views/MainPage.xaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<Page x:Class="Messaging.Views.MainPage"
<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Core="using:Microsoft.Xaml.Interactions.Core"
xmlns:Interactivity="using:Microsoft.Xaml.Interactivity"
xmlns:controls="using:Template10.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:Messaging.Views"
xmlns:local="using:Sample.Views"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="using:Messaging.ViewModels" mc:Ignorable="d">
xmlns:vm="using:Sample.ViewModels" xmlns:Behaviors="using:Template10.Behaviors" x:Class="Sample.Views.MainPage"
mc:Ignorable="d">

<Page.DataContext>
<vm:MainPageViewModel />
Expand All @@ -21,8 +22,10 @@
</Grid.RowDefinitions>

<!-- header -->
<controls:PageHeader BackButtonVisibility="Collapsed" Frame="{x:Bind Frame, Mode=OneWay}"
Content="Main Page" VisualStateNarrowMinWidth="-1" />
<controls:PageHeader BackButtonVisibility="Collapsed" Content="Main Page"
Frame="{x:Bind Frame, Mode=OneWay}" VisualStateNarrowMinWidth="-1">
<AppBarButton Icon="Setting" Label="Settings" Click="{x:Bind ViewModel.GotoSettings}" />
</controls:PageHeader>

<!-- #region content -->

Expand All @@ -31,8 +34,8 @@
<TextBlock Style="{StaticResource HeaderTextBlockStyle}" Text="{Binding Value}" />

<StackPanel Margin="0,12" Orientation="Horizontal">
<Button Click="{x:Bind ViewModel.Speak}">Speak</Button>
<Button Margin="12,0" Command="{x:Bind ViewModel.ListenCommand}">Listen</Button>
<Button Click="{x:Bind ViewModel.Speak}" Content="Speak"/>
<Button Margin="12,0" Command="{x:Bind ViewModel.ListenCommand}" Content="Listen"/>
</StackPanel>

</StackPanel>
Expand Down
9 changes: 7 additions & 2 deletions Samples/Cortana/Views/MainPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Messaging.ViewModels;
using Sample.ViewModels;
using Windows.UI.Xaml.Controls;

namespace Messaging.Views
namespace Sample.Views
{
public sealed partial class MainPage : Page
{
Expand All @@ -11,5 +11,10 @@ public MainPage()
}

public MainPageViewModel ViewModel => this.DataContext as MainPageViewModel;

private void AppBarButton_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
{

}
}
}
14 changes: 14 additions & 0 deletions Samples/Cortana/Views/SettingsPage.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Page x:Class="Sample.Views.SettingsPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="using:Template10.Controls"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:Sample.Views"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
<controls:PageHeader BackButtonVisibility="Visible" Frame="{x:Bind Frame}" Text="Settings page" />
</Grid>

</Page>
30 changes: 30 additions & 0 deletions Samples/Cortana/Views/SettingsPage.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238

namespace Sample.Views
{
/// <summary>
/// An empty page that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class SettingsPage : Page
{
public SettingsPage()
{
this.InitializeComponent();
}
}
}
4 changes: 2 additions & 2 deletions Snippets/T10_ViewModelFull.snippet
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
</Literal>
</Declarations>
<Code Language="csharp">
<![CDATA[public class $name$ViewModel : Mvvm.ViewModelBase
<![CDATA[public class $name$ViewModel : ViewModelBase
{
public $name$ViewModel()
{
Expand Down Expand Up @@ -98,4 +98,4 @@
</Code>
</Snippet>
</CodeSnippet>
</CodeSnippets>
</CodeSnippets>
Binary file modified Template10 (Installer)/Lib/Template10.MSBUILD.dll
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
15 changes: 14 additions & 1 deletion Template10 (Installer)/Template10.MSBUILD/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,23 @@ internal class Constants
<FullClassName>Microsoft.VisualStudio.Universal.TemplateWizards.PlatformVersion.Wizard</FullClassName>
</WizardExtension>
<WizardData>
<packages repository=""registry"" keyName=""NETCoreSDK"" isPreunzipped=""true"">
<packages repository=""registry"" keyName=""NETCoreSDK"" isPreunzipped=""true"" forceDesignTimeBuild=""true"">
<package id=""Microsoft.NETCore.UniversalWindowsPlatform"" version=""5.0.0"" skipAssemblyReferences=""false"" />
</packages>
</WizardData>
<WizardExtension>
<Assembly>NuGet.VisualStudio.Interop, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</Assembly>
<FullClassName>NuGet.VisualStudio.TemplateWizard</FullClassName>
</WizardExtension>
<WizardData>
<packages forceDesignTimeBuild=""true"" forceDesignTimeBuild=""true"">
<package id = ""Microsoft.Xaml.Behaviors.Uwp.Managed"" version=""1.0.3"" />
<package id = ""Newtonsoft.Json"" version=""8.0.2"" />
<package id = ""Template10"" version=""1.1.3"" />
</packages>
</WizardData>
</VSTemplate>";

}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@
<ItemGroup>
<EmbeddedResource Include="EmbeddedFiles\__PreviewImageMinimal.png" />
</ItemGroup>
<ItemGroup>
<Content Include="vstemplate.xml" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.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.
Expand Down
Loading

0 comments on commit b3e6d29

Please sign in to comment.