Skip to content

Commit

Permalink
Multitargeting updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Kinnara committed Sep 21, 2020
1 parent acf30b7 commit 868583d
Show file tree
Hide file tree
Showing 27 changed files with 105 additions and 89 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.100-preview.8.20417.9
dotnet-version: 5.0.100-rc.1.20452.10
- name: Install dependencies
run: dotnet restore
- name: Build
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<Version>0.9.2-debug.200915.0</Version>
<Version>0.9.2-preview.200922.0</Version>
<Authors>Yimeng Wu</Authors>
<Product>ModernWPF UI Library</Product>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand Down
62 changes: 62 additions & 0 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<Project>
<PropertyGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework' and $([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), '4.6.1')) or
'$(TargetFrameworkIdentifier)' == '.NETCoreApp'">
<DefineConstants>$(DefineConstants);NET461_OR_NEWER</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework' and $([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), '4.6.2')) or
'$(TargetFrameworkIdentifier)' == '.NETCoreApp'">
<DefineConstants>$(DefineConstants);NET462_OR_NEWER</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework' and $([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), '4.7')) or
'$(TargetFrameworkIdentifier)' == '.NETCoreApp'">
<DefineConstants>$(DefineConstants);NET47_OR_NEWER</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework' and $([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), '4.7.2')) or
'$(TargetFrameworkIdentifier)' == '.NETCoreApp'">
<DefineConstants>$(DefineConstants);NET472_OR_NEWER</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework' and $([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), '4.8')) or
'$(TargetFrameworkIdentifier)' == '.NETCoreApp'">
<DefineConstants>$(DefineConstants);NET48_OR_NEWER</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp' and $([MSBuild]::VersionGreaterThanOrEquals($(TargetFrameworkVersion), '5.0'))">
<DefineConstants>$(DefineConstants);NET5_0_OR_NEWER</DefineConstants>
</PropertyGroup>

<PropertyGroup Condition="'$(SupportedOSPlatform)' != '' and $([MSBuild]::VersionGreaterThan($(SupportedOSPlatform), '7.0'))">
<SupportedOSPlatform>7.0</SupportedOSPlatform>
</PropertyGroup>

<Choose>
<When Condition="'$(UseWinRT)' == 'true'">
<Choose>
<When Condition="$(DefineConstants.Contains('NET5_0_OR_NEWER'))" />
<When Condition="$(DefineConstants.Contains('NET461_OR_NEWER'))">
<ItemGroup>
<PackageReference Include="Microsoft.Windows.SDK.Contracts" Version="10.0.18362.2005" />
</ItemGroup>
</When>
<Otherwise>
<ItemGroup>
<PackageReference Include="System.Runtime.WindowsRuntime" Version="4.6.0" />
<Reference Include="Windows">
<HintPath>$(MSBuildThisFileDirectory)WinMD\Windows.WinMD</HintPath>
<IsWinMDFile>true</IsWinMDFile>
<Private>false</Private>
</Reference>
<Reference Include="Windows.Foundation.FoundationContract">
<HintPath>$(MSBuildThisFileDirectory)WinMD\Windows.Foundation.FoundationContract.winmd</HintPath>
<IsWinMDFile>true</IsWinMDFile>
<Private>false</Private>
</Reference>
<Reference Include="Windows.Foundation.UniversalApiContract">
<HintPath>$(MSBuildThisFileDirectory)WinMD\Windows.Foundation.UniversalApiContract.winmd</HintPath>
<IsWinMDFile>true</IsWinMDFile>
<Private>false</Private>
</Reference>
</ItemGroup>
</Otherwise>
</Choose>
</When>
</Choose>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ void UpdateFlowsFromAndFlowsTo()
// Ensure the SizeOfSet and PositionInSet automation properties
// for the primary commands and the MoreButton account for the
// potential MoreButton.
#if NETCOREAPP
#if NET48_OR_NEWER
EnsureAutomationSetCountAndPosition();
#endif

Expand Down Expand Up @@ -615,7 +615,7 @@ void UpdateTemplateSettings()
}
}

#if NETCOREAPP
#if NET48_OR_NEWER
void EnsureAutomationSetCountAndPosition()
{
var moreButton = m_moreButton;
Expand Down
2 changes: 1 addition & 1 deletion ModernWpf.Controls/Flyout/Flyout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ private void PlayOpenAnimation()

if (animateFrom != AnimateFrom.None)
{
#if NETCOREAPP || NET462
#if NET462_OR_NEWER
var bitmapCache = new BitmapCache(VisualTreeHelper.GetDpi(presenter).PixelsPerDip);
#else
var bitmapCache = s_bitmapCacheMode;
Expand Down
2 changes: 1 addition & 1 deletion ModernWpf.Controls/Flyout/FlyoutPresenter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ protected override void OnKeyDown(KeyEventArgs e)
}
}

