Skip to content

Commit

Permalink
Feat: Add CornerRadiusConverter for rounded SettingsExpander bottom c…
Browse files Browse the repository at this point in the history
…orners, add mica to both project, close #5
  • Loading branch information
HO-COOH committed Sep 30, 2024
1 parent 1281865 commit 8accf41
Show file tree
Hide file tree
Showing 16 changed files with 693 additions and 632 deletions.
10 changes: 7 additions & 3 deletions UWPExample/MainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@
x:Class="UWPExample.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:UWPExample"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="using:UWPExample"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
muxc:BackdropMaterial.ApplyToRootOrPageBackground="True"
mc:Ignorable="d">

<muxc:NavigationView SelectionChanged="NavigationView_SelectionChanged" IsSettingsVisible="False" MenuItemsSource="{x:Bind Pages}">
<Frame x:Name="ContentFrame"/>
<muxc:NavigationView
IsSettingsVisible="False"
MenuItemsSource="{x:Bind Pages}"
SelectionChanged="NavigationView_SelectionChanged">
<Frame x:Name="ContentFrame" />
</muxc:NavigationView>
</Page>
2 changes: 1 addition & 1 deletion UWPPackage/.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>WinUIEssential.UWP</id>
<version>1.2.7</version>
<version>1.2.8</version>
<title>WinUIEssential(UWP)</title>
<authors>Peter</authors>
<owners></owners>
Expand Down
35 changes: 35 additions & 0 deletions UWPPackage/SettingsExpanderLastItemConrnerRadiusConverter.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include "pch.h"
#include "SettingsExpanderLastItemConrnerRadiusConverter.h"
#if __has_include("SettingsExpanderLastItemConrnerRadiusConverter.g.cpp")
#include "SettingsExpanderLastItemConrnerRadiusConverter.g.cpp"
#endif

namespace winrt::UWPPackage::implementation
{
winrt::Windows::Foundation::IInspectable SettingsExpanderLastItemConrnerRadiusConverter::Convert(
winrt::Windows::Foundation::IInspectable const& value,
winrt::Windows::UI::Xaml::Interop::TypeName const&,
winrt::Windows::Foundation::IInspectable const&,
winrt::hstring const&)
{
if (auto cornerRadius = value.try_as<winrt::Windows::UI::Xaml::CornerRadius>())
{
return winrt::box_value(winrt::Windows::UI::Xaml::CornerRadius{
.TopLeft = 0,
.TopRight = 0,
.BottomRight = cornerRadius->BottomRight,
.BottomLeft = cornerRadius->BottomLeft
});
}
return value;
}

winrt::Windows::Foundation::IInspectable SettingsExpanderLastItemConrnerRadiusConverter::ConvertBack(
winrt::Windows::Foundation::IInspectable const& value,
winrt::Windows::UI::Xaml::Interop::TypeName const&,
winrt::Windows::Foundation::IInspectable const&,
winrt::hstring const&)
{
return value;
}
}
32 changes: 32 additions & 0 deletions UWPPackage/SettingsExpanderLastItemConrnerRadiusConverter.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#pragma once

#include "SettingsExpanderLastItemConrnerRadiusConverter.g.h"

namespace winrt::UWPPackage::implementation
{
struct SettingsExpanderLastItemConrnerRadiusConverter : SettingsExpanderLastItemConrnerRadiusConverterT<SettingsExpanderLastItemConrnerRadiusConverter>
{
SettingsExpanderLastItemConrnerRadiusConverter() = default;

winrt::Windows::Foundation::IInspectable Convert(
winrt::Windows::Foundation::IInspectable const& value,
winrt::Windows::UI::Xaml::Interop::TypeName const& targetType,
winrt::Windows::Foundation::IInspectable const& parameter,
winrt::hstring const& language
);

winrt::Windows::Foundation::IInspectable ConvertBack(
winrt::Windows::Foundation::IInspectable const& value,
winrt::Windows::UI::Xaml::Interop::TypeName const& targetType,
winrt::Windows::Foundation::IInspectable const& parameter,
winrt::hstring const& language
);
};
}

