Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
461167d
Added C++/WinRT blank app code
yourordinarycat Aug 22, 2023
c5c93de
Moved assets to their own folder
yourordinarycat Aug 22, 2023
55d82c2
Cleaned up package manifest, enabled optional splash screen by default
yourordinarycat Aug 22, 2023
d03d8d8
Cleaned up implementation of App class
yourordinarycat Aug 22, 2023
42b6e57
Moved MainPage to dedicated folder
yourordinarycat Aug 22, 2023
96d15dc
Improved default landing page
yourordinarycat Aug 22, 2023
d7fdf25
Adjusted template to use a single IDL file for views
yourordinarycat Aug 22, 2023
2cdd231
Renamed vstemplate file, added SimpleKit branding
yourordinarycat Aug 22, 2023
60892df
Added default output and intermediate directories
yourordinarycat Aug 22, 2023
b024243
Made C++ 20 and C 17 the default language standards
yourordinarycat Aug 22, 2023
982f8d6
Disabled prefixes by default
yourordinarycat Aug 22, 2023
c1b1440
Switched to project name for root namespace and filenames
yourordinarycat Aug 22, 2023
92ea8f6
Switched to tabs for PropertySheet
yourordinarycat Aug 22, 2023
9e226e2
Added template to VSIX manifest
yourordinarycat Aug 22, 2023
b9a2454
Added template wizard to allow for a C++ adapted root namespace
yourordinarycat Aug 22, 2023
a7183e4
Added template wizard to blank app template
yourordinarycat Aug 22, 2023
9b7d1a8
Adapted blank app template to new wizard
yourordinarycat Aug 22, 2023
9511984
Removed README
yourordinarycat Aug 22, 2023
cf63a49
Updated landing page
yourordinarycat Aug 23, 2023
cabe08b
Fixed button alignment in landing page
yourordinarycat Aug 24, 2023
13b265c
Corrected MainPage type
yourordinarycat Aug 24, 2023
21394c0
Updated VSIX manifest
yourordinarycat Aug 26, 2023
be683a2
Switched to tab alignment in VSIX
yourordinarycat Aug 26, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions templates/SimpleKit.Templates.WindowsRuntime/CppWizard.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
using EnvDTE;
using Microsoft;
using Microsoft.VisualStudio.ComponentModelHost;
using Microsoft.VisualStudio.OLE.Interop;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.TemplateWizard;
using NuGet.VisualStudio;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.ComponentModel.Composition.Hosting;

