Skip to content

Commit

Permalink
- packaged the WinUI 3 app to deploy it
Browse files Browse the repository at this point in the history
- change the way to resize the window to handle different screen dpi
  • Loading branch information
louangr committed Oct 26, 2022
1 parent 56e1042 commit 8f10d61
Show file tree
Hide file tree
Showing 66 changed files with 242 additions and 122 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
IgnorableNamespaces="uap rescap">

<Identity
Name="f232fcfb-cd0a-4c09-931a-41522384d937"
Name="01826b75-8b33-4083-911d-6bef187fa0d3"
Publisher="CN=louangr"
Version="1.0.0.0" />

<Properties>
<DisplayName>VISCA Camera Controller</DisplayName>
<DisplayName>VISCACameraController</DisplayName>
<PublisherDisplayName>louangr</PublisherDisplayName>
<Logo>Assets\StoreLogo.png</Logo>
<Logo>Images\StoreLogo.png</Logo>
</Properties>

<Dependencies>
Expand All @@ -32,13 +32,13 @@
EntryPoint="$targetentrypoint$">
<uap:VisualElements
DisplayName="VISCA Camera Controller"
Description="VISCA Camera Controller"
Description="Windows desktop app to control a PTZ camera using the VISCA protocol via a serial communication"
BackgroundColor="transparent"
Square150x150Logo="Assets\Square150x150Logo.png"
Square44x44Logo="Assets\Square44x44Logo.png">
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png" Square71x71Logo="Assets\SmallTile.png" Square310x310Logo="Assets\LargeTile.png"/>
<uap:SplashScreen Image="Assets\SplashScreen.png" />
<uap:LockScreen BadgeLogo="Assets\BadgeLogo.png" Notification="badge"/>
Square150x150Logo="Images\Square150x150Logo.png"
Square44x44Logo="Images\Square44x44Logo.png">
<uap:DefaultTile Wide310x150Logo="Images\Wide310x150Logo.png" Square71x71Logo="Images\SmallTile.png" Square310x310Logo="Images\LargeTile.png"/>
<uap:SplashScreen Image="Images\SplashScreen.png" />
<uap:LockScreen BadgeLogo="Images\BadgeLogo.png" Notification="badge"/>
</uap:VisualElements>
</Application>
</Applications>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '15.0'">
<VisualStudioVersion>15.0</VisualStudioVersion>
</PropertyGroup>
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|x86">
<Configuration>Debug</Configuration>
<Platform>x86</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x86">
<Configuration>Release</Configuration>
<Platform>x86</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|arm64">
<Configuration>Debug</Configuration>
<Platform>arm64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|arm64">
<Configuration>Release</Configuration>
<Platform>arm64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup>
<WapProjPath Condition="'$(WapProjPath)'==''">$(MSBuildExtensionsPath)\Microsoft\DesktopBridge\</WapProjPath>
<PathToXAMLWinRTImplementations>VISCACameraController\</PathToXAMLWinRTImplementations>
</PropertyGroup>
<Import Project="$(WapProjPath)\Microsoft.DesktopBridge.props" />
<PropertyGroup>
<ProjectGuid>1ae2f326-c018-4700-b554-8343e74d99aa</ProjectGuid>
<TargetPlatformVersion>10.0.19041.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.19041.0</TargetPlatformMinVersion>
<AssetTargetFallback>net6.0-windows$(TargetPlatformVersion);$(AssetTargetFallback)</AssetTargetFallback>
<DefaultLanguage>fr-FR</DefaultLanguage>
<AppxPackageSigningEnabled>True</AppxPackageSigningEnabled>
<EntryPointProjectUniqueName>..\VISCACameraController\VISCACameraController.csproj</EntryPointProjectUniqueName>
<PackageCertificateThumbprint>A51DB0BBC36B14BFA4F29DE1291835EF37702151</PackageCertificateThumbprint>
<GenerateAppInstallerFile>False</GenerateAppInstallerFile>
<AppxPackageSigningTimestampDigestAlgorithm>SHA256</AppxPackageSigningTimestampDigestAlgorithm>
<AppxAutoIncrementPackageRevision>True</AppxAutoIncrementPackageRevision>
<GenerateTestArtifacts>True</GenerateTestArtifacts>
<AppxBundlePlatforms>x86|x64</AppxBundlePlatforms>
<HoursBetweenUpdateChecks>0</HoursBetweenUpdateChecks>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|arm64'">
<DefaultLanguage>en-US</DefaultLanguage>
<AppxBundle>Always</AppxBundle>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<DefaultLanguage>en-US</DefaultLanguage>
<AppxBundle>Always</AppxBundle>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x86'">
<DefaultLanguage>en-US</DefaultLanguage>
<AppxBundle>Always</AppxBundle>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x86'">
<DefaultLanguage>en-US</DefaultLanguage>
<AppxBundle>Always</AppxBundle>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<DefaultLanguage>en-US</DefaultLanguage>
<AppxBundle>Always</AppxBundle>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|arm64'">
<DefaultLanguage>en-US</DefaultLanguage>
<AppxBundle>Always</AppxBundle>
</PropertyGroup>
<ItemGroup>
<AppxManifest Include="Package.appxmanifest">
<SubType>Designer</SubType>
</AppxManifest>
</ItemGroup>
<ItemGroup>
<Content Include="Images\BadgeLogo.scale-100.png" />
<Content Include="Images\BadgeLogo.scale-125.png" />
<Content Include="Images\BadgeLogo.scale-150.png" />
<Content Include="Images\BadgeLogo.scale-200.png" />
<Content Include="Images\BadgeLogo.scale-400.png" />
<Content Include="Images\LargeTile.scale-100.png" />
<Content Include="Images\LargeTile.scale-125.png" />
<Content Include="Images\LargeTile.scale-150.png" />
<Content Include="Images\LargeTile.scale-200.png" />
<Content Include="Images\LargeTile.scale-400.png" />
<Content Include="Images\SmallTile.scale-100.png" />
<Content Include="Images\SmallTile.scale-125.png" />
<Content Include="Images\SmallTile.scale-150.png" />
<Content Include="Images\SmallTile.scale-200.png" />
<Content Include="Images\SmallTile.scale-400.png" />
<Content Include="Images\SplashScreen.scale-100.png" />
<Content Include="Images\SplashScreen.scale-125.png" />
<Content Include="Images\SplashScreen.scale-150.png" />
<Content Include="Images\SplashScreen.scale-200.png" />
<Content Include="Images\LockScreenLogo.scale-200.png" />
<Content Include="Images\SplashScreen.scale-400.png" />
<Content Include="Images\Square150x150Logo.scale-100.png" />
<Content Include="Images\Square150x150Logo.scale-125.png" />
<Content Include="Images\Square150x150Logo.scale-150.png" />
<Content Include="Images\Square150x150Logo.scale-200.png" />
<Content Include="Images\Square150x150Logo.scale-400.png" />
<Content Include="Images\Square44x44Logo.altform-lightunplated_targetsize-16.png" />
<Content Include="Images\Square44x44Logo.altform-lightunplated_targetsize-24.png" />
<Content Include="Images\Square44x44Logo.altform-lightunplated_targetsize-256.png" />
<Content Include="Images\Square44x44Logo.altform-lightunplated_targetsize-32.png" />
<Content Include="Images\Square44x44Logo.altform-lightunplated_targetsize-48.png" />
<Content Include="Images\Square44x44Logo.altform-unplated_targetsize-16.png" />
<Content Include="Images\Square44x44Logo.altform-unplated_targetsize-256.png" />
<Content Include="Images\Square44x44Logo.altform-unplated_targetsize-32.png" />
<Content Include="Images\Square44x44Logo.altform-unplated_targetsize-48.png" />
<Content Include="Images\Square44x44Logo.scale-100.png" />
<Content Include="Images\Square44x44Logo.scale-125.png" />
<Content Include="Images\Square44x44Logo.scale-150.png" />
<Content Include="Images\Square44x44Logo.scale-200.png" />
<Content Include="Images\Square44x44Logo.scale-400.png" />
<Content Include="Images\Square44x44Logo.targetsize-16.png" />
<Content Include="Images\Square44x44Logo.targetsize-24.png" />
<Content Include="Images\Square44x44Logo.targetsize-24_altform-unplated.png" />
<Content Include="Images\Square44x44Logo.targetsize-256.png" />
<Content Include="Images\Square44x44Logo.targetsize-32.png" />
<Content Include="Images\Square44x44Logo.targetsize-48.png" />
<Content Include="Images\StoreLogo.scale-100.png" />
<Content Include="Images\StoreLogo.scale-125.png" />
<Content Include="Images\StoreLogo.scale-150.png" />
<Content Include="Images\StoreLogo.scale-200.png" />
<Content Include="Images\StoreLogo.scale-400.png" />
<Content Include="Images\Wide310x150Logo.scale-100.png" />
<Content Include="Images\Wide310x150Logo.scale-125.png" />
<Content Include="Images\Wide310x150Logo.scale-150.png" />
<Content Include="Images\Wide310x150Logo.scale-200.png" />
<Content Include="Images\Wide310x150Logo.scale-400.png" />
<None Include="VISCACameraController %28Package%29_TemporaryKey.pfx" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\VISCACameraController\VISCACameraController.csproj">
<SkipGetTargetFrameworkProperties>True</SkipGetTargetFrameworkProperties>
<PublishProfile>Properties\PublishProfiles\win10-$(Platform).pubxml</PublishProfile>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.WindowsAppSDK" Version="[1.1.3]">
<IncludeAssets>build</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="[10.0.22000.194]">
<IncludeAssets>build</IncludeAssets>
</PackageReference>
</ItemGroup>
<Import Project="$(WapProjPath)\Microsoft.DesktopBridge.targets" />
</Project>
54 changes: 34 additions & 20 deletions VISCACameraController.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.3.32922.545
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VISCACameraController", "VISCACameraController\VISCACameraController.csproj", "{F79B9427-BB5F-44A9-9E71-AA480715281F}"
Project("{C7167F0D-BC9F-4E6E-AFE1-012C56B48DB5}") = "VISCACameraController (Package)", "VISCACameraController (Package)\VISCACameraController (Package).wapproj", "{1AE2F326-C018-4700-B554-8343E74D99AA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VISCACameraController", "VISCACameraController\VISCACameraController.csproj", "{CA94495D-1E38-4FE5-989C-30C5CF211C62}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -15,29 +17,41 @@ Global
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{F79B9427-BB5F-44A9-9E71-AA480715281F}.Debug|arm64.ActiveCfg = Debug|arm64
{F79B9427-BB5F-44A9-9E71-AA480715281F}.Debug|arm64.Build.0 = Debug|arm64
{F79B9427-BB5F-44A9-9E71-AA480715281F}.Debug|arm64.Deploy.0 = Debug|arm64
{F79B9427-BB5F-44A9-9E71-AA480715281F}.Debug|x64.ActiveCfg = Debug|x64
{F79B9427-BB5F-44A9-9E71-AA480715281F}.Debug|x64.Build.0 = Debug|x64
{F79B9427-BB5F-44A9-9E71-AA480715281F}.Debug|x64.Deploy.0 = Debug|x64
{F79B9427-BB5F-44A9-9E71-AA480715281F}.Debug|x86.ActiveCfg = Debug|x86
{F79B9427-BB5F-44A9-9E71-AA480715281F}.Debug|x86.Build.0 = Debug|x86
{F79B9427-BB5F-44A9-9E71-AA480715281F}.Debug|x86.Deploy.0 = Debug|x86
{F79B9427-BB5F-44A9-9E71-AA480715281F}.Release|arm64.ActiveCfg = Release|arm64
{F79B9427-BB5F-44A9-9E71-AA480715281F}.Release|arm64.Build.0 = Release|arm64
{F79B9427-BB5F-44A9-9E71-AA480715281F}.Release|arm64.Deploy.0 = Release|arm64
{F79B9427-BB5F-44A9-9E71-AA480715281F}.Release|x64.ActiveCfg = Release|x64
{F79B9427-BB5F-44A9-9E71-AA480715281F}.Release|x64.Build.0 = Release|x64
{F79B9427-BB5F-44A9-9E71-AA480715281F}.Release|x64.Deploy.0 = Release|x64
{F79B9427-BB5F-44A9-9E71-AA480715281F}.Release|x86.ActiveCfg = Release|x86
{F79B9427-BB5F-44A9-9E71-AA480715281F}.Release|x86.Build.0 = Release|x86
{F79B9427-BB5F-44A9-9E71-AA480715281F}.Release|x86.Deploy.0 = Release|x86
{1AE2F326-C018-4700-B554-8343E74D99AA}.Debug|arm64.ActiveCfg = Debug|arm64
{1AE2F326-C018-4700-B554-8343E74D99AA}.Debug|arm64.Build.0 = Debug|arm64
{1AE2F326-C018-4700-B554-8343E74D99AA}.Debug|arm64.Deploy.0 = Debug|arm64
{1AE2F326-C018-4700-B554-8343E74D99AA}.Debug|x64.ActiveCfg = Debug|x64
{1AE2F326-C018-4700-B554-8343E74D99AA}.Debug|x64.Build.0 = Debug|x64
{1AE2F326-C018-4700-B554-8343E74D99AA}.Debug|x64.Deploy.0 = Debug|x64
{1AE2F326-C018-4700-B554-8343E74D99AA}.Debug|x86.ActiveCfg = Debug|x86
{1AE2F326-C018-4700-B554-8343E74D99AA}.Debug|x86.Build.0 = Debug|x86
{1AE2F326-C018-4700-B554-8343E74D99AA}.Debug|x86.Deploy.0 = Debug|x86
{1AE2F326-C018-4700-B554-8343E74D99AA}.Release|arm64.ActiveCfg = Release|arm64
{1AE2F326-C018-4700-B554-8343E74D99AA}.Release|arm64.Build.0 = Release|arm64
{1AE2F326-C018-4700-B554-8343E74D99AA}.Release|arm64.Deploy.0 = Release|arm64
{1AE2F326-C018-4700-B554-8343E74D99AA}.Release|x64.ActiveCfg = Release|x64
{1AE2F326-C018-4700-B554-8343E74D99AA}.Release|x64.Build.0 = Release|x64
{1AE2F326-C018-4700-B554-8343E74D99AA}.Release|x64.Deploy.0 = Release|x64
{1AE2F326-C018-4700-B554-8343E74D99AA}.Release|x86.ActiveCfg = Release|x86
{1AE2F326-C018-4700-B554-8343E74D99AA}.Release|x86.Build.0 = Release|x86
{1AE2F326-C018-4700-B554-8343E74D99AA}.Release|x86.Deploy.0 = Release|x86
{CA94495D-1E38-4FE5-989C-30C5CF211C62}.Debug|arm64.ActiveCfg = Debug|arm64
{CA94495D-1E38-4FE5-989C-30C5CF211C62}.Debug|arm64.Build.0 = Debug|arm64
{CA94495D-1E38-4FE5-989C-30C5CF211C62}.Debug|x64.ActiveCfg = Debug|x64
{CA94495D-1E38-4FE5-989C-30C5CF211C62}.Debug|x64.Build.0 = Debug|x64
{CA94495D-1E38-4FE5-989C-30C5CF211C62}.Debug|x86.ActiveCfg = Debug|x86
{CA94495D-1E38-4FE5-989C-30C5CF211C62}.Debug|x86.Build.0 = Debug|x86
{CA94495D-1E38-4FE5-989C-30C5CF211C62}.Release|arm64.ActiveCfg = Release|arm64
{CA94495D-1E38-4FE5-989C-30C5CF211C62}.Release|arm64.Build.0 = Release|arm64
{CA94495D-1E38-4FE5-989C-30C5CF211C62}.Release|x64.ActiveCfg = Release|x64
{CA94495D-1E38-4FE5-989C-30C5CF211C62}.Release|x64.Build.0 = Release|x64
{CA94495D-1E38-4FE5-989C-30C5CF211C62}.Release|x86.ActiveCfg = Release|x86
{CA94495D-1E38-4FE5-989C-30C5CF211C62}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {1AC27211-0218-49FB-9C57-85AAEDF601F8}
SolutionGuid = {13F35F02-4DAA-447C-84E9-94531DF901DC}
EndGlobalSection
EndGlobal
11 changes: 5 additions & 6 deletions VISCACameraController/App.xaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<Application
x:Class="VISCACameraController.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mtuconverters="using:CommunityToolkit.WinUI.UI.Converters"
xmlns:local="using:VISCACameraController">
<Application x:Class="VISCACameraController.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mtuconverters="using:CommunityToolkit.WinUI.UI.Converters"
xmlns:local="using:VISCACameraController">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
Expand Down
38 changes: 33 additions & 5 deletions VISCACameraController/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
using System;
using Microsoft.UI;
using System.Runtime.InteropServices;
using Microsoft.UI.Xaml;
using VISCACameraController.Core;
using Windows.ApplicationModel.Core;
using Windows.UI.ViewManagement;
using VISCACameraController.Strings;
using WinRT;