namespace winrt::UWPPackage::factory_implementation
{
struct SettingsExpanderLastItemConrnerRadiusConverter : SettingsExpanderLastItemConrnerRadiusConverterT<SettingsExpanderLastItemConrnerRadiusConverter, implementation::SettingsExpanderLastItemConrnerRadiusConverter>
{
};
}
9 changes: 9 additions & 0 deletions UWPPackage/SettingsExpanderLastItemConrnerRadiusConverter.idl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace UWPPackage
{
[bindable]
[default_interface]
runtimeclass SettingsExpanderLastItemConrnerRadiusConverter : Windows.UI.Xaml.Data.IValueConverter
{
SettingsExpanderLastItemConrnerRadiusConverter();
}
}
543 changes: 239 additions & 304 deletions UWPPackage/SettingsExpander_Resource.xaml

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions UWPPackage/UWPPackage.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,10 @@
<DependentUpon>SettingsExpanderItemStyleSelector.idl</DependentUpon>
<SubType>Code</SubType>
</ClInclude>
<ClInclude Include="SettingsExpanderLastItemConrnerRadiusConverter.h">
<DependentUpon>SettingsExpanderLastItemConrnerRadiusConverter.idl</DependentUpon>
<SubType>Code</SubType>
</ClInclude>
<ClInclude Include="SettingsPaneEx.h">
<DependentUpon>SettingsPaneEx.idl</DependentUpon>
<SubType>Code</SubType>
Expand Down Expand Up @@ -649,6 +653,10 @@
<DependentUpon>SettingsExpanderItemStyleSelector.idl</DependentUpon>
<SubType>Code</SubType>
</ClCompile>
<ClCompile Include="SettingsExpanderLastItemConrnerRadiusConverter.cpp">
<DependentUpon>SettingsExpanderLastItemConrnerRadiusConverter.idl</DependentUpon>
<SubType>Code</SubType>
</ClCompile>
<ClCompile Include="SettingsPaneEx.cpp">
<DependentUpon>SettingsPaneEx.idl</DependentUpon>
<SubType>Code</SubType>
Expand Down Expand Up @@ -755,6 +763,9 @@
<Midl Include="SettingsExpanderItemStyleSelector.idl">
<SubType>Designer</SubType>
</Midl>
<Midl Include="SettingsExpanderLastItemConrnerRadiusConverter.idl">
<SubType>Designer</SubType>
</Midl>
<Midl Include="SettingsPaneEx.idl">
<SubType>Designer</SubType>
</Midl>
Expand Down
3 changes: 3 additions & 0 deletions UWPPackage/UWPPackage.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@
<Midl Include="ImageExtension.idl">
<Filter>Controls\ImageExtension</Filter>
</Midl>
<Midl Include="SettingsExpanderLastItemConrnerRadiusConverter.idl">
<Filter>Controls\SettingsExpander</Filter>
</Midl>
</ItemGroup>
<ItemGroup>
<Page Include="GroupBox_Resource.xaml">
Expand Down
26 changes: 17 additions & 9 deletions WinUI3Example/MainWindow.xaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8" ?>
<essential:WindowEx
x:Class="WinUI3Example.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:WinUI3Example"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:essential="using:WinUI3Package"
xmlns:local="using:WinUI3Example"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Icon="Assets/MainLogo.ico"
TitleBarAutoDarkMode="True"
xmlns:essential="using:WinUI3Package"
Icon="Assets/MainLogo.ico">
mc:Ignorable="d">
<essential:WindowEx.SystemBackdrop>
<MicaBackdrop />
</essential:WindowEx.SystemBackdrop>

<!--<local:WindowEx.TitleBar>
<Grid>
<TextBlock Text="Title string"/>
<AutoSuggestBox Margin="100,0,0,0" Width="300" local:WindowEx.IsInteractive="True"/>
</Grid>
--><!--<TabView>
-->
<!--<TabView>
<TabView.TabItems>
<TabViewItem Header="Document 0">
<TabViewItem.IconSource>
Expand All @@ -35,10 +39,14 @@
</TabViewItem.IconSource>
</TabViewItem>
</TabView.TabItems>
</TabView>--><!--
</TabView>-->
<!--
</local:WindowEx.TitleBar>-->