namespace SimpleKit.Templates.WindowsRuntime
{
/// <summary>
/// A wizard extension that adds a root namespace dedicated to C++
/// type definitions.
/// </summary>
internal sealed class CppWizard : IWizard
{
[Import]
internal IVsTemplateWizard Wizard { get; set; }

private void Initialize(object automationObject)
{
ThreadHelper.ThrowIfNotOnUIThread();
using (var serviceProvider = new ServiceProvider((IServiceProvider)automationObject))
{
var componentModel = (IComponentModel)serviceProvider.GetService(typeof(SComponentModel));
Assumes.Present(componentModel);

using (var container = new CompositionContainer(componentModel.DefaultExportProvider))
{
container.ComposeParts(this);
}
}
}

// Code taken from here, many thanks to original author(s):
// https://github.com/sylveon/cppwinrt/blob/bb2339505debce51f9aed13703227668537da0ba/vsix/WizardExtension.cs
// Relevant thread: https://github.com/microsoft/cppwinrt/pull/918
void IWizard.RunStarted(object automationObject, Dictionary<string, string> replacementsDictionary, WizardRunKind runKind, object[] customParams)
{
ThreadHelper.ThrowIfNotOnUIThread();
Initialize(automationObject);

if (replacementsDictionary.TryGetValue("$rootnamespace$", out var rootNamespace))
replacementsDictionary.Add("$cpprootnamespace$", rootNamespace.Replace(".", "::"));
else if (replacementsDictionary.TryGetValue("$projectname$", out var projectName))
replacementsDictionary.Add("$cpprootnamespace$", projectName.Replace(".", "::"));

Wizard.RunStarted(automationObject, replacementsDictionary, runKind, customParams);
}

void IWizard.BeforeOpeningFile(ProjectItem projectItem)
=> Wizard.BeforeOpeningFile(projectItem);

void IWizard.ProjectFinishedGenerating(Project project)
=> Wizard.ProjectFinishedGenerating(project);

void IWizard.ProjectItemFinishedGenerating(ProjectItem projectItem)
=> Wizard.ProjectItemFinishedGenerating(projectItem);

void IWizard.RunFinished()
=> Wizard.RunFinished();

bool IWizard.ShouldAddProjectItem(string filePath)
=> Wizard.ShouldAddProjectItem(filePath);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include "pch.h"
#include "App.h"

#include "Views/MainPage.h"

namespace views = winrt::$cpprootnamespace$::Views::implementation;
namespace wama = winrt::Windows::ApplicationModel::Activation;
namespace wamc = winrt::Windows::ApplicationModel::Core;
namespace wux = winrt::Windows::UI::Xaml;

namespace winrt::$cpprootnamespace$::implementation {
App::App() {
#if defined _DEBUG && !defined DISABLE_XAML_GENERATED_BREAK_ON_UNHANDLED_EXCEPTION
UnhandledException([this](const IInspectable&, const wux::UnhandledExceptionEventArgs& e)
{
if (IsDebuggerPresent()) {
const auto errorMessage = e.Message();
__debugbreak();
}
}
);
#endif
}

void App::OnLaunched(const wama::LaunchActivatedEventArgs& args) const {
const auto window = wux::Window::Current();
if (!window.Content())
window.Content(winrt::make<views::MainPage>());

if (!args.PrelaunchActivated()) {
window.Activate();
wamc::CoreApplication::EnablePrelaunch(true);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#pragma once
#include "App.xaml.g.h"

namespace winrt::$cpprootnamespace$::implementation {
struct App : AppT<App> {
/**
* @brief Creates the singleton application object.
*/
App();

/**
* @brief Invoked when the application is launched normally by the end user.
*
* @param args Details about the launch request and process.
*/
void OnLaunched(const Windows::ApplicationModel::Activation::LaunchActivatedEventArgs&) const;
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<Application
x:Class="$projectname$.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" />
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="Globals">
<CppWinRTOptimized>true</CppWinRTOptimized>
<CppWinRTRootNamespaceAutoMerge>true</CppWinRTRootNamespaceAutoMerge>
<CppWinRTGenerateWindowsMetadata>true</CppWinRTGenerateWindowsMetadata>
<MinimalCoreWin>true</MinimalCoreWin>
<ProjectGuid>{$guid1$}</ProjectGuid>
<ProjectName>$projectname$</ProjectName>
<RootNamespace>$projectname$</RootNamespace>
<DefaultLanguage>en-US</DefaultLanguage>
<MinimumVisualStudioVersion>15.0</MinimumVisualStudioVersion>
<AppContainerApplication>true</AppContainerApplication>
<ApplicationType>Windows Store</ApplicationType>
<ApplicationTypeRevision>10.0</ApplicationTypeRevision>
<WindowsTargetPlatformVersion Condition=" '$(WindowsTargetPlatformVersion)' == '' ">$targetplatformversion$</WindowsTargetPlatformVersion>
<WindowsTargetPlatformMinVersion>10.0.17134.0</WindowsTargetPlatformMinVersion>
<CppWinRTUsePrefixes>false</CppWinRTUsePrefixes>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|ARM">
<Configuration>Debug</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|ARM64">
<Configuration>Debug</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|ARM">
<Configuration>Release</Configuration>
<Platform>ARM</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|ARM64">
<Configuration>Release</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v143</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '16.0'">v142</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '15.0'">v141</PlatformToolset>
<PlatformToolset Condition="'$(VisualStudioVersion)' == '14.0'">v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Debug'" Label="Configuration">
<UseDebugLibraries>true</UseDebugLibraries>
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'" Label="Configuration">
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets">
<Import Project="PropertySheet.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<OutDir>Out\$(Configuration)\$(Platform)\</OutDir>
<IntDir>Intermediate\$(Configuration)\$(Platform)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<PrecompiledHeaderOutputFile>$(IntDir)pch.pch</PrecompiledHeaderOutputFile>
<WarningLevel>Level4</WarningLevel>
<AdditionalOptions>%(AdditionalOptions) /bigobj</AdditionalOptions>
<PreprocessorDefinitions>WIN32_LEAN_AND_MEAN;WINRT_LEAN_AND_MEAN;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<LanguageStandard>stdcpp20</LanguageStandard>
<LanguageStandard_C>stdc17</LanguageStandard_C>
</ClCompile>
<Link>
<GenerateWindowsMetadata>false</GenerateWindowsMetadata>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
<ClCompile>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
<ClCompile>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="pch.h" />
<ClInclude Include="App.h">
<DependentUpon>App.xaml</DependentUpon>
</ClInclude>
<ClInclude Include="Views\MainPage.h">
<DependentUpon>Views\MainPage.xaml</DependentUpon>
<SubType>Code</SubType>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<SubType>Designer</SubType>
</ApplicationDefinition>
</ItemGroup>
<ItemGroup>
<AppxManifest Include="Package.appxmanifest">
<SubType>Designer</SubType>
</AppxManifest>
</ItemGroup>
<ItemGroup>
<Image Include="Assets\LockScreenLogo.scale-200.png" />
<Image Include="Assets\SplashScreen.scale-200.png" />
<Image Include="Assets\Square150x150Logo.scale-200.png" />
<Image Include="Assets\Square44x44Logo.scale-200.png" />
<Image Include="Assets\Square44x44Logo.targetsize-24_altform-unplated.png" />
<Image Include="Assets\StoreLogo.png" />
<Image Include="Assets\Wide310x150Logo.scale-200.png" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="pch.cpp">
<PrecompiledHeader>Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="App.cpp">
<DependentUpon>App.xaml</DependentUpon>
</ClCompile>
<ClCompile Include="$(GeneratedFilesDir)module.g.cpp" />
<ClCompile Include="Views\MainPage.cpp">
<DependentUpon>Views\MainPage.xaml</DependentUpon>
<SubType>Code</SubType>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="PropertySheet.props" />
</ItemGroup>
<ItemGroup>
<Page Include="Views\MainPage.xaml">
<SubType>Designer</SubType>
</Page>
</ItemGroup>
<ItemGroup>
<Midl Include="Views\Views.idl" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ApplicationDefinition Include="App.xaml" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="pch.cpp" />
<ClCompile Include="$(GeneratedFilesDir)module.g.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="pch.h" />
</ItemGroup>
<ItemGroup>
<Image Include="Assets\Wide310x150Logo.scale-200.png">
<Filter>Assets</Filter>
</Image>
<Image Include="Assets\StoreLogo.png">
<Filter>Assets</Filter>
</Image>
<Image Include="Assets\Square150x150Logo.scale-200.png">
<Filter>Assets</Filter>
</Image>
<Image Include="Assets\Square44x44Logo.targetsize-24_altform-unplated.png">
<Filter>Assets</Filter>
</Image>
<Image Include="Assets\Square44x44Logo.scale-200.png">
<Filter>Assets</Filter>
</Image>
<Image Include="Assets\SplashScreen.scale-200.png">
<Filter>Assets</Filter>
</Image>
<Image Include="Assets\LockScreenLogo.scale-200.png">
<Filter>Assets</Filter>
</Image>
</ItemGroup>
<ItemGroup>
<AppxManifest Include="Package.appxmanifest" />
</ItemGroup>
<ItemGroup>
<Filter Include="Assets">
<UniqueIdentifier>{e48dc53e-40b1-40cb-970a-f89935452892}</UniqueIdentifier>
</Filter>
<Filter Include="Views">
<UniqueIdentifier>{1b3d3152-68ee-45ff-aedd-fcf101422473}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<None Include="PropertySheet.props" />
</ItemGroup>
<ItemGroup>
<Page Include="Views\MainPage.xaml">
<Filter>Views</Filter>
</Page>
</ItemGroup>
<ItemGroup>
<Midl Include="Views\Views.idl">
<Filter>Views</Filter>
</Midl>
</ItemGroup>
</Project>
Loading