#if NETCOREAPP || NET462
#if NET462_OR_NEWER
protected override void OnDpiChanged(DpiScale oldDpi, DpiScale newDpi)
{
base.OnDpiChanged(oldDpi, newDpi);
Expand Down
4 changes: 2 additions & 2 deletions ModernWpf.Controls/ModernWpf.Controls.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">

<PropertyGroup>
<TargetFrameworks>net45;net462;netcoreapp3.0;net5.0</TargetFrameworks>
<TargetFrameworks>net45;net462;netcoreapp3.0;net5.0-windows10.0.18362.0</TargetFrameworks>
<UseWPF>true</UseWPF>
<NeutralLanguage>en-US</NeutralLanguage>
<TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificBuildOutput);GetDocumentationFile</TargetsForTfmSpecificBuildOutput>
Expand All @@ -22,7 +22,7 @@
<None Include="Properties\DesignTimeResources.xaml" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework.TrimEnd(`0123456789`))' == 'net'">
<ItemGroup Condition="!$(DefineConstants.Contains('NET47_OR_NEWER'))">
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
</ItemGroup>

Expand Down
16 changes: 8 additions & 8 deletions ModernWpf.Controls/ModernWpfUI.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,29 @@
<tags>$tags$</tags>
<dependencies>
<group targetFramework="net45">
<dependency id="System.Runtime.WindowsRuntime" version="4.7.0" exclude="Build,Analyzers" />
<dependency id="System.Runtime.WindowsRuntime" version="4.6.0" exclude="Build,Analyzers" />
<dependency id="System.ValueTuple" version="4.5.0" exclude="Build,Analyzers" />
</group>
<group targetFramework="net462">
<dependency id="System.Runtime.WindowsRuntime" version="4.7.0" exclude="Build,Analyzers" />
<dependency id="System.ValueTuple" version="4.5.0" exclude="Build,Analyzers" />
<dependency id="Microsoft.Windows.SDK.Contracts" version="10.0.18362.2005" exclude="Build,Analyzers" />
</group>
<group targetFramework="netcoreapp3.0">
<dependency id="System.Runtime.WindowsRuntime" version="4.7.0" exclude="Build,Analyzers" />
</group>
<group targetFramework="net5.0">
<dependency id="Microsoft.Windows.CsWinRT" version="0.1.0-prerelease.200629.3" exclude="Build,Analyzers" />
<dependency id="Microsoft.Windows.SDK.NET" version="10.0.18362.3-preview" exclude="Build,Analyzers" />
<dependency id="Microsoft.Windows.SDK.Contracts" version="10.0.18362.2005" exclude="Build,Analyzers" />
</group>
<group targetFramework="net5.0-windows10.0.18362" />
</dependencies>
<frameworkReferences>
<group targetFramework="netcoreapp3.0">
<frameworkReference name="Microsoft.WindowsDesktop.App.WPF" />
</group>
<group targetFramework="net5.0">
<group targetFramework="net5.0-windows10.0.18362">
<frameworkReference name="Microsoft.WindowsDesktop.App.WPF" />
</group>
</frameworkReferences>
<frameworkAssemblies>
<frameworkAssembly assemblyName="netstandard" targetFramework="net472" />
</frameworkAssemblies>
</metadata>
<files>
<file src="bin\$configuration$\**\ModernWpf*.dll" target="lib" />
Expand Down
4 changes: 2 additions & 2 deletions ModernWpf.Controls/NavigationView/NavigationView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ public NavigationView()
m_navigationViewItemsFactory = new NavigationViewItemsFactory();

m_bitmapCache = new BitmapCache();
#if NETCOREAPP || NET462
#if NET462_OR_NEWER
m_bitmapCache.RenderAtScale = VisualTreeHelper.GetDpi(this).PixelsPerDip;
#endif
}
Expand Down Expand Up @@ -5536,7 +5536,7 @@ DependencyObject IControlProtected.GetTemplateChild(string childName)
return GetTemplateChild(childName);
}

#if NETCOREAPP || NET462
#if NET462_OR_NEWER
protected override void OnDpiChanged(DpiScale oldDpi, DpiScale newDpi)
{
base.OnDpiChanged(oldDpi, newDpi);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ protected override AutomationControlType GetAutomationControlTypeCore()
}
}