namespace VISCACameraController
{
public partial class App : Application
{
private Window m_window;
private IntPtr m_windowHandle;

/// <summary>
/// Initializes the singleton application object. This is the first line of authored code
/// executed, and as such is the logical equivalent of main() or WinMain().
Expand All @@ -29,17 +32,42 @@ public App()
/// </summary>
public IServiceProvider Services { get; }

public IntPtr WindowHandle { get { return m_windowHandle; } }

/// <summary>
/// Invoked when the application is launched normally by the end user. Other entry points
/// will be used such as when the application is launched to open a specific file.
/// </summary>
/// <param name="args">Details about the launch request and process.</param>
protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args)
protected override void OnLaunched(LaunchActivatedEventArgs args)
{
m_window = new MainWindow();
var windowNative = m_window.As<IWindowNative>();
m_windowHandle = windowNative.WindowHandle;
m_window.Title = LocalizedStrings.GetString("AppName");
m_window.Activate();

SetWindowSize(m_windowHandle, 316, 604);
}

private Window m_window;
private void SetWindowSize(IntPtr hwnd, int width, int height)
{
var dpi = PInvoke.User32.GetDpiForWindow(hwnd);
float scalingFactor = (float)dpi / 96;
width = (int)(width * scalingFactor);
height = (int)(height * scalingFactor);

PInvoke.User32.SetWindowPos(hwnd, PInvoke.User32.SpecialWindowHandles.HWND_TOP,
0, 0, width, height,
PInvoke.User32.SetWindowPosFlags.SWP_NOMOVE);
}

[ComImport]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
[Guid("EECDBF0E-BAE9-4CB6-A68E-9598E1CB57BB")]
internal interface IWindowNative
{
IntPtr WindowHandle { get; }
}
}
}
31 changes: 1 addition & 30 deletions VISCACameraController/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
using Microsoft.UI;
using System;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml;
using VISCACameraController.Views;
using Microsoft.UI.Windowing;
using VISCACameraController.Strings;
using System.Runtime.InteropServices;
using Windows.Graphics;
using WinRT.Interop;

namespace VISCACameraController
{
Expand All @@ -15,29 +8,7 @@ public sealed partial class MainWindow : Window
public MainWindow()
{
InitializeComponent();

Title = LocalizedStrings.GetString("AppName");

InitializeDefaultWindowSize();

ContentFrame.Navigate(typeof(ControllerPage));
}

#region Private methods

private void InitializeDefaultWindowSize()
{
IntPtr hWnd = WindowNative.GetWindowHandle(this);
WindowId windowId = Win32Interop.GetWindowIdFromWindow(hWnd);
AppWindow appWindow = AppWindow.GetFromWindowId(windowId);

var size = new SizeInt32();
size.Width = 316;
size.Height = 604;

appWindow.Resize(size);
}

#endregion
}
}
Loading

0 comments on commit 8f10d61

Please sign in to comment.