Skip to content

Commit

Permalink
Wpf host
Browse files Browse the repository at this point in the history
  • Loading branch information
ShortDevelopment committed Feb 12, 2023
1 parent 4c0a923 commit ec934cd
Show file tree
Hide file tree
Showing 9 changed files with 138 additions and 5 deletions.
23 changes: 23 additions & 0 deletions ShortDev.Uwp.FullTrust.sln
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ShortDev.Uwp.Internal", "Sh
EndProject
Project("{C7167F0D-BC9F-4E6E-AFE1-012C56B48DB5}") = "WapProjTemplate1", "WapProjTemplate1\WapProjTemplate1.wapproj", "{7FC83479-C3DF-41FD-B73F-BCF0DABB2C48}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfApp1", "WpfApp1\WpfApp1.csproj", "{A37144C7-0608-4B52-944A-53B0A62A797C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -161,6 +163,26 @@ Global
{7FC83479-C3DF-41FD-B73F-BCF0DABB2C48}.Release|x86.ActiveCfg = Release|x86
{7FC83479-C3DF-41FD-B73F-BCF0DABB2C48}.Release|x86.Build.0 = Release|x86
{7FC83479-C3DF-41FD-B73F-BCF0DABB2C48}.Release|x86.Deploy.0 = Release|x86
{A37144C7-0608-4B52-944A-53B0A62A797C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A37144C7-0608-4B52-944A-53B0A62A797C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A37144C7-0608-4B52-944A-53B0A62A797C}.Debug|ARM.ActiveCfg = Debug|Any CPU
{A37144C7-0608-4B52-944A-53B0A62A797C}.Debug|ARM.Build.0 = Debug|Any CPU
{A37144C7-0608-4B52-944A-53B0A62A797C}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{A37144C7-0608-4B52-944A-53B0A62A797C}.Debug|ARM64.Build.0 = Debug|Any CPU
{A37144C7-0608-4B52-944A-53B0A62A797C}.Debug|x64.ActiveCfg = Debug|Any CPU
{A37144C7-0608-4B52-944A-53B0A62A797C}.Debug|x64.Build.0 = Debug|Any CPU
{A37144C7-0608-4B52-944A-53B0A62A797C}.Debug|x86.ActiveCfg = Debug|x86
{A37144C7-0608-4B52-944A-53B0A62A797C}.Debug|x86.Build.0 = Debug|x86
{A37144C7-0608-4B52-944A-53B0A62A797C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A37144C7-0608-4B52-944A-53B0A62A797C}.Release|Any CPU.Build.0 = Release|Any CPU
{A37144C7-0608-4B52-944A-53B0A62A797C}.Release|ARM.ActiveCfg = Release|Any CPU
{A37144C7-0608-4B52-944A-53B0A62A797C}.Release|ARM.Build.0 = Release|Any CPU
{A37144C7-0608-4B52-944A-53B0A62A797C}.Release|ARM64.ActiveCfg = Release|Any CPU
{A37144C7-0608-4B52-944A-53B0A62A797C}.Release|ARM64.Build.0 = Release|Any CPU
{A37144C7-0608-4B52-944A-53B0A62A797C}.Release|x64.ActiveCfg = Release|Any CPU
{A37144C7-0608-4B52-944A-53B0A62A797C}.Release|x64.Build.0 = Release|Any CPU
{A37144C7-0608-4B52-944A-53B0A62A797C}.Release|x86.ActiveCfg = Release|Any CPU
{A37144C7-0608-4B52-944A-53B0A62A797C}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -169,6 +191,7 @@ Global
{AF8198C2-56B9-4F92-9931-0C4837936F95} = {3AAF92E0-F9D8-443E-8B35-B6D97154AA0B}
{41C1474E-C3EA-4909-96AC-0FD7ACAD3938} = {3AAF92E0-F9D8-443E-8B35-B6D97154AA0B}
{7FC83479-C3DF-41FD-B73F-BCF0DABB2C48} = {3AAF92E0-F9D8-443E-8B35-B6D97154AA0B}
{A37144C7-0608-4B52-944A-53B0A62A797C} = {3AAF92E0-F9D8-443E-8B35-B6D97154AA0B}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {94079978-D490-48BD-8069-F095B27A6654}
Expand Down
7 changes: 2 additions & 5 deletions ShortDev.Uwp.FullTrust/NativeMethods.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ SetWindowTheme
NCCALCSIZE_PARAMS
SendMessage
ReleaseCapture
EnableMouseInPointer
WM_NCLBUTTONDOWN
HT_CAPTION
ScreenToClient
Expand All @@ -31,8 +32,4 @@ WM_CLOSE
WM_DESTROY
WM_NCCALCSIZE
WM_NCHITTEST
WM_ACTIVATE

GetDCEx
ReleaseDC
GetWindowDC
WM_ACTIVATE
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ static void PrepareWindowInternal(Win32Window window)
{
// Enable acrylic "HostBackdropBrush"
window.EnableHostBackdropBrush();

EnableMouseInPointer(true);
}

static XamlWindow MountXamlInternal(XamlConfig config, IntPtr hwnd, CoreWindow? coreWindow)
Expand Down
9 changes: 9 additions & 0 deletions WpfApp1/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Application x:Class="WpfApp1.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WpfApp1"
StartupUri="MainWindow.xaml">
<Application.Resources>

</Application.Resources>
</Application>
16 changes: 16 additions & 0 deletions WpfApp1/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System.Windows;

namespace WpfApp1
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
public App()
{
// Windows.UI.Xaml.Application singleton
new UwpUI.App();
}
}
}
10 changes: 10 additions & 0 deletions WpfApp1/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System.Windows;

[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)
)]
12 changes: 12 additions & 0 deletions WpfApp1/MainWindow.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Window x:Class="WpfApp1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApp1"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>

</Grid>
</Window>
38 changes: 38 additions & 0 deletions WpfApp1/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using ShortDev.Uwp.FullTrust.Xaml;
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.Interop;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace WpfApp1
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();

WindowInteropHelper windowInterop = new(this);
windowInterop.EnsureHandle();
var uwpUI = XamlWindowActivator.Attach(windowInterop.Handle, new());
uwpUI.Content = new Windows.UI.Xaml.Controls.Button()
{
Content = "Hallo!"
};
}
}
}
26 changes: 26 additions & 0 deletions WpfApp1/WpfApp1.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<UseWPF>true</UseWPF>
<LangVersion>latest</LangVersion>
<AssetTargetFallback>uap10.0.19041</AssetTargetFallback>
<TargetPlatformVersion>10.0.19041</TargetPlatformVersion>
<Platforms>AnyCPU;x86</Platforms>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Windows.SDK.Contracts" Version="10.0.22621.755" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Toolkit.Forms.UI.XamlHost" Version="6.1.2" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\ShortDev.Uwp.FullTrust\ShortDev.Uwp.FullTrust.csproj" />
<ProjectReference Include="..\Test\UwpUI\UwpUI.csproj" />
</ItemGroup>

</Project>

0 comments on commit ec934cd

Please sign in to comment.