#if NETCOREAPP || NET48
#if NET48_OR_NEWER
protected override int GetPositionInSetCore()
{
int positionInSet = 0;
Expand Down
6 changes: 3 additions & 3 deletions ModernWpf.Controls/RadioButtons/RadioButtons.cs
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ void OnRepeaterElementPrepared(ItemsRepeater sender, ItemsRepeaterElementPrepare
Select(args.Index);
}
}
#if NETCOREAPP
#if NET48_OR_NEWER
var repeater = m_repeater;
if (repeater != null)
{
Expand Down Expand Up @@ -470,7 +470,7 @@ void OnRepeaterElementIndexChanged(ItemsRepeater sender, ItemsRepeaterElementInd
var element = args.Element;
if (element != null)
{
#if NETCOREAPP
#if NET48_OR_NEWER
element.SetValue(AutomationProperties.PositionInSetProperty, args.NewIndex + 1);
#endif
// When the selected item's index changes, update selection to match
Expand All @@ -486,7 +486,7 @@ void OnRepeaterElementIndexChanged(ItemsRepeater sender, ItemsRepeaterElementInd

void OnRepeaterCollectionChanged(object sender, object args)
{
#if NETCOREAPP
#if NET48_OR_NEWER
var repeater = m_repeater;
if (repeater != null)
{
Expand Down
4 changes: 2 additions & 2 deletions ModernWpf.Controls/ToggleSwitch/ToggleSwitch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ public override void OnApplyTemplate()

if (_bitmapCache == null)
{
#if NETCOREAPP || NET462
#if NET462_OR_NEWER
_bitmapCache = new BitmapCache(VisualTreeHelper.GetDpi(this).PixelsPerDip);
#else
_bitmapCache = new BitmapCache(2);
Expand Down Expand Up @@ -344,7 +344,7 @@ protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo)
}
}

#if NETCOREAPP || NET462
#if NET462_OR_NEWER
protected override void OnDpiChanged(DpiScale oldDpi, DpiScale newDpi)
{
base.OnDpiChanged(oldDpi, newDpi);
Expand Down
2 changes: 1 addition & 1 deletion ModernWpf.MahApps/ModernWpf.MahApps.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">

<PropertyGroup>
<TargetFrameworks>net452;net46;net462;net47;netcoreapp3.0;netcoreapp3.1;net5.0</TargetFrameworks>
<TargetFrameworks>net452;net46;net462;net47;netcoreapp3.0;netcoreapp3.1;net5.0-windows10.0.18362.0</TargetFrameworks>
<UseWPF>true</UseWPF>
<NeutralLanguage>en-US</NeutralLanguage>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
Expand Down
2 changes: 1 addition & 1 deletion ModernWpf.SampleApp/ModernWpf.SampleApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFrameworks>net45;net462;netcoreapp3.1;net5.0</TargetFrameworks>
<TargetFrameworks>net45;net48;netcoreapp3.1;net5.0-windows10.0.18362.0</TargetFrameworks>
<UseWPF>true</UseWPF>
<ApplicationIcon>Assets\AppIcon.ico</ApplicationIcon>
<LangVersion>8.0</LangVersion>
Expand Down
3 changes: 2 additions & 1 deletion ModernWpf.sln
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{1387DCAB-42A4-4F47-9E85-16998E2D9C71}"
ProjectSection(SolutionItems) = preProject
Directory.Build.props = Directory.Build.props
Directory.Build.targets = Directory.Build.targets
Settings.XamlStyler = Settings.XamlStyler
EndProjectSection
EndProject
Expand Down Expand Up @@ -41,7 +42,7 @@ Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "NavigationView_TestUI", "te
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestAppUtils", "test\TestAppUtils\TestAppUtils.csproj", "{48F790D9-2231-477E-839B-C4F5C6A20595}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MultiThreadingSample", "samples\MultiThreadingSample\MultiThreadingSample.csproj", "{4067F104-92D9-4609-AC0A-D02AC5BD444B}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MultiThreadingSample", "samples\MultiThreadingSample\MultiThreadingSample.csproj", "{4067F104-92D9-4609-AC0A-D02AC5BD444B}"
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
Expand Down
8 changes: 4 additions & 4 deletions ModernWpf/Controls/Primitives/MaximizedWindowFixer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ private void SetWindow(Window window)
_hwnd = new WindowInteropHelper(window).Handle;

_window.StateChanged += WindowStateChanged;
#if NETCOREAPP || NET462
#if NET462_OR_NEWER
_window.DpiChanged += WindowDpiChanged;
#endif
_window.Closed += WindowClosed;
Expand All @@ -96,7 +96,7 @@ private void UnsubscribeWindowEvents()
{
_window.SourceInitialized -= WindowSourceInitialized;
_window.StateChanged -= WindowStateChanged;
#if NETCOREAPP || NET462
#if NET462_OR_NEWER
_window.DpiChanged -= WindowDpiChanged;
#endif
_window.Closed -= WindowClosed;
Expand Down Expand Up @@ -129,7 +129,7 @@ private void WindowStateChanged(object sender, EventArgs e)
UpdateWindowPadding();
}

#if NETCOREAPP || NET462
#if NET462_OR_NEWER
private void WindowDpiChanged(object sender, DpiChangedEventArgs e)
{
InvalidateMaximizedWindowBorder();
Expand Down Expand Up @@ -217,7 +217,7 @@ private Thickness GetMaximizedWindowBorder()
}

double dpiScaleX, dpiScaleY;
#if NETCOREAPP || NET462
#if NET462_OR_NEWER
DpiScale dpi = VisualTreeHelper.GetDpi(_window);
dpiScaleX = dpi.DpiScaleX;
dpiScaleY = dpi.DpiScaleY;
Expand Down
4 changes: 2 additions & 2 deletions ModernWpf/Controls/Primitives/ThemeShadowChrome.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ static ThemeShadowChrome()

public ThemeShadowChrome()
{
#if NETCOREAPP || NET462
#if NET462_OR_NEWER
_bitmapCache = new BitmapCache(VisualTreeHelper.GetDpi(this).PixelsPerDip);
#else
_bitmapCache = new BitmapCache();
Expand Down Expand Up @@ -281,7 +281,7 @@ protected override Size ArrangeOverride(Size arrangeSize)
return base.ArrangeOverride(arrangeSize);
}

#if NETCOREAPP || NET462
#if NET462_OR_NEWER
protected override void OnDpiChanged(DpiScale oldDpi, DpiScale newDpi)
{
base.OnDpiChanged(oldDpi, newDpi);
Expand Down
2 changes: 1 addition & 1 deletion ModernWpf/Media/Animation/NavigationAnimation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ private void OnCompleted(object sender, EventArgs e)

private BitmapCache GetBitmapCache()
{
#if NETCOREAPP || NET462
#if NET462_OR_NEWER
return new BitmapCache(VisualTreeHelper.GetDpi(_element).PixelsPerDip);
#else
return _defaultBitmapCache;
Expand Down
29 changes: 3 additions & 26 deletions ModernWpf/ModernWpf.csproj
Original file line number Diff line number Diff line change
@@ -1,41 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">

<PropertyGroup>
<TargetFrameworks>net45;net462;netcoreapp3.0;net5.0</TargetFrameworks>
<TargetFrameworks>net45;net462;netcoreapp3.0;net5.0-windows10.0.18362.0</TargetFrameworks>
<UseWPF>true</UseWPF>
<NeutralLanguage>en-US</NeutralLanguage>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<LangVersion>8.0</LangVersion>
<UseWinRT>true</UseWinRT>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework.TrimEnd(`0123456789`))' == 'net'">
<ItemGroup Condition="!$(DefineConstants.Contains('NET47_OR_NEWER'))">
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' != 'net5.0'">
<PackageReference Include="System.Runtime.WindowsRuntime" Version="4.7.0" />
<Reference Include="Windows">
<HintPath>WinMD\Windows.WinMD</HintPath>
<IsWinMDFile>true</IsWinMDFile>
<Private>false</Private>
</Reference>
<Reference Include="Windows.Foundation.FoundationContract">
<HintPath>WinMD\Windows.Foundation.FoundationContract.winmd</HintPath>
<IsWinMDFile>true</IsWinMDFile>
<Private>false</Private>
</Reference>
<Reference Include="Windows.Foundation.UniversalApiContract">
<HintPath>WinMD\Windows.Foundation.UniversalApiContract.winmd</HintPath>
<IsWinMDFile>true</IsWinMDFile>
<Private>false</Private>
</Reference>
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net5.0'">
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="0.1.0-prerelease.200629.3" />
<PackageReference Include="Microsoft.Windows.SDK.NET" Version="10.0.18362.3-preview" />
</ItemGroup>

<ItemGroup>
<Page Remove="Properties\DesignTimeResources.xaml" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Modern styles and controls for your WPF applications.

* [Additional controls](https://github.com/Kinnara/ModernWpf/wiki/Controls#additional-controls) to help you build modern applications. Some are ported from the [Windows UI Library](https://github.com/microsoft/microsoft-ui-xaml).

* Targets .NET Framework 4.5 and .NET Core 3. Runs on Windows Vista SP2 and above.
* Targets .NET Framework 4.5+, .NET Core 3+, and .NET 5. Runs on Windows Vista SP2 and above.

![Overview of controls (light theme)](docs/images/Controls.Light.png "Overview of controls (light theme)")

Expand Down
File renamed without changes.
Loading

1 comment on commit 868583d

@ShankarBUS
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Impressive @Kinnara!

Please sign in to comment.