diff --git a/wpf/WPF-WinRT/README.md b/wpf/WPF-WinRT/README.md new file mode 100644 index 00000000000..68b1384c3b1 --- /dev/null +++ b/wpf/WPF-WinRT/README.md @@ -0,0 +1,19 @@ +# WPF-WinRT + +This sample shows how to consume the Windows 10 API from .NET Core and .Net Framework projects. + +## Pre-requisites +To access Win10 APIs you need to have the Windows SDK installed. You can add it from the Visual Studio setup or download from [here](https://developer.microsoft.com/en-us/windows/downloads/windows-10-sdk) + +## Configure the reference in your project + +You can reference the winmd by using the `Add Reference` dialog or adding the following to your `.csproj` file: + +```xml + + + $(MSBuildProgramFiles32)\Windows Kits\10\UnionMetadata\10.0.16299.0\Windows.winmd + False + + +``` diff --git a/wpf/WPF-WinRT/WPF-WinRT-Core/WPF-WinRT-Core.csproj b/wpf/WPF-WinRT/WPF-WinRT-Core/WPF-WinRT-Core.csproj new file mode 100644 index 00000000000..99d7308bc27 --- /dev/null +++ b/wpf/WPF-WinRT/WPF-WinRT-Core/WPF-WinRT-Core.csproj @@ -0,0 +1,31 @@ + + + + WinExe + netcoreapp3.0 + Company.ConsoleApplication1 + + + + + + + + + + + + + + + + + + + + $(MSBuildProgramFiles32)\Windows Kits\10\UnionMetadata\10.0.16299.0\Windows.winmd + False + + + + \ No newline at end of file diff --git a/wpf/WPF-WinRT/WPF-WinRT-NetFx/App.config b/wpf/WPF-WinRT/WPF-WinRT-NetFx/App.config new file mode 100644 index 00000000000..56efbc7b5f1 --- /dev/null +++ b/wpf/WPF-WinRT/WPF-WinRT-NetFx/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/wpf/WPF-WinRT/WPF-WinRT-NetFx/App.xaml b/wpf/WPF-WinRT/WPF-WinRT-NetFx/App.xaml new file mode 100644 index 00000000000..83b72ede812 --- /dev/null +++ b/wpf/WPF-WinRT/WPF-WinRT-NetFx/App.xaml @@ -0,0 +1,9 @@ + + + + + diff --git a/wpf/WPF-WinRT/WPF-WinRT-NetFx/App.xaml.cs b/wpf/WPF-WinRT/WPF-WinRT-NetFx/App.xaml.cs new file mode 100644 index 00000000000..6a0a3936bf5 --- /dev/null +++ b/wpf/WPF-WinRT/WPF-WinRT-NetFx/App.xaml.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Linq; +using System.Threading.Tasks; +using System.Windows; + +namespace WPF_WinRT_NetFx +{ + /// + /// Interaction logic for App.xaml + /// + public partial class App : Application + { + } +} diff --git a/wpf/WPF-WinRT/WPF-WinRT-NetFx/MainWindow.xaml b/wpf/WPF-WinRT/WPF-WinRT-NetFx/MainWindow.xaml new file mode 100644 index 00000000000..8f0c64f7449 --- /dev/null +++ b/wpf/WPF-WinRT/WPF-WinRT-NetFx/MainWindow.xaml @@ -0,0 +1,12 @@ + + + + diff --git a/wpf/WPF-WinRT/WPF-WinRT-NetFx/MainWindow.xaml.cs b/wpf/WPF-WinRT/WPF-WinRT-NetFx/MainWindow.xaml.cs new file mode 100644 index 00000000000..432ae715534 --- /dev/null +++ b/wpf/WPF-WinRT/WPF-WinRT-NetFx/MainWindow.xaml.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace WPF_WinRT_NetFx +{ + /// + /// Interaction logic for MainWindow.xaml + /// + public partial class MainWindow : Window + { + public MainWindow() + { + InitializeComponent(); + } + + private void Window_Loaded(object sender, RoutedEventArgs e) + { + label1.Content = new Windows.Devices.Input.TouchCapabilities().TouchPresent == 1 ? + "Touch Present" : "Touch not present"; + } + } +} diff --git a/wpf/WPF-WinRT/WPF-WinRT-NetFx/Properties/AssemblyInfo.cs b/wpf/WPF-WinRT/WPF-WinRT-NetFx/Properties/AssemblyInfo.cs new file mode 100644 index 00000000000..666693725ed --- /dev/null +++ b/wpf/WPF-WinRT/WPF-WinRT-NetFx/Properties/AssemblyInfo.cs @@ -0,0 +1,55 @@ +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Windows; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("WPF-WinRT-NetFx")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("WPF-WinRT-NetFx")] +[assembly: AssemblyCopyright("Copyright © 2018")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +//In order to begin building localizable applications, set +//CultureYouAreCodingWith in your .csproj file +//inside a . For example, if you are using US english +//in your source files, set the to en-US. Then uncomment +//the NeutralResourceLanguage attribute below. Update the "en-US" in +//the line below to match the UICulture setting in the project file. + +//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] + + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] + + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/wpf/WPF-WinRT/WPF-WinRT-NetFx/Properties/Resources.Designer.cs b/wpf/WPF-WinRT/WPF-WinRT-NetFx/Properties/Resources.Designer.cs new file mode 100644 index 00000000000..0c51869d102 --- /dev/null +++ b/wpf/WPF-WinRT/WPF-WinRT-NetFx/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace WPF_WinRT_NetFx.Properties +{ + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WPF_WinRT_NetFx.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/wpf/WPF-WinRT/WPF-WinRT-NetFx/Properties/Resources.resx b/wpf/WPF-WinRT/WPF-WinRT-NetFx/Properties/Resources.resx new file mode 100644 index 00000000000..af7dbebbace --- /dev/null +++ b/wpf/WPF-WinRT/WPF-WinRT-NetFx/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/wpf/WPF-WinRT/WPF-WinRT-NetFx/Properties/Settings.Designer.cs b/wpf/WPF-WinRT/WPF-WinRT-NetFx/Properties/Settings.Designer.cs new file mode 100644 index 00000000000..abb652aece5 --- /dev/null +++ b/wpf/WPF-WinRT/WPF-WinRT-NetFx/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace WPF_WinRT_NetFx.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/wpf/WPF-WinRT/WPF-WinRT-NetFx/Properties/Settings.settings b/wpf/WPF-WinRT/WPF-WinRT-NetFx/Properties/Settings.settings new file mode 100644 index 00000000000..033d7a5e9e2 --- /dev/null +++ b/wpf/WPF-WinRT/WPF-WinRT-NetFx/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/wpf/WPF-WinRT/WPF-WinRT-NetFx/WPF-WinRT-NetFx.csproj b/wpf/WPF-WinRT/WPF-WinRT-NetFx/WPF-WinRT-NetFx.csproj new file mode 100644 index 00000000000..71d8ff2d233 --- /dev/null +++ b/wpf/WPF-WinRT/WPF-WinRT-NetFx/WPF-WinRT-NetFx.csproj @@ -0,0 +1,103 @@ + + + + + Debug + AnyCPU + {63B3E06D-B97F-4CF9-957E-87139EB9319B} + WinExe + WPF_WinRT_NetFx + WPF-WinRT-NetFx + v4.7.2 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + true + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + 4.0 + + + $(MSBuildProgramFiles32)\Windows Kits\10\UnionMetadata\10.0.16299.0\Windows.winmd + False + + + + + + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + App.xaml + Code + + + MainWindow.xaml + Code + + + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + ResXFileCodeGenerator + Resources.Designer.cs + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + + + diff --git a/wpf/WPF-WinRT/WPF-WinRT.sln b/wpf/WPF-WinRT/WPF-WinRT.sln new file mode 100644 index 00000000000..dcb211b8a8d --- /dev/null +++ b/wpf/WPF-WinRT/WPF-WinRT.sln @@ -0,0 +1,36 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.28010.2041 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WPF-WinRT-NetFx", "WPF-WinRT-NetFx\WPF-WinRT-NetFx.csproj", "{63B3E06D-B97F-4CF9-957E-87139EB9319B}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WPF-WinRT-Core", "WPF-WinRT-Core\WPF-WinRT-Core.csproj", "{F4EC2E20-5FFC-415F-B526-C82B2C6A2987}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{75431A46-7FAE-4B4E-A5B6-478EA70F0EC0}" + ProjectSection(SolutionItems) = preProject + README.md = README.md + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {63B3E06D-B97F-4CF9-957E-87139EB9319B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {63B3E06D-B97F-4CF9-957E-87139EB9319B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {63B3E06D-B97F-4CF9-957E-87139EB9319B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {63B3E06D-B97F-4CF9-957E-87139EB9319B}.Release|Any CPU.Build.0 = Release|Any CPU + {F4EC2E20-5FFC-415F-B526-C82B2C6A2987}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F4EC2E20-5FFC-415F-B526-C82B2C6A2987}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F4EC2E20-5FFC-415F-B526-C82B2C6A2987}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F4EC2E20-5FFC-415F-B526-C82B2C6A2987}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {83C579A4-14AB-48DA-AF25-911EFBBAC6BF} + EndGlobalSection +EndGlobal