Started experiment with unpackaged winui3 project.
27
NTwain.sln
@ -30,6 +30,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "csizes", "csizes\csizes.vcx
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WinConsole32", "samples\WinConsole32\WinConsole32.csproj", "{4E2417E7-FDC3-46D7-B976-84A97B500B74}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinUI3", "samples\WinUI3\WinUI3.csproj", "{F94F91C8-ABC7-4CBC-9D2E-2EAC5DA8974E}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@ -122,6 +124,30 @@ Global
|
||||
{4E2417E7-FDC3-46D7-B976-84A97B500B74}.Release|x64.Build.0 = Release|Any CPU
|
||||
{4E2417E7-FDC3-46D7-B976-84A97B500B74}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{4E2417E7-FDC3-46D7-B976-84A97B500B74}.Release|x86.Build.0 = Release|Any CPU
|
||||
{F94F91C8-ABC7-4CBC-9D2E-2EAC5DA8974E}.Debug|Any CPU.ActiveCfg = Debug|x64
|
||||
{F94F91C8-ABC7-4CBC-9D2E-2EAC5DA8974E}.Debug|Any CPU.Build.0 = Debug|x64
|
||||
{F94F91C8-ABC7-4CBC-9D2E-2EAC5DA8974E}.Debug|Any CPU.Deploy.0 = Debug|x64
|
||||
{F94F91C8-ABC7-4CBC-9D2E-2EAC5DA8974E}.Debug|ARM64.ActiveCfg = Debug|ARM64
|
||||
{F94F91C8-ABC7-4CBC-9D2E-2EAC5DA8974E}.Debug|ARM64.Build.0 = Debug|ARM64
|
||||
{F94F91C8-ABC7-4CBC-9D2E-2EAC5DA8974E}.Debug|ARM64.Deploy.0 = Debug|ARM64
|
||||
{F94F91C8-ABC7-4CBC-9D2E-2EAC5DA8974E}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{F94F91C8-ABC7-4CBC-9D2E-2EAC5DA8974E}.Debug|x64.Build.0 = Debug|x64
|
||||
{F94F91C8-ABC7-4CBC-9D2E-2EAC5DA8974E}.Debug|x64.Deploy.0 = Debug|x64
|
||||
{F94F91C8-ABC7-4CBC-9D2E-2EAC5DA8974E}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{F94F91C8-ABC7-4CBC-9D2E-2EAC5DA8974E}.Debug|x86.Build.0 = Debug|x86
|
||||
{F94F91C8-ABC7-4CBC-9D2E-2EAC5DA8974E}.Debug|x86.Deploy.0 = Debug|x86
|
||||
{F94F91C8-ABC7-4CBC-9D2E-2EAC5DA8974E}.Release|Any CPU.ActiveCfg = Release|x64
|
||||
{F94F91C8-ABC7-4CBC-9D2E-2EAC5DA8974E}.Release|Any CPU.Build.0 = Release|x64
|
||||
{F94F91C8-ABC7-4CBC-9D2E-2EAC5DA8974E}.Release|Any CPU.Deploy.0 = Release|x64
|
||||
{F94F91C8-ABC7-4CBC-9D2E-2EAC5DA8974E}.Release|ARM64.ActiveCfg = Release|ARM64
|
||||
{F94F91C8-ABC7-4CBC-9D2E-2EAC5DA8974E}.Release|ARM64.Build.0 = Release|ARM64
|
||||
{F94F91C8-ABC7-4CBC-9D2E-2EAC5DA8974E}.Release|ARM64.Deploy.0 = Release|ARM64
|
||||
{F94F91C8-ABC7-4CBC-9D2E-2EAC5DA8974E}.Release|x64.ActiveCfg = Release|x64
|
||||
{F94F91C8-ABC7-4CBC-9D2E-2EAC5DA8974E}.Release|x64.Build.0 = Release|x64
|
||||
{F94F91C8-ABC7-4CBC-9D2E-2EAC5DA8974E}.Release|x64.Deploy.0 = Release|x64
|
||||
{F94F91C8-ABC7-4CBC-9D2E-2EAC5DA8974E}.Release|x86.ActiveCfg = Release|x86
|
||||
{F94F91C8-ABC7-4CBC-9D2E-2EAC5DA8974E}.Release|x86.Build.0 = Release|x86
|
||||
{F94F91C8-ABC7-4CBC-9D2E-2EAC5DA8974E}.Release|x86.Deploy.0 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
@ -130,6 +156,7 @@ Global
|
||||
{7792A94E-D0B4-440D-8BD5-CA1CA548782C} = {707B4313-8EF8-4D0F-A95E-590783422187}
|
||||
{C9666CB2-C9A6-48C8-AB51-D616A48058A7} = {707B4313-8EF8-4D0F-A95E-590783422187}
|
||||
{4E2417E7-FDC3-46D7-B976-84A97B500B74} = {707B4313-8EF8-4D0F-A95E-590783422187}
|
||||
{F94F91C8-ABC7-4CBC-9D2E-2EAC5DA8974E} = {707B4313-8EF8-4D0F-A95E-590783422187}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {7459323B-44F6-4E07-8574-E1B4B525086B}
|
||||
|
16
samples/WinUI3/App.xaml
Normal file
@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Application
|
||||
x:Class="WinUI3.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="using:WinUI3">
|
||||
<Application.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
|
||||
<!-- Other merged dictionaries here -->
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
<!-- Other app resources here -->
|
||||
</ResourceDictionary>
|
||||
</Application.Resources>
|
||||
</Application>
|
50
samples/WinUI3/App.xaml.cs
Normal file
@ -0,0 +1,50 @@
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Microsoft.UI.Xaml.Controls.Primitives;
|
||||
using Microsoft.UI.Xaml.Data;
|
||||
using Microsoft.UI.Xaml.Input;
|
||||
using Microsoft.UI.Xaml.Media;
|
||||
using Microsoft.UI.Xaml.Navigation;
|
||||
using Microsoft.UI.Xaml.Shapes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices.WindowsRuntime;
|
||||
using Windows.ApplicationModel;
|
||||
using Windows.ApplicationModel.Activation;
|
||||
using Windows.Foundation;
|
||||
using Windows.Foundation.Collections;
|
||||
|
||||
// To learn more about WinUI, the WinUI project structure,
|
||||
// and more about our project templates, see: http://aka.ms/winui-project-info.
|
||||
|
||||
namespace WinUI3
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides application-specific behavior to supplement the default Application class.
|
||||
/// </summary>
|
||||
public partial class App : Application
|
||||
{
|
||||
/// <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().
|
||||
/// </summary>
|
||||
public App()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when the application is launched.
|
||||
/// </summary>
|
||||
/// <param name="args">Details about the launch request and process.</param>
|
||||
protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args)
|
||||
{
|
||||
m_window = new MainWindow();
|
||||
m_window.Activate();
|
||||
}
|
||||
|
||||
private Window m_window;
|
||||
}
|
||||
}
|
BIN
samples/WinUI3/Assets/LockScreenLogo.scale-200.png
Normal file
After Width: | Height: | Size: 432 B |
BIN
samples/WinUI3/Assets/SplashScreen.scale-200.png
Normal file
After Width: | Height: | Size: 5.2 KiB |
BIN
samples/WinUI3/Assets/Square150x150Logo.scale-200.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
samples/WinUI3/Assets/Square44x44Logo.scale-200.png
Normal file
After Width: | Height: | Size: 637 B |
After Width: | Height: | Size: 283 B |
BIN
samples/WinUI3/Assets/StoreLogo.png
Normal file
After Width: | Height: | Size: 456 B |
BIN
samples/WinUI3/Assets/Wide310x150Logo.scale-200.png
Normal file
After Width: | Height: | Size: 2.0 KiB |
14
samples/WinUI3/MainWindow.xaml
Normal file
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Window
|
||||
x:Class="WinUI3.MainWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="using:WinUI3"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d">
|
||||
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
<Button x:Name="myButton" Click="myButton_Click">Click Me</Button>
|
||||
</StackPanel>
|
||||
</Window>
|
224
samples/WinUI3/MainWindow.xaml.cs
Normal file
@ -0,0 +1,224 @@
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using NTwain;
|
||||
using NTwain.Data;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing.Imaging;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
// To learn more about WinUI, the WinUI project structure,
|
||||
// and more about our project templates, see: http://aka.ms/winui-project-info.
|
||||
|
||||
namespace WinUI3
|
||||
{
|
||||
/// <summary>
|
||||
/// An empty window that can be used on its own or navigated to within a Frame.
|
||||
/// </summary>
|
||||
public sealed partial class MainWindow : Window
|
||||
{
|
||||
TwainAppSession session;
|
||||
readonly int _jpegQuality = 75;
|
||||
readonly string saveFolder;
|
||||
readonly Stopwatch watch = new();
|
||||
readonly ImageCodecInfo _jpegEncoder;
|
||||
readonly EncoderParameters _jpegParameters;
|
||||
bool _useThreadForImag;
|
||||
bool _useSystemDrawing;
|
||||
bool _saveDisk;
|
||||
|
||||
public MainWindow()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
|
||||
var libVer = FileVersionInfo.GetVersionInfo(typeof(TwainAppSession).Assembly.Location).ProductVersion;
|
||||
Title = $"WinUI3 sample {(TWPlatform.Is32bit ? " 32bit" : " 64bit")} on NTwain {libVer}";
|
||||
|
||||
saveFolder = Path.Combine(Path.GetTempPath(), "ntwain-sample" + Path.DirectorySeparatorChar);
|
||||
Directory.CreateDirectory(saveFolder);
|
||||
|
||||
session = new TwainAppSession();
|
||||
|
||||
session.StateChanged += Session_StateChanged;
|
||||
session.SourceDisabled += Session_SourceDisabled;
|
||||
session.TransferReady += Session_TransferReady;
|
||||
session.Transferred += Session_Transferred;
|
||||
session.TransferError += Session_TransferError;
|
||||
|
||||
this.Closed += MainWindow_Closed;
|
||||
|
||||
_jpegParameters = new EncoderParameters(1);
|
||||
_jpegParameters.Param[0] = new EncoderParameter(Encoder.Quality, (long)_jpegQuality);
|
||||
_jpegEncoder = ImageCodecInfo.GetImageEncoders().First(enc => enc.FormatID == ImageFormat.Jpeg.Guid);
|
||||
}
|
||||
|
||||
private void Session_TransferError(TwainAppSession sender, TransferErrorEventArgs e)
|
||||
{
|
||||
if (e.Exception != null)
|
||||
{
|
||||
Debug.WriteLine($"[thread {Environment.CurrentManagedThreadId}] transfer error {e.Exception}.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.WriteLine($"[thread {Environment.CurrentManagedThreadId}] transfer error {e.Code}.");
|
||||
}
|
||||
}
|
||||
|
||||
private void MainWindow_Closed(object sender, WindowEventArgs args)
|
||||
{
|
||||
session.TryStepdown(STATE.S2);
|
||||
}
|
||||
|
||||
private void Session_TransferReady(TwainAppSession sender, TransferReadyEventArgs e)
|
||||
{
|
||||
Debug.WriteLine($"[thread {Environment.CurrentManagedThreadId}] transfer ready.");
|
||||
}
|
||||
private void Session_Transferred(TwainAppSession sender, TransferredEventArgs e)
|
||||
{
|
||||
Debug.WriteLine($"[thread {Environment.CurrentManagedThreadId}] data transferred with info {e.ImageInfo}");
|
||||
// if using a high-speed scanner, imaging handling could be a bottleneck
|
||||
// so it's possible to pass the data to another thread while the scanning
|
||||
// loop happens. Just remember to dispose it after.
|
||||
|
||||
if (_useThreadForImag)
|
||||
{
|
||||
// bad thread example but whatev. should use a dedicated thread of some sort for real
|
||||
Task.Run(() =>
|
||||
{
|
||||
HandleTransferredData(e);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
HandleTransferredData(e);
|
||||
}
|
||||
}
|
||||
private void HandleTransferredData(TransferredEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
// example of using some lib to handle image data
|
||||
var saveFile = Path.Combine(saveFolder, (DateTime.Now.Ticks / 1000).ToString());
|
||||
if (_useSystemDrawing)
|
||||
{
|
||||
using (var img = System.Drawing.Image.FromStream(e.Data.AsStream()))
|
||||
{
|
||||
if (img.PixelFormat == System.Drawing.Imaging.PixelFormat.Format1bppIndexed ||
|
||||
img.PixelFormat == System.Drawing.Imaging.PixelFormat.Format8bppIndexed)
|
||||
{
|
||||
// bw or gray
|
||||
saveFile += ".png";
|
||||
if (_saveDisk)
|
||||
{
|
||||
img.Save(saveFile, ImageFormat.Png);
|
||||
Debug.WriteLine($"Saved image to {saveFile}");
|
||||
}
|
||||
else img.Save(new NoOpStream(), ImageFormat.Png);
|
||||
}
|
||||
else
|
||||
{
|
||||
// color
|
||||
saveFile += ".jpg";
|
||||
if (_saveDisk)
|
||||
{
|
||||
img.Save(saveFile, _jpegEncoder, _jpegParameters);
|
||||
Debug.WriteLine($"Saved image to {saveFile}");
|
||||
}
|
||||
else img.Save(new NoOpStream(), _jpegEncoder, _jpegParameters);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
using (var stream = e.Data?.AsStream())
|
||||
{
|
||||
using (var img = new ImageMagick.MagickImage(e.Data.AsSpan()))
|
||||
{
|
||||
var format = ImageMagick.MagickFormat.Png;
|
||||
if (img.ColorType == ImageMagick.ColorType.Palette)
|
||||
{
|
||||
// bw or gray
|
||||
saveFile += ".png";
|
||||
}
|
||||
else
|
||||
{
|
||||
// color
|
||||
saveFile += ".jpg";
|
||||
format = ImageMagick.MagickFormat.Jpeg;
|
||||
img.Quality = _jpegQuality;
|
||||
}
|
||||
if (_saveDisk)
|
||||
{
|
||||
img.Write(saveFile, format);
|
||||
Debug.WriteLine($"Saved image to {saveFile}");
|
||||
}
|
||||
else img.Write(new NoOpStream(), format);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
finally
|
||||
{
|
||||
e.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
private void Session_SourceDisabled(TwainAppSession sender, TW_IDENTITY_LEGACY e)
|
||||
{
|
||||
session.CloseSource();
|
||||
DispatcherQueue.TryEnqueue(() =>
|
||||
{
|
||||
if (watch.IsRunning)
|
||||
{
|
||||
watch.Stop();
|
||||
var dlg = new ContentDialog
|
||||
{
|
||||
Title = "Completed",
|
||||
Content = $"Took {watch.Elapsed} to finish that transfer.",
|
||||
CloseButtonText = "OK",
|
||||
XamlRoot = Content.XamlRoot
|
||||
};
|
||||
_ = dlg.ShowAsync();
|
||||
|
||||
if (_saveDisk)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (Directory.Exists(saveFolder))
|
||||
{
|
||||
using (Process.Start(new ProcessStartInfo { FileName = saveFolder, UseShellExecute = true })) { }
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void Session_StateChanged(TwainAppSession sender, STATE e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private async void myButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (session.State < STATE.S3)
|
||||
await session.OpenDSMAsync();
|
||||
|
||||
if (session.ShowUserSelect().IsSuccess)
|
||||
{
|
||||
if (session.OpenSource(session.CurrentSource).IsSuccess)
|
||||
{
|
||||
if (session.EnableSource(true, false).IsSuccess)
|
||||
{
|
||||
_saveDisk = true;
|
||||
watch.Restart();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
40
samples/WinUI3/NoOpStream.cs
Normal file
@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace WinUI3
|
||||
{
|
||||
internal class NoOpStream : Stream
|
||||
{
|
||||
public override bool CanRead => false;
|
||||
|
||||
public override bool CanSeek => false;
|
||||
|
||||
public override bool CanWrite => true;
|
||||
|
||||
public override long Length => 0;
|
||||
|
||||
public override long Position { get => 0; set { } }
|
||||
|
||||
public override void Flush()
|
||||
{
|
||||
}
|
||||
|
||||
public override int Read(byte[] buffer, int offset, int count)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override long Seek(long offset, SeekOrigin origin)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public override void SetLength(long value)
|
||||
{
|
||||
}
|
||||
|
||||
public override void Write(byte[] buffer, int offset, int count)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
51
samples/WinUI3/Package.appxmanifest
Normal file
@ -0,0 +1,51 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<Package
|
||||
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
|
||||
xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest"
|
||||
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
|
||||
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
|
||||
IgnorableNamespaces="uap rescap">
|
||||
|
||||
<Identity
|
||||
Name="aa6cdc62-8d2a-45fb-b810-529d3b928630"
|
||||
Publisher="CN=yinch"
|
||||
Version="1.0.0.0" />
|
||||
|
||||
<mp:PhoneIdentity PhoneProductId="aa6cdc62-8d2a-45fb-b810-529d3b928630" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>
|
||||
|
||||
<Properties>
|
||||
<DisplayName>WinUI3</DisplayName>
|
||||
<PublisherDisplayName>yinch</PublisherDisplayName>
|
||||
<Logo>Assets\StoreLogo.png</Logo>
|
||||
</Properties>
|
||||
|
||||
<Dependencies>
|
||||
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.17763.0" MaxVersionTested="10.0.19041.0" />
|
||||
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.17763.0" MaxVersionTested="10.0.19041.0" />
|
||||
</Dependencies>
|
||||
|
||||
<Resources>
|
||||
<Resource Language="x-generate"/>
|
||||
</Resources>
|
||||
|
||||
<Applications>
|
||||
<Application Id="App"
|
||||
Executable="$targetnametoken$.exe"
|
||||
EntryPoint="$targetentrypoint$">
|
||||
<uap:VisualElements
|
||||
DisplayName="WinUI3"
|
||||
Description="WinUI3"
|
||||
BackgroundColor="transparent"
|
||||
Square150x150Logo="Assets\Square150x150Logo.png"
|
||||
Square44x44Logo="Assets\Square44x44Logo.png">
|
||||
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png" />
|
||||
<uap:SplashScreen Image="Assets\SplashScreen.png" />
|
||||
</uap:VisualElements>
|
||||
</Application>
|
||||
</Applications>
|
||||
|
||||
<Capabilities>
|
||||
<rescap:Capability Name="runFullTrust" />
|
||||
</Capabilities>
|
||||
</Package>
|
20
samples/WinUI3/Properties/PublishProfiles/win10-arm64.pubxml
Normal file
@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
https://go.microsoft.com/fwlink/?LinkID=208121.
|
||||
-->
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<PublishProtocol>FileSystem</PublishProtocol>
|
||||
<Platform>ARM64</Platform>
|
||||
<RuntimeIdentifier>win10-arm64</RuntimeIdentifier>
|
||||
<PublishDir>bin\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\publish\</PublishDir>
|
||||
<SelfContained>true</SelfContained>
|
||||
<PublishSingleFile>False</PublishSingleFile>
|
||||
<PublishReadyToRun Condition="'$(Configuration)' == 'Debug'">False</PublishReadyToRun>
|
||||
<PublishReadyToRun Condition="'$(Configuration)' != 'Debug'">True</PublishReadyToRun>
|
||||
<!--
|
||||
See https://github.com/microsoft/CsWinRT/issues/373
|
||||
<PublishTrimmed>True</PublishTrimmed>
|
||||
-->
|
||||
</PropertyGroup>
|
||||
</Project>
|
20
samples/WinUI3/Properties/PublishProfiles/win10-x64.pubxml
Normal file
@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
https://go.microsoft.com/fwlink/?LinkID=208121.
|
||||
-->
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<PublishProtocol>FileSystem</PublishProtocol>
|
||||
<Platform>x64</Platform>
|
||||
<RuntimeIdentifier>win10-x64</RuntimeIdentifier>
|
||||
<PublishDir>bin\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\publish\</PublishDir>
|
||||
<SelfContained>true</SelfContained>
|
||||
<PublishSingleFile>False</PublishSingleFile>
|
||||
<PublishReadyToRun Condition="'$(Configuration)' == 'Debug'">False</PublishReadyToRun>
|
||||
<PublishReadyToRun Condition="'$(Configuration)' != 'Debug'">True</PublishReadyToRun>
|
||||
<!--
|
||||
See https://github.com/microsoft/CsWinRT/issues/373
|
||||
<PublishTrimmed>True</PublishTrimmed>
|
||||
-->
|
||||
</PropertyGroup>
|
||||
</Project>
|
20
samples/WinUI3/Properties/PublishProfiles/win10-x86.pubxml
Normal file
@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
https://go.microsoft.com/fwlink/?LinkID=208121.
|
||||
-->
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<PublishProtocol>FileSystem</PublishProtocol>
|
||||
<Platform>x86</Platform>
|
||||
<RuntimeIdentifier>win10-x86</RuntimeIdentifier>
|
||||
<PublishDir>bin\$(Configuration)\$(TargetFramework)\$(RuntimeIdentifier)\publish\</PublishDir>
|
||||
<SelfContained>true</SelfContained>
|
||||
<PublishSingleFile>False</PublishSingleFile>
|
||||
<PublishReadyToRun Condition="'$(Configuration)' == 'Debug'">False</PublishReadyToRun>
|
||||
<PublishReadyToRun Condition="'$(Configuration)' != 'Debug'">True</PublishReadyToRun>
|
||||
<!--
|
||||
See https://github.com/microsoft/CsWinRT/issues/373
|
||||
<PublishTrimmed>True</PublishTrimmed>
|
||||
-->
|
||||
</PropertyGroup>
|
||||
</Project>
|
10
samples/WinUI3/Properties/launchSettings.json
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"profiles": {
|
||||
"WinUI3 (Package)": {
|
||||
"commandName": "MsixPackage"
|
||||
},
|
||||
"WinUI3 (Unpackaged)": {
|
||||
"commandName": "Project"
|
||||
}
|
||||
}
|
||||
}
|
55
samples/WinUI3/WinUI3.csproj
Normal file
@ -0,0 +1,55 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net6.0-windows10.0.19041.0</TargetFramework>
|
||||
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
|
||||
<RootNamespace>WinUI3</RootNamespace>
|
||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||
<Platforms>x86;x64;ARM64</Platforms>
|
||||
<RuntimeIdentifiers>win10-x86;win10-x64;win10-arm64</RuntimeIdentifiers>
|
||||
<PublishProfile>win10-$(Platform).pubxml</PublishProfile>
|
||||
<UseWinUI>true</UseWinUI>
|
||||
<EnableMsixTooling>true</EnableMsixTooling>
|
||||
<!--only for this to work at the moment-->
|
||||
<WindowsPackageType>None</WindowsPackageType>
|
||||
<WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="Assets\SplashScreen.scale-200.png" />
|
||||
<Content Include="Assets\LockScreenLogo.scale-200.png" />
|
||||
<Content Include="Assets\Square150x150Logo.scale-200.png" />
|
||||
<Content Include="Assets\Square44x44Logo.scale-200.png" />
|
||||
<Content Include="Assets\Square44x44Logo.targetsize-24_altform-unplated.png" />
|
||||
<Content Include="Assets\StoreLogo.png" />
|
||||
<Content Include="Assets\Wide310x150Logo.scale-200.png" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Magick.NET-Q8-AnyCPU" Version="13.1.3" />
|
||||
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.3.230502000" />
|
||||
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.755" />
|
||||
<Manifest Include="$(ApplicationManifest)" />
|
||||
</ItemGroup>
|
||||
|
||||
<!--
|
||||
Defining the "Msix" ProjectCapability here allows the Single-project MSIX Packaging
|
||||
Tools extension to be activated for this project even if the Windows App SDK Nuget
|
||||
package has not yet been restored.
|
||||
-->
|
||||
<ItemGroup Condition="'$(DisableMsixProjectCapabilityAddedByProject)'!='true' and '$(EnableMsixTooling)'=='true'">
|
||||
<ProjectCapability Include="Msix" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\NTwain\NTwain.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<!--
|
||||
Defining the "HasPackageAndPublishMenuAddedByProject" property here allows the Solution
|
||||
Explorer "Package and Publish" context menu entry to be enabled for this project even if
|
||||
the Windows App SDK Nuget package has not yet been restored.
|
||||
-->
|
||||
<PropertyGroup Condition="'$(DisableHasPackageAndPublishMenuAddedByProject)'!='true' and '$(EnableMsixTooling)'=='true'">
|
||||
<HasPackageAndPublishMenu>true</HasPackageAndPublishMenu>
|
||||
</PropertyGroup>
|
||||
</Project>
|
34
samples/WinUI3/app.manifest
Normal file
@ -0,0 +1,34 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<assemblyIdentity version="1.0.0.0" name="WinUI3.app"/>
|
||||
|
||||
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
|
||||
<application>
|
||||
<!--The ID below informs the system that this application is compatible with OS features first introduced in Windows 8.
|
||||
For more info see https://docs.microsoft.com/windows/win32/sysinfo/targeting-your-application-at-windows-8-1
|
||||
|
||||
It is also necessary to support features in unpackaged applications, for example the custom titlebar implementation.-->
|
||||
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />
|
||||
</application>
|
||||
</compatibility>
|
||||
|
||||
<application xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<windowsSettings>
|
||||
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2</dpiAwareness>
|
||||
</windowsSettings>
|
||||
</application>
|
||||
|
||||
<!-- Enable themes for Windows common controls and dialogs (Windows XP and later) -->
|
||||
<dependency>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity
|
||||
type="win32"
|
||||
name="Microsoft.Windows.Common-Controls"
|
||||
version="6.0.0.0"
|
||||
processorArchitecture="*"
|
||||
publicKeyToken="6595b64144ccf1df"
|
||||
language="*"
|
||||
/>
|
||||
</dependentAssembly>
|
||||
</dependency>
|
||||
</assembly>
|