<NavigationView SelectionChanged="NavigationView_SelectionChanged" IsSettingsVisible="False" MenuItemsSource="{x:Bind Pages}">
<Frame x:Name="ContentFrame"/>
<NavigationView
IsSettingsVisible="False"
MenuItemsSource="{x:Bind Pages}"
SelectionChanged="NavigationView_SelectionChanged">
<Frame x:Name="ContentFrame" />
</NavigationView>
</essential:WindowEx>
2 changes: 1 addition & 1 deletion WinUI3Package/.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>WinUIEssential.WinUI3</id>
<version>1.2.2</version>
<version>1.2.3</version>
<title>WinUIEssential(WinUI3)</title>
<authors>Peter</authors>
<owners></owners>
Expand Down
35 changes: 35 additions & 0 deletions WinUI3Package/SettingsExpanderLastItemConrnerRadiusConverter.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include "pch.h"
#include "SettingsExpanderLastItemConrnerRadiusConverter.h"
#if __has_include("SettingsExpanderLastItemConrnerRadiusConverter.g.cpp")
#include "SettingsExpanderLastItemConrnerRadiusConverter.g.cpp"
#endif

namespace winrt::WinUI3Package::implementation
{
winrt::Windows::Foundation::IInspectable SettingsExpanderLastItemConrnerRadiusConverter::Convert(
winrt::Windows::Foundation::IInspectable const& value,
winrt::Windows::UI::Xaml::Interop::TypeName const&,
winrt::Windows::Foundation::IInspectable const&,
winrt::hstring const&)
{
if (auto cornerRadius = value.try_as<winrt::Microsoft::UI::Xaml::CornerRadius>())
{
return winrt::box_value(winrt::Microsoft::UI::Xaml::CornerRadius{
.TopLeft = 0,
.TopRight = 0,
.BottomRight = cornerRadius->BottomRight,
.BottomLeft = cornerRadius->BottomLeft
});
}
return value;
}

winrt::Windows::Foundation::IInspectable SettingsExpanderLastItemConrnerRadiusConverter::ConvertBack(
winrt::Windows::Foundation::IInspectable const& value,
winrt::Windows::UI::Xaml::Interop::TypeName const&,
winrt::Windows::Foundation::IInspectable const&,
winrt::hstring const&)
{
return value;
}
}
32 changes: 32 additions & 0 deletions WinUI3Package/SettingsExpanderLastItemConrnerRadiusConverter.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#pragma once

#include "SettingsExpanderLastItemConrnerRadiusConverter.g.h"

namespace winrt::WinUI3Package::implementation
{
struct SettingsExpanderLastItemConrnerRadiusConverter : SettingsExpanderLastItemConrnerRadiusConverterT<SettingsExpanderLastItemConrnerRadiusConverter>
{
SettingsExpanderLastItemConrnerRadiusConverter() = default;

winrt::Windows::Foundation::IInspectable Convert(
winrt::Windows::Foundation::IInspectable const& value,
winrt::Windows::UI::Xaml::Interop::TypeName const& targetType,
winrt::Windows::Foundation::IInspectable const& parameter,
winrt::hstring const& language
);

winrt::Windows::Foundation::IInspectable ConvertBack(
winrt::Windows::Foundation::IInspectable const& value,
winrt::Windows::UI::Xaml::Interop::TypeName const& targetType,
winrt::Windows::Foundation::IInspectable const& parameter,
winrt::hstring const& language
);
};
}

namespace winrt::WinUI3Package::factory_implementation
{
struct SettingsExpanderLastItemConrnerRadiusConverter : SettingsExpanderLastItemConrnerRadiusConverterT<SettingsExpanderLastItemConrnerRadiusConverter, implementation::SettingsExpanderLastItemConrnerRadiusConverter>
{
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace WinUI3Package
{
[bindable]
[default_interface]
runtimeclass SettingsExpanderLastItemConrnerRadiusConverter : Microsoft.UI.Xaml.Data.IValueConverter
{
SettingsExpanderLastItemConrnerRadiusConverter();
}
}
Loading

0 comments on commit 8accf41

Please sign in to comment.