From 90f935f4b2954ce5e02a7e6f12be36b3bc2e3fc0 Mon Sep 17 00:00:00 2001 From: Alvin Ashcraft Date: Sun, 13 Aug 2023 13:40:04 -0400 Subject: [PATCH] Add chapter 10 sample project --- Chapter10/.editorconfig | 202 +++++++ Chapter10/.vsconfig | 16 + .../Contracts/Services/IFileService.cs | 10 + .../Contracts/Services/ISampleDataService.cs | 11 + .../Helpers/Json.cs | 22 + .../Models/SampleCompany.cs | 60 ++ .../Models/SampleOrder.cs | 81 +++ .../Models/SampleOrderDetail.cs | 52 ++ .../TemplateStudioSampleApp.Core/README.md | 5 + .../Services/FileService.cs | 41 ++ .../Services/SampleDataService.cs | 514 ++++++++++++++++++ .../TemplateStudioSampleApp.Core.csproj | 17 + .../Initialize.cs | 23 + .../README.md | 67 +++ ...emplateStudioSampleApp.Tests.MSTest.csproj | 22 + .../TestClass.cs | 50 ++ .../Usings.cs | 2 + .../Activation/ActivationHandler.cs | 17 + .../Activation/DefaultActivationHandler.cs | 29 + .../Activation/IActivationHandler.cs | 8 + Chapter10/TemplateStudioSampleApp/App.xaml | 15 + Chapter10/TemplateStudioSampleApp/App.xaml.cs | 107 ++++ .../Assets/LockScreenLogo.scale-200.png | Bin 0 -> 1430 bytes .../Assets/SplashScreen.scale-200.png | Bin 0 -> 7700 bytes .../Assets/Square150x150Logo.scale-200.png | Bin 0 -> 2937 bytes .../Assets/Square44x44Logo.scale-200.png | Bin 0 -> 1647 bytes ...x44Logo.targetsize-24_altform-unplated.png | Bin 0 -> 1255 bytes .../Assets/StoreLogo.png | Bin 0 -> 1451 bytes .../Assets/Wide310x150Logo.scale-200.png | Bin 0 -> 3204 bytes .../Assets/WindowIcon.ico | Bin 0 -> 66971 bytes .../Behaviors/NavigationViewHeaderBehavior.cs | 122 +++++ .../Behaviors/NavigationViewHeaderMode.cs | 8 + .../Contracts/Services/IActivationService.cs | 6 + .../Services/ILocalSettingsService.cs | 8 + .../Contracts/Services/INavigationService.cs | 23 + .../Services/INavigationViewService.cs | 22 + .../Contracts/Services/IPageService.cs | 6 + .../Services/IThemeSelectorService.cs | 17 + .../Contracts/Services/IWebViewService.cs | 34 ++ .../Contracts/ViewModels/INavigationAware.cs | 8 + .../Helpers/EnumToBooleanConverter.cs | 38 ++ .../Helpers/FrameExtensions.cs | 8 + .../Helpers/NavigationHelper.cs | 21 + .../Helpers/ResourceExtensions.cs | 10 + .../Helpers/RuntimeHelper.cs | 20 + .../Helpers/SettingsStorageExtensions.cs | 112 ++++ .../Helpers/TitleBarHelper.cs | 121 +++++ .../TemplateStudioSampleApp/MainWindow.xaml | 16 + .../MainWindow.xaml.cs | 37 ++ .../Models/LocalSettingsOptions.cs | 14 + .../Package.appinstaller | 17 + .../Package.appxmanifest | 76 +++ .../Properties/launchsettings.json | 10 + Chapter10/TemplateStudioSampleApp/README.md | 27 + .../Services/ActivationService.cs | 72 +++ .../Services/LocalSettingsService.cs | 88 +++ .../Services/NavigationService.cs | 126 +++++ .../Services/NavigationViewService.cs | 103 ++++ .../Services/PageService.cs | 59 ++ .../Services/ThemeSelectorService.cs | 63 +++ .../Services/WebViewService.cs | 50 ++ .../Strings/en-us/Resources.resw | 142 +++++ .../Styles/FontSizes.xaml | 9 + .../Styles/TextBlock.xaml | 50 ++ .../Styles/Thickness.xaml | 36 ++ .../TemplateStudio.xml | 11 + .../TemplateStudioSampleApp.csproj | 48 ++ .../TemplateStudioSampleApp.sln | 87 +++ Chapter10/TemplateStudioSampleApp/Usings.cs | 1 + .../ViewModels/DataGridViewModel.cs | 38 ++ .../ViewModels/ListDetailsViewModel.cs | 46 ++ .../ViewModels/MainViewModel.cs | 10 + .../ViewModels/SettingsViewModel.cs | 65 +++ .../ViewModels/ShellViewModel.cs | 51 ++ .../ViewModels/WebViewViewModel.cs | 110 ++++ .../Views/DataGridPage.xaml | 40 ++ .../Views/DataGridPage.xaml.cs | 21 + .../Views/ListDetailsDetailControl.xaml | 73 +++ .../Views/ListDetailsDetailControl.xaml.cs | 30 + .../Views/ListDetailsPage.xaml | 100 ++++ .../Views/ListDetailsPage.xaml.cs | 29 + .../Views/MainPage.xaml | 12 + .../Views/MainPage.xaml.cs | 19 + .../Views/SettingsPage.xaml | 67 +++ .../Views/SettingsPage.xaml.cs | 20 + .../Views/ShellPage.xaml | 95 ++++ .../Views/ShellPage.xaml.cs | 88 +++ .../Views/WebViewPage.xaml | 56 ++ .../Views/WebViewPage.xaml.cs | 22 + .../TemplateStudioSampleApp/app.manifest | 15 + .../TemplateStudioSampleApp/appsettings.json | 6 + 91 files changed, 4110 insertions(+) create mode 100644 Chapter10/.editorconfig create mode 100644 Chapter10/.vsconfig create mode 100644 Chapter10/TemplateStudioSampleApp.Core/Contracts/Services/IFileService.cs create mode 100644 Chapter10/TemplateStudioSampleApp.Core/Contracts/Services/ISampleDataService.cs create mode 100644 Chapter10/TemplateStudioSampleApp.Core/Helpers/Json.cs create mode 100644 Chapter10/TemplateStudioSampleApp.Core/Models/SampleCompany.cs create mode 100644 Chapter10/TemplateStudioSampleApp.Core/Models/SampleOrder.cs create mode 100644 Chapter10/TemplateStudioSampleApp.Core/Models/SampleOrderDetail.cs create mode 100644 Chapter10/TemplateStudioSampleApp.Core/README.md create mode 100644 Chapter10/TemplateStudioSampleApp.Core/Services/FileService.cs create mode 100644 Chapter10/TemplateStudioSampleApp.Core/Services/SampleDataService.cs create mode 100644 Chapter10/TemplateStudioSampleApp.Core/TemplateStudioSampleApp.Core.csproj create mode 100644 Chapter10/TemplateStudioSampleApp.Tests.MSTest/Initialize.cs create mode 100644 Chapter10/TemplateStudioSampleApp.Tests.MSTest/README.md create mode 100644 Chapter10/TemplateStudioSampleApp.Tests.MSTest/TemplateStudioSampleApp.Tests.MSTest.csproj create mode 100644 Chapter10/TemplateStudioSampleApp.Tests.MSTest/TestClass.cs create mode 100644 Chapter10/TemplateStudioSampleApp.Tests.MSTest/Usings.cs create mode 100644 Chapter10/TemplateStudioSampleApp/Activation/ActivationHandler.cs create mode 100644 Chapter10/TemplateStudioSampleApp/Activation/DefaultActivationHandler.cs create mode 100644 Chapter10/TemplateStudioSampleApp/Activation/IActivationHandler.cs create mode 100644 Chapter10/TemplateStudioSampleApp/App.xaml create mode 100644 Chapter10/TemplateStudioSampleApp/App.xaml.cs create mode 100644 Chapter10/TemplateStudioSampleApp/Assets/LockScreenLogo.scale-200.png create mode 100644 Chapter10/TemplateStudioSampleApp/Assets/SplashScreen.scale-200.png create mode 100644 Chapter10/TemplateStudioSampleApp/Assets/Square150x150Logo.scale-200.png create mode 100644 Chapter10/TemplateStudioSampleApp/Assets/Square44x44Logo.scale-200.png create mode 100644 Chapter10/TemplateStudioSampleApp/Assets/Square44x44Logo.targetsize-24_altform-unplated.png create mode 100644 Chapter10/TemplateStudioSampleApp/Assets/StoreLogo.png create mode 100644 Chapter10/TemplateStudioSampleApp/Assets/Wide310x150Logo.scale-200.png create mode 100644 Chapter10/TemplateStudioSampleApp/Assets/WindowIcon.ico create mode 100644 Chapter10/TemplateStudioSampleApp/Behaviors/NavigationViewHeaderBehavior.cs create mode 100644 Chapter10/TemplateStudioSampleApp/Behaviors/NavigationViewHeaderMode.cs create mode 100644 Chapter10/TemplateStudioSampleApp/Contracts/Services/IActivationService.cs create mode 100644 Chapter10/TemplateStudioSampleApp/Contracts/Services/ILocalSettingsService.cs create mode 100644 Chapter10/TemplateStudioSampleApp/Contracts/Services/INavigationService.cs create mode 100644 Chapter10/TemplateStudioSampleApp/Contracts/Services/INavigationViewService.cs create mode 100644 Chapter10/TemplateStudioSampleApp/Contracts/Services/IPageService.cs create mode 100644 Chapter10/TemplateStudioSampleApp/Contracts/Services/IThemeSelectorService.cs create mode 100644 Chapter10/TemplateStudioSampleApp/Contracts/Services/IWebViewService.cs create mode 100644 Chapter10/TemplateStudioSampleApp/Contracts/ViewModels/INavigationAware.cs create mode 100644 Chapter10/TemplateStudioSampleApp/Helpers/EnumToBooleanConverter.cs create mode 100644 Chapter10/TemplateStudioSampleApp/Helpers/FrameExtensions.cs create mode 100644 Chapter10/TemplateStudioSampleApp/Helpers/NavigationHelper.cs create mode 100644 Chapter10/TemplateStudioSampleApp/Helpers/ResourceExtensions.cs create mode 100644 Chapter10/TemplateStudioSampleApp/Helpers/RuntimeHelper.cs create mode 100644 Chapter10/TemplateStudioSampleApp/Helpers/SettingsStorageExtensions.cs create mode 100644 Chapter10/TemplateStudioSampleApp/Helpers/TitleBarHelper.cs create mode 100644 Chapter10/TemplateStudioSampleApp/MainWindow.xaml create mode 100644 Chapter10/TemplateStudioSampleApp/MainWindow.xaml.cs create mode 100644 Chapter10/TemplateStudioSampleApp/Models/LocalSettingsOptions.cs create mode 100644 Chapter10/TemplateStudioSampleApp/Package.appinstaller create mode 100644 Chapter10/TemplateStudioSampleApp/Package.appxmanifest create mode 100644 Chapter10/TemplateStudioSampleApp/Properties/launchsettings.json create mode 100644 Chapter10/TemplateStudioSampleApp/README.md create mode 100644 Chapter10/TemplateStudioSampleApp/Services/ActivationService.cs create mode 100644 Chapter10/TemplateStudioSampleApp/Services/LocalSettingsService.cs create mode 100644 Chapter10/TemplateStudioSampleApp/Services/NavigationService.cs create mode 100644 Chapter10/TemplateStudioSampleApp/Services/NavigationViewService.cs create mode 100644 Chapter10/TemplateStudioSampleApp/Services/PageService.cs create mode 100644 Chapter10/TemplateStudioSampleApp/Services/ThemeSelectorService.cs create mode 100644 Chapter10/TemplateStudioSampleApp/Services/WebViewService.cs create mode 100644 Chapter10/TemplateStudioSampleApp/Strings/en-us/Resources.resw create mode 100644 Chapter10/TemplateStudioSampleApp/Styles/FontSizes.xaml create mode 100644 Chapter10/TemplateStudioSampleApp/Styles/TextBlock.xaml create mode 100644 Chapter10/TemplateStudioSampleApp/Styles/Thickness.xaml create mode 100644 Chapter10/TemplateStudioSampleApp/TemplateStudio.xml create mode 100644 Chapter10/TemplateStudioSampleApp/TemplateStudioSampleApp.csproj create mode 100644 Chapter10/TemplateStudioSampleApp/TemplateStudioSampleApp.sln create mode 100644 Chapter10/TemplateStudioSampleApp/Usings.cs create mode 100644 Chapter10/TemplateStudioSampleApp/ViewModels/DataGridViewModel.cs create mode 100644 Chapter10/TemplateStudioSampleApp/ViewModels/ListDetailsViewModel.cs create mode 100644 Chapter10/TemplateStudioSampleApp/ViewModels/MainViewModel.cs create mode 100644 Chapter10/TemplateStudioSampleApp/ViewModels/SettingsViewModel.cs create mode 100644 Chapter10/TemplateStudioSampleApp/ViewModels/ShellViewModel.cs create mode 100644 Chapter10/TemplateStudioSampleApp/ViewModels/WebViewViewModel.cs create mode 100644 Chapter10/TemplateStudioSampleApp/Views/DataGridPage.xaml create mode 100644 Chapter10/TemplateStudioSampleApp/Views/DataGridPage.xaml.cs create mode 100644 Chapter10/TemplateStudioSampleApp/Views/ListDetailsDetailControl.xaml create mode 100644 Chapter10/TemplateStudioSampleApp/Views/ListDetailsDetailControl.xaml.cs create mode 100644 Chapter10/TemplateStudioSampleApp/Views/ListDetailsPage.xaml create mode 100644 Chapter10/TemplateStudioSampleApp/Views/ListDetailsPage.xaml.cs create mode 100644 Chapter10/TemplateStudioSampleApp/Views/MainPage.xaml create mode 100644 Chapter10/TemplateStudioSampleApp/Views/MainPage.xaml.cs create mode 100644 Chapter10/TemplateStudioSampleApp/Views/SettingsPage.xaml create mode 100644 Chapter10/TemplateStudioSampleApp/Views/SettingsPage.xaml.cs create mode 100644 Chapter10/TemplateStudioSampleApp/Views/ShellPage.xaml create mode 100644 Chapter10/TemplateStudioSampleApp/Views/ShellPage.xaml.cs create mode 100644 Chapter10/TemplateStudioSampleApp/Views/WebViewPage.xaml create mode 100644 Chapter10/TemplateStudioSampleApp/Views/WebViewPage.xaml.cs create mode 100644 Chapter10/TemplateStudioSampleApp/app.manifest create mode 100644 Chapter10/TemplateStudioSampleApp/appsettings.json diff --git a/Chapter10/.editorconfig b/Chapter10/.editorconfig new file mode 100644 index 0000000..fd05618 --- /dev/null +++ b/Chapter10/.editorconfig @@ -0,0 +1,202 @@ +# Rules in this file were initially inferred by Visual Studio IntelliCode from the Template Studio codebase. +# You can modify the rules from these initially generated values to suit your own policies. +# You can learn more about editorconfig here: https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference. + +[*.cs] + +#Core editorconfig formatting - indentation + +#use soft tabs (spaces) for indentation +indent_style = space + +#Formatting - new line options + +#place else statements on a new line +csharp_new_line_before_else = true +#require braces to be on a new line for lambdas, methods, control_blocks, types, properties, and accessors (also known as "Allman" style) +csharp_new_line_before_open_brace = all + +#Formatting - organize using options + +#sort System.* using directives alphabetically, and place them before other usings +dotnet_sort_system_directives_first = true + +#Formatting - spacing options + +#require NO space between a cast and the value +csharp_space_after_cast = false +#require a space before the colon for bases or interfaces in a type declaration +csharp_space_after_colon_in_inheritance_clause = true +#require a space after a keyword in a control flow statement such as a for loop +csharp_space_after_keywords_in_control_flow_statements = true +#require a space before the colon for bases or interfaces in a type declaration +csharp_space_before_colon_in_inheritance_clause = true +#remove space within empty argument list parentheses +csharp_space_between_method_call_empty_parameter_list_parentheses = false +#remove space between method call name and opening parenthesis +csharp_space_between_method_call_name_and_opening_parenthesis = false +#do not place space characters after the opening parenthesis and before the closing parenthesis of a method call +csharp_space_between_method_call_parameter_list_parentheses = false +#remove space within empty parameter list parentheses for a method declaration +csharp_space_between_method_declaration_empty_parameter_list_parentheses = false +#place a space character after the opening parenthesis and before the closing parenthesis of a method declaration parameter list. +csharp_space_between_method_declaration_parameter_list_parentheses = false + +#Formatting - wrapping options + +#leave code block on separate lines +csharp_preserve_single_line_blocks = false + +#Style - Code block preferences + +#prefer curly braces even for one line of code +csharp_prefer_braces = true:suggestion + +#Style - expression bodied member options + +#prefer expression bodies for accessors +csharp_style_expression_bodied_accessors = true:warning +#prefer block bodies for constructors +csharp_style_expression_bodied_constructors = false:suggestion +#prefer expression bodies for methods +csharp_style_expression_bodied_methods = when_on_single_line:silent +#prefer expression-bodied members for properties +csharp_style_expression_bodied_properties = true:warning + +#Style - expression level options + +#prefer out variables to be declared before the method call +csharp_style_inlined_variable_declaration = false:suggestion +#prefer the language keyword for member access expressions, instead of the type name, for types that have a keyword to represent them +dotnet_style_predefined_type_for_member_access = true:suggestion + +#Style - Expression-level preferences + +#prefer default over default(T) +csharp_prefer_simple_default_expression = true:suggestion +#prefer objects to be initialized using object initializers when possible +dotnet_style_object_initializer = true:suggestion + +#Style - implicit and explicit types + +#prefer var over explicit type in all cases, unless overridden by another code style rule +csharp_style_var_elsewhere = true:suggestion +#prefer var is used to declare variables with built-in system types such as int +csharp_style_var_for_built_in_types = true:suggestion +#prefer var when the type is already mentioned on the right-hand side of a declaration expression +csharp_style_var_when_type_is_apparent = true:suggestion + +#Style - language keyword and framework type options + +#prefer the language keyword for local variables, method parameters, and class members, instead of the type name, for types that have a keyword to represent them +dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion + +#Style - Language rules +csharp_style_implicit_object_creation_when_type_is_apparent = true:warning +csharp_style_var_for_built_in_types = true:warning + +#Style - modifier options + +#prefer accessibility modifiers to be declared except for public interface members. This will currently not differ from always and will act as future proofing for if C# adds default interface methods. +dotnet_style_require_accessibility_modifiers = for_non_interface_members:suggestion + +#Style - Modifier preferences + +#when this rule is set to a list of modifiers, prefer the specified ordering. +csharp_preferred_modifier_order = public,private,protected,internal,static,async,readonly,override,sealed,abstract,virtual:warning +dotnet_style_readonly_field = true:warning + +#Style - Pattern matching + +#prefer pattern matching instead of is expression with type casts +csharp_style_pattern_matching_over_as_with_null_check = true:warning + +#Style - qualification options + +#prefer events not to be prefaced with this. or Me. in Visual Basic +dotnet_style_qualification_for_event = false:suggestion +#prefer fields not to be prefaced with this. or Me. in Visual Basic +dotnet_style_qualification_for_field = false:suggestion +#prefer methods not to be prefaced with this. or Me. in Visual Basic +dotnet_style_qualification_for_method = false:suggestion +#prefer properties not to be prefaced with this. or Me. in Visual Basic +dotnet_style_qualification_for_property = false:suggestion +csharp_indent_labels = one_less_than_current +csharp_using_directive_placement = outside_namespace:silent +csharp_prefer_simple_using_statement = true:warning +csharp_style_namespace_declarations = file_scoped:warning +csharp_style_expression_bodied_operators = false:silent +csharp_style_expression_bodied_indexers = true:silent +csharp_style_expression_bodied_lambdas = true:silent +csharp_style_expression_bodied_local_functions = false:silent + +[*.{cs,vb}] +dotnet_style_operator_placement_when_wrapping = beginning_of_line +tab_width = 4 +indent_size = 4 +end_of_line = crlf +dotnet_style_coalesce_expression = true:suggestion +dotnet_style_null_propagation = true:suggestion +dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion +dotnet_style_prefer_auto_properties = true:silent +dotnet_style_object_initializer = true:suggestion +dotnet_style_collection_initializer = true:suggestion +dotnet_style_prefer_simplified_boolean_expressions = true:suggestion +dotnet_style_prefer_conditional_expression_over_assignment = true:silent +dotnet_style_prefer_conditional_expression_over_return = true:silent +[*.{cs,vb}] + +#Style - Unnecessary code rules +csharp_style_unused_value_assignment_preference = discard_variable:warning + +#### Naming styles #### + +# Naming rules + +dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion +dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface +dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i + +dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.types_should_be_pascal_case.symbols = types +dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case + +dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members +dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case + +# Symbol specifications + +dotnet_naming_symbols.interface.applicable_kinds = interface +dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.interface.required_modifiers = + +dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum +dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.types.required_modifiers = + +dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method +dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected +dotnet_naming_symbols.non_field_members.required_modifiers = + +# Naming styles + +dotnet_naming_style.begins_with_i.required_prefix = I +dotnet_naming_style.begins_with_i.required_suffix = +dotnet_naming_style.begins_with_i.word_separator = +dotnet_naming_style.begins_with_i.capitalization = pascal_case + +dotnet_naming_style.pascal_case.required_prefix = +dotnet_naming_style.pascal_case.required_suffix = +dotnet_naming_style.pascal_case.word_separator = +dotnet_naming_style.pascal_case.capitalization = pascal_case + +dotnet_naming_style.pascal_case.required_prefix = +dotnet_naming_style.pascal_case.required_suffix = +dotnet_naming_style.pascal_case.word_separator = +dotnet_naming_style.pascal_case.capitalization = pascal_case +dotnet_style_explicit_tuple_names = true:suggestion +dotnet_style_prefer_inferred_tuple_names = true:suggestion +dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion +dotnet_style_prefer_compound_assignment = true:warning +dotnet_style_prefer_simplified_interpolation = true:suggestion diff --git a/Chapter10/.vsconfig b/Chapter10/.vsconfig new file mode 100644 index 0000000..65d1f73 --- /dev/null +++ b/Chapter10/.vsconfig @@ -0,0 +1,16 @@ +{ + "version": "1.0", + "components": [ + "Microsoft.Component.MSBuild", + "Microsoft.NetCore.Component.Runtime.7.0", + "Microsoft.NetCore.Component.SDK", + "Microsoft.VisualStudio.Component.ManagedDesktop.Core", + "Microsoft.VisualStudio.Component.ManagedDesktop.Prerequisites", + "Microsoft.VisualStudio.Component.NuGet", + "Microsoft.VisualStudio.Component.Windows10SDK.19041", + "Microsoft.VisualStudio.Component.Windows10SDK", + "Microsoft.VisualStudio.ComponentGroup.MSIX.Packaging", + "Microsoft.VisualStudio.ComponentGroup.WindowsAppSDK.Cs", + "Microsoft.VisualStudio.Workload.ManagedDesktop" + ] +} diff --git a/Chapter10/TemplateStudioSampleApp.Core/Contracts/Services/IFileService.cs b/Chapter10/TemplateStudioSampleApp.Core/Contracts/Services/IFileService.cs new file mode 100644 index 0000000..2ff7b5c --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp.Core/Contracts/Services/IFileService.cs @@ -0,0 +1,10 @@ +namespace TemplateStudioSampleApp.Core.Contracts.Services; + +public interface IFileService +{ + T Read(string folderPath, string fileName); + + void Save(string folderPath, string fileName, T content); + + void Delete(string folderPath, string fileName); +} diff --git a/Chapter10/TemplateStudioSampleApp.Core/Contracts/Services/ISampleDataService.cs b/Chapter10/TemplateStudioSampleApp.Core/Contracts/Services/ISampleDataService.cs new file mode 100644 index 0000000..0bb1ee8 --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp.Core/Contracts/Services/ISampleDataService.cs @@ -0,0 +1,11 @@ +using TemplateStudioSampleApp.Core.Models; + +namespace TemplateStudioSampleApp.Core.Contracts.Services; + +// Remove this class once your pages/features are using your data. +public interface ISampleDataService +{ + Task> GetGridDataAsync(); + + Task> GetListDetailsDataAsync(); +} diff --git a/Chapter10/TemplateStudioSampleApp.Core/Helpers/Json.cs b/Chapter10/TemplateStudioSampleApp.Core/Helpers/Json.cs new file mode 100644 index 0000000..f03d49f --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp.Core/Helpers/Json.cs @@ -0,0 +1,22 @@ +using Newtonsoft.Json; + +namespace TemplateStudioSampleApp.Core.Helpers; + +public static class Json +{ + public static async Task ToObjectAsync(string value) + { + return await Task.Run(() => + { + return JsonConvert.DeserializeObject(value); + }); + } + + public static async Task StringifyAsync(object value) + { + return await Task.Run(() => + { + return JsonConvert.SerializeObject(value); + }); + } +} diff --git a/Chapter10/TemplateStudioSampleApp.Core/Models/SampleCompany.cs b/Chapter10/TemplateStudioSampleApp.Core/Models/SampleCompany.cs new file mode 100644 index 0000000..4b01b57 --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp.Core/Models/SampleCompany.cs @@ -0,0 +1,60 @@ +namespace TemplateStudioSampleApp.Core.Models; + +// Model for the SampleDataService. Replace with your own model. +public class SampleCompany +{ + public string CompanyID + { + get; set; + } + + public string CompanyName + { + get; set; + } + + public string ContactName + { + get; set; + } + + public string ContactTitle + { + get; set; + } + + public string Address + { + get; set; + } + + public string City + { + get; set; + } + + public string PostalCode + { + get; set; + } + + public string Country + { + get; set; + } + + public string Phone + { + get; set; + } + + public string Fax + { + get; set; + } + + public ICollection Orders + { + get; set; + } +} diff --git a/Chapter10/TemplateStudioSampleApp.Core/Models/SampleOrder.cs b/Chapter10/TemplateStudioSampleApp.Core/Models/SampleOrder.cs new file mode 100644 index 0000000..79efc68 --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp.Core/Models/SampleOrder.cs @@ -0,0 +1,81 @@ +namespace TemplateStudioSampleApp.Core.Models; + +// Model for the SampleDataService. Replace with your own model. +public class SampleOrder +{ + public long OrderID + { + get; set; + } + + public DateTime OrderDate + { + get; set; + } + + public DateTime RequiredDate + { + get; set; + } + + public DateTime ShippedDate + { + get; set; + } + + public string ShipperName + { + get; set; + } + + public string ShipperPhone + { + get; set; + } + + public double Freight + { + get; set; + } + + public string Company + { + get; set; + } + + public string ShipTo + { + get; set; + } + + public double OrderTotal + { + get; set; + } + + public string Status + { + get; set; + } + + public int SymbolCode + { + get; set; + } + + public string SymbolName + { + get; set; + } + + public char Symbol => (char)SymbolCode; + + public ICollection Details + { + get; set; + } + + public string ShortDescription => $"Order ID: {OrderID}"; + + public override string ToString() => $"{Company} {Status}"; +} diff --git a/Chapter10/TemplateStudioSampleApp.Core/Models/SampleOrderDetail.cs b/Chapter10/TemplateStudioSampleApp.Core/Models/SampleOrderDetail.cs new file mode 100644 index 0000000..1b59773 --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp.Core/Models/SampleOrderDetail.cs @@ -0,0 +1,52 @@ +namespace TemplateStudioSampleApp.Core.Models; + +// Model for the SampleDataService. Replace with your own model. +public class SampleOrderDetail +{ + public long ProductID + { + get; set; + } + + public string ProductName + { + get; set; + } + + public int Quantity + { + get; set; + } + + public double Discount + { + get; set; + } + + public string QuantityPerUnit + { + get; set; + } + + public double UnitPrice + { + get; set; + } + + public string CategoryName + { + get; set; + } + + public string CategoryDescription + { + get; set; + } + + public double Total + { + get; set; + } + + public string ShortDescription => $"Product ID: {ProductID} - {ProductName}"; +} diff --git a/Chapter10/TemplateStudioSampleApp.Core/README.md b/Chapter10/TemplateStudioSampleApp.Core/README.md new file mode 100644 index 0000000..906c066 --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp.Core/README.md @@ -0,0 +1,5 @@ +*Recommended Markdown Viewer: [Markdown Editor](https://marketplace.visualstudio.com/items?itemName=MadsKristensen.MarkdownEditor2)* + +## Getting Started + +The Core project contains code that can be [reused across multiple application projects](https://docs.microsoft.com/dotnet/standard/net-standard#net-5-and-net-standard). diff --git a/Chapter10/TemplateStudioSampleApp.Core/Services/FileService.cs b/Chapter10/TemplateStudioSampleApp.Core/Services/FileService.cs new file mode 100644 index 0000000..a8db112 --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp.Core/Services/FileService.cs @@ -0,0 +1,41 @@ +using System.Text; + +using Newtonsoft.Json; + +using TemplateStudioSampleApp.Core.Contracts.Services; + +namespace TemplateStudioSampleApp.Core.Services; + +public class FileService : IFileService +{ + public T Read(string folderPath, string fileName) + { + var path = Path.Combine(folderPath, fileName); + if (File.Exists(path)) + { + var json = File.ReadAllText(path); + return JsonConvert.DeserializeObject(json); + } + + return default; + } + + public void Save(string folderPath, string fileName, T content) + { + if (!Directory.Exists(folderPath)) + { + Directory.CreateDirectory(folderPath); + } + + var fileContent = JsonConvert.SerializeObject(content); + File.WriteAllText(Path.Combine(folderPath, fileName), fileContent, Encoding.UTF8); + } + + public void Delete(string folderPath, string fileName) + { + if (fileName != null && File.Exists(Path.Combine(folderPath, fileName))) + { + File.Delete(Path.Combine(folderPath, fileName)); + } + } +} diff --git a/Chapter10/TemplateStudioSampleApp.Core/Services/SampleDataService.cs b/Chapter10/TemplateStudioSampleApp.Core/Services/SampleDataService.cs new file mode 100644 index 0000000..0e9bbcb --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp.Core/Services/SampleDataService.cs @@ -0,0 +1,514 @@ +using TemplateStudioSampleApp.Core.Contracts.Services; +using TemplateStudioSampleApp.Core.Models; + +namespace TemplateStudioSampleApp.Core.Services; + +// This class holds sample data used by some generated pages to show how they can be used. +// TODO: The following classes have been created to display sample data. Delete these files once your app is using real data. +// 1. Contracts/Services/ISampleDataService.cs +// 2. Services/SampleDataService.cs +// 3. Models/SampleCompany.cs +// 4. Models/SampleOrder.cs +// 5. Models/SampleOrderDetail.cs +public class SampleDataService : ISampleDataService +{ + private List _allOrders; + + public SampleDataService() + { + } + + private static IEnumerable AllOrders() + { + // The following is order summary data + var companies = AllCompanies(); + return companies.SelectMany(c => c.Orders); + } + + private static IEnumerable AllCompanies() + { + return new List() + { + new SampleCompany() + { + CompanyID = "ALFKI", + CompanyName = "Company A", + ContactName = "Maria Anders", + ContactTitle = "Sales Representative", + Address = "Obere Str. 57", + City = "Berlin", + PostalCode = "12209", + Country = "Germany", + Phone = "030-0074321", + Fax = "030-0076545", + Orders = new List() + { + new SampleOrder() + { + OrderID = 10643, // Symbol Globe + OrderDate = new DateTime(1997, 8, 25), + RequiredDate = new DateTime(1997, 9, 22), + ShippedDate = new DateTime(1997, 9, 22), + ShipperName = "Speedy Express", + ShipperPhone = "(503) 555-9831", + Freight = 29.46, + Company = "Company A", + ShipTo = "Company A, Obere Str. 57, Berlin, 12209, Germany", + OrderTotal = 814.50, + Status = "Shipped", + SymbolCode = 57643, + SymbolName = "Globe", + Details = new List() + { + new SampleOrderDetail() + { + ProductID = 28, + ProductName = "Rössle Sauerkraut", + Quantity = 15, + Discount = 0.25, + QuantityPerUnit = "25 - 825 g cans", + UnitPrice = 45.60, + CategoryName = "Produce", + CategoryDescription = "Dried fruit and bean curd", + Total = 513.00 + }, + new SampleOrderDetail() + { + ProductID = 39, + ProductName = "Chartreuse verte", + Quantity = 21, + Discount = 0.25, + QuantityPerUnit = "750 cc per bottle", + UnitPrice = 18.0, + CategoryName = "Beverages", + CategoryDescription = "Soft drinks, coffees, teas, beers, and ales", + Total = 283.50 + }, + new SampleOrderDetail() + { + ProductID = 46, + ProductName = "Spegesild", + Quantity = 2, + Discount = 0.25, + QuantityPerUnit = "4 - 450 g glasses", + UnitPrice = 12.0, + CategoryName = "Seafood", + CategoryDescription = "Seaweed and fish", + Total = 18.00 + } + } + }, + new SampleOrder() + { + OrderID = 10835, // Symbol Music + OrderDate = new DateTime(1998, 1, 15), + RequiredDate = new DateTime(1998, 2, 12), + ShippedDate = new DateTime(1998, 1, 21), + ShipperName = "Federal Shipping", + ShipperPhone = "(503) 555-9931", + Freight = 69.53, + Company = "Company A", + ShipTo = "Company A, Obere Str. 57, Berlin, 12209, Germany", + OrderTotal = 845.80, + Status = "Closed", + SymbolCode = 57737, + SymbolName = "Audio", + Details = new List() + { + new SampleOrderDetail() + { + ProductID = 59, + ProductName = "Raclette Courdavault", + Quantity = 15, + Discount = 0, + QuantityPerUnit = "5 kg pkg.", + UnitPrice = 55.00, + CategoryName = "Dairy Products", + CategoryDescription = "Cheeses", + Total = 825.00 + }, + new SampleOrderDetail() + { + ProductID = 77, + ProductName = "Original Frankfurter grüne Soße", + Quantity = 2, + Discount = 0.2, + QuantityPerUnit = "12 boxes", + UnitPrice = 13.0, + CategoryName = "Condiments", + CategoryDescription = "Sweet and savory sauces, relishes, spreads, and seasonings", + Total = 20.80 + } + } + }, + new SampleOrder() + { + OrderID = 10952, // Symbol Calendar + OrderDate = new DateTime(1998, 3, 16), + RequiredDate = new DateTime(1998, 4, 27), + ShippedDate = new DateTime(1998, 3, 24), + ShipperName = "Speedy Express", + ShipperPhone = "(503) 555-9831", + Freight = 40.42, + Company = "Company A", + ShipTo = "Company A, Obere Str. 57, Berlin, 12209, Germany", + OrderTotal = 471.20, + Status = "Closed", + SymbolCode = 57699, + SymbolName = "Calendar", + Details = new List() + { + new SampleOrderDetail() + { + ProductID = 6, + ProductName = "Grandma's Boysenberry Spread", + Quantity = 16, + Discount = 0.05, + QuantityPerUnit = "12 - 8 oz jars", + UnitPrice = 25.0, + CategoryName = "Condiments", + CategoryDescription = "Sweet and savory sauces, relishes, spreads, and seasonings", + Total = 380.00 + }, + new SampleOrderDetail() + { + ProductID = 28, + ProductName = "Rössle Sauerkraut", + Quantity = 2, + Discount = 0, + QuantityPerUnit = "25 - 825 g cans", + UnitPrice = 45.60, + CategoryName = "Produce", + CategoryDescription = "Dried fruit and bean curd", + Total = 91.20 + } + } + } + } + }, + new SampleCompany() + { + CompanyID = "ANATR", + CompanyName = "Company F", + ContactName = "Ana Trujillo", + ContactTitle = "Owner", + Address = "Avda. de la Constitución 2222", + City = "México D.F.", + PostalCode = "05021", + Country = "Mexico", + Phone = "(5) 555-4729", + Fax = "(5) 555-3745", + Orders = new List() + { + new SampleOrder() + { + OrderID = 10625, // Symbol Camera + OrderDate = new DateTime(1997, 8, 8), + RequiredDate = new DateTime(1997, 9, 5), + ShippedDate = new DateTime(1997, 8, 14), + ShipperName = "Speedy Express", + ShipperPhone = "(503) 555-9831", + Freight = 43.90, + Company = "Company F", + ShipTo = "Company F, Avda. de la Constitución 2222, 05021, México D.F., Mexico", + OrderTotal = 469.75, + Status = "Shipped", + SymbolCode = 57620, + SymbolName = "Camera", + Details = new List() + { + new SampleOrderDetail() + { + ProductID = 14, + ProductName = "Tofu", + Quantity = 3, + Discount = 0, + QuantityPerUnit = "40 - 100 g pkgs.", + UnitPrice = 23.25, + CategoryName = "Produce", + CategoryDescription = "Dried fruit and bean curd", + Total = 69.75 + }, + new SampleOrderDetail() + { + ProductID = 42, + ProductName = "Singaporean Hokkien Fried Mee", + Quantity = 5, + Discount = 0, + QuantityPerUnit = "32 - 1 kg pkgs.", + UnitPrice = 14.0, + CategoryName = "Grains/Cereals", + CategoryDescription = "Breads, crackers, pasta, and cereal", + Total = 70.00 + }, + new SampleOrderDetail() + { + ProductID = 60, + ProductName = "Camembert Pierrot", + Quantity = 10, + Discount = 0, + QuantityPerUnit = "15 - 300 g rounds", + UnitPrice = 34.00, + CategoryName = "Dairy Products", + CategoryDescription = "Cheeses", + Total = 340.00 + } + } + }, + new SampleOrder() + { + OrderID = 10926, // Symbol Clock + OrderDate = new DateTime(1998, 3, 4), + RequiredDate = new DateTime(1998, 4, 1), + ShippedDate = new DateTime(1998, 3, 11), + ShipperName = "Federal Shipping", + ShipperPhone = "(503) 555-9931", + Freight = 39.92, + Company = "Company F", + ShipTo = "Company F, Avda. de la Constitución 2222, 05021, México D.F., Mexico", + OrderTotal = 507.20, + Status = "Shipped", + SymbolCode = 57633, + SymbolName = "Clock", + Details = new List() + { + new SampleOrderDetail() + { + ProductID = 11, + ProductName = "Queso Cabrales", + Quantity = 2, + Discount = 0, + QuantityPerUnit = "1 kg pkg.", + UnitPrice = 21.0, + CategoryName = "Dairy Products", + CategoryDescription = "Cheeses", + Total = 42.00 + }, + new SampleOrderDetail() + { + ProductID = 13, + ProductName = "Konbu", + Quantity = 10, + Discount = 0, + QuantityPerUnit = "2 kg box", + UnitPrice = 6.0, + CategoryName = "Seafood", + CategoryDescription = "Seaweed and fish", + Total = 60.00 + }, + new SampleOrderDetail() + { + ProductID = 19, + ProductName = "Teatime Chocolate Biscuits", + Quantity = 7, + Discount = 0, + QuantityPerUnit = "10 boxes x 12 pieces", + UnitPrice = 9.20, + CategoryName = "Confections", + CategoryDescription = "Desserts, candies, and sweet breads", + Total = 64.40 + }, + new SampleOrderDetail() + { + ProductID = 72, + ProductName = "Mozzarella di Giovanni", + Quantity = 10, + Discount = 0, + QuantityPerUnit = "24 - 200 g pkgs.", + UnitPrice = 34.80, + CategoryName = "Dairy Products", + CategoryDescription = "Cheeses", + Total = 340.80 + } + } + } + } + }, + new SampleCompany() + { + CompanyID = "ANTON", + CompanyName = "Company Z", + ContactName = "Antonio Moreno", + ContactTitle = "Owner", + Address = "Mataderos 2312", + City = "México D.F.", + PostalCode = "05023", + Country = "Mexico", + Phone = "(5) 555-3932", + Fax = string.Empty, + Orders = new List() + { + new SampleOrder() + { + OrderID = 10507, // Symbol Contact + OrderDate = new DateTime(1997, 4, 15), + RequiredDate = new DateTime(1997, 5, 13), + ShippedDate = new DateTime(1997, 4, 22), + ShipperName = "Speedy Express", + ShipperPhone = "(503) 555-9831", + Freight = 47.45, + Company = "Company Z", + ShipTo = "Company Z, Mataderos 2312, 05023, México D.F., Mexico", + OrderTotal = 978.50, + Status = "Closed", + SymbolCode = 57661, + SymbolName = "Contact", + Details = new List() + { + new SampleOrderDetail() + { + ProductID = 43, + ProductName = "Ipoh Coffee", + Quantity = 15, + Discount = 0.15, + QuantityPerUnit = "16 - 500 g tins", + UnitPrice = 46.0, + CategoryName = "Beverages", + CategoryDescription = "Soft drinks, coffees, teas, beers, and ales", + Total = 816.00 + }, + new SampleOrderDetail() + { + ProductID = 48, + ProductName = "Chocolade", + Quantity = 15, + Discount = 0.15, + QuantityPerUnit = "10 pkgs.", + UnitPrice = 12.75, + CategoryName = "Confections", + CategoryDescription = "Desserts, candies, and sweet breads", + Total = 162.50 + } + } + }, + new SampleOrder() + { + OrderID = 10573, // Symbol Star + OrderDate = new DateTime(1997, 6, 19), + RequiredDate = new DateTime(1997, 7, 17), + ShippedDate = new DateTime(1997, 6, 20), + ShipperName = "Federal Shipping", + ShipperPhone = "(503) 555-9931", + Freight = 84.84, + Company = "Company Z", + ShipTo = "Company Z, Mataderos 2312, 05023, México D.F., Mexico", + OrderTotal = 2082.00, + Status = "Closed", + SymbolCode = 57619, + SymbolName = "Favorite", + Details = new List() + { + new SampleOrderDetail() + { + ProductID = 17, + ProductName = "Alice Mutton", + Quantity = 18, + Discount = 0, + QuantityPerUnit = "20 - 1 kg tins", + UnitPrice = 39.00, + CategoryName = "Meat/Poultry", + CategoryDescription = "Prepared meats", + Total = 702.00 + }, + new SampleOrderDetail() + { + ProductID = 34, + ProductName = "Sasquatch Ale", + Quantity = 40, + Discount = 0, + QuantityPerUnit = "24 - 12 oz bottles", + UnitPrice = 14.0, + CategoryName = "Beverages", + CategoryDescription = "Soft drinks, coffees, teas, beers, and ales", + Total = 560.00 + }, + new SampleOrderDetail() + { + ProductID = 53, + ProductName = "Perth Pasties", + Quantity = 25, + Discount = 0, + QuantityPerUnit = "48 pieces", + UnitPrice = 32.80, + CategoryName = "Meat/Poultry", + CategoryDescription = "Prepared meats", + Total = 820.00 + } + } + }, + new SampleOrder() + { + OrderID = 10682, // Symbol Home + OrderDate = new DateTime(1997, 9, 25), + RequiredDate = new DateTime(1997, 10, 23), + ShippedDate = new DateTime(1997, 10, 1), + ShipperName = "United Package", + ShipperPhone = "(503) 555-3199", + Freight = 36.13, + Company = "Company Z", + ShipTo = "Company Z, Mataderos 2312, 05023, México D.F., Mexico", + OrderTotal = 375.50, + Status = "Closed", + SymbolCode = 57615, + SymbolName = "Home", + Details = new List() + { + new SampleOrderDetail() + { + ProductID = 33, + ProductName = "Geitost", + Quantity = 30, + Discount = 0, + QuantityPerUnit = "500 g", + UnitPrice = 2.50, + CategoryName = "Dairy Products", + CategoryDescription = "Cheeses", + Total = 75.00 + }, + new SampleOrderDetail() + { + ProductID = 66, + ProductName = "Louisiana Hot Spiced Okra", + Quantity = 4, + Discount = 0, + QuantityPerUnit = "24 - 8 oz jars", + UnitPrice = 17.00, + CategoryName = "Condiments", + CategoryDescription = "Sweet and savory sauces, relishes, spreads, and seasonings", + Total = 68.00 + }, + new SampleOrderDetail() + { + ProductID = 75, + ProductName = "Rhönbräu Klosterbier", + Quantity = 30, + Discount = 0, + QuantityPerUnit = "24 - 0.5 l bottles", + UnitPrice = 7.75, + CategoryName = "Beverages", + CategoryDescription = "Soft drinks, coffees, teas, beers, and ales", + Total = 232.50 + } + } + } + } + } + }; + } + + public async Task> GetGridDataAsync() + { + _allOrders ??= new List(AllOrders()); + + await Task.CompletedTask; + return _allOrders; + } + + public async Task> GetListDetailsDataAsync() + { + _allOrders ??= new List(AllOrders()); + + await Task.CompletedTask; + return _allOrders; + } +} diff --git a/Chapter10/TemplateStudioSampleApp.Core/TemplateStudioSampleApp.Core.csproj b/Chapter10/TemplateStudioSampleApp.Core/TemplateStudioSampleApp.Core.csproj new file mode 100644 index 0000000..9fa92dc --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp.Core/TemplateStudioSampleApp.Core.csproj @@ -0,0 +1,17 @@ + + + net7.0 + TemplateStudioSampleApp.Core + AnyCPU;x64;x86 + x86;x64;arm64;AnyCPU + enable + + + + + + + + + + diff --git a/Chapter10/TemplateStudioSampleApp.Tests.MSTest/Initialize.cs b/Chapter10/TemplateStudioSampleApp.Tests.MSTest/Initialize.cs new file mode 100644 index 0000000..2b9ad70 --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp.Tests.MSTest/Initialize.cs @@ -0,0 +1,23 @@ +using Microsoft.Windows.ApplicationModel.DynamicDependency; + +[assembly: WinUITestTarget(typeof(TemplateStudioSampleApp.App))] + +namespace TemplateStudioSampleApp.Tests.MSTest; + +[TestClass] +public class Initialize +{ + [AssemblyInitialize] + public static void AssemblyInitialize(TestContext context) + { + // TODO: Initialize the appropriate version of the Windows App SDK. + // This is required when testing MSIX apps that are framework-dependent on the Windows App SDK. + Bootstrap.TryInitialize(0x00010001, out var _); + } + + [AssemblyCleanup] + public static void AssemblyCleanup() + { + Bootstrap.Shutdown(); + } +} diff --git a/Chapter10/TemplateStudioSampleApp.Tests.MSTest/README.md b/Chapter10/TemplateStudioSampleApp.Tests.MSTest/README.md new file mode 100644 index 0000000..ab7f793 --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp.Tests.MSTest/README.md @@ -0,0 +1,67 @@ +*Recommended Markdown Viewer: [Markdown Editor](https://marketplace.visualstudio.com/items?itemName=MadsKristensen.MarkdownEditor2)* + +## Getting Started + +[Get started with unit testing](https://docs.microsoft.com/visualstudio/test/getting-started-with-unit-testing?view=vs-2022&tabs=dotnet%2Cmstest), [Use the MSTest framework in unit tests](https://docs.microsoft.com/visualstudio/test/using-microsoft-visualstudio-testtools-unittesting-members-in-unit-tests), and [Run unit tests with Test Explorer](https://docs.microsoft.com/visualstudio/test/run-unit-tests-with-test-explorer) provide an overview of the MSTest framework and Test Explorer. + +## Testing UI Controls + +Unit tests that exercise UI controls must run on the WinUI UI thread or they will throw an exception. To run a test on the WinUI UI thread, mark the test method with `[UITestMethod]` instead of `[TestMethod]`. During test execution, the test host will launch the app and dispatch the test to the app's UI thread. + +The below example creates a `new Grid()` and then validates that its `ActualWidth` is `0`. + +```csharp +[UITestMethod] +public void UITestMethod() +{ + Assert.AreEqual(0, new Grid().ActualWidth); +} +``` + +## Dependency Injection and Mocking + +Template Studio uses [dependency injection](https://docs.microsoft.com/dotnet/core/extensions/dependency-injection) which means class dependencies implement interfaces and those dependencies are injected via class constructors. + +One of the many benefits of this approach is improved testability, since tests can produce mock implementations of the interfaces and pass them into the object being tested, isolating the object being tested from its dependencies. To mock an interface, create a class that implements the interface, create stub implementations of the interface members, then pass an instance of the class into the object constructor. + +The below example demonstrates testing the ViewModel for the Settings page. `SettingsViewModel` depends on `IThemeSelectorService`, so a `MockThemeSelectorService` class is introduced that implements the interface with stub implementations, and then an instance of that class is passed into the `SettingsViewModel` constructor. The `VerifyVersionDescription` test then validates that the `VersionDescription` property of the `SettingsViewModel` returns the expected value. + +```csharp +// SettingsViewModelTests.cs + +[TestClass] +public class SettingsViewModelTests +{ + private readonly SettingsViewModel _viewModel; + + public SettingsViewModelTests() + { + _viewModel = new SettingsViewModel(new MockThemeSelectorService()); + } + + [TestMethod] + public void VerifyVersionDescription() + { + Assert.IsTrue(Regex.IsMatch(_viewModel.VersionDescription, @"App1 - \d\.\d\.\d\.\d")); + } +} +``` + +```csharp +// Mocks/MockThemeSelectorService.cs + +internal class MockThemeSelectorService : IThemeSelectorService +{ + public ElementTheme Theme => ElementTheme.Default; + + public Task InitializeAsync() => Task.CompletedTask; + + public Task SetRequestedThemeAsync() => Task.CompletedTask; + + public Task SetThemeAsync(ElementTheme theme) => Task.CompletedTask; +} +``` + +## CI Pipelines + +See [README.md](https://github.com/microsoft/TemplateStudio/blob/main/docs/WinUI/pipelines/README.md) for guidance on building and testing projects in CI pipelines. diff --git a/Chapter10/TemplateStudioSampleApp.Tests.MSTest/TemplateStudioSampleApp.Tests.MSTest.csproj b/Chapter10/TemplateStudioSampleApp.Tests.MSTest/TemplateStudioSampleApp.Tests.MSTest.csproj new file mode 100644 index 0000000..ff03e52 --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp.Tests.MSTest/TemplateStudioSampleApp.Tests.MSTest.csproj @@ -0,0 +1,22 @@ + + + net7.0-windows10.0.19041.0 + TemplateStudioSampleApp.Tests.MSTest + x86;x64;arm64 + false + enable + enable + true + true + resources.pri + + + + + + + + + + + diff --git a/Chapter10/TemplateStudioSampleApp.Tests.MSTest/TestClass.cs b/Chapter10/TemplateStudioSampleApp.Tests.MSTest/TestClass.cs new file mode 100644 index 0000000..2d9ff54 --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp.Tests.MSTest/TestClass.cs @@ -0,0 +1,50 @@ +using System.Diagnostics; + +using Microsoft.UI.Xaml.Controls; + +namespace TemplateStudioSampleApp.Tests.MSTest; + +// TODO: Write unit tests. +// https://docs.microsoft.com/visualstudio/test/getting-started-with-unit-testing +// https://docs.microsoft.com/visualstudio/test/using-microsoft-visualstudio-testtools-unittesting-members-in-unit-tests +// https://docs.microsoft.com/visualstudio/test/run-unit-tests-with-test-explorer + +[TestClass] +public class TestClass +{ + [ClassInitialize] + public static void ClassInitialize(TestContext context) + { + Debug.WriteLine("ClassInitialize"); + } + + [ClassCleanup] + public static void ClassCleanup() + { + Debug.WriteLine("ClassCleanup"); + } + + [TestInitialize] + public void TestInitialize() + { + Debug.WriteLine("TestInitialize"); + } + + [TestCleanup] + public void TestCleanup() + { + Debug.WriteLine("TestCleanup"); + } + + [TestMethod] + public void TestMethod() + { + Assert.IsTrue(true); + } + + [UITestMethod] + public void UITestMethod() + { + Assert.AreEqual(0, new Grid().ActualWidth); + } +} diff --git a/Chapter10/TemplateStudioSampleApp.Tests.MSTest/Usings.cs b/Chapter10/TemplateStudioSampleApp.Tests.MSTest/Usings.cs new file mode 100644 index 0000000..e91519c --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp.Tests.MSTest/Usings.cs @@ -0,0 +1,2 @@ +global using Microsoft.VisualStudio.TestTools.UnitTesting; +global using Microsoft.VisualStudio.TestTools.UnitTesting.AppContainer; diff --git a/Chapter10/TemplateStudioSampleApp/Activation/ActivationHandler.cs b/Chapter10/TemplateStudioSampleApp/Activation/ActivationHandler.cs new file mode 100644 index 0000000..433b0e6 --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp/Activation/ActivationHandler.cs @@ -0,0 +1,17 @@ +namespace TemplateStudioSampleApp.Activation; + +// Extend this class to implement new ActivationHandlers. See DefaultActivationHandler for an example. +// https://github.com/microsoft/TemplateStudio/blob/main/docs/WinUI/activation.md +public abstract class ActivationHandler : IActivationHandler + where T : class +{ + // Override this method to add the logic for whether to handle the activation. + protected virtual bool CanHandleInternal(T args) => true; + + // Override this method to add the logic for your activation handler. + protected abstract Task HandleInternalAsync(T args); + + public bool CanHandle(object args) => args is T && CanHandleInternal((args as T)!); + + public async Task HandleAsync(object args) => await HandleInternalAsync((args as T)!); +} diff --git a/Chapter10/TemplateStudioSampleApp/Activation/DefaultActivationHandler.cs b/Chapter10/TemplateStudioSampleApp/Activation/DefaultActivationHandler.cs new file mode 100644 index 0000000..f8dc7a3 --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp/Activation/DefaultActivationHandler.cs @@ -0,0 +1,29 @@ +using Microsoft.UI.Xaml; + +using TemplateStudioSampleApp.Contracts.Services; +using TemplateStudioSampleApp.ViewModels; + +namespace TemplateStudioSampleApp.Activation; + +public class DefaultActivationHandler : ActivationHandler +{ + private readonly INavigationService _navigationService; + + public DefaultActivationHandler(INavigationService navigationService) + { + _navigationService = navigationService; + } + + protected override bool CanHandleInternal(LaunchActivatedEventArgs args) + { + // None of the ActivationHandlers has handled the activation. + return _navigationService.Frame?.Content == null; + } + + protected async override Task HandleInternalAsync(LaunchActivatedEventArgs args) + { + _navigationService.NavigateTo(typeof(MainViewModel).FullName!, args.Arguments); + + await Task.CompletedTask; + } +} diff --git a/Chapter10/TemplateStudioSampleApp/Activation/IActivationHandler.cs b/Chapter10/TemplateStudioSampleApp/Activation/IActivationHandler.cs new file mode 100644 index 0000000..54b5d85 --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp/Activation/IActivationHandler.cs @@ -0,0 +1,8 @@ +namespace TemplateStudioSampleApp.Activation; + +public interface IActivationHandler +{ + bool CanHandle(object args); + + Task HandleAsync(object args); +} diff --git a/Chapter10/TemplateStudioSampleApp/App.xaml b/Chapter10/TemplateStudioSampleApp/App.xaml new file mode 100644 index 0000000..7d360dc --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp/App.xaml @@ -0,0 +1,15 @@ + + + + + + + + + + + + diff --git a/Chapter10/TemplateStudioSampleApp/App.xaml.cs b/Chapter10/TemplateStudioSampleApp/App.xaml.cs new file mode 100644 index 0000000..acb74b5 --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp/App.xaml.cs @@ -0,0 +1,107 @@ +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Microsoft.UI.Xaml; + +using TemplateStudioSampleApp.Activation; +using TemplateStudioSampleApp.Contracts.Services; +using TemplateStudioSampleApp.Core.Contracts.Services; +using TemplateStudioSampleApp.Core.Services; +using TemplateStudioSampleApp.Helpers; +using TemplateStudioSampleApp.Models; +using TemplateStudioSampleApp.Services; +using TemplateStudioSampleApp.ViewModels; +using TemplateStudioSampleApp.Views; + +namespace TemplateStudioSampleApp; + +// To learn more about WinUI 3, see https://docs.microsoft.com/windows/apps/winui/winui3/. +public partial class App : Application +{ + // The .NET Generic Host provides dependency injection, configuration, logging, and other services. + // https://docs.microsoft.com/dotnet/core/extensions/generic-host + // https://docs.microsoft.com/dotnet/core/extensions/dependency-injection + // https://docs.microsoft.com/dotnet/core/extensions/configuration + // https://docs.microsoft.com/dotnet/core/extensions/logging + public IHost Host + { + get; + } + + public static T GetService() + where T : class + { + if ((App.Current as App)!.Host.Services.GetService(typeof(T)) is not T service) + { + throw new ArgumentException($"{typeof(T)} needs to be registered in ConfigureServices within App.xaml.cs."); + } + + return service; + } + + public static WindowEx MainWindow { get; } = new MainWindow(); + + public static UIElement? AppTitlebar { get; set; } + + public App() + { + InitializeComponent(); + + Host = Microsoft.Extensions.Hosting.Host. + CreateDefaultBuilder(). + UseContentRoot(AppContext.BaseDirectory). + ConfigureServices((context, services) => + { + // Default Activation Handler + services.AddTransient, DefaultActivationHandler>(); + + // Other Activation Handlers + + // Services + services.AddSingleton(); + services.AddSingleton(); + services.AddTransient(); + services.AddTransient(); + + services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); + + // Core Services + services.AddSingleton(); + services.AddSingleton(); + + // Views and ViewModels + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + + // Configuration + services.Configure(context.Configuration.GetSection(nameof(LocalSettingsOptions))); + }). + Build(); + + UnhandledException += App_UnhandledException; + } + + private void App_UnhandledException(object sender, Microsoft.UI.Xaml.UnhandledExceptionEventArgs e) + { + // TODO: Log and handle exceptions as appropriate. + // https://docs.microsoft.com/windows/windows-app-sdk/api/winrt/microsoft.ui.xaml.application.unhandledexception. + } + + protected async override void OnLaunched(LaunchActivatedEventArgs args) + { + base.OnLaunched(args); + + await App.GetService().ActivateAsync(args); + } +} diff --git a/Chapter10/TemplateStudioSampleApp/Assets/LockScreenLogo.scale-200.png b/Chapter10/TemplateStudioSampleApp/Assets/LockScreenLogo.scale-200.png new file mode 100644 index 0000000000000000000000000000000000000000..735f57adb5dfc01886d137b4e493d7e97cf13af3 GIT binary patch literal 1430 zcmaJ>TTC2P7~aKltDttVHYH6u8Io4i*}3fO&d$gd*bA_<3j~&e7%8(eXJLfhS!M@! zKrliY>>6yT4+Kr95$!DoD(Qn-5TP|{V_KS`k~E6(LGS@#`v$hQo&^^BKsw3HIsZBT z_y6C2n`lK@apunKojRQ^(_P}Mgewt$(^BBKCTZ;*xa?J3wQ7~@S0lUvbcLeq1Bg4o zH-bvQi|wt~L7q$~a-gDFP!{&TQfc3fX*6=uHv* zT&1&U(-)L%Xp^djI2?~eBF2cxC@YOP$+9d?P&h?lPy-9M2UT9fg5jKm1t$m#iWE{M zIf%q9@;fyT?0UP>tcw-bLkz;s2LlKl2qeP0w zECS7Ate+Awk|KQ+DOk;fl}Xsy4o^CY=pwq%QAAKKl628_yNPsK>?A>%D8fQG6IgdJ ztnxttBz#NI_a@fk7SU`WtrpsfZsNs9^0(2a z@C3#YO3>k~w7?2hipBf{#b6`}Xw1hlG$yi?;1dDs7k~xDAw@jiI*+tc;t2Lflg&bM)0!Y;0_@=w%`LW^8DsYpS#-bLOklX9r?Ei}TScw|4DbpW%+7 zFgAI)f51s}{y-eWb|vrU-Ya!GuYKP)J7z#*V_k^Xo>4!1Yqj*m)x&0L^tg3GJbVAJ zJ-Pl$R=NAabouV=^z_t;^K*0AvFs!vYU>_<|I^#c?>>CR<(T?=%{;U=aI*SbZADLH z&(f2wz_Y0??Tf|g;?|1Znw6}6U43Q#qNRwv1vp9uFn1)V#*4p&%$mP9x&15^OaBiDS(XppT|z^>;B{PLVEbS3IFYV yGvCsSX*m literal 0 HcmV?d00001 diff --git a/Chapter10/TemplateStudioSampleApp/Assets/SplashScreen.scale-200.png b/Chapter10/TemplateStudioSampleApp/Assets/SplashScreen.scale-200.png new file mode 100644 index 0000000000000000000000000000000000000000..023e7f1feda78d5100569825acedfd213a0d84e9 GIT binary patch literal 7700 zcmeHLYj~4Yw%(;oxoEH#Kxq-eR|+VkP17b#Vk;?4QwkI+A{L04G+#<<(x#Un1#+h5>eArRq zTw$)ZvTWW_Y?bDho0nPVTh08+s`sp!j74rJTTtXIDww0SILedFv?sZ?yb@@}GN;#8 znk_b~Q(A0YR#uV4ef!osoV1M3;vQ8N$O|fStfgf$S5;ddUNv`tWtGjM;koG#N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sRgwzwq!N6obW9+7(R; z(SZ=23`|`>qil!LMGG{_Heq!BD>(Y-zV9wD)}hz25JA37YR%39;kI4y9pgtcUass6 zP24}ZY$vvYeI`zy&)A_X#nY3017ap*0&jx|mVwyGhg3;!keU53a}Uhm3BZI$N$6Se zLWlAmy1S0xKJm4G_U@sN_Tm=`$xWJSEwKU98rZ&)1R^*$$1vA3oG#&*%SMxY_~oGP zP&PFJatFLM-Ps%84IV-+Ow)T{C7cqUAvauy4C z(FRz&?6$Rypj{xO!`y=*J5o4@U8Q-(y5(*=YoKeZ+-1YdljXxkA#B)zo=FeQH#?Le zycNUmEEHWO9a=X^pb#&cOq7-`7UA87#|S22)<7RUtZo|(zibX=w;K3qur9vy#`MNV z6UUcf9ZwEnKCCp+OoBnF@OdbvH)ANXO0o~Pi9l8=x3))}L<#vO0-~O4!~--Ket?d} zJaqsj<@CD1%S2cTW%rOP{Vto%0sGW~1RMa_j^)5nil0Yw- z0EE#bP+l4#P^%PQ+N*oxu1Zq05xZ!bXfYTg>9c{(Iw*lnjR^>kz%lAN^zFce7rppy zY8zA~3GD=A6d*hze&l4D_wA~+O!56)BZTe_rEu}Ezi<4!kG|W#amBZ5{&XS2@6R~H z{9o^y*BkH4$~yX9U&@CgbOzX1bn9xqF|zh$Dh0Y5y*E0e90*$!ObrHY3Ok0`2=O~r zCuke6KrP9KOf?V(YDsM<6pX2nVoN%M$LT^q#FmtaF?1^27F*IcNX~XRB(|hCFvdcc zc)$=S-)acdk$g4?_>jRqxpI6M3vHZk?0c^3=byamYDNf;uB{3NlKW5IhnOS3DNkMV z?tK8?kJ}pmvp%&&eTVOVjHP`q34hN1@!aK}H(K!vI`~gf|Gv+FNEQD5Yd<~yX7k_l h&G-K)@HZb3BABY{)U1?^%I#E6`MGoTtustd{~yM6srvu` literal 0 HcmV?d00001 diff --git a/Chapter10/TemplateStudioSampleApp/Assets/Square150x150Logo.scale-200.png b/Chapter10/TemplateStudioSampleApp/Assets/Square150x150Logo.scale-200.png new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fr2^t8H(>L?>K#>^+jWROLral(Qy-xoBq1U7A&DV||wClb)Otd9?(gZ|8znMF}D zf<1haWz^s0qgecz;RFGt0C-B4g`jNGHsFU+;{<%t65v^sjk^h$lmWn#B0#_)9ij&d z-~lc`A)YYExi^7sBuPM^Y|wA2g*5?`K?#7tzELQYNxGo$UB$4J8RJp1k(8Jj+~hMT zlN~>M@KTTh^--8y3PK_NZ@AC!{PT=CziBzGd+wTJ^@icH!Bd}%)g8V)%K?|c&WTUk zy}qv1C%(fjRoZ4ozC3{O%@5?)XzH35zHns$pgU*Q?fj4v?fp1Qbm+j;3l;9jam9Da zXVcKjPlQ73x78QPu|Ffm6x?`~e3oD=gl=4kYK?={kD5j~QCXU)`HSdduNNENzA*2$ zOm3PzF!lN5e*06-f1Uot67wY#{o-S1!KZ7E=!~7ynnk9_iJR#kFoNbAOT#^2Gd17F zMmvU6>lndZQGd|ax9kUoXXO+$N?|j@6qpsF&_j7YXvwo_C{JpmLw5&#e6k>atv%es z5)7r*Wvv_JkUpT}M!_o!nVlEk1Zbl=a*2hQ*<|%*K1Glj^FcF`6kTzGQ3lz~2tCc@ z&x|tj;aH&1&9HwcJBcT`;{?a+pnej;M1HO(6Z{#J!cZA04hnFl;NXA+&`=7bjW_^o zfC40u3LMG?NdPtwGl>Tq6u}*QG)}-y;)lu-_>ee3kibW(69n0$0Zy!}9rQz%*v1iO zT9_H>99yIrSPYVy6^);rR}7Yo=J_T@hi+qhTZXnVWyf;JDYm5#eYLTxr*?kiNn!+Y zQ+LUkBafNJ#rH#C(?d5^;gw9o#%daEI{mA*LHPIHPU`#|H$hD zwm>0&+kahQ)E#%~k>&5@&#Vg82H?s%71=)(soi@174pi9--2{w{1$}Sz4zGn3Du&x bht0Iza^2ykEt4(epJ78uh5nDlX8(TxzDYwP literal 0 HcmV?d00001 diff --git a/Chapter10/TemplateStudioSampleApp/Assets/Square44x44Logo.scale-200.png b/Chapter10/TemplateStudioSampleApp/Assets/Square44x44Logo.scale-200.png new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w#txRWhb3%TQvPqjkC`F69G4b! ze7z9MZ#+;_#l?H37UqUhDFb^l&s2{oM$3I0o^Q!yx;;V)QmCMo)Tb_ui|mit8MS?U zm##6$sZZ1$@|s%?l@>4Z<*Q}sRBSKMhb4I{e5LdEhsHIHTe8Bod5c>6QtT>$XgUBz z6MK`kO$=jmt@FqggOhJ5j~e@ygRbG;<{Vu)*+nn9aQeo0;$#j;|MS=S$&L?BeV25z xs3B`@=#`5TF{^6(A1rvdY@|-RtQ|iS5{tyX+wH?;n8E)G$kykv-D^wh{{!TZT%7;_ literal 0 HcmV?d00001 diff --git a/Chapter10/TemplateStudioSampleApp/Assets/Square44x44Logo.targetsize-24_altform-unplated.png b/Chapter10/TemplateStudioSampleApp/Assets/Square44x44Logo.targetsize-24_altform-unplated.png new file mode 100644 index 0000000000000000000000000000000000000000..f6c02ce97e0a802b85f6021e822c89f8bf57d5cd GIT binary patch literal 1255 zcmaJ>TWs4@7*5+{G#S+&C!qC#> zf>5N3P6jO*Cz>ug*(_DmW=)kea&m$gZ^+nyiF`;j%w@}y8)>p*SH}C`m?DXeieF2U zyQHecc_L%Gh!7GMt+hG06y;+|p4>m~}PjA}rKViGiEnn7G0ZO<>G|7q;2?NwGCM3s?eued6%hd$B+ z*kQJ{#~$S=DFE(%=E+UkmlEI*%3llUf~8Ja9YU1Vui0IbGBkW_gHB%Rd&!!ioX zs40O?i9I{};kle7GMvE7(rk`la=gTI)47=>%?q@^iL-nUo3}h4S}N-KHn8t5mVP8w z&bSErwp+37 zNJJ8?a|{r5Q3R0Z5s-LB1WHOwYC@7pCHWND#cL1cZ?{kJ368_*(UDWUDyb<}0y@o# zfMF016iMWPCb6obAxT$JlB6(2DrlXDTB&!0`!m??4F(qWMhjVZo?JXQmz`1*58Z=& zcDmB|S-E@j?BoFGix0flckqdS4jsPNzhfWyWIM98GxcLs89C(~dw%$_t;JjX-SD}E zfiGV;{8Q%8r}w9x>EEigW81>`kvnU@pK)4+xk9@+bNj9L!AAZ@SZ@q|)&BmY3+HZx zul~BeG4|}-;L%cHViQGQX?^zFfO0&#cHwel=d`lH9sJ-@Sl@n*(8J2>%Ac`IxyY?Q z{=GhWvC#gu-~Ia7*n{=+;qM?Ul_wy1+u7ho;=`>EwP^g~R@{unBds`!#@}tluZQpS zm)M~nYEifJWJGx?_6DcTy>#uh%>!H9=hb^(v`=m3F1{L>db=<5_tm+_&knAQ2EU$s Mu9UqpbNZeC0BbUo^Z)<= literal 0 HcmV?d00001 diff --git a/Chapter10/TemplateStudioSampleApp/Assets/StoreLogo.png b/Chapter10/TemplateStudioSampleApp/Assets/StoreLogo.png new file mode 100644 index 0000000000000000000000000000000000000000..7385b56c0e4d3c6b0efe3324aa1194157d837826 GIT binary patch literal 1451 zcmaJ>eN5D57_Z|bH;{0+1#mbl)eTU3{h)Wf7EZV?;HD@XL@{B`Ui%(2aMxQ~xdXSv z5nzWi(LW)U2=Vc-cY@s7nPt{i0hc6!7xN4NNHI#EQl>YNBy8l4%x9gr_W-j zEZMQmmTIy(>;lblRfh`dIyTgc9W5d!VP$L4(kKrN1c5G~(O_#xG zAJCNTstD^5SeXFB+&$h=ToJP2H>xr$iqPs-#O*;4(!Fjw25-!gEb*)mU}=)J;Iu>w zxK(5XoD0wrPSKQ~rbL^Cw6O_03*l*}i=ydbu7adJ6y;%@tjFeXIXT+ms30pmbOP%Q zX}S;+LBh8Tea~TSkHzvX6$rYb)+n&{kSbIqh|c7hmlxmwSiq5iVhU#iEQ<>a18|O^Sln-8t&+t`*{qBWo5M?wFM(JuimAOb5!K#D}XbslM@#1ZVz_;!9U zpfEpLAOz=0g@bd6Xj_ILi-x^!M}73h^o@}hM$1jflTs|Yuj9AL@A3<-?MV4!^4q`e z)fO@A;{9K^?W?DbnesnPr6kK>$zaKo&;FhFd(GYFCIU^T+OIMb%Tqo+P%oq(IdX7S zf6+HLO?7o0m+p>~Tp5UrXWh!UH!wZ5kv!E`_w)PTpI(#Iw{AS`gH4^b(bm^ZCq^FZ zY9DD7bH}rq9mg88+KgA$Zp!iWncuU2n1AuIa@=sWvUR-s`Qb{R*kk(SPU^`$6BXz8 zn#7yaFOIK%qGxyi`dYtm#&qqox0$h=pNi#u=M8zUG@bpiZ=3sT=1}Trr}39cC)H|v zbL?W)=&s4zrh)7>L(|cc%$1#!zfL?HjpeP%T+x_a+jZ16b^iKOHxFEX$7d|8${H-* zIrOJ5w&i$>*D>AKaIoYg`;{L@jM((Kt?$N$5OnuPqVvq**Nm}(f0wwOF%iX_Pba;V z;m@wxX&NcV3?<1+u?A{y_DIj7#m3Af1rCE)o`D&Y3}0%7E;iX1yMDiS)sh0wKi!36 zL!Wmq?P^Ku&rK~HJd97KkLTRl>ScGFYZNlYytWnhmuu|)L&ND8_PmkayQb{HOY640 bno1(wj@u8DCVuFR|31B*4ek@pZJqxCDDe1x literal 0 HcmV?d00001 diff --git a/Chapter10/TemplateStudioSampleApp/Assets/Wide310x150Logo.scale-200.png b/Chapter10/TemplateStudioSampleApp/Assets/Wide310x150Logo.scale-200.png new file mode 100644 index 0000000000000000000000000000000000000000..288995b397fdbef1fb7e85afd71445d5de1952c5 GIT binary patch literal 3204 zcmbVPeQXow8NYmBd90>}0NP?GhXW~VaeThm=a0tV#EwJMI!)6M3}|c4_Bl3=Kd>G0 z(GHx1wl<7(tP?FsOQkTilSo*iIvF%uArExJ73~P zSv1xEy!U(Wd4A9D`FQV@W3@F^qJ@PEF$@z`Z!*BbFsS(^?B zyiAzJ+q})bkgiQHWqEb*jJD-coHYr1^iocg)l!Qa{Xqs-l~6J}p-|##ZHYofskQ3$ zI0;xzXyhazBeXhIsg5A=%ufo@f)1yy&ScKS0;HF^!r_2UE^lpZEom(+@duma3awTv zCrCL-%D_SvYWIcdHkmI}#50(fkUi)Qgx!80ju>g1za^}ff>JI8Z@^-iCiaCgg@TgF z+vtE?Q9{VQUX&MW9SYYmGcxA14%N2@7FwBTD4N<(2{nWgV8$e3?-F=L^&FrtWn~(U_Q~~^uYiyeY6-KoTnfh9AWz@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)LJ`xzilqID~Izxc5=H28K+a9x@P-_yf2JN3=8 z-wX6&&e`~Brk?M5zfAQ|H6d$sf)RjNTd_4CzI%vp7R;I)coNkG`!Q6HQy_j{h*M_P zz8F)=_YHyV!wB#QX}!1xK97%8yFCi`>nG0mgn&M0YvMC@2J1RH3$tu+T({U&hhX$KPW)!YgcOsQ%cUp%LpNA#K z|7X`i#Ft<#=`UI%&^V9pTw`H5xVIa{WQ*+WWDiHQ`HR+8pIw7cU1V(TvH{E*2ko;k z|6?M)1!5m&*HYs4d|0bhS=$iXti2rA!*QKaVJ8=@X>4H~1?x1ly`l|PRK7Kfk7xY_ zu-_?}vxyy=*uxp@JI?!P2dDV)s`E36$G|!$E*#fJWNila?e&tR?^m*KLwTw8wY;d! zziN3@K1eUnjcY)lUz+>5z4XYQc?1UydmlN;3vj*irSfRGxJIGJRdZ_hO$VE6$_9A> z+FYwEuWA|M=fsW+a~s+Vaj!3ID|-J&Y`D}eDQ=U*bpo@067FmBefy~3Jcj#)pq+-X zr2+N~>}YVze9sqX2Mppj@6STYW9MUHi$PnRGpsXUK87+ym{+tF!nK0x_I<&53+6$v zKao8h3SfRA@V4frP9x|_jy{RT_ONbpp8%}lg|BCw%FIz5DDHN7T z6~eq!I5vvB`9n?S5Hq}9m6OFahg8VPg1e7uK`v3Kn#D2q%Ho;BCl|=?yvyOb&>xbp zP#@MyO5(hT-ZlCFz73W zI2eo{GXc?y{yv#!*5kZVVJpFRSoEdgxQgR-lB0~V=*MCQSkC9(P4N-jD-M5;+-@!@j5Zf6ZnO;~~W#^BMY8waLCu?0X3MAK*RftKY0;@uCH|=M0RioyhwJ zi?;^90`$h}{}8{6>u|;{4*T+Ws$_oe_(brQuxCbw*RS0-1D3d)GCja|0mv%~0blS3 uP%O@+*Bs76h}X~NDhso;l*+SeDGRfulm&$ +{ + private static NavigationViewHeaderBehavior? _current; + + private Page? _currentPage; + + public DataTemplate? DefaultHeaderTemplate + { + get; set; + } + + public object DefaultHeader + { + get => GetValue(DefaultHeaderProperty); + set => SetValue(DefaultHeaderProperty, value); + } + + public static readonly DependencyProperty DefaultHeaderProperty = + DependencyProperty.Register("DefaultHeader", typeof(object), typeof(NavigationViewHeaderBehavior), new PropertyMetadata(null, (d, e) => _current!.UpdateHeader())); + + public static NavigationViewHeaderMode GetHeaderMode(Page item) => (NavigationViewHeaderMode)item.GetValue(HeaderModeProperty); + + public static void SetHeaderMode(Page item, NavigationViewHeaderMode value) => item.SetValue(HeaderModeProperty, value); + + public static readonly DependencyProperty HeaderModeProperty = + DependencyProperty.RegisterAttached("HeaderMode", typeof(bool), typeof(NavigationViewHeaderBehavior), new PropertyMetadata(NavigationViewHeaderMode.Always, (d, e) => _current!.UpdateHeader())); + + public static object GetHeaderContext(Page item) => item.GetValue(HeaderContextProperty); + + public static void SetHeaderContext(Page item, object value) => item.SetValue(HeaderContextProperty, value); + + public static readonly DependencyProperty HeaderContextProperty = + DependencyProperty.RegisterAttached("HeaderContext", typeof(object), typeof(NavigationViewHeaderBehavior), new PropertyMetadata(null, (d, e) => _current!.UpdateHeader())); + + public static DataTemplate GetHeaderTemplate(Page item) => (DataTemplate)item.GetValue(HeaderTemplateProperty); + + public static void SetHeaderTemplate(Page item, DataTemplate value) => item.SetValue(HeaderTemplateProperty, value); + + public static readonly DependencyProperty HeaderTemplateProperty = + DependencyProperty.RegisterAttached("HeaderTemplate", typeof(DataTemplate), typeof(NavigationViewHeaderBehavior), new PropertyMetadata(null, (d, e) => _current!.UpdateHeaderTemplate())); + + protected override void OnAttached() + { + base.OnAttached(); + + var navigationService = App.GetService(); + navigationService.Navigated += OnNavigated; + + _current = this; + } + + protected override void OnDetaching() + { + base.OnDetaching(); + + var navigationService = App.GetService(); + navigationService.Navigated -= OnNavigated; + } + + private void OnNavigated(object sender, NavigationEventArgs e) + { + if (sender is Frame frame && frame.Content is Page page) + { + _currentPage = page; + + UpdateHeader(); + UpdateHeaderTemplate(); + } + } + + private void UpdateHeader() + { + if (_currentPage != null) + { + var headerMode = GetHeaderMode(_currentPage); + if (headerMode == NavigationViewHeaderMode.Never) + { + AssociatedObject.Header = null; + AssociatedObject.AlwaysShowHeader = false; + } + else + { + var headerFromPage = GetHeaderContext(_currentPage); + if (headerFromPage != null) + { + AssociatedObject.Header = headerFromPage; + } + else + { + AssociatedObject.Header = DefaultHeader; + } + + if (headerMode == NavigationViewHeaderMode.Always) + { + AssociatedObject.AlwaysShowHeader = true; + } + else + { + AssociatedObject.AlwaysShowHeader = false; + } + } + } + } + + private void UpdateHeaderTemplate() + { + if (_currentPage != null) + { + var headerTemplate = GetHeaderTemplate(_currentPage); + AssociatedObject.HeaderTemplate = headerTemplate ?? DefaultHeaderTemplate; + } + } +} diff --git a/Chapter10/TemplateStudioSampleApp/Behaviors/NavigationViewHeaderMode.cs b/Chapter10/TemplateStudioSampleApp/Behaviors/NavigationViewHeaderMode.cs new file mode 100644 index 0000000..8b95edb --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp/Behaviors/NavigationViewHeaderMode.cs @@ -0,0 +1,8 @@ +namespace TemplateStudioSampleApp.Behaviors; + +public enum NavigationViewHeaderMode +{ + Always, + Never, + Minimal +} diff --git a/Chapter10/TemplateStudioSampleApp/Contracts/Services/IActivationService.cs b/Chapter10/TemplateStudioSampleApp/Contracts/Services/IActivationService.cs new file mode 100644 index 0000000..3a2389e --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp/Contracts/Services/IActivationService.cs @@ -0,0 +1,6 @@ +namespace TemplateStudioSampleApp.Contracts.Services; + +public interface IActivationService +{ + Task ActivateAsync(object activationArgs); +} diff --git a/Chapter10/TemplateStudioSampleApp/Contracts/Services/ILocalSettingsService.cs b/Chapter10/TemplateStudioSampleApp/Contracts/Services/ILocalSettingsService.cs new file mode 100644 index 0000000..92b4405 --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp/Contracts/Services/ILocalSettingsService.cs @@ -0,0 +1,8 @@ +namespace TemplateStudioSampleApp.Contracts.Services; + +public interface ILocalSettingsService +{ + Task ReadSettingAsync(string key); + + Task SaveSettingAsync(string key, T value); +} diff --git a/Chapter10/TemplateStudioSampleApp/Contracts/Services/INavigationService.cs b/Chapter10/TemplateStudioSampleApp/Contracts/Services/INavigationService.cs new file mode 100644 index 0000000..1a8d9ef --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp/Contracts/Services/INavigationService.cs @@ -0,0 +1,23 @@ +using Microsoft.UI.Xaml.Controls; +using Microsoft.UI.Xaml.Navigation; + +namespace TemplateStudioSampleApp.Contracts.Services; + +public interface INavigationService +{ + event NavigatedEventHandler Navigated; + + bool CanGoBack + { + get; + } + + Frame? Frame + { + get; set; + } + + bool NavigateTo(string pageKey, object? parameter = null, bool clearNavigation = false); + + bool GoBack(); +} diff --git a/Chapter10/TemplateStudioSampleApp/Contracts/Services/INavigationViewService.cs b/Chapter10/TemplateStudioSampleApp/Contracts/Services/INavigationViewService.cs new file mode 100644 index 0000000..9848006 --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp/Contracts/Services/INavigationViewService.cs @@ -0,0 +1,22 @@ +using Microsoft.UI.Xaml.Controls; + +namespace TemplateStudioSampleApp.Contracts.Services; + +public interface INavigationViewService +{ + IList? MenuItems + { + get; + } + + object? SettingsItem + { + get; + } + + void Initialize(NavigationView navigationView); + + void UnregisterEvents(); + + NavigationViewItem? GetSelectedItem(Type pageType); +} diff --git a/Chapter10/TemplateStudioSampleApp/Contracts/Services/IPageService.cs b/Chapter10/TemplateStudioSampleApp/Contracts/Services/IPageService.cs new file mode 100644 index 0000000..fd1b93c --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp/Contracts/Services/IPageService.cs @@ -0,0 +1,6 @@ +namespace TemplateStudioSampleApp.Contracts.Services; + +public interface IPageService +{ + Type GetPageType(string key); +} diff --git a/Chapter10/TemplateStudioSampleApp/Contracts/Services/IThemeSelectorService.cs b/Chapter10/TemplateStudioSampleApp/Contracts/Services/IThemeSelectorService.cs new file mode 100644 index 0000000..f0346c1 --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp/Contracts/Services/IThemeSelectorService.cs @@ -0,0 +1,17 @@ +using Microsoft.UI.Xaml; + +namespace TemplateStudioSampleApp.Contracts.Services; + +public interface IThemeSelectorService +{ + ElementTheme Theme + { + get; + } + + Task InitializeAsync(); + + Task SetThemeAsync(ElementTheme theme); + + Task SetRequestedThemeAsync(); +} diff --git a/Chapter10/TemplateStudioSampleApp/Contracts/Services/IWebViewService.cs b/Chapter10/TemplateStudioSampleApp/Contracts/Services/IWebViewService.cs new file mode 100644 index 0000000..e8e202b --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp/Contracts/Services/IWebViewService.cs @@ -0,0 +1,34 @@ +using Microsoft.UI.Xaml.Controls; +using Microsoft.Web.WebView2.Core; + +namespace TemplateStudioSampleApp.Contracts.Services; + +public interface IWebViewService +{ + Uri? Source + { + get; + } + + bool CanGoBack + { + get; + } + + bool CanGoForward + { + get; + } + + event EventHandler? NavigationCompleted; + + void Initialize(WebView2 webView); + + void GoBack(); + + void GoForward(); + + void Reload(); + + void UnregisterEvents(); +} diff --git a/Chapter10/TemplateStudioSampleApp/Contracts/ViewModels/INavigationAware.cs b/Chapter10/TemplateStudioSampleApp/Contracts/ViewModels/INavigationAware.cs new file mode 100644 index 0000000..1583ffb --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp/Contracts/ViewModels/INavigationAware.cs @@ -0,0 +1,8 @@ +namespace TemplateStudioSampleApp.Contracts.ViewModels; + +public interface INavigationAware +{ + void OnNavigatedTo(object parameter); + + void OnNavigatedFrom(); +} diff --git a/Chapter10/TemplateStudioSampleApp/Helpers/EnumToBooleanConverter.cs b/Chapter10/TemplateStudioSampleApp/Helpers/EnumToBooleanConverter.cs new file mode 100644 index 0000000..759e4f4 --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp/Helpers/EnumToBooleanConverter.cs @@ -0,0 +1,38 @@ +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Data; + +namespace TemplateStudioSampleApp.Helpers; + +public class EnumToBooleanConverter : IValueConverter +{ + public EnumToBooleanConverter() + { + } + + public object Convert(object value, Type targetType, object parameter, string language) + { + if (parameter is string enumString) + { + if (!Enum.IsDefined(typeof(ElementTheme), value)) + { + throw new ArgumentException("ExceptionEnumToBooleanConverterValueMustBeAnEnum"); + } + + var enumValue = Enum.Parse(typeof(ElementTheme), enumString); + + return enumValue.Equals(value); + } + + throw new ArgumentException("ExceptionEnumToBooleanConverterParameterMustBeAnEnumName"); + } + + public object ConvertBack(object value, Type targetType, object parameter, string language) + { + if (parameter is string enumString) + { + return Enum.Parse(typeof(ElementTheme), enumString); + } + + throw new ArgumentException("ExceptionEnumToBooleanConverterParameterMustBeAnEnumName"); + } +} diff --git a/Chapter10/TemplateStudioSampleApp/Helpers/FrameExtensions.cs b/Chapter10/TemplateStudioSampleApp/Helpers/FrameExtensions.cs new file mode 100644 index 0000000..6fa9d93 --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp/Helpers/FrameExtensions.cs @@ -0,0 +1,8 @@ +using Microsoft.UI.Xaml.Controls; + +namespace TemplateStudioSampleApp.Helpers; + +public static class FrameExtensions +{ + public static object? GetPageViewModel(this Frame frame) => frame?.Content?.GetType().GetProperty("ViewModel")?.GetValue(frame.Content, null); +} diff --git a/Chapter10/TemplateStudioSampleApp/Helpers/NavigationHelper.cs b/Chapter10/TemplateStudioSampleApp/Helpers/NavigationHelper.cs new file mode 100644 index 0000000..36a2733 --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp/Helpers/NavigationHelper.cs @@ -0,0 +1,21 @@ +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; + +namespace TemplateStudioSampleApp.Helpers; + +// Helper class to set the navigation target for a NavigationViewItem. +// +// Usage in XAML: +// +// +// Usage in code: +// NavigationHelper.SetNavigateTo(navigationViewItem, typeof(MainViewModel).FullName); +public class NavigationHelper +{ + public static string GetNavigateTo(NavigationViewItem item) => (string)item.GetValue(NavigateToProperty); + + public static void SetNavigateTo(NavigationViewItem item, string value) => item.SetValue(NavigateToProperty, value); + + public static readonly DependencyProperty NavigateToProperty = + DependencyProperty.RegisterAttached("NavigateTo", typeof(string), typeof(NavigationHelper), new PropertyMetadata(null)); +} diff --git a/Chapter10/TemplateStudioSampleApp/Helpers/ResourceExtensions.cs b/Chapter10/TemplateStudioSampleApp/Helpers/ResourceExtensions.cs new file mode 100644 index 0000000..d532540 --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp/Helpers/ResourceExtensions.cs @@ -0,0 +1,10 @@ +using Microsoft.Windows.ApplicationModel.Resources; + +namespace TemplateStudioSampleApp.Helpers; + +public static class ResourceExtensions +{ + private static readonly ResourceLoader _resourceLoader = new(); + + public static string GetLocalized(this string resourceKey) => _resourceLoader.GetString(resourceKey); +} diff --git a/Chapter10/TemplateStudioSampleApp/Helpers/RuntimeHelper.cs b/Chapter10/TemplateStudioSampleApp/Helpers/RuntimeHelper.cs new file mode 100644 index 0000000..4fcdf88 --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp/Helpers/RuntimeHelper.cs @@ -0,0 +1,20 @@ +using System.Runtime.InteropServices; +using System.Text; + +namespace TemplateStudioSampleApp.Helpers; + +public class RuntimeHelper +{ + [DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)] + private static extern int GetCurrentPackageFullName(ref int packageFullNameLength, StringBuilder? packageFullName); + + public static bool IsMSIX + { + get + { + var length = 0; + + return GetCurrentPackageFullName(ref length, null) != 15700L; + } + } +} diff --git a/Chapter10/TemplateStudioSampleApp/Helpers/SettingsStorageExtensions.cs b/Chapter10/TemplateStudioSampleApp/Helpers/SettingsStorageExtensions.cs new file mode 100644 index 0000000..c608c65 --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp/Helpers/SettingsStorageExtensions.cs @@ -0,0 +1,112 @@ +using TemplateStudioSampleApp.Core.Helpers; + +using Windows.Storage; +using Windows.Storage.Streams; + +namespace TemplateStudioSampleApp.Helpers; + +// Use these extension methods to store and retrieve local and roaming app data +// More details regarding storing and retrieving app data at https://docs.microsoft.com/windows/apps/design/app-settings/store-and-retrieve-app-data +public static class SettingsStorageExtensions +{ + private const string FileExtension = ".json"; + + public static bool IsRoamingStorageAvailable(this ApplicationData appData) + { + return appData.RoamingStorageQuota == 0; + } + + public static async Task SaveAsync(this StorageFolder folder, string name, T content) + { + var file = await folder.CreateFileAsync(GetFileName(name), CreationCollisionOption.ReplaceExisting); + var fileContent = await Json.StringifyAsync(content); + + await FileIO.WriteTextAsync(file, fileContent); + } + + public static async Task ReadAsync(this StorageFolder folder, string name) + { + if (!File.Exists(Path.Combine(folder.Path, GetFileName(name)))) + { + return default; + } + + var file = await folder.GetFileAsync($"{name}.json"); + var fileContent = await FileIO.ReadTextAsync(file); + + return await Json.ToObjectAsync(fileContent); + } + + public static async Task SaveAsync(this ApplicationDataContainer settings, string key, T value) + { + settings.SaveString(key, await Json.StringifyAsync(value)); + } + + public static void SaveString(this ApplicationDataContainer settings, string key, string value) + { + settings.Values[key] = value; + } + + public static async Task ReadAsync(this ApplicationDataContainer settings, string key) + { + object? obj; + + if (settings.Values.TryGetValue(key, out obj)) + { + return await Json.ToObjectAsync((string)obj); + } + + return default; + } + + public static async Task SaveFileAsync(this StorageFolder folder, byte[] content, string fileName, CreationCollisionOption options = CreationCollisionOption.ReplaceExisting) + { + if (content == null) + { + throw new ArgumentNullException(nameof(content)); + } + + if (string.IsNullOrEmpty(fileName)) + { + throw new ArgumentException("File name is null or empty. Specify a valid file name", nameof(fileName)); + } + + var storageFile = await folder.CreateFileAsync(fileName, options); + await FileIO.WriteBytesAsync(storageFile, content); + return storageFile; + } + + public static async Task ReadFileAsync(this StorageFolder folder, string fileName) + { + var item = await folder.TryGetItemAsync(fileName).AsTask().ConfigureAwait(false); + + if ((item != null) && item.IsOfType(StorageItemTypes.File)) + { + var storageFile = await folder.GetFileAsync(fileName); + var content = await storageFile.ReadBytesAsync(); + return content; + } + + return null; + } + + public static async Task ReadBytesAsync(this StorageFile file) + { + if (file != null) + { + using IRandomAccessStream stream = await file.OpenReadAsync(); + using var reader = new DataReader(stream.GetInputStreamAt(0)); + await reader.LoadAsync((uint)stream.Size); + var bytes = new byte[stream.Size]; + reader.ReadBytes(bytes); + return bytes; + } + + return null; + } + + private static string GetFileName(string name) + { + return string.Concat(name, FileExtension); + } +} diff --git a/Chapter10/TemplateStudioSampleApp/Helpers/TitleBarHelper.cs b/Chapter10/TemplateStudioSampleApp/Helpers/TitleBarHelper.cs new file mode 100644 index 0000000..cd1f070 --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp/Helpers/TitleBarHelper.cs @@ -0,0 +1,121 @@ +using System.Runtime.InteropServices; + +using Microsoft.UI; +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Media; + +using Windows.UI; +using Windows.UI.ViewManagement; + +namespace TemplateStudioSampleApp.Helpers; + +// Helper class to workaround custom title bar bugs. +// DISCLAIMER: The resource key names and color values used below are subject to change. Do not depend on them. +// https://github.com/microsoft/TemplateStudio/issues/4516 +internal class TitleBarHelper +{ + private const int WAINACTIVE = 0x00; + private const int WAACTIVE = 0x01; + private const int WMACTIVATE = 0x0006; + + [DllImport("user32.dll")] + private static extern IntPtr GetActiveWindow(); + + [DllImport("user32.dll", CharSet = CharSet.Auto)] + private static extern IntPtr SendMessage(IntPtr hWnd, int msg, int wParam, IntPtr lParam); + + public static void UpdateTitleBar(ElementTheme theme) + { + if (App.MainWindow.ExtendsContentIntoTitleBar) + { + if (theme == ElementTheme.Default) + { + var uiSettings = new UISettings(); + var background = uiSettings.GetColorValue(UIColorType.Background); + + theme = background == Colors.White ? ElementTheme.Light : ElementTheme.Dark; + } + + if (theme == ElementTheme.Default) + { + theme = Application.Current.RequestedTheme == ApplicationTheme.Light ? ElementTheme.Light : ElementTheme.Dark; + } + + Application.Current.Resources["WindowCaptionForeground"] = theme switch + { + ElementTheme.Dark => new SolidColorBrush(Colors.White), + ElementTheme.Light => new SolidColorBrush(Colors.Black), + _ => new SolidColorBrush(Colors.Transparent) + }; + + Application.Current.Resources["WindowCaptionForegroundDisabled"] = theme switch + { + ElementTheme.Dark => new SolidColorBrush(Color.FromArgb(0x66, 0xFF, 0xFF, 0xFF)), + ElementTheme.Light => new SolidColorBrush(Color.FromArgb(0x66, 0x00, 0x00, 0x00)), + _ => new SolidColorBrush(Colors.Transparent) + }; + + Application.Current.Resources["WindowCaptionButtonBackgroundPointerOver"] = theme switch + { + ElementTheme.Dark => new SolidColorBrush(Color.FromArgb(0x33, 0xFF, 0xFF, 0xFF)), + ElementTheme.Light => new SolidColorBrush(Color.FromArgb(0x33, 0x00, 0x00, 0x00)), + _ => new SolidColorBrush(Colors.Transparent) + }; + + Application.Current.Resources["WindowCaptionButtonBackgroundPressed"] = theme switch + { + ElementTheme.Dark => new SolidColorBrush(Color.FromArgb(0x66, 0xFF, 0xFF, 0xFF)), + ElementTheme.Light => new SolidColorBrush(Color.FromArgb(0x66, 0x00, 0x00, 0x00)), + _ => new SolidColorBrush(Colors.Transparent) + }; + + Application.Current.Resources["WindowCaptionButtonStrokePointerOver"] = theme switch + { + ElementTheme.Dark => new SolidColorBrush(Colors.White), + ElementTheme.Light => new SolidColorBrush(Colors.Black), + _ => new SolidColorBrush(Colors.Transparent) + }; + + Application.Current.Resources["WindowCaptionButtonStrokePressed"] = theme switch + { + ElementTheme.Dark => new SolidColorBrush(Colors.White), + ElementTheme.Light => new SolidColorBrush(Colors.Black), + _ => new SolidColorBrush(Colors.Transparent) + }; + + Application.Current.Resources["WindowCaptionBackground"] = new SolidColorBrush(Colors.Transparent); + Application.Current.Resources["WindowCaptionBackgroundDisabled"] = new SolidColorBrush(Colors.Transparent); + + var hwnd = WinRT.Interop.WindowNative.GetWindowHandle(App.MainWindow); + if (hwnd == GetActiveWindow()) + { + SendMessage(hwnd, WMACTIVATE, WAINACTIVE, IntPtr.Zero); + SendMessage(hwnd, WMACTIVATE, WAACTIVE, IntPtr.Zero); + } + else + { + SendMessage(hwnd, WMACTIVATE, WAACTIVE, IntPtr.Zero); + SendMessage(hwnd, WMACTIVATE, WAINACTIVE, IntPtr.Zero); + } + } + } + + public static void ApplySystemThemeToCaptionButtons() + { + var res = Application.Current.Resources; + var frame = App.AppTitlebar as FrameworkElement; + if (frame != null) + { + if (frame.ActualTheme == ElementTheme.Dark) + { + res["WindowCaptionForeground"] = Colors.White; + } + else + { + res["WindowCaptionForeground"] = Colors.Black; + } + + UpdateTitleBar(frame.ActualTheme); + } + } +} diff --git a/Chapter10/TemplateStudioSampleApp/MainWindow.xaml b/Chapter10/TemplateStudioSampleApp/MainWindow.xaml new file mode 100644 index 0000000..d6716cd --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp/MainWindow.xaml @@ -0,0 +1,16 @@ + + + + + diff --git a/Chapter10/TemplateStudioSampleApp/MainWindow.xaml.cs b/Chapter10/TemplateStudioSampleApp/MainWindow.xaml.cs new file mode 100644 index 0000000..13176e7 --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp/MainWindow.xaml.cs @@ -0,0 +1,37 @@ +using TemplateStudioSampleApp.Helpers; + +using Windows.UI.ViewManagement; + +namespace TemplateStudioSampleApp; + +public sealed partial class MainWindow : WindowEx +{ + private Microsoft.UI.Dispatching.DispatcherQueue dispatcherQueue; + + private UISettings settings; + + public MainWindow() + { + InitializeComponent(); + + AppWindow.SetIcon(Path.Combine(AppContext.BaseDirectory, "Assets/WindowIcon.ico")); + Content = null; + Title = "AppDisplayName".GetLocalized(); + + // Theme change code picked from https://github.com/microsoft/WinUI-Gallery/pull/1239 + dispatcherQueue = Microsoft.UI.Dispatching.DispatcherQueue.GetForCurrentThread(); + settings = new UISettings(); + settings.ColorValuesChanged += Settings_ColorValuesChanged; // cannot use FrameworkElement.ActualThemeChanged event + } + + // this handles updating the caption button colors correctly when indows system theme is changed + // while the app is open + private void Settings_ColorValuesChanged(UISettings sender, object args) + { + // This calls comes off-thread, hence we will need to dispatch it to current app's thread + dispatcherQueue.TryEnqueue(() => + { + TitleBarHelper.ApplySystemThemeToCaptionButtons(); + }); + } +} diff --git a/Chapter10/TemplateStudioSampleApp/Models/LocalSettingsOptions.cs b/Chapter10/TemplateStudioSampleApp/Models/LocalSettingsOptions.cs new file mode 100644 index 0000000..15e74c9 --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp/Models/LocalSettingsOptions.cs @@ -0,0 +1,14 @@ +namespace TemplateStudioSampleApp.Models; + +public class LocalSettingsOptions +{ + public string? ApplicationDataFolder + { + get; set; + } + + public string? LocalSettingsFile + { + get; set; + } +} diff --git a/Chapter10/TemplateStudioSampleApp/Package.appinstaller b/Chapter10/TemplateStudioSampleApp/Package.appinstaller new file mode 100644 index 0000000..c619457 --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp/Package.appinstaller @@ -0,0 +1,17 @@ + + + + + + + + + + + + diff --git a/Chapter10/TemplateStudioSampleApp/Package.appxmanifest b/Chapter10/TemplateStudioSampleApp/Package.appxmanifest new file mode 100644 index 0000000..2bdf494 --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp/Package.appxmanifest @@ -0,0 +1,76 @@ + + + + + + + + + + TemplateStudioSampleApp + alash + Assets\StoreLogo.png + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter10/TemplateStudioSampleApp/Properties/launchsettings.json b/Chapter10/TemplateStudioSampleApp/Properties/launchsettings.json new file mode 100644 index 0000000..b0fb403 --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp/Properties/launchsettings.json @@ -0,0 +1,10 @@ +{ + "profiles": { + "TemplateStudioSampleApp (Package)": { + "commandName": "MsixPackage" + }, + "TemplateStudioSampleApp (Unpackaged)": { + "commandName": "Project" + } + } +} diff --git a/Chapter10/TemplateStudioSampleApp/README.md b/Chapter10/TemplateStudioSampleApp/README.md new file mode 100644 index 0000000..e24cced --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp/README.md @@ -0,0 +1,27 @@ +*Recommended Markdown Viewer: [Markdown Editor](https://marketplace.visualstudio.com/items?itemName=MadsKristensen.MarkdownEditor2)* + +## Getting Started + +Browse and address `TODO:` comments in `View -> Task List` to learn the codebase and understand next steps for turning the generated code into production code. + +Explore the [WinUI Gallery](https://www.microsoft.com/store/productId/9P3JFPWWDZRC) to learn about available controls and design patterns. + +Relaunch Template Studio to modify the project by right-clicking on the project in `View -> Solution Explorer` then selecting `Add -> New Item (Template Studio)`. + +## Publishing + +For projects with MSIX packaging, right-click on the application project and select `Package and Publish -> Create App Packages...` to create an MSIX package. + +For projects without MSIX packaging, follow the [deployment guide](https://docs.microsoft.com/windows/apps/windows-app-sdk/deploy-unpackaged-apps) or add the `Self-Contained` Feature to enable xcopy deployment. + +## CI Pipelines + +See [README.md](https://github.com/microsoft/TemplateStudio/blob/main/docs/WinUI/pipelines/README.md) for guidance on building and testing projects in CI pipelines. + +## Changelog + +See [releases](https://github.com/microsoft/TemplateStudio/releases) and [milestones](https://github.com/microsoft/TemplateStudio/milestones). + +## Feedback + +Bugs and feature requests should be filed at https://aka.ms/templatestudio. diff --git a/Chapter10/TemplateStudioSampleApp/Services/ActivationService.cs b/Chapter10/TemplateStudioSampleApp/Services/ActivationService.cs new file mode 100644 index 0000000..9510eb3 --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp/Services/ActivationService.cs @@ -0,0 +1,72 @@ +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; + +using TemplateStudioSampleApp.Activation; +using TemplateStudioSampleApp.Contracts.Services; +using TemplateStudioSampleApp.Views; + +namespace TemplateStudioSampleApp.Services; + +public class ActivationService : IActivationService +{ + private readonly ActivationHandler _defaultHandler; + private readonly IEnumerable _activationHandlers; + private readonly IThemeSelectorService _themeSelectorService; + private UIElement? _shell = null; + + public ActivationService(ActivationHandler defaultHandler, IEnumerable activationHandlers, IThemeSelectorService themeSelectorService) + { + _defaultHandler = defaultHandler; + _activationHandlers = activationHandlers; + _themeSelectorService = themeSelectorService; + } + + public async Task ActivateAsync(object activationArgs) + { + // Execute tasks before activation. + await InitializeAsync(); + + // Set the MainWindow Content. + if (App.MainWindow.Content == null) + { + _shell = App.GetService(); + App.MainWindow.Content = _shell ?? new Frame(); + } + + // Handle activation via ActivationHandlers. + await HandleActivationAsync(activationArgs); + + // Activate the MainWindow. + App.MainWindow.Activate(); + + // Execute tasks after activation. + await StartupAsync(); + } + + private async Task HandleActivationAsync(object activationArgs) + { + var activationHandler = _activationHandlers.FirstOrDefault(h => h.CanHandle(activationArgs)); + + if (activationHandler != null) + { + await activationHandler.HandleAsync(activationArgs); + } + + if (_defaultHandler.CanHandle(activationArgs)) + { + await _defaultHandler.HandleAsync(activationArgs); + } + } + + private async Task InitializeAsync() + { + await _themeSelectorService.InitializeAsync().ConfigureAwait(false); + await Task.CompletedTask; + } + + private async Task StartupAsync() + { + await _themeSelectorService.SetRequestedThemeAsync(); + await Task.CompletedTask; + } +} diff --git a/Chapter10/TemplateStudioSampleApp/Services/LocalSettingsService.cs b/Chapter10/TemplateStudioSampleApp/Services/LocalSettingsService.cs new file mode 100644 index 0000000..33426d2 --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp/Services/LocalSettingsService.cs @@ -0,0 +1,88 @@ +using Microsoft.Extensions.Options; + +using TemplateStudioSampleApp.Contracts.Services; +using TemplateStudioSampleApp.Core.Contracts.Services; +using TemplateStudioSampleApp.Core.Helpers; +using TemplateStudioSampleApp.Helpers; +using TemplateStudioSampleApp.Models; + +using Windows.ApplicationModel; +using Windows.Storage; + +namespace TemplateStudioSampleApp.Services; + +public class LocalSettingsService : ILocalSettingsService +{ + private const string _defaultApplicationDataFolder = "TemplateStudioSampleApp/ApplicationData"; + private const string _defaultLocalSettingsFile = "LocalSettings.json"; + + private readonly IFileService _fileService; + private readonly LocalSettingsOptions _options; + + private readonly string _localApplicationData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); + private readonly string _applicationDataFolder; + private readonly string _localsettingsFile; + + private IDictionary _settings; + + private bool _isInitialized; + + public LocalSettingsService(IFileService fileService, IOptions options) + { + _fileService = fileService; + _options = options.Value; + + _applicationDataFolder = Path.Combine(_localApplicationData, _options.ApplicationDataFolder ?? _defaultApplicationDataFolder); + _localsettingsFile = _options.LocalSettingsFile ?? _defaultLocalSettingsFile; + + _settings = new Dictionary(); + } + + private async Task InitializeAsync() + { + if (!_isInitialized) + { + _settings = await Task.Run(() => _fileService.Read>(_applicationDataFolder, _localsettingsFile)) ?? new Dictionary(); + + _isInitialized = true; + } + } + + public async Task ReadSettingAsync(string key) + { + if (RuntimeHelper.IsMSIX) + { + if (ApplicationData.Current.LocalSettings.Values.TryGetValue(key, out var obj)) + { + return await Json.ToObjectAsync((string)obj); + } + } + else + { + await InitializeAsync(); + + if (_settings != null && _settings.TryGetValue(key, out var obj)) + { + return await Json.ToObjectAsync((string)obj); + } + } + + return default; + } + + public async Task SaveSettingAsync(string key, T value) + { + if (RuntimeHelper.IsMSIX) + { + ApplicationData.Current.LocalSettings.Values[key] = await Json.StringifyAsync(value); + } + else + { + await InitializeAsync(); + + _settings[key] = await Json.StringifyAsync(value); + + await Task.Run(() => _fileService.Save(_applicationDataFolder, _localsettingsFile, _settings)); + } + } +} diff --git a/Chapter10/TemplateStudioSampleApp/Services/NavigationService.cs b/Chapter10/TemplateStudioSampleApp/Services/NavigationService.cs new file mode 100644 index 0000000..c4747b0 --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp/Services/NavigationService.cs @@ -0,0 +1,126 @@ +using System.Diagnostics.CodeAnalysis; + +using Microsoft.UI.Xaml.Controls; +using Microsoft.UI.Xaml.Navigation; + +using TemplateStudioSampleApp.Contracts.Services; +using TemplateStudioSampleApp.Contracts.ViewModels; +using TemplateStudioSampleApp.Helpers; + +namespace TemplateStudioSampleApp.Services; + +// For more information on navigation between pages see +// https://github.com/microsoft/TemplateStudio/blob/main/docs/WinUI/navigation.md +public class NavigationService : INavigationService +{ + private readonly IPageService _pageService; + private object? _lastParameterUsed; + private Frame? _frame; + + public event NavigatedEventHandler? Navigated; + + public Frame? Frame + { + get + { + if (_frame == null) + { + _frame = App.MainWindow.Content as Frame; + RegisterFrameEvents(); + } + + return _frame; + } + + set + { + UnregisterFrameEvents(); + _frame = value; + RegisterFrameEvents(); + } + } + + [MemberNotNullWhen(true, nameof(Frame), nameof(_frame))] + public bool CanGoBack => Frame != null && Frame.CanGoBack; + + public NavigationService(IPageService pageService) + { + _pageService = pageService; + } + + private void RegisterFrameEvents() + { + if (_frame != null) + { + _frame.Navigated += OnNavigated; + } + } + + private void UnregisterFrameEvents() + { + if (_frame != null) + { + _frame.Navigated -= OnNavigated; + } + } + + public bool GoBack() + { + if (CanGoBack) + { + var vmBeforeNavigation = _frame.GetPageViewModel(); + _frame.GoBack(); + if (vmBeforeNavigation is INavigationAware navigationAware) + { + navigationAware.OnNavigatedFrom(); + } + + return true; + } + + return false; + } + + public bool NavigateTo(string pageKey, object? parameter = null, bool clearNavigation = false) + { + var pageType = _pageService.GetPageType(pageKey); + + if (_frame != null && (_frame.Content?.GetType() != pageType || (parameter != null && !parameter.Equals(_lastParameterUsed)))) + { + _frame.Tag = clearNavigation; + var vmBeforeNavigation = _frame.GetPageViewModel(); + var navigated = _frame.Navigate(pageType, parameter); + if (navigated) + { + _lastParameterUsed = parameter; + if (vmBeforeNavigation is INavigationAware navigationAware) + { + navigationAware.OnNavigatedFrom(); + } + } + + return navigated; + } + + return false; + } + + private void OnNavigated(object sender, NavigationEventArgs e) + { + if (sender is Frame frame) + { + var clearNavigation = (bool)frame.Tag; + if (clearNavigation) + { + frame.BackStack.Clear(); + } + + if (frame.GetPageViewModel() is INavigationAware navigationAware) + { + navigationAware.OnNavigatedTo(e.Parameter); + } + + Navigated?.Invoke(sender, e); + } + } +} diff --git a/Chapter10/TemplateStudioSampleApp/Services/NavigationViewService.cs b/Chapter10/TemplateStudioSampleApp/Services/NavigationViewService.cs new file mode 100644 index 0000000..c9c55c7 --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp/Services/NavigationViewService.cs @@ -0,0 +1,103 @@ +using System.Diagnostics.CodeAnalysis; + +using Microsoft.UI.Xaml.Controls; + +using TemplateStudioSampleApp.Contracts.Services; +using TemplateStudioSampleApp.Helpers; +using TemplateStudioSampleApp.ViewModels; + +namespace TemplateStudioSampleApp.Services; + +public class NavigationViewService : INavigationViewService +{ + private readonly INavigationService _navigationService; + + private readonly IPageService _pageService; + + private NavigationView? _navigationView; + + public IList? MenuItems => _navigationView?.MenuItems; + + public object? SettingsItem => _navigationView?.SettingsItem; + + public NavigationViewService(INavigationService navigationService, IPageService pageService) + { + _navigationService = navigationService; + _pageService = pageService; + } + + [MemberNotNull(nameof(_navigationView))] + public void Initialize(NavigationView navigationView) + { + _navigationView = navigationView; + _navigationView.BackRequested += OnBackRequested; + _navigationView.ItemInvoked += OnItemInvoked; + } + + public void UnregisterEvents() + { + if (_navigationView != null) + { + _navigationView.BackRequested -= OnBackRequested; + _navigationView.ItemInvoked -= OnItemInvoked; + } + } + + public NavigationViewItem? GetSelectedItem(Type pageType) + { + if (_navigationView != null) + { + return GetSelectedItem(_navigationView.MenuItems, pageType) ?? GetSelectedItem(_navigationView.FooterMenuItems, pageType); + } + + return null; + } + + private void OnBackRequested(NavigationView sender, NavigationViewBackRequestedEventArgs args) => _navigationService.GoBack(); + + private void OnItemInvoked(NavigationView sender, NavigationViewItemInvokedEventArgs args) + { + if (args.IsSettingsInvoked) + { + _navigationService.NavigateTo(typeof(SettingsViewModel).FullName!); + } + else + { + var selectedItem = args.InvokedItemContainer as NavigationViewItem; + + if (selectedItem?.GetValue(NavigationHelper.NavigateToProperty) is string pageKey) + { + _navigationService.NavigateTo(pageKey); + } + } + } + + private NavigationViewItem? GetSelectedItem(IEnumerable menuItems, Type pageType) + { + foreach (var item in menuItems.OfType()) + { + if (IsMenuItemForPageType(item, pageType)) + { + return item; + } + + var selectedChild = GetSelectedItem(item.MenuItems, pageType); + if (selectedChild != null) + { + return selectedChild; + } + } + + return null; + } + + private bool IsMenuItemForPageType(NavigationViewItem menuItem, Type sourcePageType) + { + if (menuItem.GetValue(NavigationHelper.NavigateToProperty) is string pageKey) + { + return _pageService.GetPageType(pageKey) == sourcePageType; + } + + return false; + } +} diff --git a/Chapter10/TemplateStudioSampleApp/Services/PageService.cs b/Chapter10/TemplateStudioSampleApp/Services/PageService.cs new file mode 100644 index 0000000..9822049 --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp/Services/PageService.cs @@ -0,0 +1,59 @@ +using CommunityToolkit.Mvvm.ComponentModel; + +using Microsoft.UI.Xaml.Controls; + +using TemplateStudioSampleApp.Contracts.Services; +using TemplateStudioSampleApp.ViewModels; +using TemplateStudioSampleApp.Views; + +namespace TemplateStudioSampleApp.Services; + +public class PageService : IPageService +{ + private readonly Dictionary _pages = new(); + + public PageService() + { + Configure(); + Configure(); + Configure(); + Configure(); + Configure(); + } + + public Type GetPageType(string key) + { + Type? pageType; + lock (_pages) + { + if (!_pages.TryGetValue(key, out pageType)) + { + throw new ArgumentException($"Page not found: {key}. Did you forget to call PageService.Configure?"); + } + } + + return pageType; + } + + private void Configure() + where VM : ObservableObject + where V : Page + { + lock (_pages) + { + var key = typeof(VM).FullName!; + if (_pages.ContainsKey(key)) + { + throw new ArgumentException($"The key {key} is already configured in PageService"); + } + + var type = typeof(V); + if (_pages.ContainsValue(type)) + { + throw new ArgumentException($"This type is already configured with key {_pages.First(p => p.Value == type).Key}"); + } + + _pages.Add(key, type); + } + } +} diff --git a/Chapter10/TemplateStudioSampleApp/Services/ThemeSelectorService.cs b/Chapter10/TemplateStudioSampleApp/Services/ThemeSelectorService.cs new file mode 100644 index 0000000..d4530ca --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp/Services/ThemeSelectorService.cs @@ -0,0 +1,63 @@ +using Microsoft.UI.Xaml; + +using TemplateStudioSampleApp.Contracts.Services; +using TemplateStudioSampleApp.Helpers; + +namespace TemplateStudioSampleApp.Services; + +public class ThemeSelectorService : IThemeSelectorService +{ + private const string SettingsKey = "AppBackgroundRequestedTheme"; + + public ElementTheme Theme { get; set; } = ElementTheme.Default; + + private readonly ILocalSettingsService _localSettingsService; + + public ThemeSelectorService(ILocalSettingsService localSettingsService) + { + _localSettingsService = localSettingsService; + } + + public async Task InitializeAsync() + { + Theme = await LoadThemeFromSettingsAsync(); + await Task.CompletedTask; + } + + public async Task SetThemeAsync(ElementTheme theme) + { + Theme = theme; + + await SetRequestedThemeAsync(); + await SaveThemeInSettingsAsync(Theme); + } + + public async Task SetRequestedThemeAsync() + { + if (App.MainWindow.Content is FrameworkElement rootElement) + { + rootElement.RequestedTheme = Theme; + + TitleBarHelper.UpdateTitleBar(Theme); + } + + await Task.CompletedTask; + } + + private async Task LoadThemeFromSettingsAsync() + { + var themeName = await _localSettingsService.ReadSettingAsync(SettingsKey); + + if (Enum.TryParse(themeName, out ElementTheme cacheTheme)) + { + return cacheTheme; + } + + return ElementTheme.Default; + } + + private async Task SaveThemeInSettingsAsync(ElementTheme theme) + { + await _localSettingsService.SaveSettingAsync(SettingsKey, theme.ToString()); + } +} diff --git a/Chapter10/TemplateStudioSampleApp/Services/WebViewService.cs b/Chapter10/TemplateStudioSampleApp/Services/WebViewService.cs new file mode 100644 index 0000000..74ac005 --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp/Services/WebViewService.cs @@ -0,0 +1,50 @@ +using System.Diagnostics.CodeAnalysis; + +using Microsoft.UI.Xaml.Controls; +using Microsoft.Web.WebView2.Core; + +using TemplateStudioSampleApp.Contracts.Services; + +namespace TemplateStudioSampleApp.Services; + +public class WebViewService : IWebViewService +{ + private WebView2? _webView; + + public Uri? Source => _webView?.Source; + + [MemberNotNullWhen(true, nameof(_webView))] + public bool CanGoBack => _webView != null && _webView.CanGoBack; + + [MemberNotNullWhen(true, nameof(_webView))] + public bool CanGoForward => _webView != null && _webView.CanGoForward; + + public event EventHandler? NavigationCompleted; + + public WebViewService() + { + } + + [MemberNotNull(nameof(_webView))] + public void Initialize(WebView2 webView) + { + _webView = webView; + _webView.NavigationCompleted += OnWebViewNavigationCompleted; + } + + public void GoBack() => _webView?.GoBack(); + + public void GoForward() => _webView?.GoForward(); + + public void Reload() => _webView?.Reload(); + + public void UnregisterEvents() + { + if (_webView != null) + { + _webView.NavigationCompleted -= OnWebViewNavigationCompleted; + } + } + + private void OnWebViewNavigationCompleted(WebView2 sender, CoreWebView2NavigationCompletedEventArgs args) => NavigationCompleted?.Invoke(this, args.WebErrorStatus); +} diff --git a/Chapter10/TemplateStudioSampleApp/Strings/en-us/Resources.resw b/Chapter10/TemplateStudioSampleApp/Strings/en-us/Resources.resw new file mode 100644 index 0000000..5352dbf --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp/Strings/en-us/Resources.resw @@ -0,0 +1,142 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + TemplateStudioSampleApp + + + TemplateStudioSampleApp + + + Main + + + DataGrid + + + Select an item from the list. + + + ListDetails + + + Loading... + + + Page failed to load. Check connection and reload. + + + Browser back + + + Browser back + + + Browser forward + + + Browser forward + + + Reload + + + Reload + + + Reload + + + Open in browser + + + Open in browser + + + WebView + + + Personalization + + + Theme + + + Light + + + Dark + + + Default + + + About this application + + + TODO: Replace with your app description. + + + Privacy Statement + + + https://YourPrivacyUrlGoesHere/ + + diff --git a/Chapter10/TemplateStudioSampleApp/Styles/FontSizes.xaml b/Chapter10/TemplateStudioSampleApp/Styles/FontSizes.xaml new file mode 100644 index 0000000..44904b1 --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp/Styles/FontSizes.xaml @@ -0,0 +1,9 @@ + + + 24 + + 16 + + diff --git a/Chapter10/TemplateStudioSampleApp/Styles/TextBlock.xaml b/Chapter10/TemplateStudioSampleApp/Styles/TextBlock.xaml new file mode 100644 index 0000000..8626187 --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp/Styles/TextBlock.xaml @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + diff --git a/Chapter10/TemplateStudioSampleApp/Styles/Thickness.xaml b/Chapter10/TemplateStudioSampleApp/Styles/Thickness.xaml new file mode 100644 index 0000000..96ef0c9 --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp/Styles/Thickness.xaml @@ -0,0 +1,36 @@ + + + 0,36,0,0 + 0,36,0,36 + + 0,24,0,0 + 0,24,0,24 + 24,0,24,0 + 0,0,0,24 + + 12,0,0,0 + 12,0,12,0 + 0,12,0,0 + 0,0,12,0 + 0,12,0,12 + + 8,0,0,0 + 0,8,0,0 + 8,8,8,8 + + 0,4,0,0 + 4,4,4,4 + + 1,1,0,0 + 8,0,0,0 + 0,48,0,0 + 56,34,0,0 + 56,24,56,0 + + 36,24,36,0 + + -12,4,0,0 + + diff --git a/Chapter10/TemplateStudioSampleApp/TemplateStudio.xml b/Chapter10/TemplateStudioSampleApp/TemplateStudio.xml new file mode 100644 index 0000000..03eb2eb --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp/TemplateStudio.xml @@ -0,0 +1,11 @@ + + + + + + + + + + diff --git a/Chapter10/TemplateStudioSampleApp/TemplateStudioSampleApp.csproj b/Chapter10/TemplateStudioSampleApp/TemplateStudioSampleApp.csproj new file mode 100644 index 0000000..dbb5a4f --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp/TemplateStudioSampleApp.csproj @@ -0,0 +1,48 @@ + + + WinExe + net7.0-windows10.0.19041.0 + 10.0.17763.0 + TemplateStudioSampleApp + Assets/WindowIcon.ico + app.manifest + x86;x64;arm64 + win10-x86;win10-x64;win10-arm64 + Properties\PublishProfiles\win10-$(Platform).pubxml + enable + enable + true + true + + + + + + + + + + + + + + + + + + + + + + Always + + + + + + + + + true + + diff --git a/Chapter10/TemplateStudioSampleApp/TemplateStudioSampleApp.sln b/Chapter10/TemplateStudioSampleApp/TemplateStudioSampleApp.sln new file mode 100644 index 0000000..8c8b5e4 --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp/TemplateStudioSampleApp.sln @@ -0,0 +1,87 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.6.33829.357 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TemplateStudioSampleApp", "TemplateStudioSampleApp.csproj", "{3F694A38-930D-4522-B78F-2976E34B9953}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TemplateStudioSampleApp.Core", "..\TemplateStudioSampleApp.Core\TemplateStudioSampleApp.Core.csproj", "{18C90AC3-6ACE-41A9-B202-096D52E9067B}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TemplateStudioSampleApp.Tests.MSTest", "..\TemplateStudioSampleApp.Tests.MSTest\TemplateStudioSampleApp.Tests.MSTest.csproj", "{AD8C9424-173F-400F-A904-531BC374BF62}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|arm64 = Debug|arm64 + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|arm64 = Release|arm64 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {3F694A38-930D-4522-B78F-2976E34B9953}.Debug|Any CPU.ActiveCfg = Debug|x64 + {3F694A38-930D-4522-B78F-2976E34B9953}.Debug|Any CPU.Build.0 = Debug|x64 + {3F694A38-930D-4522-B78F-2976E34B9953}.Debug|Any CPU.Deploy.0 = Debug|x64 + {3F694A38-930D-4522-B78F-2976E34B9953}.Debug|arm64.ActiveCfg = Debug|arm64 + {3F694A38-930D-4522-B78F-2976E34B9953}.Debug|arm64.Build.0 = Debug|arm64 + {3F694A38-930D-4522-B78F-2976E34B9953}.Debug|arm64.Deploy.0 = Debug|arm64 + {3F694A38-930D-4522-B78F-2976E34B9953}.Debug|x64.ActiveCfg = Debug|x64 + {3F694A38-930D-4522-B78F-2976E34B9953}.Debug|x64.Build.0 = Debug|x64 + {3F694A38-930D-4522-B78F-2976E34B9953}.Debug|x64.Deploy.0 = Debug|x64 + {3F694A38-930D-4522-B78F-2976E34B9953}.Debug|x86.ActiveCfg = Debug|x86 + {3F694A38-930D-4522-B78F-2976E34B9953}.Debug|x86.Build.0 = Debug|x86 + {3F694A38-930D-4522-B78F-2976E34B9953}.Debug|x86.Deploy.0 = Debug|x86 + {3F694A38-930D-4522-B78F-2976E34B9953}.Release|Any CPU.ActiveCfg = Release|x64 + {3F694A38-930D-4522-B78F-2976E34B9953}.Release|Any CPU.Build.0 = Release|x64 + {3F694A38-930D-4522-B78F-2976E34B9953}.Release|Any CPU.Deploy.0 = Release|x64 + {3F694A38-930D-4522-B78F-2976E34B9953}.Release|arm64.ActiveCfg = Release|arm64 + {3F694A38-930D-4522-B78F-2976E34B9953}.Release|arm64.Build.0 = Release|arm64 + {3F694A38-930D-4522-B78F-2976E34B9953}.Release|arm64.Deploy.0 = Release|arm64 + {3F694A38-930D-4522-B78F-2976E34B9953}.Release|x64.ActiveCfg = Release|x64 + {3F694A38-930D-4522-B78F-2976E34B9953}.Release|x64.Build.0 = Release|x64 + {3F694A38-930D-4522-B78F-2976E34B9953}.Release|x64.Deploy.0 = Release|x64 + {3F694A38-930D-4522-B78F-2976E34B9953}.Release|x86.ActiveCfg = Release|x86 + {3F694A38-930D-4522-B78F-2976E34B9953}.Release|x86.Build.0 = Release|x86 + {3F694A38-930D-4522-B78F-2976E34B9953}.Release|x86.Deploy.0 = Release|x86 + {18C90AC3-6ACE-41A9-B202-096D52E9067B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {18C90AC3-6ACE-41A9-B202-096D52E9067B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {18C90AC3-6ACE-41A9-B202-096D52E9067B}.Debug|arm64.ActiveCfg = Debug|arm64 + {18C90AC3-6ACE-41A9-B202-096D52E9067B}.Debug|arm64.Build.0 = Debug|arm64 + {18C90AC3-6ACE-41A9-B202-096D52E9067B}.Debug|x64.ActiveCfg = Debug|x64 + {18C90AC3-6ACE-41A9-B202-096D52E9067B}.Debug|x64.Build.0 = Debug|x64 + {18C90AC3-6ACE-41A9-B202-096D52E9067B}.Debug|x86.ActiveCfg = Debug|x86 + {18C90AC3-6ACE-41A9-B202-096D52E9067B}.Debug|x86.Build.0 = Debug|x86 + {18C90AC3-6ACE-41A9-B202-096D52E9067B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {18C90AC3-6ACE-41A9-B202-096D52E9067B}.Release|Any CPU.Build.0 = Release|Any CPU + {18C90AC3-6ACE-41A9-B202-096D52E9067B}.Release|arm64.ActiveCfg = Release|arm64 + {18C90AC3-6ACE-41A9-B202-096D52E9067B}.Release|arm64.Build.0 = Release|arm64 + {18C90AC3-6ACE-41A9-B202-096D52E9067B}.Release|x64.ActiveCfg = Release|x64 + {18C90AC3-6ACE-41A9-B202-096D52E9067B}.Release|x64.Build.0 = Release|x64 + {18C90AC3-6ACE-41A9-B202-096D52E9067B}.Release|x86.ActiveCfg = Release|x86 + {18C90AC3-6ACE-41A9-B202-096D52E9067B}.Release|x86.Build.0 = Release|x86 + {AD8C9424-173F-400F-A904-531BC374BF62}.Debug|Any CPU.ActiveCfg = Debug|x64 + {AD8C9424-173F-400F-A904-531BC374BF62}.Debug|Any CPU.Build.0 = Debug|x64 + {AD8C9424-173F-400F-A904-531BC374BF62}.Debug|arm64.ActiveCfg = Debug|arm64 + {AD8C9424-173F-400F-A904-531BC374BF62}.Debug|arm64.Build.0 = Debug|arm64 + {AD8C9424-173F-400F-A904-531BC374BF62}.Debug|x64.ActiveCfg = Debug|x64 + {AD8C9424-173F-400F-A904-531BC374BF62}.Debug|x64.Build.0 = Debug|x64 + {AD8C9424-173F-400F-A904-531BC374BF62}.Debug|x86.ActiveCfg = Debug|x86 + {AD8C9424-173F-400F-A904-531BC374BF62}.Debug|x86.Build.0 = Debug|x86 + {AD8C9424-173F-400F-A904-531BC374BF62}.Release|Any CPU.ActiveCfg = Release|x64 + {AD8C9424-173F-400F-A904-531BC374BF62}.Release|Any CPU.Build.0 = Release|x64 + {AD8C9424-173F-400F-A904-531BC374BF62}.Release|arm64.ActiveCfg = Release|arm64 + {AD8C9424-173F-400F-A904-531BC374BF62}.Release|arm64.Build.0 = Release|arm64 + {AD8C9424-173F-400F-A904-531BC374BF62}.Release|x64.ActiveCfg = Release|x64 + {AD8C9424-173F-400F-A904-531BC374BF62}.Release|x64.Build.0 = Release|x64 + {AD8C9424-173F-400F-A904-531BC374BF62}.Release|x86.ActiveCfg = Release|x86 + {AD8C9424-173F-400F-A904-531BC374BF62}.Release|x86.Build.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {33371BFB-B272-47FC-9A71-FB2911ED8A6D} + EndGlobalSection +EndGlobal diff --git a/Chapter10/TemplateStudioSampleApp/Usings.cs b/Chapter10/TemplateStudioSampleApp/Usings.cs new file mode 100644 index 0000000..4cc487e --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp/Usings.cs @@ -0,0 +1 @@ +global using WinUIEx; diff --git a/Chapter10/TemplateStudioSampleApp/ViewModels/DataGridViewModel.cs b/Chapter10/TemplateStudioSampleApp/ViewModels/DataGridViewModel.cs new file mode 100644 index 0000000..877c751 --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp/ViewModels/DataGridViewModel.cs @@ -0,0 +1,38 @@ +using System.Collections.ObjectModel; + +using CommunityToolkit.Mvvm.ComponentModel; + +using TemplateStudioSampleApp.Contracts.ViewModels; +using TemplateStudioSampleApp.Core.Contracts.Services; +using TemplateStudioSampleApp.Core.Models; + +namespace TemplateStudioSampleApp.ViewModels; + +public partial class DataGridViewModel : ObservableRecipient, INavigationAware +{ + private readonly ISampleDataService _sampleDataService; + + public ObservableCollection Source { get; } = new ObservableCollection(); + + public DataGridViewModel(ISampleDataService sampleDataService) + { + _sampleDataService = sampleDataService; + } + + public async void OnNavigatedTo(object parameter) + { + Source.Clear(); + + // TODO: Replace with real data. + var data = await _sampleDataService.GetGridDataAsync(); + + foreach (var item in data) + { + Source.Add(item); + } + } + + public void OnNavigatedFrom() + { + } +} diff --git a/Chapter10/TemplateStudioSampleApp/ViewModels/ListDetailsViewModel.cs b/Chapter10/TemplateStudioSampleApp/ViewModels/ListDetailsViewModel.cs new file mode 100644 index 0000000..54df6d0 --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp/ViewModels/ListDetailsViewModel.cs @@ -0,0 +1,46 @@ +using System.Collections.ObjectModel; + +using CommunityToolkit.Mvvm.ComponentModel; + +using TemplateStudioSampleApp.Contracts.ViewModels; +using TemplateStudioSampleApp.Core.Contracts.Services; +using TemplateStudioSampleApp.Core.Models; + +namespace TemplateStudioSampleApp.ViewModels; + +public partial class ListDetailsViewModel : ObservableRecipient, INavigationAware +{ + private readonly ISampleDataService _sampleDataService; + + [ObservableProperty] + private SampleOrder? selected; + + public ObservableCollection SampleItems { get; private set; } = new ObservableCollection(); + + public ListDetailsViewModel(ISampleDataService sampleDataService) + { + _sampleDataService = sampleDataService; + } + + public async void OnNavigatedTo(object parameter) + { + SampleItems.Clear(); + + // TODO: Replace with real data. + var data = await _sampleDataService.GetListDetailsDataAsync(); + + foreach (var item in data) + { + SampleItems.Add(item); + } + } + + public void OnNavigatedFrom() + { + } + + public void EnsureItemSelected() + { + Selected ??= SampleItems.First(); + } +} diff --git a/Chapter10/TemplateStudioSampleApp/ViewModels/MainViewModel.cs b/Chapter10/TemplateStudioSampleApp/ViewModels/MainViewModel.cs new file mode 100644 index 0000000..7e4783d --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp/ViewModels/MainViewModel.cs @@ -0,0 +1,10 @@ +using CommunityToolkit.Mvvm.ComponentModel; + +namespace TemplateStudioSampleApp.ViewModels; + +public partial class MainViewModel : ObservableRecipient +{ + public MainViewModel() + { + } +} diff --git a/Chapter10/TemplateStudioSampleApp/ViewModels/SettingsViewModel.cs b/Chapter10/TemplateStudioSampleApp/ViewModels/SettingsViewModel.cs new file mode 100644 index 0000000..e90376b --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp/ViewModels/SettingsViewModel.cs @@ -0,0 +1,65 @@ +using System.Reflection; +using System.Windows.Input; + +using CommunityToolkit.Mvvm.ComponentModel; +using CommunityToolkit.Mvvm.Input; + +using Microsoft.UI.Xaml; + +using TemplateStudioSampleApp.Contracts.Services; +using TemplateStudioSampleApp.Helpers; + +using Windows.ApplicationModel; + +namespace TemplateStudioSampleApp.ViewModels; + +public partial class SettingsViewModel : ObservableRecipient +{ + private readonly IThemeSelectorService _themeSelectorService; + + [ObservableProperty] + private ElementTheme _elementTheme; + + [ObservableProperty] + private string _versionDescription; + + public ICommand SwitchThemeCommand + { + get; + } + + public SettingsViewModel(IThemeSelectorService themeSelectorService) + { + _themeSelectorService = themeSelectorService; + _elementTheme = _themeSelectorService.Theme; + _versionDescription = GetVersionDescription(); + + SwitchThemeCommand = new RelayCommand( + async (param) => + { + if (ElementTheme != param) + { + ElementTheme = param; + await _themeSelectorService.SetThemeAsync(param); + } + }); + } + + private static string GetVersionDescription() + { + Version version; + + if (RuntimeHelper.IsMSIX) + { + var packageVersion = Package.Current.Id.Version; + + version = new(packageVersion.Major, packageVersion.Minor, packageVersion.Build, packageVersion.Revision); + } + else + { + version = Assembly.GetExecutingAssembly().GetName().Version!; + } + + return $"{"AppDisplayName".GetLocalized()} - {version.Major}.{version.Minor}.{version.Build}.{version.Revision}"; + } +} diff --git a/Chapter10/TemplateStudioSampleApp/ViewModels/ShellViewModel.cs b/Chapter10/TemplateStudioSampleApp/ViewModels/ShellViewModel.cs new file mode 100644 index 0000000..c81087e --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp/ViewModels/ShellViewModel.cs @@ -0,0 +1,51 @@ +using CommunityToolkit.Mvvm.ComponentModel; + +using Microsoft.UI.Xaml.Navigation; + +using TemplateStudioSampleApp.Contracts.Services; +using TemplateStudioSampleApp.Views; + +namespace TemplateStudioSampleApp.ViewModels; + +public partial class ShellViewModel : ObservableRecipient +{ + [ObservableProperty] + private bool isBackEnabled; + + [ObservableProperty] + private object? selected; + + public INavigationService NavigationService + { + get; + } + + public INavigationViewService NavigationViewService + { + get; + } + + public ShellViewModel(INavigationService navigationService, INavigationViewService navigationViewService) + { + NavigationService = navigationService; + NavigationService.Navigated += OnNavigated; + NavigationViewService = navigationViewService; + } + + private void OnNavigated(object sender, NavigationEventArgs e) + { + IsBackEnabled = NavigationService.CanGoBack; + + if (e.SourcePageType == typeof(SettingsPage)) + { + Selected = NavigationViewService.SettingsItem; + return; + } + + var selectedItem = NavigationViewService.GetSelectedItem(e.SourcePageType); + if (selectedItem != null) + { + Selected = selectedItem; + } + } +} diff --git a/Chapter10/TemplateStudioSampleApp/ViewModels/WebViewViewModel.cs b/Chapter10/TemplateStudioSampleApp/ViewModels/WebViewViewModel.cs new file mode 100644 index 0000000..f908e8c --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp/ViewModels/WebViewViewModel.cs @@ -0,0 +1,110 @@ +using CommunityToolkit.Mvvm.ComponentModel; +using CommunityToolkit.Mvvm.Input; + +using Microsoft.Web.WebView2.Core; + +using TemplateStudioSampleApp.Contracts.Services; +using TemplateStudioSampleApp.Contracts.ViewModels; + +namespace TemplateStudioSampleApp.ViewModels; + +// TODO: Review best practices and distribution guidelines for WebView2. +// https://docs.microsoft.com/microsoft-edge/webview2/get-started/winui +// https://docs.microsoft.com/microsoft-edge/webview2/concepts/developer-guide +// https://docs.microsoft.com/microsoft-edge/webview2/concepts/distribution +public partial class WebViewViewModel : ObservableRecipient, INavigationAware +{ + // TODO: Set the default URL to display. + [ObservableProperty] + private Uri source = new("https://docs.microsoft.com/windows/apps/"); + + [ObservableProperty] + private bool isLoading = true; + + [ObservableProperty] + private bool hasFailures; + + public IWebViewService WebViewService + { + get; + } + + public WebViewViewModel(IWebViewService webViewService) + { + WebViewService = webViewService; + } + + [RelayCommand] + private async Task OpenInBrowser() + { + if (WebViewService.Source != null) + { + await Windows.System.Launcher.LaunchUriAsync(WebViewService.Source); + } + } + + [RelayCommand] + private void Reload() + { + WebViewService.Reload(); + } + + [RelayCommand(CanExecute = nameof(BrowserCanGoForward))] + private void BrowserForward() + { + if (WebViewService.CanGoForward) + { + WebViewService.GoForward(); + } + } + + private bool BrowserCanGoForward() + { + return WebViewService.CanGoForward; + } + + [RelayCommand(CanExecute = nameof(BrowserCanGoBack))] + private void BrowserBack() + { + if (WebViewService.CanGoBack) + { + WebViewService.GoBack(); + } + } + + private bool BrowserCanGoBack() + { + return WebViewService.CanGoBack; + } + + public void OnNavigatedTo(object parameter) + { + WebViewService.NavigationCompleted += OnNavigationCompleted; + } + + public void OnNavigatedFrom() + { + WebViewService.UnregisterEvents(); + WebViewService.NavigationCompleted -= OnNavigationCompleted; + } + + private void OnNavigationCompleted(object? sender, CoreWebView2WebErrorStatus webErrorStatus) + { + IsLoading = false; + BrowserBackCommand.NotifyCanExecuteChanged(); + BrowserForwardCommand.NotifyCanExecuteChanged(); + + if (webErrorStatus != default) + { + HasFailures = true; + } + } + + [RelayCommand] + private void OnRetry() + { + HasFailures = false; + IsLoading = true; + WebViewService?.Reload(); + } +} diff --git a/Chapter10/TemplateStudioSampleApp/Views/DataGridPage.xaml b/Chapter10/TemplateStudioSampleApp/Views/DataGridPage.xaml new file mode 100644 index 0000000..9959695 --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp/Views/DataGridPage.xaml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter10/TemplateStudioSampleApp/Views/DataGridPage.xaml.cs b/Chapter10/TemplateStudioSampleApp/Views/DataGridPage.xaml.cs new file mode 100644 index 0000000..0590e19 --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp/Views/DataGridPage.xaml.cs @@ -0,0 +1,21 @@ +using Microsoft.UI.Xaml.Controls; + +using TemplateStudioSampleApp.ViewModels; + +namespace TemplateStudioSampleApp.Views; + +// TODO: Change the grid as appropriate for your app. Adjust the column definitions on DataGridPage.xaml. +// For more details, see the documentation at https://docs.microsoft.com/windows/communitytoolkit/controls/datagrid. +public sealed partial class DataGridPage : Page +{ + public DataGridViewModel ViewModel + { + get; + } + + public DataGridPage() + { + ViewModel = App.GetService(); + InitializeComponent(); + } +} diff --git a/Chapter10/TemplateStudioSampleApp/Views/ListDetailsDetailControl.xaml b/Chapter10/TemplateStudioSampleApp/Views/ListDetailsDetailControl.xaml new file mode 100644 index 0000000..aa667aa --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp/Views/ListDetailsDetailControl.xaml @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter10/TemplateStudioSampleApp/Views/ListDetailsDetailControl.xaml.cs b/Chapter10/TemplateStudioSampleApp/Views/ListDetailsDetailControl.xaml.cs new file mode 100644 index 0000000..ce960c9 --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp/Views/ListDetailsDetailControl.xaml.cs @@ -0,0 +1,30 @@ +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; + +using TemplateStudioSampleApp.Core.Models; + +namespace TemplateStudioSampleApp.Views; + +public sealed partial class ListDetailsDetailControl : UserControl +{ + public SampleOrder? ListDetailsMenuItem + { + get => GetValue(ListDetailsMenuItemProperty) as SampleOrder; + set => SetValue(ListDetailsMenuItemProperty, value); + } + + public static readonly DependencyProperty ListDetailsMenuItemProperty = DependencyProperty.Register("ListDetailsMenuItem", typeof(SampleOrder), typeof(ListDetailsDetailControl), new PropertyMetadata(null, OnListDetailsMenuItemPropertyChanged)); + + public ListDetailsDetailControl() + { + InitializeComponent(); + } + + private static void OnListDetailsMenuItemPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (d is ListDetailsDetailControl control) + { + control.ForegroundElement.ChangeView(0, 0, 1); + } + } +} diff --git a/Chapter10/TemplateStudioSampleApp/Views/ListDetailsPage.xaml b/Chapter10/TemplateStudioSampleApp/Views/ListDetailsPage.xaml new file mode 100644 index 0000000..9f5a621 --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp/Views/ListDetailsPage.xaml @@ -0,0 +1,100 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter10/TemplateStudioSampleApp/Views/ListDetailsPage.xaml.cs b/Chapter10/TemplateStudioSampleApp/Views/ListDetailsPage.xaml.cs new file mode 100644 index 0000000..2f72dde --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp/Views/ListDetailsPage.xaml.cs @@ -0,0 +1,29 @@ +using CommunityToolkit.WinUI.UI.Controls; + +using Microsoft.UI.Xaml.Controls; + +using TemplateStudioSampleApp.ViewModels; + +namespace TemplateStudioSampleApp.Views; + +public sealed partial class ListDetailsPage : Page +{ + public ListDetailsViewModel ViewModel + { + get; + } + + public ListDetailsPage() + { + ViewModel = App.GetService(); + InitializeComponent(); + } + + private void OnViewStateChanged(object sender, ListDetailsViewState e) + { + if (e == ListDetailsViewState.Both) + { + ViewModel.EnsureItemSelected(); + } + } +} diff --git a/Chapter10/TemplateStudioSampleApp/Views/MainPage.xaml b/Chapter10/TemplateStudioSampleApp/Views/MainPage.xaml new file mode 100644 index 0000000..4656d91 --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp/Views/MainPage.xaml @@ -0,0 +1,12 @@ + + + + + + diff --git a/Chapter10/TemplateStudioSampleApp/Views/MainPage.xaml.cs b/Chapter10/TemplateStudioSampleApp/Views/MainPage.xaml.cs new file mode 100644 index 0000000..3ab9192 --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp/Views/MainPage.xaml.cs @@ -0,0 +1,19 @@ +using Microsoft.UI.Xaml.Controls; + +using TemplateStudioSampleApp.ViewModels; + +namespace TemplateStudioSampleApp.Views; + +public sealed partial class MainPage : Page +{ + public MainViewModel ViewModel + { + get; + } + + public MainPage() + { + ViewModel = App.GetService(); + InitializeComponent(); + } +} diff --git a/Chapter10/TemplateStudioSampleApp/Views/SettingsPage.xaml b/Chapter10/TemplateStudioSampleApp/Views/SettingsPage.xaml new file mode 100644 index 0000000..eff8579 --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp/Views/SettingsPage.xaml @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + Light + + + + + Dark + + + + + Default + + + + + + + + + + + + + + + + diff --git a/Chapter10/TemplateStudioSampleApp/Views/SettingsPage.xaml.cs b/Chapter10/TemplateStudioSampleApp/Views/SettingsPage.xaml.cs new file mode 100644 index 0000000..ac5adf1 --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp/Views/SettingsPage.xaml.cs @@ -0,0 +1,20 @@ +using Microsoft.UI.Xaml.Controls; + +using TemplateStudioSampleApp.ViewModels; + +namespace TemplateStudioSampleApp.Views; + +// TODO: Set the URL for your privacy policy by updating SettingsPage_PrivacyTermsLink.NavigateUri in Resources.resw. +public sealed partial class SettingsPage : Page +{ + public SettingsViewModel ViewModel + { + get; + } + + public SettingsPage() + { + ViewModel = App.GetService(); + InitializeComponent(); + } +} diff --git a/Chapter10/TemplateStudioSampleApp/Views/ShellPage.xaml b/Chapter10/TemplateStudioSampleApp/Views/ShellPage.xaml new file mode 100644 index 0000000..1d29702 --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp/Views/ShellPage.xaml @@ -0,0 +1,95 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter10/TemplateStudioSampleApp/Views/ShellPage.xaml.cs b/Chapter10/TemplateStudioSampleApp/Views/ShellPage.xaml.cs new file mode 100644 index 0000000..1385b0c --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp/Views/ShellPage.xaml.cs @@ -0,0 +1,88 @@ +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; +using Microsoft.UI.Xaml.Input; +using Microsoft.UI.Xaml.Media; + +using TemplateStudioSampleApp.Contracts.Services; +using TemplateStudioSampleApp.Helpers; +using TemplateStudioSampleApp.ViewModels; + +using Windows.System; + +namespace TemplateStudioSampleApp.Views; + +// TODO: Update NavigationViewItem titles and icons in ShellPage.xaml. +public sealed partial class ShellPage : Page +{ + public ShellViewModel ViewModel + { + get; + } + + public ShellPage(ShellViewModel viewModel) + { + ViewModel = viewModel; + InitializeComponent(); + + ViewModel.NavigationService.Frame = NavigationFrame; + ViewModel.NavigationViewService.Initialize(NavigationViewControl); + + // TODO: Set the title bar icon by updating /Assets/WindowIcon.ico. + // A custom title bar is required for full window theme and Mica support. + // https://docs.microsoft.com/windows/apps/develop/title-bar?tabs=winui3#full-customization + App.MainWindow.ExtendsContentIntoTitleBar = true; + App.MainWindow.SetTitleBar(AppTitleBar); + App.MainWindow.Activated += MainWindow_Activated; + AppTitleBarText.Text = "AppDisplayName".GetLocalized(); + } + + private void OnLoaded(object sender, Microsoft.UI.Xaml.RoutedEventArgs e) + { + TitleBarHelper.UpdateTitleBar(RequestedTheme); + + KeyboardAccelerators.Add(BuildKeyboardAccelerator(VirtualKey.Left, VirtualKeyModifiers.Menu)); + KeyboardAccelerators.Add(BuildKeyboardAccelerator(VirtualKey.GoBack)); + } + + private void MainWindow_Activated(object sender, WindowActivatedEventArgs args) + { + var resource = args.WindowActivationState == WindowActivationState.Deactivated ? "WindowCaptionForegroundDisabled" : "WindowCaptionForeground"; + + AppTitleBarText.Foreground = (SolidColorBrush)App.Current.Resources[resource]; + App.AppTitlebar = AppTitleBarText as UIElement; + } + + private void NavigationViewControl_DisplayModeChanged(NavigationView sender, NavigationViewDisplayModeChangedEventArgs args) + { + AppTitleBar.Margin = new Thickness() + { + Left = sender.CompactPaneLength * (sender.DisplayMode == NavigationViewDisplayMode.Minimal ? 2 : 1), + Top = AppTitleBar.Margin.Top, + Right = AppTitleBar.Margin.Right, + Bottom = AppTitleBar.Margin.Bottom + }; + } + + private static KeyboardAccelerator BuildKeyboardAccelerator(VirtualKey key, VirtualKeyModifiers? modifiers = null) + { + var keyboardAccelerator = new KeyboardAccelerator() { Key = key }; + + if (modifiers.HasValue) + { + keyboardAccelerator.Modifiers = modifiers.Value; + } + + keyboardAccelerator.Invoked += OnKeyboardAcceleratorInvoked; + + return keyboardAccelerator; + } + + private static void OnKeyboardAcceleratorInvoked(KeyboardAccelerator sender, KeyboardAcceleratorInvokedEventArgs args) + { + var navigationService = App.GetService(); + + var result = navigationService.GoBack(); + + args.Handled = result; + } +} diff --git a/Chapter10/TemplateStudioSampleApp/Views/WebViewPage.xaml b/Chapter10/TemplateStudioSampleApp/Views/WebViewPage.xaml new file mode 100644 index 0000000..4e0e02d --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp/Views/WebViewPage.xaml @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Chapter10/TemplateStudioSampleApp/Views/WebViewPage.xaml.cs b/Chapter10/TemplateStudioSampleApp/Views/WebViewPage.xaml.cs new file mode 100644 index 0000000..8f7c3a0 --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp/Views/WebViewPage.xaml.cs @@ -0,0 +1,22 @@ +using Microsoft.UI.Xaml.Controls; + +using TemplateStudioSampleApp.ViewModels; + +namespace TemplateStudioSampleApp.Views; + +// To learn more about WebView2, see https://docs.microsoft.com/microsoft-edge/webview2/. +public sealed partial class WebViewPage : Page +{ + public WebViewViewModel ViewModel + { + get; + } + + public WebViewPage() + { + ViewModel = App.GetService(); + InitializeComponent(); + + ViewModel.WebViewService.Initialize(WebView); + } +} diff --git a/Chapter10/TemplateStudioSampleApp/app.manifest b/Chapter10/TemplateStudioSampleApp/app.manifest new file mode 100644 index 0000000..db41c95 --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp/app.manifest @@ -0,0 +1,15 @@ + + + + + + + + + + + true/PM + PerMonitorV2, PerMonitor + + + diff --git a/Chapter10/TemplateStudioSampleApp/appsettings.json b/Chapter10/TemplateStudioSampleApp/appsettings.json new file mode 100644 index 0000000..73104ff --- /dev/null +++ b/Chapter10/TemplateStudioSampleApp/appsettings.json @@ -0,0 +1,6 @@ +{ + "LocalSettingsOptions": { + "ApplicationDataFolder": "TemplateStudioSampleApp/ApplicationData", + "LocalSettingsFile": "LocalSettings.json" + } +}