diff --git a/code/src/UI/ViewModels/NewProject/MainViewModel.cs b/code/src/UI/ViewModels/NewProject/MainViewModel.cs index e4d40baaf..61f16cdf2 100644 --- a/code/src/UI/ViewModels/NewProject/MainViewModel.cs +++ b/code/src/UI/ViewModels/NewProject/MainViewModel.cs @@ -21,6 +21,7 @@ namespace Microsoft.Templates.UI.ViewModels.NewProject { public class MainViewModel : BaseMainViewModel { + private bool _needRestartConfiguration = false; public static MainViewModel Current; public MainView MainView; @@ -69,10 +70,12 @@ namespace Microsoft.Templates.UI.ViewModels.NewProject if (CheckProjectSetupChanged()) { WizardStatus.SetStatus(StatusViewModel.Warning(string.Format(StringRes.ResetSelection, ProjectTemplates.ContextProjectType.DisplayName, ProjectTemplates.ContextFramework.DisplayName), true, 5)); + _needRestartConfiguration = true; } else { CleanStatus(); + _needRestartConfiguration = false; } } @@ -133,15 +136,15 @@ namespace Microsoft.Templates.UI.ViewModels.NewProject base.OnNext(); if (CurrentStep == 1) { - WizardStatus.WizardTitle = StringRes.ProjectPagesTitle; - await ProjectTemplates.InitializeAsync(); - NavigationService.Navigate(new ProjectPagesView()); - if (CheckProjectSetupChanged()) + if (_needRestartConfiguration) { ResetSelection(); Ordering.Panel.Children.Clear(); CleanStatus(); } + WizardStatus.WizardTitle = StringRes.ProjectPagesTitle; + await ProjectTemplates.InitializeAsync(); + NavigationService.Navigate(new ProjectPagesView()); } else if (CurrentStep == 2) { diff --git a/code/src/UI/ViewModels/NewProject/ProjectSetupViewModel.cs b/code/src/UI/ViewModels/NewProject/ProjectSetupViewModel.cs index 914b9ebc3..773823029 100644 --- a/code/src/UI/ViewModels/NewProject/ProjectSetupViewModel.cs +++ b/code/src/UI/ViewModels/NewProject/ProjectSetupViewModel.cs @@ -38,15 +38,17 @@ namespace Microsoft.Templates.UI.ViewModels.NewProject { DataService.LoadFrameworks(Frameworks, value.Name); FrameworkHeader = string.Format(StringRes.GroupFrameworkHeader_SF, Frameworks.Count); - - SelectedFramework = Frameworks.FirstOrDefault(f => f.Name == _selectedFramework?.Name); - if (SelectedFramework == null) + if (_selectedFramework != null) + { + SelectedFramework = Frameworks.FirstOrDefault(f => f.Name == _selectedFramework.Name); + } + else { SelectedFramework = Frameworks.FirstOrDefault(); } - + var hasChanged = _selectedProjectType != null && _selectedProjectType.Name != value.Name; SetProperty(ref _selectedProjectType, value); - if (_selectedProjectType != null && _selectedProjectType != value) + if (hasChanged) { MainViewModel.Current.AlertProjectSetupChanged(); } @@ -62,16 +64,16 @@ namespace Microsoft.Templates.UI.ViewModels.NewProject get => _selectedFramework; set { - var orgframework = _selectedFramework; - - SetProperty(ref _selectedFramework, value); - - if (value != null && orgframework != null && orgframework != _selectedFramework) + if (value != null) { - MainViewModel.Current.AlertProjectSetupChanged(); + bool hasChanged = _selectedFramework != null && _selectedFramework.Name != value.Name; + SetProperty(ref _selectedFramework, value); + if (hasChanged) + { + MainViewModel.Current.AlertProjectSetupChanged(); + } + MainViewModel.Current.RebuildLicenses(); } - - MainViewModel.Current.RebuildLicenses(); } } diff --git a/code/test/Templates.Test/BaseGenAndBuildTests.cs b/code/test/Templates.Test/BaseGenAndBuildTests.cs index 4841f1976..84228ae6c 100644 --- a/code/test/Templates.Test/BaseGenAndBuildTests.cs +++ b/code/test/Templates.Test/BaseGenAndBuildTests.cs @@ -231,6 +231,11 @@ namespace Microsoft.Templates.Test case "MVVMLight": result = context.Factory.Run(() => BuildMVVMLightFixture.GetProjectTemplatesAsync(framework)); break; + + case "CaliburnMicro": + result = context.Factory.Run(() => BuildCaliburnMicroFixture.GetProjectTemplatesAsync(framework)); + break; + default: result = context.Factory.Run(() => BuildFixture.GetProjectTemplatesAsync()); break; @@ -259,6 +264,10 @@ namespace Microsoft.Templates.Test case "MVVMLight": result = context.Factory.Run(() => BuildMVVMLightFixture.GetPageAndFeatureTemplatesAsync(framework)); break; + + case "CaliburnMicro": + result = context.Factory.Run(() => BuildCaliburnMicroFixture.GetPageAndFeatureTemplatesAsync(framework)); + break; } return result; } diff --git a/code/test/Templates.Test/BuildCaliburnMicroTests/BuildCaliburnMicroCollection.cs b/code/test/Templates.Test/BuildCaliburnMicroTests/BuildCaliburnMicroCollection.cs new file mode 100644 index 000000000..b25608e81 --- /dev/null +++ b/code/test/Templates.Test/BuildCaliburnMicroTests/BuildCaliburnMicroCollection.cs @@ -0,0 +1,13 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using Xunit; + +namespace Microsoft.Templates.Test +{ + [CollectionDefinition("BuildCaliburnMicroCollection")] + public class BuildCaliburnMicroCollection : ICollectionFixture + { + } +} diff --git a/code/test/Templates.Test/BuildCaliburnMicroTests/BuildCaliburnMicroFixture.cs b/code/test/Templates.Test/BuildCaliburnMicroTests/BuildCaliburnMicroFixture.cs new file mode 100644 index 000000000..1e71b28c1 --- /dev/null +++ b/code/test/Templates.Test/BuildCaliburnMicroTests/BuildCaliburnMicroFixture.cs @@ -0,0 +1,122 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Diagnostics.CodeAnalysis; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading.Tasks; + +using Microsoft.TemplateEngine.Abstractions; +using Microsoft.Templates.Core; +using Microsoft.Templates.Core.Gen; +using Microsoft.Templates.Core.Locations; +using Microsoft.Templates.Fakes; +using Microsoft.Templates.UI; + +namespace Microsoft.Templates.Test +{ + public sealed class BuildCaliburnMicroFixture : BaseGenAndBuildFixture, IDisposable + { + private string testExecutionTimeStamp = DateTime.Now.FormatAsDateHoursMinutes(); + public override string GetTestRunPath() => $"{Path.GetPathRoot(Environment.CurrentDirectory)}\\UIT\\CM\\{testExecutionTimeStamp}\\"; + + public TemplatesSource Source => new BuildCaliburnMicroTestTemplatesSource(); + + private static bool syncExecuted; + + public static async Task> GetProjectTemplatesAsync(string frameworkFilter) + { + List result = new List(); + foreach (var language in ProgrammingLanguages.GetAllLanguages()) + { + await InitializeTemplatesForLanguageAsync(new BuildCaliburnMicroTestTemplatesSource(), language); + + var projectTemplates = GenContext.ToolBox.Repo.GetAll().Where(t => t.GetTemplateType() == TemplateType.Project + && t.GetLanguage() == language); + + foreach (var projectTemplate in projectTemplates) + { + var projectTypeList = projectTemplate.GetProjectTypeList(); + + foreach (var projectType in projectTypeList) + { + var frameworks = GenComposer.GetSupportedFx(projectType).Where(f => f == frameworkFilter); + + foreach (var framework in frameworks) + { + result.Add(new object[] { projectType, framework, language }); + } + } + } + } + return result; + } + + public static async Task> GetPageAndFeatureTemplatesAsync(string frameworkFilter) + { + List result = new List(); + foreach (var language in ProgrammingLanguages.GetAllLanguages()) + { + await InitializeTemplatesForLanguageAsync(new BuildCaliburnMicroTestTemplatesSource(), language); + await InitializeTemplatesForLanguageAsync(new BuildCaliburnMicroTestTemplatesSource(), language); + + var projectTemplates = GenContext.ToolBox.Repo.GetAll().Where(t => t.GetTemplateType() == TemplateType.Project + && t.GetLanguage() == language); + + foreach (var projectTemplate in projectTemplates) + { + var projectTypeList = projectTemplate.GetProjectTypeList(); + + foreach (var projectType in projectTypeList) + { + var frameworks = GenComposer.GetSupportedFx(projectType).Where(f => f == frameworkFilter); + + foreach (var framework in frameworks) + { + var itemTemplates = GenContext.ToolBox.Repo.GetAll().Where(t => t.GetFrameworkList().Contains(framework) + && (t.GetTemplateType() == TemplateType.Page || t.GetTemplateType() == TemplateType.Feature) + && t.GetLanguage() == language + && !t.GetIsHidden()); + + foreach (var itemTemplate in itemTemplates) + { + result.Add(new object[] + { itemTemplate.Name, projectType, framework, itemTemplate.Identity, language }); + } + } + } + } + } + return result; + } + + private static async Task InitializeTemplatesForLanguageAsync(TemplatesSource source, string language) + { + GenContext.Bootstrap(source, new FakeGenShell(language), language); + + if (!syncExecuted) + { + await GenContext.ToolBox.Repo.SynchronizeAsync(); + syncExecuted = true; + } + else + { + await GenContext.ToolBox.Repo.RefreshAsync(); + } + } + + public override async Task InitializeFixtureAsync(string language, IContextProvider contextProvider) + { + GenContext.Current = contextProvider; + + await InitializeTemplatesForLanguageAsync(Source, language); + } + } +} diff --git a/code/test/Templates.Test/BuildCaliburnMicroTests/BuildCaliburnMicroProjectTests.cs b/code/test/Templates.Test/BuildCaliburnMicroTests/BuildCaliburnMicroProjectTests.cs new file mode 100644 index 000000000..347c5d55d --- /dev/null +++ b/code/test/Templates.Test/BuildCaliburnMicroTests/BuildCaliburnMicroProjectTests.cs @@ -0,0 +1,125 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; + +using Microsoft.Templates.Core; +using Microsoft.Templates.Core.Gen; +using Microsoft.Templates.Core.Locations; +using Microsoft.Templates.Fakes; +using Microsoft.Templates.UI; +using Microsoft.VisualStudio.Threading; +using Microsoft.TemplateEngine.Abstractions; + +using Xunit; + +namespace Microsoft.Templates.Test +{ + [Collection("BuildCaliburnMicroCollection")] + [Trait("ExecutionSet", "BuildCaliburnMicro")] + [Trait("ExecutionSet", "Build")] + public class BuildCaliburnMicroProjectTests : BaseGenAndBuildTests + { + public BuildCaliburnMicroProjectTests(BuildCaliburnMicroFixture fixture) + { + _fixture = fixture; + } + + [Theory] + [MemberData("GetProjectTemplatesForBuildAsync", "CaliburnMicro")] + [Trait("Type", "BuildProjects")] + public async Task BuildEmptyProjectAsync(string projectType, string framework, string language) + { + Func selector = + t => t.GetTemplateType() == TemplateType.Project + && t.GetProjectTypeList().Contains(projectType) + && t.GetFrameworkList().Contains(framework) + && !t.GetIsHidden() + && t.GetLanguage() == language; + + var projectName = $"{projectType}"; + + var projectPath = await AssertGenerateProjectAsync(selector, projectName, projectType, framework, language, null, false); + + AssertBuildProjectAsync(projectPath, projectName); + } + + [Theory] + [MemberData("GetProjectTemplatesForBuildAsync", "CaliburnMicro")] + [Trait("Type", "BuildAllPagesAndFeatures")] + public async Task BuildAllPagesAndFeaturesAsync(string projectType, string framework, string language) + { + Func selector = + t => t.GetTemplateType() == TemplateType.Project + && t.GetProjectTypeList().Contains(projectType) + && t.GetFrameworkList().Contains(framework) + && !t.GetIsHidden() + && t.GetLanguage() == language; + + var projectName = $"{projectType}All"; + + var projectPath = await AssertGenerateProjectAsync(selector, projectName, projectType, framework, language, GenerationFixture.GetDefaultName, false); + + AssertBuildProjectAsync(projectPath, projectName); + } + + [Theory] + [MemberData("GetProjectTemplatesForBuildAsync", "CaliburnMicro")] + [Trait("Type", "BuildRandomNames")] + [Trait("ExecutionSet", "Minimum")] + public async Task BuildAllPagesAndFeaturesRandomNamesAsync(string projectType, string framework, string language) + { + Func selector = + t => t.GetTemplateType() == TemplateType.Project + && t.GetProjectTypeList().Contains(projectType) + && t.GetFrameworkList().Contains(framework) + && !t.GetIsHidden() + && t.GetLanguage() == language; + + var projectName = $"{projectType}AllRandom"; + + var projectPath = await AssertGenerateProjectAsync(selector, projectName, projectType, framework, language, GenerationFixture.GetRandomName, false); + + AssertBuildProjectAsync(projectPath, projectName); + } + + [Theory] + [MemberData("GetProjectTemplatesForBuildAsync", "CaliburnMicro")] + [Trait("Type", "BuildRightClick")] + public async Task BuildEmptyProjectWithAllRightClickItemsAsync(string projectType, string framework, string language) + { + var projectName = $"{projectType}AllRightClick"; + + var projectPath = await AssertGenerateRightClickAsync(projectName, projectType, framework, language, true, false); + + AssertBuildProjectAsync(projectPath, projectName); + } + + [Theory] + [MemberData("GetProjectTemplatesForBuildAsync", "CaliburnMicro")] + [Trait("Type", "BuildRightClick")] + public async Task BuildCompleteProjectWithAllRightClickItemsAsync(string projectType, string framework, string language) + { + var projectName = $"{projectType}AllRightClick2"; + + var projectPath = await AssertGenerateRightClickAsync(projectName, projectType, framework, language, false, false); + + AssertBuildProjectAsync(projectPath, projectName); + } + + [Theory] + [MemberData("GetPageAndFeatureTemplatesForBuildAsync", "CaliburnMicro")] + [Trait("Type", "BuildOneByOneCaliburnMicro")] + public async Task BuildCaliburnMicroOneByOneItemsAsync(string itemName, string projectType, string framework, string itemId, string language) + { + var result = await AssertGenerationOneByOneAsync(itemName, projectType, framework, itemId, language, false); + + AssertBuildProjectAsync(result.ProjectPath, result.ProjecName); + } + } +} diff --git a/code/test/Templates.Test/BuildCaliburnMicroTests/BuildCaliburnMicroTestTemplatesSource.cs b/code/test/Templates.Test/BuildCaliburnMicroTests/BuildCaliburnMicroTestTemplatesSource.cs new file mode 100644 index 000000000..ff266808f --- /dev/null +++ b/code/test/Templates.Test/BuildCaliburnMicroTests/BuildCaliburnMicroTestTemplatesSource.cs @@ -0,0 +1,43 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using System.IO; +using System.Text; +using Microsoft.Templates.Core; +using Microsoft.Templates.Core.Locations; +using Microsoft.Templates.Core.Packaging; + +namespace Microsoft.Templates.Test +{ + public sealed class BuildCaliburnMicroTestTemplatesSource : TemplatesSource + { + public string LocalTemplatesVersion { get; private set; } + + protected override bool VerifyPackageSignatures => false; + + public override bool ForcedAcquisition => true; + + public string Origin => $@"..\..\..\..\..\{SourceFolderName}"; + + public override string Id => "TestBuildCaliburnMicro"; + + protected override string AcquireMstx() + { + // Compress Content adding version return TemplatePackage path. + var tempFolder = Path.Combine(GetTempFolder(), SourceFolderName); + + Copy(Origin, tempFolder); + + File.WriteAllText(Path.Combine(tempFolder, "version.txt"), LocalTemplatesVersion, Encoding.UTF8); + + return TemplatePackage.Pack(tempFolder); + } + + private void Copy(string sourceFolder, string targetFolder) + { + Fs.SafeDeleteDirectory(targetFolder); + Fs.CopyRecursive(sourceFolder, targetFolder); + } + } +} diff --git a/code/test/Templates.Test/BuildCodeBehindTests/BuildCodeBehindFixture.cs b/code/test/Templates.Test/BuildCodeBehindTests/BuildCodeBehindFixture.cs index ce60933ca..7b24d2c89 100644 --- a/code/test/Templates.Test/BuildCodeBehindTests/BuildCodeBehindFixture.cs +++ b/code/test/Templates.Test/BuildCodeBehindTests/BuildCodeBehindFixture.cs @@ -25,7 +25,7 @@ namespace Microsoft.Templates.Test public sealed class BuildCodeBehindFixture : BaseGenAndBuildFixture, IDisposable { private string testExecutionTimeStamp = DateTime.Now.FormatAsDateHoursMinutes(); - public override string GetTestRunPath() => $"{Path.GetPathRoot(Environment.CurrentDirectory)}\\UIT\\CodeBehind\\{testExecutionTimeStamp}\\"; + public override string GetTestRunPath() => $"{Path.GetPathRoot(Environment.CurrentDirectory)}\\UIT\\CB\\{testExecutionTimeStamp}\\"; public TemplatesSource Source => new BuildCodeBehindTestTemplatesSource(); diff --git a/code/test/Templates.Test/BuildMVVMBasic/BuildMVVMBasicFixture.cs b/code/test/Templates.Test/BuildMVVMBasic/BuildMVVMBasicFixture.cs index 8186ee58d..50357a534 100644 --- a/code/test/Templates.Test/BuildMVVMBasic/BuildMVVMBasicFixture.cs +++ b/code/test/Templates.Test/BuildMVVMBasic/BuildMVVMBasicFixture.cs @@ -25,7 +25,7 @@ namespace Microsoft.Templates.Test public sealed class BuildMVVMBasicFixture : BaseGenAndBuildFixture, IDisposable { private string testExecutionTimeStamp = DateTime.Now.FormatAsDateHoursMinutes(); - public override string GetTestRunPath() => $"{Path.GetPathRoot(Environment.CurrentDirectory)}\\UIT\\MVVMBasic\\{testExecutionTimeStamp}\\"; + public override string GetTestRunPath() => $"{Path.GetPathRoot(Environment.CurrentDirectory)}\\UIT\\MB\\{testExecutionTimeStamp}\\"; public TemplatesSource Source => new BuildMVVMBasicTestTemplatesSource(); diff --git a/code/test/Templates.Test/BuildMVVMLightTests/BuildMVVMLightFixture.cs b/code/test/Templates.Test/BuildMVVMLightTests/BuildMVVMLightFixture.cs index 9981f4ff5..edcc90ae3 100644 --- a/code/test/Templates.Test/BuildMVVMLightTests/BuildMVVMLightFixture.cs +++ b/code/test/Templates.Test/BuildMVVMLightTests/BuildMVVMLightFixture.cs @@ -25,7 +25,7 @@ namespace Microsoft.Templates.Test public sealed class BuildMVVMLightFixture : BaseGenAndBuildFixture, IDisposable { private string testExecutionTimeStamp = DateTime.Now.FormatAsDateHoursMinutes(); - public override string GetTestRunPath() => $"{Path.GetPathRoot(Environment.CurrentDirectory)}\\UIT\\MVVMLight\\{testExecutionTimeStamp}\\"; + public override string GetTestRunPath() => $"{Path.GetPathRoot(Environment.CurrentDirectory)}\\UIT\\ML\\{testExecutionTimeStamp}\\"; public TemplatesSource Source => new BuildMVVMLightTestTemplatesSource(); diff --git a/code/test/Templates.Test/GenTests/GenProjectsTests.cs b/code/test/Templates.Test/GenTests/GenProjectsTests.cs index 709b708f8..424fa6cf6 100644 --- a/code/test/Templates.Test/GenTests/GenProjectsTests.cs +++ b/code/test/Templates.Test/GenTests/GenProjectsTests.cs @@ -110,6 +110,14 @@ namespace Microsoft.Templates.Test await AssertGenerationOneByOneAsync(itemName, projectType, framework, itemId, language); } + [Theory] + [MemberData("GetPageAndFeatureTemplatesAsync", "CaliburnMicro")] + [Trait("Type", "GenerationOneByOneCaliburnMicro")] + public async Task GenCaliburnMicroOneByOneItemsAsync(string itemName, string projectType, string framework, string itemId, string language) + { + await AssertGenerationOneByOneAsync(itemName, projectType, framework, itemId, language); + } + [Theory] [MemberData("GetPageAndFeatureTemplatesForGenerationAsync", "MVVMBasic")] [Trait("Type", "GenerationOneByOneMVVMBasic")] diff --git a/code/test/Templates.Test/Templates.Test.csproj b/code/test/Templates.Test/Templates.Test.csproj index 71120a00d..72e111b52 100644 --- a/code/test/Templates.Test/Templates.Test.csproj +++ b/code/test/Templates.Test/Templates.Test.csproj @@ -120,6 +120,10 @@ + + + + diff --git a/docs/projectTypes/navigationpane.md b/docs/projectTypes/navigationpane.md index 1f10c14f7..4e438c366 100644 --- a/docs/projectTypes/navigationpane.md +++ b/docs/projectTypes/navigationpane.md @@ -6,6 +6,7 @@ This document covers: * [Modifying the menu items](#menu) * [Using the navigation pane with command bars](#commandbar) +* [Have the menu item invoke code rather than navigate](#invokecode) @@ -147,3 +148,110 @@ Events and commands are not shown in the above code but can easily be added like In all the above code examples the `Label` values have been hard-coded. This is to make the samples simpler. To use localized text, set the `x:Uid` value for the `AppBarButton` and add a corresponding resource entry for "{name}.Label". The examples also only show a single `AppBarButton` being added. This is to keep the code sample as simple as possible but you can add any appropriate content to the bar, as [documented here](https://docs.microsoft.com/en-us/windows/uwp/controls-and-patterns/app-bars). + + + +## Have the menu item invoke code rather than navigate + +Extending the app to add this functionality requires making two changes. + +1. Change the ShellNavigationItem to be able to handle an `Action`. +1. Change the ShellPage or ShellViewModel to invoke the action. + +In **ShellNavigationItem.cs** add the following + +```csharp + public Action Action { get; private set; } + + private ShellNavigationItem(string label, Symbol symbol, Action action) + : this(label, null) + { + Symbol = symbol; + Action = action; + } + + public static ShellNavigationItem ForAction(string label, Symbol symbol, Action action) + { + return new ShellNavigationItem(label, symbol, action); + } +``` + +### If using CodeBehind + +In **ShellPage.xaml.cs** change the `Navigate` method to be like this. + +```csharp + private void Navigate(object item) + { + var navigationItem = item as ShellNavigationItem; + if (navigationItem != null) + { + if (navigationItem.Action != null) + { + navigationItem.Action.Invoke(); + } + else + { + NavigationService.Navigate(navigationItem.PageType); + } + } + } +``` + +### If using MVVM Basic + +In **ShellPageViewModel** change the `Navigate` method to be like this. + +```csharp + private void Navigate(object item) + { + var navigationItem = item as ShellNavigationItem; + if (navigationItem != null) + { + if (navigationItem.Action != null) + { + navigationItem.Action.Invoke(); + } + else + { + NavigationService.Navigate(navigationItem.PageType); + } + } + } +``` + +### If using MVVM Light + +In **ShellPageViewModel** change the `Navigate` method to be like this. + +```csharp + private void Navigate(object item) + { + var navigationItem = item as ShellNavigationItem; + if (navigationItem != null) + { + if (navigationItem.Action != null) + { + navigationItem.Action.Invoke(); + } + else + { + NavigationService.Navigate(navigationItem.ViewModelName); + } + } + } +``` + +You can then add a menu item that uses the above. +e.g. In `PopulateNavItems()` add something like this: + +```csharp +_secondaryItems.Add( + ShellNavigationItem.ForAction( + "Rate this app", + Symbol.OutlineStar, + async () => { + await new Windows.UI.Popups.MessageDialog("5 stars please").ShowAsync(); + // .. code to launch the review process, etc. + })); +``` diff --git a/templates/Features/BackgroundTask/.template.config/template.json b/templates/Features/BackgroundTask/.template.config/template.json index d5039931b..5120ee37b 100644 --- a/templates/Features/BackgroundTask/.template.config/template.json +++ b/templates/Features/BackgroundTask/.template.config/template.json @@ -9,7 +9,7 @@ "language": "C#", "type": "item", "wts.type": "feature", - "wts.framework": "MVVMBasic|MVVMLight|CodeBehind", + "wts.framework": "MVVMBasic|MVVMLight|CodeBehind|CaliburnMicro", "wts.version": "1.0.0", "wts.displayOrder": "1", "wts.group": "BackgroundWork", diff --git a/templates/Features/FirstUsePrompt/.template.config/template.json b/templates/Features/FirstUsePrompt/.template.config/template.json index f7a6e4297..1199f89c2 100644 --- a/templates/Features/FirstUsePrompt/.template.config/template.json +++ b/templates/Features/FirstUsePrompt/.template.config/template.json @@ -9,7 +9,7 @@ "language": "C#", "type": "item", "wts.type": "feature", - "wts.framework": "MVVMBasic|MVVMLight|CodeBehind", + "wts.framework": "MVVMBasic|MVVMLight|CodeBehind|CaliburnMicro", "wts.version": "1.0.0", "wts.displayOrder": "5", "wts.group": "UserInteraction", diff --git a/templates/Features/HubNotifications/.template.config/template.json b/templates/Features/HubNotifications/.template.config/template.json index fd562c9b6..2f1bc594d 100644 --- a/templates/Features/HubNotifications/.template.config/template.json +++ b/templates/Features/HubNotifications/.template.config/template.json @@ -11,7 +11,7 @@ "language": "C#", "type": "item", "wts.type": "feature", - "wts.framework": "MVVMBasic|MVVMLight|CodeBehind", + "wts.framework": "MVVMBasic|MVVMLight|CodeBehind|CaliburnMicro", "wts.version": "1.0.0", "wts.displayOrder": "2", "wts.group": "UserInteraction", diff --git a/templates/Features/LiveTile/.template.config/template.json b/templates/Features/LiveTile/.template.config/template.json index b2877f4df..d8720d51a 100644 --- a/templates/Features/LiveTile/.template.config/template.json +++ b/templates/Features/LiveTile/.template.config/template.json @@ -11,7 +11,7 @@ "language": "C#", "type": "item", "wts.type": "feature", - "wts.framework": "MVVMBasic|MVVMLight|CodeBehind", + "wts.framework": "MVVMBasic|MVVMLight|CodeBehind|CaliburnMicro", "wts.version": "1.0.0", "wts.displayOrder": "4", "wts.group": "UserInteraction", diff --git a/templates/Features/SampleData/.template.config/template.json b/templates/Features/SampleData/.template.config/template.json index 0b0a46d20..6a5b132b0 100644 --- a/templates/Features/SampleData/.template.config/template.json +++ b/templates/Features/SampleData/.template.config/template.json @@ -9,7 +9,7 @@ "language": "C#", "type": "item", "wts.type": "feature", - "wts.framework": "MVVMBasic|MVVMLight|CodeBehind", + "wts.framework": "MVVMBasic|MVVMLight|CodeBehind|CaliburnMicro", "wts.version": "1.0.0", "wts.displayOrder": "1", "wts.defaultInstance": "SampleDataService", diff --git a/templates/Features/SettingsStorage/.template.config/template.json b/templates/Features/SettingsStorage/.template.config/template.json index e0d0ae013..8bef03753 100644 --- a/templates/Features/SettingsStorage/.template.config/template.json +++ b/templates/Features/SettingsStorage/.template.config/template.json @@ -9,7 +9,7 @@ "language": "C#", "type": "item", "wts.type": "feature", - "wts.framework": "MVVMBasic|MVVMLight|CodeBehind", + "wts.framework": "MVVMBasic|MVVMLight|CodeBehind|CaliburnMicro", "wts.version": "1.0.0", "wts.displayOrder": "1", "wts.group": "ApplicationLifecycle", diff --git a/templates/Features/SettingsStorage/Helpers/SettingsStorageExtensions.cs b/templates/Features/SettingsStorage/Helpers/SettingsStorageExtensions.cs index eedd68258..a5bd48c24 100644 --- a/templates/Features/SettingsStorage/Helpers/SettingsStorageExtensions.cs +++ b/templates/Features/SettingsStorage/Helpers/SettingsStorageExtensions.cs @@ -66,7 +66,7 @@ namespace Param_ItemNamespace.Helpers if (string.IsNullOrEmpty(fileName)) { - throw new ArgumentException("File name is null or empty. Specify a valid file name", nameof(fileName)); + throw new ArgumentException("ExceptionSettingsStorageExtensionsFileNameIsNullOrEmpty".GetLocalized(), nameof(fileName)); } var storageFile = await folder.CreateFileAsync(fileName, options); diff --git a/templates/Features/SettingsStorage/Strings/en-us/Resources_postaction.resw b/templates/Features/SettingsStorage/Strings/en-us/Resources_postaction.resw new file mode 100644 index 000000000..6fb6f6342 --- /dev/null +++ b/templates/Features/SettingsStorage/Strings/en-us/Resources_postaction.resw @@ -0,0 +1,13 @@ + + + + + + + + + File name is null or empty. Specify a valid file name + File name is null or empty to save file in settings storage extensions + + + diff --git a/templates/Features/StoreNotifications/.template.config/template.json b/templates/Features/StoreNotifications/.template.config/template.json index adf4444e7..8c3ce7a1c 100644 --- a/templates/Features/StoreNotifications/.template.config/template.json +++ b/templates/Features/StoreNotifications/.template.config/template.json @@ -11,7 +11,7 @@ "language": "C#", "type": "item", "wts.type": "feature", - "wts.framework": "MVVMBasic|MVVMLight|CodeBehind", + "wts.framework": "MVVMBasic|MVVMLight|CodeBehind|CaliburnMicro", "wts.version": "1.0.0", "wts.displayOrder": "2", "wts.group": "UserInteraction", diff --git a/templates/Features/SuspendAndResume/.template.config/template.json b/templates/Features/SuspendAndResume/.template.config/template.json index e86ee6b71..81ae65923 100644 --- a/templates/Features/SuspendAndResume/.template.config/template.json +++ b/templates/Features/SuspendAndResume/.template.config/template.json @@ -9,7 +9,7 @@ "language": "C#", "type": "item", "wts.type": "feature", - "wts.framework": "MVVMBasic|MVVMLight|CodeBehind", + "wts.framework": "MVVMBasic|MVVMLight|CodeBehind|CaliburnMicro", "wts.version": "1.0.0", "wts.displayOrder": "2", "wts.group": "ApplicationLifecycle", diff --git a/templates/Features/ToastNotifications/.template.config/template.json b/templates/Features/ToastNotifications/.template.config/template.json index 6d164e9f1..e3e0d62e2 100644 --- a/templates/Features/ToastNotifications/.template.config/template.json +++ b/templates/Features/ToastNotifications/.template.config/template.json @@ -11,7 +11,7 @@ "language": "C#", "type": "item", "wts.type": "feature", - "wts.framework": "MVVMBasic|MVVMLight|CodeBehind", + "wts.framework": "MVVMBasic|MVVMLight|CodeBehind|CaliburnMicro", "wts.version": "1.0.0", "wts.displayOrder": "1", "wts.group": "UserInteraction", diff --git a/templates/Features/ToastNotifications/Activation/DefaultLaunchActivationHandler_postaction.cs b/templates/Features/ToastNotifications/Activation/DefaultLaunchActivationHandler_postaction.cs index 29e105f87..b4c64da31 100644 --- a/templates/Features/ToastNotifications/Activation/DefaultLaunchActivationHandler_postaction.cs +++ b/templates/Features/ToastNotifications/Activation/DefaultLaunchActivationHandler_postaction.cs @@ -3,6 +3,7 @@ //**} //{[{ using Param_RootNamespace.Helpers; +using Param_RootNamespace.Services; //}]} namespace Param_RootNamespace.Activation diff --git a/templates/Features/ToastNotifications/Services/ActivationService_postaction.cs b/templates/Features/ToastNotifications/Services/ActivationService_postaction.cs index 92e69975d..85892e30b 100644 --- a/templates/Features/ToastNotifications/Services/ActivationService_postaction.cs +++ b/templates/Features/ToastNotifications/Services/ActivationService_postaction.cs @@ -6,6 +6,7 @@ using System; //{[{ using Param_RootNamespace.Helpers; +using Param_RootNamespace.Services; //}]} namespace Param_ItemNamespace.Services diff --git a/templates/Features/WhatsNewPrompt/.template.config/template.json b/templates/Features/WhatsNewPrompt/.template.config/template.json index 5fbaacff9..bada48080 100644 --- a/templates/Features/WhatsNewPrompt/.template.config/template.json +++ b/templates/Features/WhatsNewPrompt/.template.config/template.json @@ -9,7 +9,7 @@ "language": "C#", "type": "item", "wts.type": "feature", - "wts.framework": "MVVMBasic|MVVMLight|CodeBehind", + "wts.framework": "MVVMBasic|MVVMLight|CodeBehind|CaliburnMicro", "wts.version": "1.0.0", "wts.displayOrder": "6", "wts.group": "UserInteraction", diff --git a/templates/Pages/Blank/.template.config/template.json b/templates/Pages/Blank/.template.config/template.json index 62b9eda87..2dca58b8b 100644 --- a/templates/Pages/Blank/.template.config/template.json +++ b/templates/Pages/Blank/.template.config/template.json @@ -11,7 +11,7 @@ "language": "C#", "type": "item", "wts.type": "page", - "wts.framework": "MVVMBasic|MVVMLight", + "wts.framework": "MVVMBasic|MVVMLight|CaliburnMicro", "wts.version": "1.0.0", "wts.displayOrder": "1", "wts.genGroup": "0", diff --git a/templates/Pages/Chart/.template.config/template.json b/templates/Pages/Chart/.template.config/template.json index 69d261d8f..38bbc5512 100644 --- a/templates/Pages/Chart/.template.config/template.json +++ b/templates/Pages/Chart/.template.config/template.json @@ -11,7 +11,7 @@ "language": "C#", "type": "item", "wts.type": "page", - "wts.framework": "MVVMBasic|MVVMLight", + "wts.framework": "MVVMBasic|MVVMLight|CaliburnMicro", "wts.version": "1.0.0", "wts.displayOrder": "7", "wts.licenses": "[Telerik.UI-For-UWP](https://github.com/telerik/UI-For-UWP/blob/master/LICENSE.md)", diff --git a/templates/Pages/Grid/.template.config/template.json b/templates/Pages/Grid/.template.config/template.json index 80a938112..d44d6664b 100644 --- a/templates/Pages/Grid/.template.config/template.json +++ b/templates/Pages/Grid/.template.config/template.json @@ -11,7 +11,7 @@ "language": "C#", "type": "item", "wts.type": "page", - "wts.framework": "MVVMBasic|MVVMLight", + "wts.framework": "MVVMBasic|MVVMLight|CaliburnMicro", "wts.version": "1.0.0", "wts.displayOrder": "6", "wts.licenses": "[Telerik.UI-For-UWP](https://github.com/telerik/UI-For-UWP/blob/master/LICENSE.md)", diff --git a/templates/Pages/Map.CaliburnMicro/.template.config/description.md b/templates/Pages/Map.CaliburnMicro/.template.config/description.md new file mode 100644 index 000000000..b1bfa45a9 --- /dev/null +++ b/templates/Pages/Map.CaliburnMicro/.template.config/description.md @@ -0,0 +1 @@ +The map page is based around the Windows Map Control. Code includes adding a Map Icon and getting a location from the Location Service and setting the map's center point. diff --git a/templates/Pages/Map.CaliburnMicro/.template.config/icon.xaml b/templates/Pages/Map.CaliburnMicro/.template.config/icon.xaml new file mode 100644 index 000000000..eff46ce71 --- /dev/null +++ b/templates/Pages/Map.CaliburnMicro/.template.config/icon.xaml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/templates/Pages/Map.CaliburnMicro/.template.config/template.json b/templates/Pages/Map.CaliburnMicro/.template.config/template.json new file mode 100644 index 000000000..223c250c4 --- /dev/null +++ b/templates/Pages/Map.CaliburnMicro/.template.config/template.json @@ -0,0 +1,47 @@ +{ + "author": "Nigel Sampson", + "classifications": [ "Universal" ], + "name": "Map", + "groupIdentity": "wts.Page.Map", + "identity": "wts.Page.Map.CaliburnMicro", + "description": "The map page is based around the Windows Map Control. Code includes adding a Map Icon and getting your location.", + "tags": { + "language": "C#", + "type": "item", + "wts.type": "page", + "wts.framework": "CaliburnMicro", + "wts.version": "1.0.0", + "wts.displayOrder": "9", + "wts.genGroup": "0", + "wts.rightClickEnabled":"true" + }, + "sourceName": "MapPage", + "preferNameDirectory": true, + "PrimaryOutputs": + [ + { "path": ".\\Views\\IMapPageView.cs" }, + { "path": ".\\Views\\MapPagePage.xaml" }, + { "path": ".\\Views\\MapPagePage.xaml.cs" }, + { "path": ".\\ViewModels\\MapPageViewModel.cs" }, + { "path": ".\\Assets\\map.png" }, + { "path": ".\\Services\\LocationService.cs" } + ], + "symbols": { + "wts.rootNamespace": { + "type": "parameter", + "replaces": "Param_RootNamespace" + }, + "wts.itemNamespace": { + "type": "parameter", + "replaces": "Param_ItemNamespace" + }, + "baseclass": { + "type": "parameter", + "replaces": "System.ComponentModel.INotifyPropertyChanged" + }, + "setter": { + "type": "parameter", + "replaces": "Set" + } + } +} diff --git a/templates/Pages/Map.CaliburnMicro/Assets/map.png b/templates/Pages/Map.CaliburnMicro/Assets/map.png new file mode 100644 index 000000000..ea28b5cf9 Binary files /dev/null and b/templates/Pages/Map.CaliburnMicro/Assets/map.png differ diff --git a/templates/Pages/Map.CaliburnMicro/Package_postaction.appxmanifest b/templates/Pages/Map.CaliburnMicro/Package_postaction.appxmanifest new file mode 100644 index 000000000..9e86276ea --- /dev/null +++ b/templates/Pages/Map.CaliburnMicro/Package_postaction.appxmanifest @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/templates/Pages/Map.CaliburnMicro/Services/LocationService.cs b/templates/Pages/Map.CaliburnMicro/Services/LocationService.cs new file mode 100644 index 000000000..79a66794d --- /dev/null +++ b/templates/Pages/Map.CaliburnMicro/Services/LocationService.cs @@ -0,0 +1,123 @@ +using System; +using System.Threading.Tasks; +using Windows.Devices.Geolocation; + +namespace Param_ItemNamespace.Services +{ + public class LocationService + { + private Geolocator geolocator; + + /// + /// Raised when the current position is updated. + /// + public event EventHandler PositionChanged; + + /// + /// Gets the last known recorded position. + /// + public Geoposition CurrentPosition { get; private set; } + + /// + /// Initializes the location service with a default accuracy (100 meters) and movement threshold. + /// + /// True if the initialization was successful and the service can be used. + public Task InitializeAsync() + { + return InitializeAsync(100); + } + + /// + /// Initializes the location service with the specified accuracy and default movement threshold. + /// + /// The desired accuracy at which the service provides location updates. + /// True if the initialization was successful and the service can be used. + public Task InitializeAsync(uint desiredAccuracyInMeters) + { + return InitializeAsync(desiredAccuracyInMeters, (double)desiredAccuracyInMeters / 2); + } + + /// + /// Initializes the location service with the specified accuracy and movement threshold. + /// + /// The desired accuracy at which the service provides location updates. + /// The distance of movement, in meters, that is required for the service to raise the PositionChanged event. + /// True if the initialization was successful and the service can be used. + public async Task InitializeAsync(uint desiredAccuracyInMeters, double movementThreshold) + { + // to find out more about getting location, go to https://docs.microsoft.com/en-us/windows/uwp/maps-and-location/get-location + if (geolocator != null) + { + geolocator.PositionChanged -= GeolocatorOnPositionChanged; + geolocator = null; + } + + var access = await Geolocator.RequestAccessAsync(); + + bool result; + + switch (access) + { + case GeolocationAccessStatus.Allowed: + geolocator = new Geolocator + { + DesiredAccuracyInMeters = desiredAccuracyInMeters, + MovementThreshold = movementThreshold + }; + result = true; + break; + case GeolocationAccessStatus.Unspecified: + case GeolocationAccessStatus.Denied: + default: + result = false; + break; + } + + return result; + } + + /// + /// Starts the service listening for location updates. + /// + /// An object that is used to manage the asynchronous operation. + public async Task StartListeningAsync() + { + if (geolocator == null) + { + throw new InvalidOperationException("The StartListening method cannot be called before the InitializeAsync method."); + } + + geolocator.PositionChanged += GeolocatorOnPositionChanged; + + CurrentPosition = await geolocator.GetGeopositionAsync(); + } + + /// + /// Stops the service listening for location updates. + /// + public void StopListening() + { + if (geolocator == null) + { + return; + } + + geolocator.PositionChanged -= GeolocatorOnPositionChanged; + } + + private async void GeolocatorOnPositionChanged(Geolocator sender, PositionChangedEventArgs args) + { + if (args == null) + { + return; + } + + CurrentPosition = args.Position; + + await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => + { + PositionChanged?.Invoke(this, CurrentPosition); + }); + } + } +} diff --git a/templates/Pages/Map.CaliburnMicro/Strings/en-us/Resources_postaction.resw b/templates/Pages/Map.CaliburnMicro/Strings/en-us/Resources_postaction.resw new file mode 100644 index 000000000..504f2eb24 --- /dev/null +++ b/templates/Pages/Map.CaliburnMicro/Strings/en-us/Resources_postaction.resw @@ -0,0 +1,12 @@ + + + + + + + + + Your location + + + diff --git a/templates/Pages/Map.CaliburnMicro/ViewModels/MapPageViewModel.cs b/templates/Pages/Map.CaliburnMicro/ViewModels/MapPageViewModel.cs new file mode 100644 index 000000000..81c971706 --- /dev/null +++ b/templates/Pages/Map.CaliburnMicro/ViewModels/MapPageViewModel.cs @@ -0,0 +1,111 @@ +using System; +using System.Threading.Tasks; +using System.Windows.Input; +using Windows.Devices.Geolocation; +using Windows.Foundation; +using Windows.Storage.Streams; +using Windows.UI.Xaml.Controls.Maps; +using Param_ItemNamespace.Helpers; +using Param_ItemNamespace.Services; +using Param_ItemNamespace.Views; + +namespace Param_ItemNamespace.ViewModels +{ + public class MapPageViewModel : System.ComponentModel.INotifyPropertyChanged + { + // TODO WTS: Specify your preferred default zoom level + private const double DefaultZoomLevel = 17; + + private readonly LocationService locationService; + + // TODO WTS: Specify your preferred default location if a geolock can't be found. + private readonly BasicGeoposition defaultPosition = new BasicGeoposition() + { + Latitude = 47.609425, + Longitude = -122.3417 + }; + + private double _zoomLevel; + + public double ZoomLevel + { + get { return _zoomLevel; } + set { Set(ref _zoomLevel, value); } + } + + private Geopoint _center; + + public Geopoint Center + { + get { return _center; } + set { Set(ref _center, value); } + } + + private string _mapServiceToken; + + public string MapServiceToken + { + get { return _mapServiceToken; } + set { Set(ref _mapServiceToken, value); } + } + + public MapPageViewModel() + { + locationService = new LocationService(); + Center = new Geopoint(defaultPosition); + ZoomLevel = DefaultZoomLevel; + } + + protected override async void OnActivate() + { + base.OnActivate(); + + if (locationService != null) + { + locationService.PositionChanged += LocationServicePositionChanged; + + var initializationSuccessful = await locationService.InitializeAsync(); + + if (initializationSuccessful) + { + await locationService.StartListeningAsync(); + } + + if (initializationSuccessful && locationService.CurrentPosition != null) + { + Center = locationService.CurrentPosition.Coordinate.Point; + } + else + { + Center = new Geopoint(defaultPosition); + } + } + + // TODO WTS: Specify your map service token. If you don't have one, request at https://www.bingmapsportal.com/ + MapServiceToken = string.Empty; + + var view = GetView() as IMapPageView; + + view?.AddMapIcon(Center, "Map_YourLocation".GetLocalized()); + } + + protected override void OnDeactivate(bool close) + { + base.OnDeactivate(close); + + if (locationService != null) + { + locationService.PositionChanged -= LocationServicePositionChanged; + locationService.StopListening(); + } + } + + private void LocationServicePositionChanged(object sender, Geoposition geoposition) + { + if (geoposition != null) + { + Center = geoposition.Coordinate.Point; + } + } + } +} diff --git a/templates/Pages/Map.CaliburnMicro/Views/IMapPageView.cs b/templates/Pages/Map.CaliburnMicro/Views/IMapPageView.cs new file mode 100644 index 000000000..e2349ab15 --- /dev/null +++ b/templates/Pages/Map.CaliburnMicro/Views/IMapPageView.cs @@ -0,0 +1,10 @@ +using System; +using Windows.Devices.Geolocation; + +namespace Param_ItemNamespace.Views +{ + public interface IMapPageView + { + void AddMapIcon(Geopoint position, string title); + } +} diff --git a/templates/Pages/Map.CaliburnMicro/Views/MapPagePage.xaml b/templates/Pages/Map.CaliburnMicro/Views/MapPagePage.xaml new file mode 100644 index 000000000..9ce896193 --- /dev/null +++ b/templates/Pages/Map.CaliburnMicro/Views/MapPagePage.xaml @@ -0,0 +1,17 @@ + + + + + + + diff --git a/templates/Pages/Map.CaliburnMicro/Views/MapPagePage.xaml.cs b/templates/Pages/Map.CaliburnMicro/Views/MapPagePage.xaml.cs new file mode 100644 index 000000000..2ee1c6b3e --- /dev/null +++ b/templates/Pages/Map.CaliburnMicro/Views/MapPagePage.xaml.cs @@ -0,0 +1,31 @@ +using System; +using Windows.Devices.Geolocation; +using Windows.Foundation; +using Windows.Storage.Streams; +using Windows.UI.Xaml.Controls; +using Windows.UI.Xaml.Controls.Maps; + +namespace Param_ItemNamespace.Views +{ + public sealed partial class MapPagePage : Page, IMapPageView + { + public MapPagePage() + { + InitializeComponent(); + } + + public void AddMapIcon(Geopoint position, string title) + { + var mapIcon = new MapIcon() + { + Location = position, + NormalizedAnchorPoint = new Point(0.5, 1.0), + Title = title, + Image = RandomAccessStreamReference.CreateFromUri(new Uri("ms-appx:///Assets/map.png")), + ZIndex = 0 + }; + + mapControl.MapElements.Add(mapIcon); + } + } +} diff --git a/templates/Pages/Map.CodeBehind/Services/LocationService.cs b/templates/Pages/Map.CodeBehind/Services/LocationService.cs index afac7fb15..79c174821 100644 --- a/templates/Pages/Map.CodeBehind/Services/LocationService.cs +++ b/templates/Pages/Map.CodeBehind/Services/LocationService.cs @@ -1,6 +1,7 @@ using System; using System.Threading.Tasks; using Windows.Devices.Geolocation; +using Param_ItemNamespace.Helpers; namespace Param_ItemNamespace.Services { @@ -84,7 +85,7 @@ namespace Param_ItemNamespace.Services { if (geolocator == null) { - throw new InvalidOperationException("The StartListening method cannot be called before the InitializeAsync method."); + throw new InvalidOperationException("ExceptionLocationServiceStartListeningCanNotBeCalled".GetLocalized()); } geolocator.PositionChanged += Geolocator_PositionChanged; diff --git a/templates/Pages/Map.CodeBehind/Strings/en-us/Resources_postaction.resw b/templates/Pages/Map.CodeBehind/Strings/en-us/Resources_postaction.resw index 1673e7f0a..627caac1c 100644 --- a/templates/Pages/Map.CodeBehind/Strings/en-us/Resources_postaction.resw +++ b/templates/Pages/Map.CodeBehind/Strings/en-us/Resources_postaction.resw @@ -9,5 +9,9 @@ Your location Your location text on map page + + The StartListening method cannot be called before the InitializeAsync method. + Start listening cannot be called before the initialize in location service + diff --git a/templates/Pages/Map/Services/LocationService.cs b/templates/Pages/Map/Services/LocationService.cs index afac7fb15..79c174821 100644 --- a/templates/Pages/Map/Services/LocationService.cs +++ b/templates/Pages/Map/Services/LocationService.cs @@ -1,6 +1,7 @@ using System; using System.Threading.Tasks; using Windows.Devices.Geolocation; +using Param_ItemNamespace.Helpers; namespace Param_ItemNamespace.Services { @@ -84,7 +85,7 @@ namespace Param_ItemNamespace.Services { if (geolocator == null) { - throw new InvalidOperationException("The StartListening method cannot be called before the InitializeAsync method."); + throw new InvalidOperationException("ExceptionLocationServiceStartListeningCanNotBeCalled".GetLocalized()); } geolocator.PositionChanged += Geolocator_PositionChanged; diff --git a/templates/Pages/Map/Strings/en-us/Resources_postaction.resw b/templates/Pages/Map/Strings/en-us/Resources_postaction.resw index 1673e7f0a..627caac1c 100644 --- a/templates/Pages/Map/Strings/en-us/Resources_postaction.resw +++ b/templates/Pages/Map/Strings/en-us/Resources_postaction.resw @@ -9,5 +9,9 @@ Your location Your location text on map page + + The StartListening method cannot be called before the InitializeAsync method. + Start listening cannot be called before the initialize in location service + diff --git a/templates/Pages/MasterDetail.CaliburnMicro/.template.config/description.md b/templates/Pages/MasterDetail.CaliburnMicro/.template.config/description.md new file mode 100644 index 000000000..d98fd62c1 --- /dev/null +++ b/templates/Pages/MasterDetail.CaliburnMicro/.template.config/description.md @@ -0,0 +1,3 @@ +The master-detail page has a master pane and a details pane for content. When an item in the master list is selected, the details pane is updated. This pattern is frequently used for email and address books. + +More information about the master-detail pattern can be found [docs.microsoft.com](https://docs.microsoft.com/en-us/windows/uwp/controls-and-patterns/master-details). diff --git a/templates/Pages/MasterDetail.CaliburnMicro/.template.config/icon.xaml b/templates/Pages/MasterDetail.CaliburnMicro/.template.config/icon.xaml new file mode 100644 index 000000000..003711b0e --- /dev/null +++ b/templates/Pages/MasterDetail.CaliburnMicro/.template.config/icon.xaml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/templates/Pages/MasterDetail.CaliburnMicro/.template.config/template.json b/templates/Pages/MasterDetail.CaliburnMicro/.template.config/template.json new file mode 100644 index 000000000..da3030cdf --- /dev/null +++ b/templates/Pages/MasterDetail.CaliburnMicro/.template.config/template.json @@ -0,0 +1,63 @@ +{ + "author": "Nigel Sampson", + "classifications": [ + "Universal" + ], + "name": "Master/Detail", + "groupIdentity": "wts.Page.MasterDetail", + "identity": "wts.Page.MasterDetail.CaliburnMicro", + "description": "The master-detail page has a master pane and a details pane for content.", + "tags": { + "language": "C#", + "type": "item", + "wts.type": "page", + "wts.framework": "CaliburnMicro", + "wts.version": "1.0.0", + "wts.displayOrder": "5", + "wts.dependencies": "wts.Feat.SampleDataService", + "wts.genGroup": "0", + "wts.rightClickEnabled":"true" + }, + "sourceName": "MasterDetailsItem", + "preferNameDirectory": true, + "PrimaryOutputs": [ + { + "path": ".\\Views\\MasterDetailsItemPage.xaml" + }, + { + "path": ".\\Views\\MasterDetailsItemPage.xaml.cs" + }, + { + "path": ".\\Views\\MasterDetailsItemDetail\\DetailsView.xaml" + }, + { + "path": ".\\Views\\MasterDetailsItemDetail\\DetailsView.xaml.cs" + }, + { + "path": ".\\Views\\MasterDetailsItemDetail\\MasterView.xaml" + }, + { + "path": ".\\Views\\MasterDetailsItemDetail\\MasterView.xaml.cs" + }, + { + "path": ".\\ViewModels\\MasterDetailsItemViewModel.cs" + }, + { + "path": ".\\ViewModels\\MasterDetailsItemDetailViewModel.cs" + } + ], + "symbols": { + "wts.rootNamespace": { + "type": "parameter", + "replaces": "Param_RootNamespace" + }, + "wts.itemNamespace": { + "type": "parameter", + "replaces": "Param_ItemNamespace" + }, + "baseclass": { + "type": "parameter", + "replaces": "System.ComponentModel.INotifyPropertyChanged" + } + } +} diff --git a/templates/Pages/MasterDetail.CaliburnMicro/Strings/en-us/Resources_postaction.resw b/templates/Pages/MasterDetail.CaliburnMicro/Strings/en-us/Resources_postaction.resw new file mode 100644 index 000000000..5eeb20f3b --- /dev/null +++ b/templates/Pages/MasterDetail.CaliburnMicro/Strings/en-us/Resources_postaction.resw @@ -0,0 +1,12 @@ + + + + + + + + + MasterDetailsItem + + + diff --git a/templates/Pages/MasterDetail.CaliburnMicro/ViewModels/MasterDetailsItemDetailViewModel.cs b/templates/Pages/MasterDetail.CaliburnMicro/ViewModels/MasterDetailsItemDetailViewModel.cs new file mode 100644 index 000000000..edb6edde5 --- /dev/null +++ b/templates/Pages/MasterDetail.CaliburnMicro/ViewModels/MasterDetailsItemDetailViewModel.cs @@ -0,0 +1,16 @@ +using System; +using Caliburn.Micro; +using Param_ItemNamespace.Models; + +namespace Param_ItemNamespace.ViewModels +{ + public class MasterDetailsItemDetailViewModel : System.ComponentModel.INotifyPropertyChanged + { + public MasterDetailsItemDetailViewModel(SampleOrder item) + { + Item = item; + } + + public SampleOrder Item { get; } + } +} diff --git a/templates/Pages/MasterDetail.CaliburnMicro/ViewModels/MasterDetailsItemViewModel.cs b/templates/Pages/MasterDetail.CaliburnMicro/ViewModels/MasterDetailsItemViewModel.cs new file mode 100644 index 000000000..4511f1b88 --- /dev/null +++ b/templates/Pages/MasterDetail.CaliburnMicro/ViewModels/MasterDetailsItemViewModel.cs @@ -0,0 +1,29 @@ +using System; +using System.Linq; +using System.Threading.Tasks; +using Caliburn.Micro; +using Param_ItemNamespace.Services; + +namespace Param_ItemNamespace.ViewModels +{ + public class MasterDetailsItemViewModel : Conductor.Collection.OneActive + { + protected override async void OnInitialize() + { + base.OnInitialize(); + + await LoadDataAsync(); + } + + public async Task LoadDataAsync() + { + Items.Clear(); + + var data = await SampleDataService.GetSampleModelDataAsync(); + + Items.AddRange(data.Select(d => new MasterDetailsItemDetailViewModel(d))); + + ActiveItem = Items.First(); + } + } +} diff --git a/templates/Pages/MasterDetail.CaliburnMicro/Views/MasterDetailsItemDetail/DetailsView.xaml b/templates/Pages/MasterDetail.CaliburnMicro/Views/MasterDetailsItemDetail/DetailsView.xaml new file mode 100644 index 000000000..0b770581a --- /dev/null +++ b/templates/Pages/MasterDetail.CaliburnMicro/Views/MasterDetailsItemDetail/DetailsView.xaml @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/templates/Pages/MasterDetail.CaliburnMicro/Views/MasterDetailsItemDetail/DetailsView.xaml.cs b/templates/Pages/MasterDetail.CaliburnMicro/Views/MasterDetailsItemDetail/DetailsView.xaml.cs new file mode 100644 index 000000000..4e8b2931e --- /dev/null +++ b/templates/Pages/MasterDetail.CaliburnMicro/Views/MasterDetailsItemDetail/DetailsView.xaml.cs @@ -0,0 +1,15 @@ +using System; +using Param_ItemNamespace.ViewModels; + +namespace Param_ItemNamespace.Views.MasterDetailsItemDetail +{ + public sealed partial class DetailsView + { + public DetailsView() + { + InitializeComponent(); + } + + public MasterDetailsItemDetailViewModel ViewModel => DataContext as MasterDetailsItemDetailViewModel; + } +} diff --git a/templates/Pages/MasterDetail.CaliburnMicro/Views/MasterDetailsItemDetail/MasterView.xaml b/templates/Pages/MasterDetail.CaliburnMicro/Views/MasterDetailsItemDetail/MasterView.xaml new file mode 100644 index 000000000..889d6218b --- /dev/null +++ b/templates/Pages/MasterDetail.CaliburnMicro/Views/MasterDetailsItemDetail/MasterView.xaml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + diff --git a/templates/Pages/MasterDetail.CaliburnMicro/Views/MasterDetailsItemDetail/MasterView.xaml.cs b/templates/Pages/MasterDetail.CaliburnMicro/Views/MasterDetailsItemDetail/MasterView.xaml.cs new file mode 100644 index 000000000..68113b8b3 --- /dev/null +++ b/templates/Pages/MasterDetail.CaliburnMicro/Views/MasterDetailsItemDetail/MasterView.xaml.cs @@ -0,0 +1,15 @@ +using System; +using Param_ItemNamespace.ViewModels; + +namespace Param_ItemNamespace.Views.MasterDetailsItemDetail +{ + public sealed partial class MasterView + { + public MasterView() + { + InitializeComponent(); + } + + public MasterDetailsItemDetailViewModel ViewModel => DataContext as MasterDetailsItemDetailViewModel; + } +} diff --git a/templates/Pages/MasterDetail.CaliburnMicro/Views/MasterDetailsItemPage.xaml b/templates/Pages/MasterDetail.CaliburnMicro/Views/MasterDetailsItemPage.xaml new file mode 100644 index 000000000..2ae9a02fe --- /dev/null +++ b/templates/Pages/MasterDetail.CaliburnMicro/Views/MasterDetailsItemPage.xaml @@ -0,0 +1,71 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/templates/Pages/MasterDetail.CaliburnMicro/Views/MasterDetailsItemPage.xaml.cs b/templates/Pages/MasterDetail.CaliburnMicro/Views/MasterDetailsItemPage.xaml.cs new file mode 100644 index 000000000..d70b1a7a3 --- /dev/null +++ b/templates/Pages/MasterDetail.CaliburnMicro/Views/MasterDetailsItemPage.xaml.cs @@ -0,0 +1,13 @@ +using System; +using Windows.UI.Xaml.Controls; + +namespace Param_ItemNamespace.Views +{ + public sealed partial class MasterDetailsItemPage : Page + { + public MasterDetailsItemPage() + { + InitializeComponent(); + } + } +} diff --git a/templates/Pages/MasterDetail.CaliburnMicro/_postaction.csproj b/templates/Pages/MasterDetail.CaliburnMicro/_postaction.csproj new file mode 100644 index 000000000..94d14219d --- /dev/null +++ b/templates/Pages/MasterDetail.CaliburnMicro/_postaction.csproj @@ -0,0 +1,6 @@ + + + + 1.5.0 + + diff --git a/templates/Pages/MediaPlayer/.template.config/template.json b/templates/Pages/MediaPlayer/.template.config/template.json index be9a861d3..ac1a5f8c8 100644 --- a/templates/Pages/MediaPlayer/.template.config/template.json +++ b/templates/Pages/MediaPlayer/.template.config/template.json @@ -11,7 +11,7 @@ "language": "C#", "type": "item", "wts.type": "page", - "wts.framework": "MVVMBasic|MVVMLight", + "wts.framework": "MVVMBasic|MVVMLight|CaliburnMicro", "wts.version": "1.0.0", "wts.displayOrder": "4", "wts.genGroup": "0", @@ -42,6 +42,10 @@ "baseclass": { "type": "parameter", "replaces": "System.ComponentModel.INotifyPropertyChanged" + }, + "setter": { + "type": "parameter", + "replaces": "Set" } } } diff --git a/templates/Pages/MediaPlayer/ViewModels/MediaPlayerViewViewModel.cs b/templates/Pages/MediaPlayer/ViewModels/MediaPlayerViewViewModel.cs index 0a7f08b4a..a0aadfe79 100644 --- a/templates/Pages/MediaPlayer/ViewModels/MediaPlayerViewViewModel.cs +++ b/templates/Pages/MediaPlayer/ViewModels/MediaPlayerViewViewModel.cs @@ -7,7 +7,7 @@ namespace Param_ItemNamespace.ViewModels { public class MediaPlayerViewViewModel : System.ComponentModel.INotifyPropertyChanged { - // TODO WTS: Set your video default and image here + // TODO WTS: Specify your video default and image here private const string DefaultSource = "https://sec.ch9.ms/ch9/db15/43c9fbed-535e-4013-8a4a-a74cc00adb15/C9L12WinTemplateStudio_high.mp4"; // The poster image is displayed until the video is started diff --git a/templates/Pages/Settings.CaliburnMicro/.template.config/description.md b/templates/Pages/Settings.CaliburnMicro/.template.config/description.md new file mode 100644 index 000000000..67fe7b1f5 --- /dev/null +++ b/templates/Pages/Settings.CaliburnMicro/.template.config/description.md @@ -0,0 +1 @@ +The settings page is the page where we recommend putting the configuration settings for your application such as setting a dark / light theme. This could also include any licenses, version number and your privacy terms. diff --git a/templates/Pages/Settings.CaliburnMicro/.template.config/icon.xaml b/templates/Pages/Settings.CaliburnMicro/.template.config/icon.xaml new file mode 100644 index 000000000..cd94f3da3 --- /dev/null +++ b/templates/Pages/Settings.CaliburnMicro/.template.config/icon.xaml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/templates/Pages/Settings.CaliburnMicro/.template.config/template.json b/templates/Pages/Settings.CaliburnMicro/.template.config/template.json new file mode 100644 index 000000000..7e0eede91 --- /dev/null +++ b/templates/Pages/Settings.CaliburnMicro/.template.config/template.json @@ -0,0 +1,55 @@ +{ + "author": "Nigel Sampson", + "classifications": [ + "Universal" + ], + "name": "Settings", + "groupIdentity": "wts.Page.Settings", + "identity": "wts.Page.Settings.CaliburnMicro", + "description": "The settings page is the page where we recommend putting the configuration settings for your app.", + "tags": { + "language": "C#", + "type": "item", + "wts.type": "page", + "wts.framework": "CaliburnMicro", + "wts.version": "1.0.0", + "wts.displayOrder": "2", + "wts.dependencies":"wts.Feat.SettingsStorage", + "wts.multipleInstance": "false", + "wts.genGroup": "1", + "wts.rightClickEnabled":"true" + }, + "sourceName": "SettingsPage", + "preferNameDirectory": true, + "PrimaryOutputs": [ + { + "path": ".\\Helpers\\EnumToBooleanConverter.cs" + }, + { + "path": ".\\Views\\SettingsPagePage.xaml" + }, + { + "path": ".\\Views\\SettingsPagePage.xaml.cs" + }, + { + "path": ".\\ViewModels\\SettingsPageViewModel.cs" + }, + { + "path": ".\\Services\\ThemeSelectorService.cs" + } + ], + "symbols": { + "wts.rootNamespace": { + "type": "parameter", + "replaces": "Param_RootNamespace" + }, + "wts.itemNamespace": { + "type": "parameter", + "replaces": "Param_ItemNamespace" + }, + "baseclass": { + "type": "parameter", + "replaces": "System.ComponentModel.INotifyPropertyChanged" + } + } +} diff --git a/templates/Pages/Settings.CaliburnMicro/Helpers/EnumToBooleanConverter.cs b/templates/Pages/Settings.CaliburnMicro/Helpers/EnumToBooleanConverter.cs new file mode 100644 index 000000000..cb828ad26 --- /dev/null +++ b/templates/Pages/Settings.CaliburnMicro/Helpers/EnumToBooleanConverter.cs @@ -0,0 +1,38 @@ +using System; + +using Windows.UI.Xaml.Data; + +namespace Param_RootNamespace.Helpers +{ + public class EnumToBooleanConverter : IValueConverter + { + public Type EnumType { get; set; } + + public object Convert(object value, Type targetType, object parameter, string language) + { + if (parameter is string enumString) + { + if (!Enum.IsDefined(EnumType, value)) + { + throw new ArgumentException("value must be an Enum!"); + } + + var enumValue = Enum.Parse(EnumType, enumString); + + return enumValue.Equals(value); + } + + throw new ArgumentException("parameter must be an Enum name!"); + } + + public object ConvertBack(object value, Type targetType, object parameter, string language) + { + if (parameter is string enumString) + { + return Enum.Parse(EnumType, enumString); + } + + throw new ArgumentException("parameter must be an Enum name!"); + } + } +} \ No newline at end of file diff --git a/templates/Pages/Settings.CaliburnMicro/Services/ActivationService_postaction.cs b/templates/Pages/Settings.CaliburnMicro/Services/ActivationService_postaction.cs new file mode 100644 index 000000000..5c0072c50 --- /dev/null +++ b/templates/Pages/Settings.CaliburnMicro/Services/ActivationService_postaction.cs @@ -0,0 +1,17 @@ +//{** +// These code blocks add the ThemeSelectorService initialization to the ActivationService of your project. +//**} + +private async Task InitializeAsync() +{ + //{[{ + await ThemeSelectorService.InitializeAsync(); + //}]} +} + +private async Task StartupAsync() +{ + //{[{ + ThemeSelectorService.SetRequestedTheme(); + //}]} +} diff --git a/templates/Pages/Settings.CaliburnMicro/Services/ThemeSelectorService.cs b/templates/Pages/Settings.CaliburnMicro/Services/ThemeSelectorService.cs new file mode 100644 index 000000000..cd2e26dd7 --- /dev/null +++ b/templates/Pages/Settings.CaliburnMicro/Services/ThemeSelectorService.cs @@ -0,0 +1,56 @@ +using System; +using System.Threading.Tasks; + +using Windows.Storage; +using Windows.UI.Xaml; + +using Param_RootNamespace.Helpers; + +namespace Param_RootNamespace.Services +{ + public static class ThemeSelectorService + { + private const string SettingsKey = "RequestedTheme"; + + public static ElementTheme Theme { get; set; } = ElementTheme.Default; + + public static async Task InitializeAsync() + { + Theme = await LoadThemeFromSettingsAsync(); + } + + public static async Task SetThemeAsync(ElementTheme theme) + { + Theme = theme; + + SetRequestedTheme(); + await SaveThemeInSettingsAsync(Theme); + } + + public static void SetRequestedTheme() + { + if (Window.Current.Content is FrameworkElement frameworkElement) + { + frameworkElement.RequestedTheme = Theme; + } + } + + private static async Task LoadThemeFromSettingsAsync() + { + ElementTheme cacheTheme = ElementTheme.Default; + string themeName = await ApplicationData.Current.LocalSettings.ReadAsync(SettingsKey); + + if (!string.IsNullOrEmpty(themeName)) + { + Enum.TryParse(themeName, out cacheTheme); + } + + return cacheTheme; + } + + private static async Task SaveThemeInSettingsAsync(ElementTheme theme) + { + await ApplicationData.Current.LocalSettings.SaveAsync(SettingsKey, theme.ToString()); + } + } +} diff --git a/templates/Pages/Settings.CaliburnMicro/Strings/en-us/Resources_postaction.resw b/templates/Pages/Settings.CaliburnMicro/Strings/en-us/Resources_postaction.resw new file mode 100644 index 000000000..64fcb891c --- /dev/null +++ b/templates/Pages/Settings.CaliburnMicro/Strings/en-us/Resources_postaction.resw @@ -0,0 +1,40 @@ + + + + + + + + + SettingsPage + + + Choose Theme + + + Dark + + + Windows default + + + Light + + + About this application + + + Settings page placeholder text. Your app description goes here. + + + Privacy Statement + + + https://YourPrivacyUrlGoesHere/ + + + Personalization + + NavigateUri + + diff --git a/templates/Pages/Settings.CaliburnMicro/ViewModels/SettingsPageViewModel.cs b/templates/Pages/Settings.CaliburnMicro/ViewModels/SettingsPageViewModel.cs new file mode 100644 index 000000000..39d668baf --- /dev/null +++ b/templates/Pages/Settings.CaliburnMicro/ViewModels/SettingsPageViewModel.cs @@ -0,0 +1,55 @@ +using System; +using System.Windows.Input; +using Param_RootNamespace.Services; +using Windows.ApplicationModel; +using Windows.UI.Xaml; + +namespace Param_ItemNamespace.ViewModels +{ + public class SettingsPageViewModel : System.ComponentModel.INotifyPropertyChanged + { + // TODO WTS: Add other settings as necessary. For help see https://github.com/Microsoft/WindowsTemplateStudio/blob/master/docs/pages/settings.md + private ElementTheme _elementTheme = ThemeSelectorService.Theme; + + public ElementTheme ElementTheme + { + get { return _elementTheme; } + + set { Set(ref _elementTheme, value); } + } + + private string _versionDescription; + + public string VersionDescription + { + get { return _versionDescription; } + + set { Set(ref _versionDescription, value); } + } + + public async void SwitchTheme(ElementTheme theme) + { + await ThemeSelectorService.SetThemeAsync(theme); + } + + public SettingsPageViewModel() + { + } + + protected override void OnInitialize() + { + base.OnInitialize(); + + VersionDescription = GetVersionDescription(); + } + + private string GetVersionDescription() + { + var package = Package.Current; + var packageId = package.Id; + var version = packageId.Version; + + return $"{package.DisplayName} - {version.Major}.{version.Minor}.{version.Build}.{version.Revision}"; + } + } +} diff --git a/templates/Pages/Settings.CaliburnMicro/Views/SettingsPagePage.xaml b/templates/Pages/Settings.CaliburnMicro/Views/SettingsPagePage.xaml new file mode 100644 index 000000000..5f97dbf1e --- /dev/null +++ b/templates/Pages/Settings.CaliburnMicro/Views/SettingsPagePage.xaml @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + + + + + + + Light + + + + + Dark + + + + + Default + + + + + + + + + + + + + + + + + diff --git a/templates/Pages/Settings.CaliburnMicro/Views/SettingsPagePage.xaml.cs b/templates/Pages/Settings.CaliburnMicro/Views/SettingsPagePage.xaml.cs new file mode 100644 index 000000000..6427bd069 --- /dev/null +++ b/templates/Pages/Settings.CaliburnMicro/Views/SettingsPagePage.xaml.cs @@ -0,0 +1,15 @@ +using System; +using Windows.UI.Xaml.Controls; + +namespace Param_ItemNamespace.Views +{ + public sealed partial class SettingsPagePage : Page + { + //// TODO WTS: Change the URL for your privacy policy in the Resource File, currently set to https://YourPrivacyUrlGoesHere + + public SettingsPagePage() + { + InitializeComponent(); + } + } +} diff --git a/templates/Pages/Settings.CodeBehind/Helpers/EnumToBooleanConverter.cs b/templates/Pages/Settings.CodeBehind/Helpers/EnumToBooleanConverter.cs index cb828ad26..679096554 100644 --- a/templates/Pages/Settings.CodeBehind/Helpers/EnumToBooleanConverter.cs +++ b/templates/Pages/Settings.CodeBehind/Helpers/EnumToBooleanConverter.cs @@ -14,7 +14,7 @@ namespace Param_RootNamespace.Helpers { if (!Enum.IsDefined(EnumType, value)) { - throw new ArgumentException("value must be an Enum!"); + throw new ArgumentException("ExceptionEnumToBooleanConverterValueMustBeAnEnum".GetLocalized()); } var enumValue = Enum.Parse(EnumType, enumString); @@ -22,7 +22,7 @@ namespace Param_RootNamespace.Helpers return enumValue.Equals(value); } - throw new ArgumentException("parameter must be an Enum name!"); + throw new ArgumentException("ExceptionEnumToBooleanConverterParameterMustBeAnEnumName".GetLocalized()); } public object ConvertBack(object value, Type targetType, object parameter, string language) @@ -32,7 +32,7 @@ namespace Param_RootNamespace.Helpers return Enum.Parse(EnumType, enumString); } - throw new ArgumentException("parameter must be an Enum name!"); + throw new ArgumentException("ExceptionEnumToBooleanConverterParameterMustBeAnEnumName".GetLocalized()); } } } \ No newline at end of file diff --git a/templates/Pages/Settings.CodeBehind/Strings/en-us/Resources_postaction.resw b/templates/Pages/Settings.CodeBehind/Strings/en-us/Resources_postaction.resw index d9ca4eda5..61c6049ba 100644 --- a/templates/Pages/Settings.CodeBehind/Strings/en-us/Resources_postaction.resw +++ b/templates/Pages/Settings.CodeBehind/Strings/en-us/Resources_postaction.resw @@ -45,6 +45,14 @@ Personalization Personalization text for SettingsPage + + value must be an Enum! + Value must be an Enum in enum to boolean converter + + + parameter must be an Enum name! + Parameter must be an Enum name in enum to boolean converter + NavigateUri diff --git a/templates/Pages/Settings.MVVMLight/Helpers/EnumToBooleanConverter.cs b/templates/Pages/Settings.MVVMLight/Helpers/EnumToBooleanConverter.cs index cb828ad26..679096554 100644 --- a/templates/Pages/Settings.MVVMLight/Helpers/EnumToBooleanConverter.cs +++ b/templates/Pages/Settings.MVVMLight/Helpers/EnumToBooleanConverter.cs @@ -14,7 +14,7 @@ namespace Param_RootNamespace.Helpers { if (!Enum.IsDefined(EnumType, value)) { - throw new ArgumentException("value must be an Enum!"); + throw new ArgumentException("ExceptionEnumToBooleanConverterValueMustBeAnEnum".GetLocalized()); } var enumValue = Enum.Parse(EnumType, enumString); @@ -22,7 +22,7 @@ namespace Param_RootNamespace.Helpers return enumValue.Equals(value); } - throw new ArgumentException("parameter must be an Enum name!"); + throw new ArgumentException("ExceptionEnumToBooleanConverterParameterMustBeAnEnumName".GetLocalized()); } public object ConvertBack(object value, Type targetType, object parameter, string language) @@ -32,7 +32,7 @@ namespace Param_RootNamespace.Helpers return Enum.Parse(EnumType, enumString); } - throw new ArgumentException("parameter must be an Enum name!"); + throw new ArgumentException("ExceptionEnumToBooleanConverterParameterMustBeAnEnumName".GetLocalized()); } } } \ No newline at end of file diff --git a/templates/Pages/Settings.MVVMLight/Strings/en-us/Resources_postaction.resw b/templates/Pages/Settings.MVVMLight/Strings/en-us/Resources_postaction.resw index d9ca4eda5..61c6049ba 100644 --- a/templates/Pages/Settings.MVVMLight/Strings/en-us/Resources_postaction.resw +++ b/templates/Pages/Settings.MVVMLight/Strings/en-us/Resources_postaction.resw @@ -45,6 +45,14 @@ Personalization Personalization text for SettingsPage + + value must be an Enum! + Value must be an Enum in enum to boolean converter + + + parameter must be an Enum name! + Parameter must be an Enum name in enum to boolean converter + NavigateUri diff --git a/templates/Pages/Settings/Helpers/EnumToBooleanConverter.cs b/templates/Pages/Settings/Helpers/EnumToBooleanConverter.cs index cb828ad26..679096554 100644 --- a/templates/Pages/Settings/Helpers/EnumToBooleanConverter.cs +++ b/templates/Pages/Settings/Helpers/EnumToBooleanConverter.cs @@ -14,7 +14,7 @@ namespace Param_RootNamespace.Helpers { if (!Enum.IsDefined(EnumType, value)) { - throw new ArgumentException("value must be an Enum!"); + throw new ArgumentException("ExceptionEnumToBooleanConverterValueMustBeAnEnum".GetLocalized()); } var enumValue = Enum.Parse(EnumType, enumString); @@ -22,7 +22,7 @@ namespace Param_RootNamespace.Helpers return enumValue.Equals(value); } - throw new ArgumentException("parameter must be an Enum name!"); + throw new ArgumentException("ExceptionEnumToBooleanConverterParameterMustBeAnEnumName".GetLocalized()); } public object ConvertBack(object value, Type targetType, object parameter, string language) @@ -32,7 +32,7 @@ namespace Param_RootNamespace.Helpers return Enum.Parse(EnumType, enumString); } - throw new ArgumentException("parameter must be an Enum name!"); + throw new ArgumentException("ExceptionEnumToBooleanConverterParameterMustBeAnEnumName".GetLocalized()); } } } \ No newline at end of file diff --git a/templates/Pages/Settings/Strings/en-us/Resources_postaction.resw b/templates/Pages/Settings/Strings/en-us/Resources_postaction.resw index d9ca4eda5..61c6049ba 100644 --- a/templates/Pages/Settings/Strings/en-us/Resources_postaction.resw +++ b/templates/Pages/Settings/Strings/en-us/Resources_postaction.resw @@ -45,6 +45,14 @@ Personalization Personalization text for SettingsPage + + value must be an Enum! + Value must be an Enum in enum to boolean converter + + + parameter must be an Enum name! + Parameter must be an Enum name in enum to boolean converter + NavigateUri diff --git a/templates/Pages/TabbedPivot.CaliburnMicro/.template.config/description.md b/templates/Pages/TabbedPivot.CaliburnMicro/.template.config/description.md new file mode 100644 index 000000000..3702ee497 --- /dev/null +++ b/templates/Pages/TabbedPivot.CaliburnMicro/.template.config/description.md @@ -0,0 +1,3 @@ +The tabbed page is used for navigating frequently accessed, distinct content categories. Pivots allow for navigation between two or more content panes and relies on text headers to articulate the different sections of content. + +To find out more if this is a good solution for you, head to [docs.microsoft.com](https://docs.microsoft.com/en-us/windows/uwp/controls-and-patterns/tabs-pivot). diff --git a/templates/Pages/TabbedPivot.CaliburnMicro/.template.config/icon.xaml b/templates/Pages/TabbedPivot.CaliburnMicro/.template.config/icon.xaml new file mode 100644 index 000000000..1356cbf05 --- /dev/null +++ b/templates/Pages/TabbedPivot.CaliburnMicro/.template.config/icon.xaml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/templates/Pages/TabbedPivot.CaliburnMicro/.template.config/template.json b/templates/Pages/TabbedPivot.CaliburnMicro/.template.config/template.json new file mode 100644 index 000000000..60386a4a6 --- /dev/null +++ b/templates/Pages/TabbedPivot.CaliburnMicro/.template.config/template.json @@ -0,0 +1,56 @@ +{ + "author": "Nigel Sampson", + "classifications": [ + "Universal" + ], + "name": "Tabbed", + "groupIdentity": "wts.Page.TabbedPivot", + "identity": "wts.Page.TabbedPivot.CaliburnMicro", + "description": "The tabbed page is used for navigating frequently accessed, distinct content categories.", + "tags": { + "language": "C#", + "type": "item", + "wts.type": "page", + "wts.framework": "CaliburnMicro", + "wts.version": "1.0.0", + "wts.displayOrder": "8", + "wts.genGroup": "0", + "wts.rightClickEnabled":"true" + }, + "sourceName": "TabbedPivotPage", + "preferNameDirectory": true, + "PrimaryOutputs": [ + { + "path": ".\\Views\\TabbedPivotPagePage.xaml" + }, + { + "path": ".\\Views\\TabbedPivotPagePage.xaml.cs" + }, + { + "path": ".\\ViewModels\\TabbedPivotPageViewModel.cs" + }, + { + "path": ".\\Views\\ExampleTabPage.xaml" + }, + { + "path": ".\\Views\\ExampleTabPage.xaml.cs" + }, + { + "path": ".\\ViewModels\\ExampleTabViewModel.cs" + } + ], + "symbols": { + "wts.rootNamespace": { + "type": "parameter", + "replaces": "Param_RootNamespace" + }, + "wts.itemNamespace": { + "type": "parameter", + "replaces": "Param_ItemNamespace" + }, + "baseclass": { + "type": "parameter", + "replaces": "System.ComponentModel.INotifyPropertyChanged" + } + } +} diff --git a/templates/Pages/TabbedPivot.CaliburnMicro/Strings/en-us/Resources_postaction.resw b/templates/Pages/TabbedPivot.CaliburnMicro/Strings/en-us/Resources_postaction.resw new file mode 100644 index 000000000..85812612b --- /dev/null +++ b/templates/Pages/TabbedPivot.CaliburnMicro/Strings/en-us/Resources_postaction.resw @@ -0,0 +1,18 @@ + + + + + + + + + TabbedPivotPage + + + Example Tab 1 + + + Example Tab 2 + + + diff --git a/templates/Pages/TabbedPivot.CaliburnMicro/ViewModels/ExampleTabViewModel.cs b/templates/Pages/TabbedPivot.CaliburnMicro/ViewModels/ExampleTabViewModel.cs new file mode 100644 index 000000000..781d1e796 --- /dev/null +++ b/templates/Pages/TabbedPivot.CaliburnMicro/ViewModels/ExampleTabViewModel.cs @@ -0,0 +1,12 @@ +using System; +using Caliburn.Micro; + +namespace Param_ItemNamespace.ViewModels +{ + public class ExampleTabViewModel : Screen + { + public ExampleTabViewModel() + { + } + } +} diff --git a/templates/Pages/TabbedPivot.CaliburnMicro/ViewModels/TabbedPivotPageViewModel.cs b/templates/Pages/TabbedPivot.CaliburnMicro/ViewModels/TabbedPivotPageViewModel.cs new file mode 100644 index 000000000..1e001229c --- /dev/null +++ b/templates/Pages/TabbedPivot.CaliburnMicro/ViewModels/TabbedPivotPageViewModel.cs @@ -0,0 +1,22 @@ +using System; +using Caliburn.Micro; +using Param_ItemNamespace.Helpers; + +namespace Param_ItemNamespace.ViewModels +{ + public class TabbedPivotPageViewModel : Conductor.Collection.OneActive + { + public TabbedPivotPageViewModel() + { + } + + protected override void OnInitialize() + { + base.OnInitialize(); + + // WTS Add view models to the Items collection to display them in the Tabs + Items.Add(new ExampleTabViewModel { DisplayName = "TabbedPivotPageExampleTabPage1_DisplayName".GetLocalized() }); + Items.Add(new ExampleTabViewModel { DisplayName = "TabbedPivotPageExampleTabPage1_DisplayName".GetLocalized() }); + } + } +} diff --git a/templates/Pages/TabbedPivot.CaliburnMicro/Views/ExampleTabPage.xaml b/templates/Pages/TabbedPivot.CaliburnMicro/Views/ExampleTabPage.xaml new file mode 100644 index 000000000..16c682b69 --- /dev/null +++ b/templates/Pages/TabbedPivot.CaliburnMicro/Views/ExampleTabPage.xaml @@ -0,0 +1,13 @@ + + + + + + diff --git a/templates/Pages/TabbedPivot.CaliburnMicro/Views/ExampleTabPage.xaml.cs b/templates/Pages/TabbedPivot.CaliburnMicro/Views/ExampleTabPage.xaml.cs new file mode 100644 index 000000000..198068c7d --- /dev/null +++ b/templates/Pages/TabbedPivot.CaliburnMicro/Views/ExampleTabPage.xaml.cs @@ -0,0 +1,13 @@ +using System; +using Windows.UI.Xaml.Controls; + +namespace Param_ItemNamespace.Views +{ + public sealed partial class ExampleTabPage : Page + { + public ExampleTabPage() + { + InitializeComponent(); + } + } +} diff --git a/templates/Pages/TabbedPivot.CaliburnMicro/Views/TabbedPivotPagePage.xaml b/templates/Pages/TabbedPivot.CaliburnMicro/Views/TabbedPivotPagePage.xaml new file mode 100644 index 000000000..0e57ebe90 --- /dev/null +++ b/templates/Pages/TabbedPivot.CaliburnMicro/Views/TabbedPivotPagePage.xaml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/templates/Pages/TabbedPivot.CaliburnMicro/Views/TabbedPivotPagePage.xaml.cs b/templates/Pages/TabbedPivot.CaliburnMicro/Views/TabbedPivotPagePage.xaml.cs new file mode 100644 index 000000000..9e36bbf25 --- /dev/null +++ b/templates/Pages/TabbedPivot.CaliburnMicro/Views/TabbedPivotPagePage.xaml.cs @@ -0,0 +1,13 @@ +using System; +using Windows.UI.Xaml.Controls; + +namespace Param_ItemNamespace.Views +{ + public sealed partial class TabbedPivotPagePage : Page + { + public TabbedPivotPagePage() + { + InitializeComponent(); + } + } +} diff --git a/templates/Pages/WebView.CaliburnMicro/.template.config/description.md b/templates/Pages/WebView.CaliburnMicro/.template.config/description.md new file mode 100644 index 000000000..e04d2f5b9 --- /dev/null +++ b/templates/Pages/WebView.CaliburnMicro/.template.config/description.md @@ -0,0 +1,3 @@ +The web view page embeds a view into your app that renders web content using the Microsoft Edge rendering engine. Hyperlinks can also appear and function in a web view control. You can use a web view control to display richly formatted HTML content from a remote web server, dynamically generated code, or content files in your app package. Rich content can also contain script code and communicate between the script and your app's code. + +To find out more if this is a good solution for you, head to [docs.microsoft.com](https://docs.microsoft.com/en-us/windows/uwp/controls-and-patterns/web-view). diff --git a/templates/Pages/WebView.CaliburnMicro/.template.config/icon.xaml b/templates/Pages/WebView.CaliburnMicro/.template.config/icon.xaml new file mode 100644 index 000000000..64a198a3a --- /dev/null +++ b/templates/Pages/WebView.CaliburnMicro/.template.config/icon.xaml @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/templates/Pages/WebView.CaliburnMicro/.template.config/template.json b/templates/Pages/WebView.CaliburnMicro/.template.config/template.json new file mode 100644 index 000000000..52b027353 --- /dev/null +++ b/templates/Pages/WebView.CaliburnMicro/.template.config/template.json @@ -0,0 +1,47 @@ +{ + "author": "Nigel Sampson", + "classifications": [ + "Universal" + ], + "name": "Web View", + "groupIdentity": "wts.Page.WebView", + "identity": "wts.Page.WebView.CaliburnMicro", + "description": "The web view page embeds a view into your app that renders web content using the Microsoft Edge rendering engine.", + "tags": { + "language": "C#", + "type": "item", + "wts.type": "page", + "wts.framework": "CaliburnMicro", + "wts.version": "1.0.0", + "wts.displayOrder": "3", + "wts.rightClickEnabled":"true", + "wts.genGroup": "0" + }, + "sourceName": "WebViewPage", + "preferNameDirectory": true, + "PrimaryOutputs": [ + { + "path": ".\\Views\\WebViewPagePage.xaml" + }, + { + "path": ".\\Views\\WebViewPagePage.xaml.cs" + }, + { + "path": ".\\ViewModels\\WebViewPageViewModel.cs" + } + ], + "symbols": { + "wts.rootNamespace": { + "type": "parameter", + "replaces": "Param_RootNamespace" + }, + "wts.itemNamespace": { + "type": "parameter", + "replaces": "Param_ItemNamespace" + }, + "baseclass": { + "type": "parameter", + "replaces": "System.ComponentModel.INotifyPropertyChanged" + } + } +} diff --git a/templates/Pages/WebView.CaliburnMicro/Strings/en-us/Resources_postaction.resw b/templates/Pages/WebView.CaliburnMicro/Strings/en-us/Resources_postaction.resw new file mode 100644 index 000000000..20176490d --- /dev/null +++ b/templates/Pages/WebView.CaliburnMicro/Strings/en-us/Resources_postaction.resw @@ -0,0 +1,42 @@ + + + + + + + + + Page failed to load. Check connection and retry. + + + Loading... + + + retry + + + Back + + + Back + + + Forward + + + Forward + + + Refresh + + + Refresh + + + Open in browser + + + Open in browser + + + diff --git a/templates/Pages/WebView.CaliburnMicro/ViewModels/WebViewPageViewModel.cs b/templates/Pages/WebView.CaliburnMicro/ViewModels/WebViewPageViewModel.cs new file mode 100644 index 000000000..f02c3e211 --- /dev/null +++ b/templates/Pages/WebView.CaliburnMicro/ViewModels/WebViewPageViewModel.cs @@ -0,0 +1,131 @@ +using System; +using System.Windows.Input; +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; +using Param_ItemNamespace.Helpers; +using Caliburn.Micro; + +namespace Param_ItemNamespace.ViewModels +{ + public class WebViewPageViewModel : Screen + { + // TODO WTS: Specify your hyperlink default here + private const string DefaultUrl = "https://developer.microsoft.com/en-us/windows/apps"; + + private Uri _source; + + public Uri Source + { + get { return _source; } + set { Set(ref _source, value); } + } + + private bool _isLoading; + + public bool IsLoading + { + get + { + return _isLoading; + } + + set + { + if (value) + { + IsShowingFailedMessage = false; + } + + Set(ref _isLoading, value); + IsLoadingVisibility = value ? Visibility.Visible : Visibility.Collapsed; + } + } + + private Visibility _isLoadingVisibility; + + public Visibility IsLoadingVisibility + { + get { return _isLoadingVisibility; } + set { Set(ref _isLoadingVisibility, value); } + } + + private bool _isShowingFailedMessage; + + public bool IsShowingFailedMessage + { + get + { + return _isShowingFailedMessage; + } + + set + { + if (value) + { + IsLoading = false; + } + + Set(ref _isShowingFailedMessage, value); + FailedMesageVisibility = value ? Visibility.Visible : Visibility.Collapsed; + } + } + + private Visibility _failedMesageVisibility; + + public Visibility FailedMesageVisibility + { + get { return _failedMesageVisibility; } + set { Set(ref _failedMesageVisibility, value); } + } + + public void NavCompleted(WebViewNavigationCompletedEventArgs e) + { + IsLoading = false; + + NotifyOfPropertyChange(() => CanGoBack); + NotifyOfPropertyChange(() => CanGoForward); + } + + public void NavFailed(WebViewNavigationFailedEventArgs e) + { + // Use `e.WebErrorStatus` to vary the displayed message based on the error reason + IsShowingFailedMessage = true; + + NotifyOfPropertyChange(() => CanGoBack); + NotifyOfPropertyChange(() => CanGoForward); + } + + public void Retry() + { + IsShowingFailedMessage = false; + IsLoading = true; + + _webView?.Refresh(); + } + + public void GoBack() => _webView?.GoBack(); + + public bool CanGoBack => _webView?.CanGoBack ?? false; + + public void GoForward() => _webView?.GoForward(); + + public bool CanGoForward => _webView?.CanGoForward ?? false; + + public void RefreshBrowser() => _webView?.Refresh(); + + public async void OpenInBrowser() => await Windows.System.Launcher.LaunchUriAsync(Source); + + private WebView _webView; + + public WebViewPageViewModel() + { + IsLoading = true; + Source = new Uri(DefaultUrl); + } + + public void Initialize(WebView webView) + { + _webView = webView; + } + } +} diff --git a/templates/Pages/WebView.CaliburnMicro/Views/WebViewPagePage.xaml b/templates/Pages/WebView.CaliburnMicro/Views/WebViewPagePage.xaml new file mode 100644 index 000000000..cb65840b5 --- /dev/null +++ b/templates/Pages/WebView.CaliburnMicro/Views/WebViewPagePage.xaml @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/templates/Pages/WebView.CaliburnMicro/Views/WebViewPagePage.xaml.cs b/templates/Pages/WebView.CaliburnMicro/Views/WebViewPagePage.xaml.cs new file mode 100644 index 000000000..ef5720ee7 --- /dev/null +++ b/templates/Pages/WebView.CaliburnMicro/Views/WebViewPagePage.xaml.cs @@ -0,0 +1,15 @@ +using System; +using Windows.UI.Xaml.Controls; + +namespace Param_ItemNamespace.Views +{ + public sealed partial class WebViewPagePage : Page + { + public WebViewPagePage() + { + InitializeComponent(); + + Loaded += (s, e) => ViewModel.Initialize(webView); + } + } +} diff --git a/templates/Projects/Default/.template.config/template.json b/templates/Projects/Default/.template.config/template.json index 29f5ad319..0d0077426 100644 --- a/templates/Projects/Default/.template.config/template.json +++ b/templates/Projects/Default/.template.config/template.json @@ -9,7 +9,7 @@ "language": "C#", "type": "project", "wts.type": "project", - "wts.framework": "MVVMBasic|MVVMLight|CodeBehind", + "wts.framework": "MVVMBasic|MVVMLight|CodeBehind|CaliburnMicro", "wts.projecttype":"Blank|SplitView|TabbedPivot", "wts.version": "1.0.0", "wts.displayOrder": "1" @@ -60,4 +60,4 @@ } } } -} +} \ No newline at end of file diff --git a/templates/_catalog/frameworks.json b/templates/_catalog/frameworks.json index 03877ac64..c3d405001 100644 --- a/templates/_catalog/frameworks.json +++ b/templates/_catalog/frameworks.json @@ -24,6 +24,15 @@ "author": "Microsoft", "order": "1", "licenses": "", - "languages": [ "C#", "VisualBasic" ] + "languages": [ "C#", "VisualBasic" ] + }, + { + "name": "CaliburnMicro", + "displayName": "Caliburn.Micro", + "summary": "Caliburn.Micro is a popular MVVM framework emphasising conventions and composability.", + "author": "Nigel Sampson", + "order": "4", + "licenses": "[Caliburn.Micro](https://github.com/Caliburn-Micro/Caliburn.Micro/blob/master/License.txt)", + "languages": [ "C#" ] } ] diff --git a/templates/_catalog/frameworks/CaliburnMicro.md b/templates/_catalog/frameworks/CaliburnMicro.md new file mode 100644 index 000000000..a2eafcdc2 --- /dev/null +++ b/templates/_catalog/frameworks/CaliburnMicro.md @@ -0,0 +1,3 @@ +Caliburn.Micro is a popular, 3rd party framework based on the [Model-View-ViewModel pattern](https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93viewmodel). The framework helps you to separate your View from your Model which creates applications that are cleaner and easier to maintain and extend. It also creates testable applications and allows you to have a much thinner user interface layer (which is more difficult to test automatically). + +You can find more out at [Caliburn.Micro's homepage](http://caliburnmicro.com/) diff --git a/templates/_catalog/frameworks/CaliburnMicro.png b/templates/_catalog/frameworks/CaliburnMicro.png new file mode 100644 index 000000000..65635ea8f Binary files /dev/null and b/templates/_catalog/frameworks/CaliburnMicro.png differ diff --git a/templates/_composition/CaliburnMicro/Feature.BackgroundTask.AddOnBackgroundNavigated/.template.config/template.json b/templates/_composition/CaliburnMicro/Feature.BackgroundTask.AddOnBackgroundNavigated/.template.config/template.json new file mode 100644 index 000000000..6ec7ab537 --- /dev/null +++ b/templates/_composition/CaliburnMicro/Feature.BackgroundTask.AddOnBackgroundNavigated/.template.config/template.json @@ -0,0 +1,28 @@ +{ + "author": "Microsoft", + "classifications": [ + "Universal" + ], + "name": "CaliburnMicro.Feature.BackgroundTask.AddOnBackgroundNavigated", + "tags": { + "language": "C#", + "type": "item", + "wts.type": "composition", + "wts.version": "1.0.0", + "wts.compositionFilter": "$framework == CaliburnMicro & identity == wts.Feat.BackgroundTask" + }, + "sourceName": "wts.ItemName", + "preferNameDirectory": true, + "PrimaryOutputs": [ + ], + "symbols": { + "wts.rootNamespace": { + "type": "parameter", + "replaces": "Param_RootNamespace" + }, + "wts.itemNamespace": { + "type": "parameter", + "replaces": "Param_ItemNamespace" + } + } +} diff --git a/templates/_composition/CaliburnMicro/Feature.BackgroundTask.AddOnBackgroundNavigated/App_postaction.xaml.cs b/templates/_composition/CaliburnMicro/Feature.BackgroundTask.AddOnBackgroundNavigated/App_postaction.xaml.cs new file mode 100644 index 000000000..77291e686 --- /dev/null +++ b/templates/_composition/CaliburnMicro/Feature.BackgroundTask.AddOnBackgroundNavigated/App_postaction.xaml.cs @@ -0,0 +1,17 @@ +//{** +// This code block adds the OnBackgroundActivated event handler to the App class of your project. +//**} +namespace Param_RootNamespace +{ + public sealed partial class App + { +//^^ +//{[{ + + protected override async void OnBackgroundActivated(BackgroundActivatedEventArgs args) + { + await ActivationService.ActivateAsync(args); + } +//}]} + } +} diff --git a/templates/_composition/CaliburnMicro/Feature.SuspendAndResume.AddNavigation/.template.config/template.json b/templates/_composition/CaliburnMicro/Feature.SuspendAndResume.AddNavigation/.template.config/template.json new file mode 100644 index 000000000..99397e79e --- /dev/null +++ b/templates/_composition/CaliburnMicro/Feature.SuspendAndResume.AddNavigation/.template.config/template.json @@ -0,0 +1,28 @@ +{ + "author": "Nigel Sampson", + "classifications": [ + "Universal" + ], + "name": "CaliburnMicro.Feature.SuspendAndResume.AddNavigation", + "tags": { + "language": "C#", + "type": "item", + "wts.type": "composition", + "wts.version": "1.0.0", + "wts.compositionFilter": "$framework == CaliburnMicro & identity == wts.Feat.SuspendAndResume" + }, + "sourceName": "wts.ItemName", + "preferNameDirectory": true, + "PrimaryOutputs": [ + ], + "symbols": { + "wts.rootNamespace": { + "type": "parameter", + "replaces": "Param_RootNamespace" + }, + "wts.itemNamespace": { + "type": "parameter", + "replaces": "Param_ItemNamespace" + } + } +} diff --git a/templates/_composition/CaliburnMicro/Feature.SuspendAndResume.AddNavigation/Services/SuspendAndResumeService_postaction.cs b/templates/_composition/CaliburnMicro/Feature.SuspendAndResume.AddNavigation/Services/SuspendAndResumeService_postaction.cs new file mode 100644 index 000000000..13e755a37 --- /dev/null +++ b/templates/_composition/CaliburnMicro/Feature.SuspendAndResume.AddNavigation/Services/SuspendAndResumeService_postaction.cs @@ -0,0 +1,20 @@ +//{[{ +using Caliburn.Micro; +//}]} +namespace Param_ItemNamespace.Services +{ + internal class SuspendAndResumeService : ActivationHandler + { + private async Task RestoreStateAsync() + { + //^^ + //{[{ + if (saveState?.Target != null) + { + var navigationService = IoC.Get(); + navigationService.NavigateToViewModel(saveState.Target, saveState.SuspensionState); + } + //}]} + } + } +} diff --git a/templates/_composition/CaliburnMicro/Feature.SuspendAndResume.AddOnBackgroundEntered/.template.config/template.json b/templates/_composition/CaliburnMicro/Feature.SuspendAndResume.AddOnBackgroundEntered/.template.config/template.json new file mode 100644 index 000000000..e1e264b4f --- /dev/null +++ b/templates/_composition/CaliburnMicro/Feature.SuspendAndResume.AddOnBackgroundEntered/.template.config/template.json @@ -0,0 +1,28 @@ +{ + "author": "Microsoft", + "classifications": [ + "Universal" + ], + "name": "CaliburnMicro.Feature.SuspendAndResume.AddOnBackgroundEntered", + "tags": { + "language": "C#", + "type": "item", + "wts.type": "composition", + "wts.version": "1.0.0", + "wts.compositionFilter": "$framework == CaliburnMicro & identity == wts.Feat.SuspendAndResume" + }, + "sourceName": "wts.ItemName", + "preferNameDirectory": true, + "PrimaryOutputs": [ + ], + "symbols": { + "wts.rootNamespace": { + "type": "parameter", + "replaces": "Param_RootNamespace" + }, + "wts.itemNamespace": { + "type": "parameter", + "replaces": "Param_ItemNamespace" + } + } +} diff --git a/templates/_composition/CaliburnMicro/Feature.SuspendAndResume.AddOnBackgroundEntered/App_postaction.xaml.cs b/templates/_composition/CaliburnMicro/Feature.SuspendAndResume.AddOnBackgroundEntered/App_postaction.xaml.cs new file mode 100644 index 000000000..7d8c4209e --- /dev/null +++ b/templates/_composition/CaliburnMicro/Feature.SuspendAndResume.AddOnBackgroundEntered/App_postaction.xaml.cs @@ -0,0 +1,34 @@ +//{** +//This code block adds the subscription to `App_EnteredBackground` to the App class of your project. +//**} + +using System; + +//{[{ +using Windows.ApplicationModel; +//}]} + +namespace Param_RootNamespace +{ + public sealed partial class App + { + public App() + { + InitializeComponent(); + +//{[{ + EnteredBackground += App_EnteredBackground; +//}]} + } +//^^ +//{[{ + + private async void App_EnteredBackground(object sender, EnteredBackgroundEventArgs e) + { + var deferral = e.GetDeferral(); + await Helpers.Singleton.Instance.SaveStateAsync(); + deferral.Complete(); + } +//}]} + } +} diff --git a/templates/_composition/CaliburnMicro/Page.AddViewModel/.template.config/template.json b/templates/_composition/CaliburnMicro/Page.AddViewModel/.template.config/template.json new file mode 100644 index 000000000..ccdd5d736 --- /dev/null +++ b/templates/_composition/CaliburnMicro/Page.AddViewModel/.template.config/template.json @@ -0,0 +1,30 @@ +{ + "author": "Nigel Sampson", + "classifications": [ + "Universal" + ], + "name": "CaliburnMicro.Page.AddViewModel", + "tags": { + "language": "C#", + "type": "item", + "wts.type": "composition", + "wts.version": "1.0.0", + "wts.compositionFilter": "$framework == CaliburnMicro & wts.type==page", + "wts.export.baseclass": "Screen", + "wts.export.setter": "Set" + }, + "sourceName": "wts.ItemName", + "preferNameDirectory": true, + "PrimaryOutputs": [ + ], + "symbols": { + "wts.rootNamespace": { + "type": "parameter", + "replaces": "Param_RootNamespace" + }, + "wts.itemNamespace": { + "type": "parameter", + "replaces": "Param_ItemNamespace" + } + } +} diff --git a/templates/_composition/CaliburnMicro/Page.AddViewModel/App_postaction.xaml.cs b/templates/_composition/CaliburnMicro/Page.AddViewModel/App_postaction.xaml.cs new file mode 100644 index 000000000..796b6fcdf --- /dev/null +++ b/templates/_composition/CaliburnMicro/Page.AddViewModel/App_postaction.xaml.cs @@ -0,0 +1,17 @@ +//{[{ +using Param_RootNamespace.ViewModels; +//}]} + +namespace Param_ItemNamespace +{ + public sealed partial class App + { + protected override void Configure() + { + //^^ + //{[{ + _container.PerRequest(); + //}]} + } + } +} diff --git a/templates/_composition/CaliburnMicro/Page.AddViewModel/ViewModels/wts.ItemNameViewModel_postaction.cs b/templates/_composition/CaliburnMicro/Page.AddViewModel/ViewModels/wts.ItemNameViewModel_postaction.cs new file mode 100644 index 000000000..a681a8533 --- /dev/null +++ b/templates/_composition/CaliburnMicro/Page.AddViewModel/ViewModels/wts.ItemNameViewModel_postaction.cs @@ -0,0 +1,8 @@ +//{[{ +using Caliburn.Micro; +using Param_RootNamespace.Helpers; +//}]} + +namespace Param_ItemNamespace.ViewModels +{ +} diff --git a/templates/_composition/CaliburnMicro/Page.AddViewModel/Views/wts.ItemNamePage_postaction.xaml.cs b/templates/_composition/CaliburnMicro/Page.AddViewModel/Views/wts.ItemNamePage_postaction.xaml.cs new file mode 100644 index 000000000..766055e47 --- /dev/null +++ b/templates/_composition/CaliburnMicro/Page.AddViewModel/Views/wts.ItemNamePage_postaction.xaml.cs @@ -0,0 +1,17 @@ +//{[{ +using Param_ItemNamespace.ViewModels; +//}]} +namespace Param_ItemNamespace.Views +{ + public wts.ItemNamePage() + { + InitializeComponent(); + } + + //{[{ + private wts.ItemNameViewModel ViewModel + { + get { return DataContext as wts.ItemNameViewModel; } + } + //}]} +} diff --git a/templates/_composition/CaliburnMicro/Project.Blank.AddNavigation/.template.config/template.json b/templates/_composition/CaliburnMicro/Project.Blank.AddNavigation/.template.config/template.json new file mode 100644 index 000000000..520733095 --- /dev/null +++ b/templates/_composition/CaliburnMicro/Project.Blank.AddNavigation/.template.config/template.json @@ -0,0 +1,30 @@ +{ + "author": "Nigel Sampson", + "classifications": [ + "Universal" + ], + "name": "CaliburnMicro.Project.Blank.AddNavigation", + "tags": { + "language": "C#", + "type": "item", + "wts.type": "composition", + "wts.version": "1.0.0", + "wts.compositionFilter": "$framework == CaliburnMicro & $projectType == Blank & wts.type == project" + }, + "sourceName": "wts.ItemName", + "preferNameDirectory": true, + "symbols": { + "wts.rootNamespace": { + "type": "parameter", + "replaces": "Param_RootNamespace" + }, + "wts.itemNamespace": { + "type": "parameter", + "replaces": "Param_ItemNamespace" + }, + "wts.homePageName": { + "type":"parameter", + "replaces":"Param_HomeName" + } + } +} diff --git a/templates/_composition/CaliburnMicro/Project.Blank.AddNavigation/App_postaction.xaml.cs b/templates/_composition/CaliburnMicro/Project.Blank.AddNavigation/App_postaction.xaml.cs new file mode 100644 index 000000000..a941a7cba --- /dev/null +++ b/templates/_composition/CaliburnMicro/Project.Blank.AddNavigation/App_postaction.xaml.cs @@ -0,0 +1,14 @@ +namespace Param_ItemNamespace +{ + public sealed partial class App + { +//^^ +//{[{ + + private ActivationService CreateActivationService() + { + return new ActivationService(_container, typeof(ViewModels.Param_HomeNameViewModel)); + } +//}]} + } +} \ No newline at end of file diff --git a/templates/_composition/CaliburnMicro/Project.SplitView.AddToPrimaryNavigationItems/.template.config/template.json b/templates/_composition/CaliburnMicro/Project.SplitView.AddToPrimaryNavigationItems/.template.config/template.json new file mode 100644 index 000000000..42dcfa1c5 --- /dev/null +++ b/templates/_composition/CaliburnMicro/Project.SplitView.AddToPrimaryNavigationItems/.template.config/template.json @@ -0,0 +1,28 @@ +{ + "author": "Nigel Sampson", + "classifications": [ + "Universal" + ], + "name": "CaliburnMicro.Project.SplitView.AddToPrimaryNavigationItems", + "tags": { + "language": "C#", + "type": "item", + "wts.type": "composition", + "wts.version": "1.0.0", + "wts.compositionFilter": "wts.type == page & groupidentity != wts.Page.Settings & $framework == CaliburnMicro & $projectType == SplitView" + }, + "sourceName": "wts.ItemName", + "preferNameDirectory": true, + "PrimaryOutputs": [ + ], + "symbols": { + "wts.rootNamespace": { + "type": "parameter", + "replaces": "Param_RootNamespace" + }, + "wts.itemNamespace": { + "type": "parameter", + "replaces": "Param_ItemNamespace" + } + } +} diff --git a/templates/_composition/CaliburnMicro/Project.SplitView.AddToPrimaryNavigationItems/ViewModels/ShellViewModel_postaction.cs b/templates/_composition/CaliburnMicro/Project.SplitView.AddToPrimaryNavigationItems/ViewModels/ShellViewModel_postaction.cs new file mode 100644 index 000000000..ea0d05724 --- /dev/null +++ b/templates/_composition/CaliburnMicro/Project.SplitView.AddToPrimaryNavigationItems/ViewModels/ShellViewModel_postaction.cs @@ -0,0 +1,19 @@ +//{** +//This code block adds the wts.ItemNameViewModel to the _primaryItems of the ShellViewModel. +//**} +//{[{ +using Param_ItemNamespace.Helpers; +//}]} +namespace Param_ItemNamespace.ViewModels +{ + public class ShellViewModel : Screen + { + private void PopulateNavItems() + { + //^^ + //{[{ + PrimaryItems.Add(new ShellNavigationItem("Shell_wts.ItemName".GetLocalized(), Symbol.Document, typeof(wts.ItemNameViewModel))); + //}]} + } + } +} \ No newline at end of file diff --git a/templates/_composition/CaliburnMicro/Project.SplitView.AddToSecondaryNavigationItems/.template.config/template.json b/templates/_composition/CaliburnMicro/Project.SplitView.AddToSecondaryNavigationItems/.template.config/template.json new file mode 100644 index 000000000..4110f6b1e --- /dev/null +++ b/templates/_composition/CaliburnMicro/Project.SplitView.AddToSecondaryNavigationItems/.template.config/template.json @@ -0,0 +1,28 @@ +{ + "author": "Nigel Sampson", + "classifications": [ + "Universal" + ], + "name": "CaliburnMicro.Project.SplitView.AddToSecondaryNavigationItems", + "tags": { + "language": "C#", + "type": "item", + "wts.type": "composition", + "wts.version": "1.0.0", + "wts.compositionFilter": "wts.type == page & groupidentity == wts.Page.Settings & $framework == CaliburnMicro & $projectType == SplitView" + }, + "sourceName": "wts.ItemName", + "preferNameDirectory": true, + "PrimaryOutputs": [ + ], + "symbols": { + "wts.rootNamespace": { + "type": "parameter", + "replaces": "Param_RootNamespace" + }, + "wts.itemNamespace": { + "type": "parameter", + "replaces": "Param_ItemNamespace" + } + } +} diff --git a/templates/_composition/CaliburnMicro/Project.SplitView.AddToSecondaryNavigationItems/ViewModels/ShellViewModel_postaction.cs b/templates/_composition/CaliburnMicro/Project.SplitView.AddToSecondaryNavigationItems/ViewModels/ShellViewModel_postaction.cs new file mode 100644 index 000000000..6b9b7e6e2 --- /dev/null +++ b/templates/_composition/CaliburnMicro/Project.SplitView.AddToSecondaryNavigationItems/ViewModels/ShellViewModel_postaction.cs @@ -0,0 +1,19 @@ +//{** +//This code block adds the wts.ItemNameViewModel to the _secondaryItems of the ShellViewModel. +//**} +//{[{ +using Param_ItemNamespace.Helpers; +//}]} +namespace Param_ItemNamespace.ViewModels +{ + public class ShellViewModel : Screen + { + private void PopulateNavItems() + { + //^^ + //{[{ + SecondaryItems.Add(new ShellNavigationItem("Shell_wts.ItemName".GetLocalized(), Symbol.Setting, typeof(wts.ItemNameViewModel))); + //}]} + } + } +} diff --git a/templates/_composition/CaliburnMicro/Project.SplitView.Page.AddAdaptiveTriggerForPageTitle.MasterDetail/.template.config/template.json b/templates/_composition/CaliburnMicro/Project.SplitView.Page.AddAdaptiveTriggerForPageTitle.MasterDetail/.template.config/template.json new file mode 100644 index 000000000..f3e1dfd70 --- /dev/null +++ b/templates/_composition/CaliburnMicro/Project.SplitView.Page.AddAdaptiveTriggerForPageTitle.MasterDetail/.template.config/template.json @@ -0,0 +1,28 @@ +{ + "author": "Nigel Sampson", + "classifications": [ + "Universal" + ], + "name": "Project.SplitView.Page.AddAdaptiveTriggerForPageTitle_MasterDetail.CaliburnMicro", + "tags": { + "language": "C#", + "type": "item", + "wts.type": "composition", + "wts.version": "1.0.0", + "wts.compositionFilter": "$projectType == SplitView & groupidentity == wts.Page.MasterDetail & $framework == CaliburnMicro" + }, + "sourceName": "wts.ItemName", + "preferNameDirectory": true, + "PrimaryOutputs": [ + ], + "symbols": { + "wts.rootNamespace": { + "type": "parameter", + "replaces": "Param_RootNamespace" + }, + "wts.itemNamespace": { + "type": "parameter", + "replaces": "Param_ItemNamespace" + } + } +} diff --git a/templates/_composition/CaliburnMicro/Project.SplitView.Page.AddAdaptiveTriggerForPageTitle.MasterDetail/Views/wts.ItemNamePage_postaction.xaml b/templates/_composition/CaliburnMicro/Project.SplitView.Page.AddAdaptiveTriggerForPageTitle.MasterDetail/Views/wts.ItemNamePage_postaction.xaml new file mode 100644 index 000000000..53235dce8 --- /dev/null +++ b/templates/_composition/CaliburnMicro/Project.SplitView.Page.AddAdaptiveTriggerForPageTitle.MasterDetail/Views/wts.ItemNamePage_postaction.xaml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/templates/_composition/CaliburnMicro/Project.SplitView/.template.config/template.json b/templates/_composition/CaliburnMicro/Project.SplitView/.template.config/template.json new file mode 100644 index 000000000..999567f38 --- /dev/null +++ b/templates/_composition/CaliburnMicro/Project.SplitView/.template.config/template.json @@ -0,0 +1,48 @@ +{ + "author": "Nigel Sampson", + "classifications": [ + "Universal" + ], + "name": "CaliburnMicro.Project.SplitView", + "tags": { + "language": "C#", + "type": "item", + "wts.type": "composition", + "wts.version": "1.0.0", + "wts.compositionFilter": "$framework == CaliburnMicro & $projectType == SplitView & wts.type == project", + "wts.licenses": "[Microsoft.Toolkit.Uwp](https://github.com/Microsoft/UWPCommunityToolkit/blob/master/license.md)" + }, + "sourceName": "wts.ItemName", + "preferNameDirectory": true, + "PrimaryOutputs": [ + { + "path": ".\\ViewModels\\ShellNavigationItem.cs" + }, + { + "path": ".\\ViewModels\\ShellViewModel.cs" + }, + { + "path": ".\\Views\\ShellPage.xaml" + }, + { + "path": ".\\Views\\ShellPage.xaml.cs" + }, + { + "path": ".\\Views\\IShellView.cs" + } + ], + "symbols": { + "wts.rootNamespace": { + "type": "parameter", + "replaces": "Param_RootNamespace" + }, + "wts.itemNamespace": { + "type": "parameter", + "replaces": "Param_ItemNamespace" + }, + "wts.homePageName": { + "type":"parameter", + "replaces":"Param_HomeName" + } + } +} diff --git a/templates/_composition/CaliburnMicro/Project.SplitView/App_postaction.xaml.cs b/templates/_composition/CaliburnMicro/Project.SplitView/App_postaction.xaml.cs new file mode 100644 index 000000000..120b38a74 --- /dev/null +++ b/templates/_composition/CaliburnMicro/Project.SplitView/App_postaction.xaml.cs @@ -0,0 +1,25 @@ +//{[{ +using Param_RootNamespace.ViewModels; +//}]} + +namespace Param_RootNamespace +{ + public sealed partial class App + { + protected override void Configure() + { + //^^ + //{[{ + _container.PerRequest(); + //}]} + } +//^^ +//{[{ + + private ActivationService CreateActivationService() + { + return new ActivationService(_container, typeof(ViewModels.Param_HomeNameViewModel), new Views.ShellPage()); + } +//}]} + } +} diff --git a/templates/_composition/CaliburnMicro/Project.SplitView/ViewModels/ShellNavigationItem.cs b/templates/_composition/CaliburnMicro/Project.SplitView/ViewModels/ShellNavigationItem.cs new file mode 100644 index 000000000..2e7ae66bc --- /dev/null +++ b/templates/_composition/CaliburnMicro/Project.SplitView/ViewModels/ShellNavigationItem.cs @@ -0,0 +1,120 @@ +using System; +using Caliburn.Micro; +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; +using Windows.UI.Xaml.Data; +using Windows.UI.Xaml.Media; +using Param_ItemNamespace.Helpers; + +namespace wts.ItemName.ViewModels +{ + public class ShellNavigationItem : PropertyChangedBase + { + private bool _isSelected; + + private Visibility _selectedVis = Visibility.Collapsed; + + public Visibility SelectedVis + { + get { return _selectedVis; } + set { Set(ref _selectedVis, value); } + } + + private SolidColorBrush _selectedForeground = null; + + public SolidColorBrush SelectedForeground + { + get { return _selectedForeground ?? (_selectedForeground = GetStandardTextColorBrush()); } + set { Set(ref _selectedForeground, value); } + } + + public string Label { get; set; } + + public Symbol Symbol { get; set; } + + public char SymbolAsChar + { + get { return (char)Symbol; } + } + + public Type ViewModelType { get; set; } + + private IconElement _iconElement = null; + + public IconElement Icon + { + get + { + var foregroundBinding = new Binding + { + Source = this, + Path = new PropertyPath("SelectedForeground"), + Mode = BindingMode.OneWay, + UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged + }; + + if (_iconElement != null) + { + BindingOperations.SetBinding(_iconElement, IconElement.ForegroundProperty, foregroundBinding); + + return _iconElement; + } + + var fontIcon = new FontIcon { FontSize = 16, Glyph = SymbolAsChar.ToString() }; + + BindingOperations.SetBinding(fontIcon, FontIcon.ForegroundProperty, foregroundBinding); + + return fontIcon; + } + } + + public bool IsSelected + { + get + { + return _isSelected; + } + + set + { + Set(ref _isSelected, value); + SelectedVis = value ? Visibility.Visible : Visibility.Collapsed; + SelectedForeground = value + ? Application.Current.Resources["ThemeControlForegroundBaseHighBrush"] as SolidColorBrush + : GetStandardTextColorBrush(); + } + } + + private SolidColorBrush GetStandardTextColorBrush() + { + var brush = Application.Current.Resources["ThemeControlForegroundBaseHighBrush"] as SolidColorBrush; + + return brush; + } + + protected ShellNavigationItem() + { + } + + public ShellNavigationItem(string label, Symbol symbol, Type viewModeType) + : this() + { + Label = label; + Symbol = symbol; + ViewModelType = viewModeType; + } + + public ShellNavigationItem(string label, IconElement icon, Type viewModeType) + : this() + { + Label = label; + _iconElement = icon; + ViewModelType = viewModeType; + } + + public override string ToString() + { + return Label; + } + } +} diff --git a/templates/_composition/CaliburnMicro/Project.SplitView/ViewModels/ShellViewModel.cs b/templates/_composition/CaliburnMicro/Project.SplitView/ViewModels/ShellViewModel.cs new file mode 100644 index 000000000..16dd1f2ec --- /dev/null +++ b/templates/_composition/CaliburnMicro/Project.SplitView/ViewModels/ShellViewModel.cs @@ -0,0 +1,183 @@ +using System; +using System.Collections.ObjectModel; +using System.Linq; +using System.Windows.Input; +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; +using Windows.UI.Xaml.Navigation; +using Caliburn.Micro; +using wts.ItemName.Services; +using wts.ItemName.Views; + +namespace wts.ItemName.ViewModels +{ + public class ShellViewModel : Screen + { + private const string PanoramicStateName = "PanoramicState"; + private const string WideStateName = "WideState"; + private const string NarrowStateName = "NarrowState"; + private const double WideStateMinWindowWidth = 640; + private const double PanoramicStateMinWindowWidth = 1024; + + private readonly WinRTContainer _container; + private INavigationService _navigationService; + + public ShellViewModel(WinRTContainer container) + { + _container = container; + } + + private bool _isPaneOpen; + + public bool IsPaneOpen + { + get { return _isPaneOpen; } + set { Set(ref _isPaneOpen, value); } + } + + private SplitViewDisplayMode _displayMode = SplitViewDisplayMode.CompactInline; + + public SplitViewDisplayMode DisplayMode + { + get { return _displayMode; } + set { Set(ref _displayMode, value); } + } + + private object _lastSelectedItem; + + public ObservableCollection PrimaryItems { get; } = new ObservableCollection(); + + public ObservableCollection SecondaryItems { get; } = new ObservableCollection(); + + public void Open() + { + IsPaneOpen = !IsPaneOpen; + } + + public void StateChanged(VisualStateChangedEventArgs args) + { + GoToState(args.NewState.Name); + } + + private void GoToState(string stateName) + { + switch (stateName) + { + case PanoramicStateName: + DisplayMode = SplitViewDisplayMode.CompactInline; + break; + case WideStateName: + DisplayMode = SplitViewDisplayMode.CompactInline; + IsPaneOpen = false; + break; + case NarrowStateName: + DisplayMode = SplitViewDisplayMode.Overlay; + IsPaneOpen = false; + break; + default: + break; + } + } + + protected override void OnInitialize() + { + var view = GetView() as IShellView; + + _navigationService = view?.CreateNavigationService(_container); + + if (_navigationService != null) + { + _navigationService.Navigated += NavigationService_Navigated; + } + + PopulateNavItems(); + + InitializeState(Window.Current.Bounds.Width); + } + + private void InitializeState(double windowWith) + { + if (windowWith < WideStateMinWindowWidth) + { + GoToState(NarrowStateName); + } + else if (windowWith < PanoramicStateMinWindowWidth) + { + GoToState(WideStateName); + } + else + { + GoToState(PanoramicStateName); + } + } + + private void PopulateNavItems() + { + PrimaryItems.Clear(); + SecondaryItems.Clear(); + + // TODO WTS: Change the symbols for each item as appropriate for your app + // More on Segoe UI Symbol icons: https://docs.microsoft.com/windows/uwp/style/segoe-ui-symbol-font + // Or to use an IconElement instead of a Symbol see https://github.com/Microsoft/WindowsTemplateStudio/blob/master/docs/projectTypes/navigationpane.md + // Edit String/en-US/Resources.resw: Add a menu item title for each page + } + + public void ItemSelected(ItemClickEventArgs args) + { + if (DisplayMode == SplitViewDisplayMode.CompactOverlay || DisplayMode == SplitViewDisplayMode.Overlay) + { + IsPaneOpen = false; + } + + Navigate(args.ClickedItem); + } + + private void NavigationService_Navigated(object sender, NavigationEventArgs e) + { + if (e != null) + { + var viewType = _navigationService.CurrentSourcePageType; + var viewModelType = ViewModelLocator.LocateTypeForViewType(viewType, false); + + var navigationItem = PrimaryItems?.FirstOrDefault(i => i.ViewModelType == viewModelType); + if (navigationItem == null) + { + navigationItem = SecondaryItems?.FirstOrDefault(i => i.ViewModelType == viewModelType); + } + + if (navigationItem != null) + { + ChangeSelected(_lastSelectedItem, navigationItem); + _lastSelectedItem = navigationItem; + } + } + } + + private void ChangeSelected(object oldValue, object newValue) + { + if (oldValue != null) + { + (oldValue as ShellNavigationItem).IsSelected = false; + } + + if (newValue != null) + { + (newValue as ShellNavigationItem).IsSelected = true; + } + } + + private void Navigate(object item) + { + if (_lastSelectedItem == item) + { + return; + } + + var navigationItem = item as ShellNavigationItem; + if (navigationItem != null) + { + _navigationService.NavigateToViewModel(navigationItem.ViewModelType); + } + } + } +} diff --git a/templates/_composition/CaliburnMicro/Project.SplitView/Views/IShellView.cs b/templates/_composition/CaliburnMicro/Project.SplitView/Views/IShellView.cs new file mode 100644 index 000000000..7dfe7c21c --- /dev/null +++ b/templates/_composition/CaliburnMicro/Project.SplitView/Views/IShellView.cs @@ -0,0 +1,10 @@ +using System; +using Caliburn.Micro; + +namespace wts.ItemName.Views +{ + public interface IShellView + { + INavigationService CreateNavigationService(WinRTContainer container); + } +} diff --git a/templates/_composition/CaliburnMicro/Project.SplitView/Views/ShellPage.xaml b/templates/_composition/CaliburnMicro/Project.SplitView/Views/ShellPage.xaml new file mode 100644 index 000000000..20cdedfef --- /dev/null +++ b/templates/_composition/CaliburnMicro/Project.SplitView/Views/ShellPage.xaml @@ -0,0 +1,132 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/templates/_composition/CaliburnMicro/Project.SplitView/Views/ShellPage.xaml.cs b/templates/_composition/CaliburnMicro/Project.SplitView/Views/ShellPage.xaml.cs new file mode 100644 index 000000000..8d83415b7 --- /dev/null +++ b/templates/_composition/CaliburnMicro/Project.SplitView/Views/ShellPage.xaml.cs @@ -0,0 +1,29 @@ +using Caliburn.Micro; +using Windows.UI.Xaml.Controls; +using Windows.UI.Xaml.Navigation; +using Windows.UI.Xaml; +using wts.ItemName.Services; +using wts.ItemName.ViewModels; + +namespace wts.ItemName.Views +{ + public sealed partial class ShellPage : IShellView + { + private ShellViewModel ViewModel => DataContext as ShellViewModel; + + public ShellPage() + { + InitializeComponent(); + } + + public INavigationService CreateNavigationService(WinRTContainer container) + { + return container.RegisterNavigationService(shellFrame); + } + + private void OnStateChanged(object sender, VisualStateChangedEventArgs e) + { + ViewModel.StateChanged(e); + } + } +} diff --git a/templates/_composition/CaliburnMicro/Project.SplitView/_postaction.csproj b/templates/_composition/CaliburnMicro/Project.SplitView/_postaction.csproj new file mode 100644 index 000000000..94d14219d --- /dev/null +++ b/templates/_composition/CaliburnMicro/Project.SplitView/_postaction.csproj @@ -0,0 +1,6 @@ + + + + 1.5.0 + + diff --git a/templates/_composition/CaliburnMicro/Project.TabbedPivot.AddTabbedPivotItems/.template.config/template.json b/templates/_composition/CaliburnMicro/Project.TabbedPivot.AddTabbedPivotItems/.template.config/template.json new file mode 100644 index 000000000..6e2632f83 --- /dev/null +++ b/templates/_composition/CaliburnMicro/Project.TabbedPivot.AddTabbedPivotItems/.template.config/template.json @@ -0,0 +1,27 @@ +{ + "author": "Nigel Sampson", + "classifications": [ + "Universal" + ], + "name": "CaliburnMicro.Project.TabbedPivot.AddTabbedPivotItems", + "tags": { + "language": "C#", + "type": "item", + "wts.type": "composition", + "wts.version": "1.0.0", + "wts.compositionFilter": "$framework == CaliburnMicro & $projectType == TabbedPivot & wts.type==page" + }, + "sourceName": "wts.ItemName", + "preferNameDirectory": true, + "PrimaryOutputs": [], + "symbols": { + "wts.rootNamespace": { + "type": "parameter", + "replaces": "Param_RootNamespace" + }, + "wts.itemNamespace": { + "type": "parameter", + "replaces": "Param_ItemNamespace" + } + } +} diff --git a/templates/_composition/CaliburnMicro/Project.TabbedPivot.AddTabbedPivotItems/Strings/en-us/Resources_postaction.resw b/templates/_composition/CaliburnMicro/Project.TabbedPivot.AddTabbedPivotItems/Strings/en-us/Resources_postaction.resw new file mode 100644 index 000000000..17fdd7a14 --- /dev/null +++ b/templates/_composition/CaliburnMicro/Project.TabbedPivot.AddTabbedPivotItems/Strings/en-us/Resources_postaction.resw @@ -0,0 +1,8 @@ + + + + + wts.ItemName + + + diff --git a/templates/_composition/CaliburnMicro/Project.TabbedPivot.AddTabbedPivotItems/ViewModels/PivotViewModel_postaction.cs b/templates/_composition/CaliburnMicro/Project.TabbedPivot.AddTabbedPivotItems/ViewModels/PivotViewModel_postaction.cs new file mode 100644 index 000000000..b95e5c070 --- /dev/null +++ b/templates/_composition/CaliburnMicro/Project.TabbedPivot.AddTabbedPivotItems/ViewModels/PivotViewModel_postaction.cs @@ -0,0 +1,13 @@ +namespace Param_ItemNamespace.ViewModels +{ + public class PivotViewModel : Conductor.Collection.OneActive + { + protected override void OnInitialize() + { + //^^ + //{[{ + Items.Add(new wts.ItemNameViewModel { DisplayName = "PivotItem_wts.ItemName/Header".GetLocalized() }); + //}]} + } + } +} diff --git a/templates/_composition/CaliburnMicro/Project.TabbedPivot/.template.config/template.json b/templates/_composition/CaliburnMicro/Project.TabbedPivot/.template.config/template.json new file mode 100644 index 000000000..5338c175e --- /dev/null +++ b/templates/_composition/CaliburnMicro/Project.TabbedPivot/.template.config/template.json @@ -0,0 +1,37 @@ +{ + "author": "Nigel Sampson", + "classifications": [ + "Universal" + ], + "name": "CaliburnMicro.Project.TabbedPivot", + "tags": { + "language": "C#", + "type": "item", + "wts.type": "composition", + "wts.version": "1.0.0", + "wts.compositionFilter": "$framework == CaliburnMicro & $projectType == TabbedPivot & wts.type == project" + }, + "sourceName": "wts.ItemName", + "preferNameDirectory": true, + "PrimaryOutputs": [ + { + "path": ".\\ViewModels\\PivotViewModel.cs" + }, + { + "path": ".\\Views\\PivotPage.xaml" + }, + { + "path": ".\\Views\\PivotPage.xaml.cs" + } + ], + "symbols": { + "wts.rootNamespace": { + "type": "parameter", + "replaces": "Param_RootNamespace" + }, + "wts.itemNamespace": { + "type": "parameter", + "replaces": "Param_ItemNamespace" + } + } +} diff --git a/templates/_composition/CaliburnMicro/Project.TabbedPivot/App_postaction.xaml.cs b/templates/_composition/CaliburnMicro/Project.TabbedPivot/App_postaction.xaml.cs new file mode 100644 index 000000000..cc4914bab --- /dev/null +++ b/templates/_composition/CaliburnMicro/Project.TabbedPivot/App_postaction.xaml.cs @@ -0,0 +1,21 @@ +namespace Param_RootNamespace +{ + public sealed partial class App + { + protected override void Configure() + { + //^^ + //{[{ + _container.PerRequest(); + //}]} + } +//^^ +//{[{ + + private ActivationService CreateActivationService() + { + return new ActivationService(_container, typeof(PivotViewModel)); + } +//}]} + } +} diff --git a/templates/_composition/CaliburnMicro/Project.TabbedPivot/ViewModels/PivotViewModel.cs b/templates/_composition/CaliburnMicro/Project.TabbedPivot/ViewModels/PivotViewModel.cs new file mode 100644 index 000000000..8ef82100b --- /dev/null +++ b/templates/_composition/CaliburnMicro/Project.TabbedPivot/ViewModels/PivotViewModel.cs @@ -0,0 +1,16 @@ +using wts.ItemName.Helpers; +using Caliburn.Micro; + +namespace wts.ItemName.ViewModels +{ + public class PivotViewModel : Conductor.Collection.OneActive + { + public PivotViewModel() + { + } + + protected override void OnInitialize() + { + } + } +} diff --git a/templates/_composition/CaliburnMicro/Project.TabbedPivot/Views/PivotPage.xaml b/templates/_composition/CaliburnMicro/Project.TabbedPivot/Views/PivotPage.xaml new file mode 100644 index 000000000..f109cf57f --- /dev/null +++ b/templates/_composition/CaliburnMicro/Project.TabbedPivot/Views/PivotPage.xaml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + diff --git a/templates/_composition/CaliburnMicro/Project.TabbedPivot/Views/PivotPage.xaml.cs b/templates/_composition/CaliburnMicro/Project.TabbedPivot/Views/PivotPage.xaml.cs new file mode 100644 index 000000000..0c9c508c9 --- /dev/null +++ b/templates/_composition/CaliburnMicro/Project.TabbedPivot/Views/PivotPage.xaml.cs @@ -0,0 +1,19 @@ +using wts.ItemName.ViewModels; +using Windows.UI.Xaml.Controls; +using Windows.UI.Xaml.Navigation; + +namespace wts.ItemName.Views +{ + public sealed partial class PivotPage : Page + { + public PivotPage() + { + // We use NavigationCacheMode.Required to keep track the selected item on navigation. For further information see the following links. + // https://msdn.microsoft.com/en-us/library/windows/apps/xaml/windows.ui.xaml.controls.page.navigationcachemode.aspx + // https://msdn.microsoft.com/en-us/library/windows/apps/xaml/Hh771188.aspx + NavigationCacheMode = NavigationCacheMode.Required; + + InitializeComponent(); + } + } +} diff --git a/templates/_composition/CaliburnMicro/Project/.template.config/template.json b/templates/_composition/CaliburnMicro/Project/.template.config/template.json new file mode 100644 index 000000000..0f42a2524 --- /dev/null +++ b/templates/_composition/CaliburnMicro/Project/.template.config/template.json @@ -0,0 +1,33 @@ +{ + "author": "Nigel Sampson", + "classifications": [ + "Universal" + ], + "name": "CaliburnMicro.Project", + "tags": { + "language": "C#", + "type": "item", + "wts.type": "composition", + "wts.version": "1.0.0", + "wts.licenses": "[Caliburn.Micro](https://github.com/Caliburn-Micro/Caliburn.Micro/blob/master/License.txt)", + "wts.compositionFilter": "$framework == CaliburnMicro & wts.type == project" + }, + "sourceName": "wts.ItemName", + "preferNameDirectory": true, + "PrimaryOutputs": [ + { "path": ".\\Helpers\\PropertyChangedBaseExtensions.cs" }, + { "path": ".\\Activation\\DefaultLaunchActivationHandler.cs" }, + { "path": ".\\Services\\ActivationService.cs" }, + { "path": ".\\App.xaml" } + ], + "symbols": { + "wts.rootNamespace": { + "type": "parameter", + "replaces": "Param_RootNamespace" + }, + "wts.itemNamespace": { + "type": "parameter", + "replaces": "Param_ItemNamespace" + } + } +} diff --git a/templates/_composition/CaliburnMicro/Project/Activation/DefaultLaunchActivationHandler.cs b/templates/_composition/CaliburnMicro/Project/Activation/DefaultLaunchActivationHandler.cs new file mode 100644 index 000000000..4a2044c8f --- /dev/null +++ b/templates/_composition/CaliburnMicro/Project/Activation/DefaultLaunchActivationHandler.cs @@ -0,0 +1,35 @@ +using System; +using System.Threading.Tasks; +using Caliburn.Micro; +using Windows.ApplicationModel.Activation; + +namespace Param_RootNamespace.Activation +{ + internal class DefaultLaunchActivationHandler : ActivationHandler + { + private readonly Type _navElement; + private readonly INavigationService _navigationService; + + public DefaultLaunchActivationHandler(Type navElement, INavigationService navigationService) + { + _navElement = navElement; + _navigationService = navigationService; + } + + protected override async Task HandleInternalAsync(LaunchActivatedEventArgs args) + { + // When the navigation stack isn't restored navigate to the first page, + // configuring the new page by passing required information as a navigation + // parameter + _navigationService.NavigateToViewModel(_navElement, args.Arguments); + + await Task.CompletedTask; + } + + protected override bool CanHandleInternal(LaunchActivatedEventArgs args) + { + // None of the ActivationHandlers has handled the app activation + return _navigationService.SourcePageType == null; + } + } +} diff --git a/templates/_composition/CaliburnMicro/Project/App.xaml b/templates/_composition/CaliburnMicro/Project/App.xaml new file mode 100644 index 000000000..343bef08e --- /dev/null +++ b/templates/_composition/CaliburnMicro/Project/App.xaml @@ -0,0 +1,14 @@ + + + + + + + + + diff --git a/templates/_composition/CaliburnMicro/Project/App.xaml.cs b/templates/_composition/CaliburnMicro/Project/App.xaml.cs new file mode 100644 index 000000000..23c0d7ccb --- /dev/null +++ b/templates/_composition/CaliburnMicro/Project/App.xaml.cs @@ -0,0 +1,96 @@ +using System; +using Windows.ApplicationModel.Activation; +using Windows.UI.Xaml; +using System.Collections.Generic; +using Caliburn.Micro; +using Param_RootNamespace.Services; + +namespace Param_RootNamespace +{ + /// + /// Provides application-specific behavior to supplement the default Application class. + /// + public sealed partial class App + { + private Lazy _activationService; + + private ActivationService ActivationService + { + get { return _activationService.Value; } + } + + /// + /// Initializes a new instance of the class. + /// This is the first line of authored code executed, and as such + /// is the logical equivalent of main() or WinMain(). + /// + public App() + { + InitializeComponent(); + + Initialize(); + + // Deferred execution until used. Check https://msdn.microsoft.com/library/dd642331(v=vs.110).aspx for further info on Lazy class. + _activationService = new Lazy(CreateActivationService); + } + + /// + /// Invoked when the application is launched normally by the end user. Other entry points + /// will be used such as when the application is launched to open a specific file. + /// + /// Details about the launch request and process. + protected override async void OnLaunched(LaunchActivatedEventArgs args) + { + if (!args.PrelaunchActivated) + { + await ActivationService.ActivateAsync(args); + } + } + + /// + /// Invoked when the application is activated by some means other than normal launching. + /// + /// Event data for the event. + protected override async void OnActivated(IActivatedEventArgs args) + { + await ActivationService.ActivateAsync(args); + } + + private WinRTContainer _container; + + /// + /// Configuration for Caliburn.Micro + /// + protected override void Configure() + { + // This configures the framework to map between MainViewModel and MainPage + // Normally it would map between MainPageViewModel and MainPage + var config = new TypeMappingConfiguration + { + IncludeViewSuffixInViewModelNames = false + }; + + ViewLocator.ConfigureTypeMappings(config); + ViewModelLocator.ConfigureTypeMappings(config); + + _container = new WinRTContainer(); + _container.RegisterWinRTServices(); + + } + + protected override object GetInstance(Type service, string key) + { + return _container.GetInstance(service, key); + } + + protected override IEnumerable GetAllInstances(Type service) + { + return _container.GetAllInstances(service); + } + + protected override void BuildUp(object instance) + { + _container.BuildUp(instance); + } + } +} diff --git a/templates/_composition/CaliburnMicro/Project/Helpers/PropertyChangedBaseExtensions.cs b/templates/_composition/CaliburnMicro/Project/Helpers/PropertyChangedBaseExtensions.cs new file mode 100644 index 000000000..395df468c --- /dev/null +++ b/templates/_composition/CaliburnMicro/Project/Helpers/PropertyChangedBaseExtensions.cs @@ -0,0 +1,22 @@ +using System; +using System.Runtime.CompilerServices; +using Caliburn.Micro; + +namespace Param_RootNamespace.Helpers +{ + public static class PropertyChangedBaseExtensions + { + public static bool Set(this PropertyChangedBase propertyChangedBase, ref T oldValue, T newValue, [CallerMemberName] string propertyName = null) + { + if (Equals(oldValue, newValue)) + { + return false; + } + + oldValue = newValue; + propertyChangedBase.NotifyOfPropertyChange(propertyName); + + return true; + } + } +} diff --git a/templates/_composition/CaliburnMicro/Project/Services/ActivationService.cs b/templates/_composition/CaliburnMicro/Project/Services/ActivationService.cs new file mode 100644 index 000000000..5fd0f01dd --- /dev/null +++ b/templates/_composition/CaliburnMicro/Project/Services/ActivationService.cs @@ -0,0 +1,126 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Caliburn.Micro; +using Windows.ApplicationModel.Activation; +using Windows.UI.Core; +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; +using Windows.UI.Xaml.Navigation; + +using Param_RootNamespace.Activation; + +namespace Param_RootNamespace.Services +{ + // For more information on application activation see https://github.com/Microsoft/WindowsTemplateStudio/blob/master/docs/activation.md + internal class ActivationService + { + private readonly WinRTContainer _container; + private readonly Type _defaultNavItem; + private UIElement _shell; + + public ActivationService(WinRTContainer container, Type defaultNavItem, UIElement shell = null) + { + _container = container; + _shell = shell; + _defaultNavItem = defaultNavItem; + } + + public async Task ActivateAsync(object activationArgs) + { + if (IsInteractive(activationArgs)) + { + // Initialize things like registering background task before the app is loaded + await InitializeAsync(); + + // Do not repeat app initialization when the Window already has content, + // just ensure that the window is active + if (Window.Current.Content == null) + { + // Create a Frame to act as the navigation context and navigate to the first page + if (_shell == null) + { + var frame = new Frame(); + _shell = frame; + + NavigationService = _container.RegisterNavigationService(frame); + } + else + { + var viewModel = ViewModelLocator.LocateForView(_shell); + + ViewModelBinder.Bind(viewModel, _shell, null); + + ScreenExtensions.TryActivate(viewModel); + + NavigationService = _container.GetInstance(); + } + + Window.Current.Content = _shell; + + if (NavigationService != null) + { + NavigationService.NavigationFailed += (sender, e) => + { + throw new Exception("Failed to load Page " + e.SourcePageType.FullName); + }; + + NavigationService.Navigated += OnFrameNavigated; + } + } + } + + var activationHandler = GetActivationHandlers() + .FirstOrDefault(h => h.CanHandle(activationArgs)); + + if (activationHandler != null) + { + await activationHandler.HandleAsync(activationArgs); + } + + if (IsInteractive(activationArgs)) + { + var defaultHandler = new DefaultLaunchActivationHandler(_defaultNavItem, NavigationService); + if (defaultHandler.CanHandle(activationArgs)) + { + await defaultHandler.HandleAsync(activationArgs); + } + + // Ensure the current window is active + Window.Current.Activate(); + + // Tasks after activation + await StartupAsync(); + } + } + + private INavigationService NavigationService { get; set; } + + private async Task InitializeAsync() + { + await Task.CompletedTask; + } + + private async Task StartupAsync() + { + await Task.CompletedTask; + } + + private IEnumerable GetActivationHandlers() + { + yield break; + } + + private bool IsInteractive(object args) + { + return args is IActivatedEventArgs; + } + + private void OnFrameNavigated(object sender, NavigationEventArgs e) + { + SystemNavigationManager.GetForCurrentView().AppViewBackButtonVisibility = NavigationService.CanGoBack ? + AppViewBackButtonVisibility.Visible : AppViewBackButtonVisibility.Collapsed; + } + } +} diff --git a/templates/_composition/CaliburnMicro/Project/_postaction.csproj b/templates/_composition/CaliburnMicro/Project/_postaction.csproj new file mode 100644 index 000000000..cb5dd3493 --- /dev/null +++ b/templates/_composition/CaliburnMicro/Project/_postaction.csproj @@ -0,0 +1,6 @@ + + + + 3.2.0 + + diff --git a/templates/_composition/MVVMLight/Project/Services/NavigationServiceEx.cs b/templates/_composition/MVVMLight/Project/Services/NavigationServiceEx.cs index 4a83dabae..b1ad76b7c 100644 --- a/templates/_composition/MVVMLight/Project/Services/NavigationServiceEx.cs +++ b/templates/_composition/MVVMLight/Project/Services/NavigationServiceEx.cs @@ -6,6 +6,8 @@ using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Media.Animation; using Windows.UI.Xaml.Navigation; +using Param_RootNamespace.Helpers; + namespace Param_RootNamespace.Services { public class NavigationServiceEx @@ -53,7 +55,7 @@ namespace Param_RootNamespace.Services { if (!_pages.ContainsKey(pageKey)) { - throw new ArgumentException($"Page not found: {pageKey}. Did you forget to call NavigationService.Configure?", nameof(pageKey)); + throw new ArgumentException(string.Format("ExceptionNavigationServiceExPageNotFound".GetLocalized(), pageKey), nameof(pageKey)); } var navigationResult = Frame.Navigate(_pages[pageKey], parameter, infoOverride); @@ -67,12 +69,12 @@ namespace Param_RootNamespace.Services { if (_pages.ContainsKey(key)) { - throw new ArgumentException($"The key {key} is already configured in NavigationService"); + throw new ArgumentException(string.Format("ExceptionNavigationServiceExKeyIsInNavigationService".GetLocalized(), key)); } if (_pages.Any(p => p.Value == pageType)) { - throw new ArgumentException($"This type is already configured with key {_pages.First(p => p.Value == pageType).Key}"); + throw new ArgumentException(string.Format("ExceptionNavigationServiceExTypeAlreadyConfigured".GetLocalized(), _pages.First(p => p.Value == pageType).Key)); } _pages.Add(key, pageType); @@ -89,7 +91,7 @@ namespace Param_RootNamespace.Services } else { - throw new ArgumentException($"The page '{page.Name}' is unknown by the NavigationService"); + throw new ArgumentException(string.Format("ExceptionNavigationServiceExPageUnknow".GetLocalized(), page.Name)); } } } diff --git a/templates/_composition/MVVMLight/Project/Strings/en-us/Resources_postaction.resw b/templates/_composition/MVVMLight/Project/Strings/en-us/Resources_postaction.resw new file mode 100644 index 000000000..1a8155c77 --- /dev/null +++ b/templates/_composition/MVVMLight/Project/Strings/en-us/Resources_postaction.resw @@ -0,0 +1,21 @@ + + + + + Page not found: {0}. Did you forget to call NavigationService.Configure? + Page to navigate not found in navigation service + + + The key {0} is already configured in NavigationService + The page is already configured in navigation service + + + This type is already configured with key {0} + The page type is already configured with page key in navigation service + + + The page '{0}' is unknown by the NavigationService + The page is unknown or not registered in navigation service + + + diff --git a/templates/_composition/_shared/Feature.BackgroundTask.AddOnBackgroundNavigated/.template.config/template.json b/templates/_composition/_shared/Feature.BackgroundTask.AddOnBackgroundNavigated/.template.config/template.json new file mode 100644 index 000000000..a0139c2af --- /dev/null +++ b/templates/_composition/_shared/Feature.BackgroundTask.AddOnBackgroundNavigated/.template.config/template.json @@ -0,0 +1,28 @@ +{ + "author": "Microsoft", + "classifications": [ + "Universal" + ], + "name": "Feature.BackgroundTask.AddOnBackgroundNavigated", + "tags": { + "language": "C#", + "type": "item", + "wts.type": "composition", + "wts.version": "1.0.0", + "wts.compositionFilter": "$framework == CodeBehind|MVVMBasic|MVVMLight & identity == wts.Feat.BackgroundTask" + }, + "sourceName": "wts.ItemName", + "preferNameDirectory": true, + "PrimaryOutputs": [ + ], + "symbols": { + "wts.rootNamespace": { + "type": "parameter", + "replaces": "Param_RootNamespace" + }, + "wts.itemNamespace": { + "type": "parameter", + "replaces": "Param_ItemNamespace" + } + } +} diff --git a/templates/Features/BackgroundTask/App_postaction.xaml.cs b/templates/_composition/_shared/Feature.BackgroundTask.AddOnBackgroundNavigated/App_postaction.xaml.cs similarity index 100% rename from templates/Features/BackgroundTask/App_postaction.xaml.cs rename to templates/_composition/_shared/Feature.BackgroundTask.AddOnBackgroundNavigated/App_postaction.xaml.cs diff --git a/templates/_composition/_shared/Feature.SuspendAndResume.AddOnBackgroundEntered/.template.config/template.json b/templates/_composition/_shared/Feature.SuspendAndResume.AddOnBackgroundEntered/.template.config/template.json new file mode 100644 index 000000000..1605129d6 --- /dev/null +++ b/templates/_composition/_shared/Feature.SuspendAndResume.AddOnBackgroundEntered/.template.config/template.json @@ -0,0 +1,28 @@ +{ + "author": "Microsoft", + "classifications": [ + "Universal" + ], + "name": "Feature.SuspendAndResume.AddOnBackgroundEntered", + "tags": { + "language": "C#", + "type": "item", + "wts.type": "composition", + "wts.version": "1.0.0", + "wts.compositionFilter": "$framework == CodeBehind|MVVMBasic|MVVMLight & identity == wts.Feat.SuspendAndResume" + }, + "sourceName": "wts.ItemName", + "preferNameDirectory": true, + "PrimaryOutputs": [ + ], + "symbols": { + "wts.rootNamespace": { + "type": "parameter", + "replaces": "Param_RootNamespace" + }, + "wts.itemNamespace": { + "type": "parameter", + "replaces": "Param_ItemNamespace" + } + } +} diff --git a/templates/Features/SuspendAndResume/App_postaction.xaml.cs b/templates/_composition/_shared/Feature.SuspendAndResume.AddOnBackgroundEntered/App_postaction.xaml.cs similarity index 100% rename from templates/Features/SuspendAndResume/App_postaction.xaml.cs rename to templates/_composition/_shared/Feature.SuspendAndResume.AddOnBackgroundEntered/App_postaction.xaml.cs diff --git a/templates/_composition/_shared/Page.Chart.SampleDataService/.template.config/template.json b/templates/_composition/_shared/Page.Chart.SampleDataService/.template.config/template.json index d85cce7fb..ba21605f0 100644 --- a/templates/_composition/_shared/Page.Chart.SampleDataService/.template.config/template.json +++ b/templates/_composition/_shared/Page.Chart.SampleDataService/.template.config/template.json @@ -9,7 +9,7 @@ "type": "item", "wts.type": "composition", "wts.version": "1.0.0", - "wts.compositionFilter": "$framework == MVVMBasic|MVVMLight|CodeBehind & identity == wts.Page.Chart|wts.Page.Chart.CodeBehind" + "wts.compositionFilter": "$framework == MVVMBasic|MVVMLight|CodeBehind|CaliburnMicro & identity == wts.Page.Chart|wts.Page.Chart.CodeBehind" }, "sourceName": "wts.ItemName", "preferNameDirectory": true, diff --git a/templates/_composition/_shared/Page.Grid.SampleDataService/.template.config/template.json b/templates/_composition/_shared/Page.Grid.SampleDataService/.template.config/template.json index cf498eeab..575744a2d 100644 --- a/templates/_composition/_shared/Page.Grid.SampleDataService/.template.config/template.json +++ b/templates/_composition/_shared/Page.Grid.SampleDataService/.template.config/template.json @@ -9,7 +9,7 @@ "type": "item", "wts.type": "composition", "wts.version": "1.0.0", - "wts.compositionFilter": "$framework == MVVMBasic|MVVMLight|CodeBehind & identity == wts.Page.Grid|wts.Page.Grid.CodeBehind" + "wts.compositionFilter": "$framework == MVVMBasic|MVVMLight|CodeBehind|CaliburnMicro & identity == wts.Page.Grid|wts.Page.Grid.CodeBehind" }, "sourceName": "wts.ItemName", "preferNameDirectory": true, diff --git a/templates/_composition/_shared/Page.MasterDetail.SampleDataService/.template.config/template.json b/templates/_composition/_shared/Page.MasterDetail.SampleDataService/.template.config/template.json index 844f0c81f..a01561ef3 100644 --- a/templates/_composition/_shared/Page.MasterDetail.SampleDataService/.template.config/template.json +++ b/templates/_composition/_shared/Page.MasterDetail.SampleDataService/.template.config/template.json @@ -9,7 +9,7 @@ "type": "item", "wts.type": "composition", "wts.version": "1.0.0", - "wts.compositionFilter": "$framework == MVVMBasic|MVVMLight|CodeBehind & identity == wts.Page.MasterDetail|wts.Page.MasterDetail.CodeBehind" + "wts.compositionFilter": "$framework == MVVMBasic|MVVMLight|CodeBehind|CaliburnMicro & identity == wts.Page.MasterDetail|wts.Page.MasterDetail.CodeBehind|wts.Page.MasterDetail.CaliburnMicro" }, "sourceName": "wts.ItemName", "preferNameDirectory": true, diff --git a/templates/_composition/_shared/Project.SplitView.Page.AddAdaptiveTriggerForPageTitle.MasterDetail/.template.config/template.json b/templates/_composition/_shared/Project.SplitView.Page.AddAdaptiveTriggerForPageTitle.MasterDetail/.template.config/template.json index 970dc347b..e8376f44b 100644 --- a/templates/_composition/_shared/Project.SplitView.Page.AddAdaptiveTriggerForPageTitle.MasterDetail/.template.config/template.json +++ b/templates/_composition/_shared/Project.SplitView.Page.AddAdaptiveTriggerForPageTitle.MasterDetail/.template.config/template.json @@ -9,7 +9,7 @@ "type": "item", "wts.type": "composition", "wts.version": "1.0.0", - "wts.compositionFilter": "$projectType == SplitView & groupidentity == wts.Page.MasterDetail" + "wts.compositionFilter": "$projectType == SplitView & groupidentity == wts.Page.MasterDetail & $framework != CaliburnMicro" }, "sourceName": "wts.ItemName", "preferNameDirectory": true, diff --git a/templates/_composition/_shared/Project.TabbedPivot.AddTabbedPivotItems/.template.config/template.json b/templates/_composition/_shared/Project.TabbedPivot.AddTabbedPivotItems/.template.config/template.json index 078e087f4..77cc3186d 100644 --- a/templates/_composition/_shared/Project.TabbedPivot.AddTabbedPivotItems/.template.config/template.json +++ b/templates/_composition/_shared/Project.TabbedPivot.AddTabbedPivotItems/.template.config/template.json @@ -9,7 +9,7 @@ "type": "item", "wts.type": "composition", "wts.version": "1.0.0", - "wts.compositionFilter": "$projectType == TabbedPivot & wts.type==page" + "wts.compositionFilter": "$framework == CodeBehind|MVVMBasic|MVVMLight & $projectType == TabbedPivot & wts.type==page" }, "sourceName": "wts.ItemName", "preferNameDirectory": true,