From 0fcb076479e8f5e4e91c585789848b9a78434d48 Mon Sep 17 00:00:00 2001 From: Niels Laute Date: Tue, 4 Jul 2023 21:04:59 +0200 Subject: [PATCH 01/26] Init --- components/TitleBar/OpenSolution.bat | 3 + components/TitleBar/samples/Assets/icon.png | Bin 0 -> 6192 bytes components/TitleBar/samples/BlankPage1.xaml | 43 +++ .../TitleBar/samples/BlankPage1.xaml.cs | 24 ++ .../TitleBar/samples/Dependencies.props | 31 ++ .../TitleBar/samples/TitleBar.Samples.csproj | 15 + components/TitleBar/samples/TitleBar.md | 33 ++ .../samples/TitleBarCustomSample.xaml | 35 ++ .../samples/TitleBarCustomSample.xaml.cs | 64 +++ .../TitleBar/src/AdditionalAssemblyInfo.cs | 13 + ...nityToolkit.WinUI.Controls.TitleBar.csproj | 13 + components/TitleBar/src/Dependencies.props | 31 ++ components/TitleBar/src/MultiTarget.props | 9 + components/TitleBar/src/Themes/Generic.xaml | 9 + .../TitleBar/src/TitleBar.Properties.cs | 215 +++++++++++ components/TitleBar/src/TitleBar.UWP.cs | 62 +++ components/TitleBar/src/TitleBar.WASDK.cs | 194 ++++++++++ components/TitleBar/src/TitleBar.cs | 157 ++++++++ components/TitleBar/src/TitleBar.xaml | 363 ++++++++++++++++++ .../tests/ExampleTitleBarTestClass.cs | 99 +++++ .../tests/ExampleTitleBarTestPage.xaml | 14 + .../tests/ExampleTitleBarTestPage.xaml.cs | 16 + .../TitleBar/tests/TitleBar.Tests.projitems | 23 ++ .../TitleBar/tests/TitleBar.Tests.shproj | 13 + 24 files changed, 1479 insertions(+) create mode 100644 components/TitleBar/OpenSolution.bat create mode 100644 components/TitleBar/samples/Assets/icon.png create mode 100644 components/TitleBar/samples/BlankPage1.xaml create mode 100644 components/TitleBar/samples/BlankPage1.xaml.cs create mode 100644 components/TitleBar/samples/Dependencies.props create mode 100644 components/TitleBar/samples/TitleBar.Samples.csproj create mode 100644 components/TitleBar/samples/TitleBar.md create mode 100644 components/TitleBar/samples/TitleBarCustomSample.xaml create mode 100644 components/TitleBar/samples/TitleBarCustomSample.xaml.cs create mode 100644 components/TitleBar/src/AdditionalAssemblyInfo.cs create mode 100644 components/TitleBar/src/CommunityToolkit.WinUI.Controls.TitleBar.csproj create mode 100644 components/TitleBar/src/Dependencies.props create mode 100644 components/TitleBar/src/MultiTarget.props create mode 100644 components/TitleBar/src/Themes/Generic.xaml create mode 100644 components/TitleBar/src/TitleBar.Properties.cs create mode 100644 components/TitleBar/src/TitleBar.UWP.cs create mode 100644 components/TitleBar/src/TitleBar.WASDK.cs create mode 100644 components/TitleBar/src/TitleBar.cs create mode 100644 components/TitleBar/src/TitleBar.xaml create mode 100644 components/TitleBar/tests/ExampleTitleBarTestClass.cs create mode 100644 components/TitleBar/tests/ExampleTitleBarTestPage.xaml create mode 100644 components/TitleBar/tests/ExampleTitleBarTestPage.xaml.cs create mode 100644 components/TitleBar/tests/TitleBar.Tests.projitems create mode 100644 components/TitleBar/tests/TitleBar.Tests.shproj diff --git a/components/TitleBar/OpenSolution.bat b/components/TitleBar/OpenSolution.bat new file mode 100644 index 000000000..814a56d4b --- /dev/null +++ b/components/TitleBar/OpenSolution.bat @@ -0,0 +1,3 @@ +@ECHO OFF + +powershell ..\..\tooling\ProjectHeads\GenerateSingleSampleHeads.ps1 -componentPath %CD% %* \ No newline at end of file diff --git a/components/TitleBar/samples/Assets/icon.png b/components/TitleBar/samples/Assets/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..5f574ceca233597ecc5d775fd2f516c0d9685cfa GIT binary patch literal 6192 zcmV-07|-X4P)(A#0FSU0V~+BLKO>0TE|I) z+7v-aRYc9N|<-MF- zi1b%r@3F{l^-$8!0R-@AuNN68cbxCgtQtH~7r^fAZ0@y8>k33}5Dv?5~4wfAB#-0ASbA8OC7v zdvB0BF+HH3LzI&{1NSS$#1$BHAZ^$ImXFJa&|Ht|TD5@H>%^+bwcx_$VDO2p zAaz>-D&y|21)R8kV4+z03WI%ydM}-j-7mfjOROZC6tq#GA7cP2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G$q{dkk zZ2kmDQ>5>7qWw8LMXvQf=85~ajc_Lwc;?A9%yoCA)o1ZBcTj{iomvdAXDdrOW~sx_ z`?fCHQvgKC*%ak0UhQuU&HGDZi}$Hmj=)=K83y(PswqQ%@C|xK%u08vIoMkiMjgvK zrCIGLUj0uKzzrW^^jO=)1z}$cF;bqNJi+VL1wBD zXvFjtU>rDXq(+-e#PS+<+lJ z1xhVODF#oTUQ15Yq{zz~dl`u7$MWe6zc*wrDSA6TS&P0xlqNBgM7xWMO-;7_wNpRn zRT~gM)fJ+cG^L@VoNSjBxVJYQ;8azg5JvY+B_#HdDyYypUcaCI#Tj@*-h`TBC&5V- zyBQ3&F)eNiuKEx@DhpxEFxf(x6T1U6gh!1<0fJGlx>f%SvPtA8mXJe?!ZRkFjHxcN z+5If(Vy!TRtU;>m5m78!=mkafPxVPCs#y~p)L7hlPuEn}5DJDPUhKNL&+HD+XFu^8 zY{D<{=_lHYH$q+ex>VJ-*^{!R(}uXc@8Y}!Cl<9>+sreRT&L@Wpg$D`)Z*(v84EhB zV5PsIge#I<1SG}%ZQ*qpF7W>^47%B0c>jq{o`vhL>#yst>#v`n*Z%>kPgzNgtS&GB O0000 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/components/TitleBar/samples/SamplePages/ShellPage.xaml.cs b/components/TitleBar/samples/SamplePages/ShellPage.xaml.cs new file mode 100644 index 000000000..56d609414 --- /dev/null +++ b/components/TitleBar/samples/SamplePages/ShellPage.xaml.cs @@ -0,0 +1,56 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace TitleBarExperiment.Samples; +/// +/// An empty page that can be used on its own or navigated to within a Frame. +/// +public sealed partial class ShellPage : Page +{ +#if WINAPPSDK + public ShellPage(Window window) + { + this.InitializeComponent(); + appTitleBar.Window = window; + } +#else + public ShellPage() + { + this.InitializeComponent(); + Microsoft.UI.Xaml.Controls.BackdropMaterial.SetApplyToRootOrPageBackground(this, true); + } +#endif + private void appTitleBar_BackButtonClick(object sender, RoutedEventArgs e) + { + if (NavFrame.CanGoBack) + { + NavFrame.GoBack(); + } + } + + private void appTitleBar_PaneButtonClick(object sender, RoutedEventArgs e) + { + NavView.IsPaneOpen = !NavView.IsPaneOpen; + } + + private void NavView_SelectionChanged(MUXC.NavigationView sender, MUXC.NavigationViewSelectionChangedEventArgs args) + { + switch ((string)((MUXC.NavigationViewItem)NavView.SelectedItem).Tag) + { + case "1": NavFrame.Navigate(typeof(FirstPage)); break; + case "2": NavFrame.Navigate(typeof(SecondPage)); break; + } + + } + + private void NavView_Loaded(object sender, RoutedEventArgs e) + { + NavView.SelectedItem = NavView.MenuItems[0]; + } + + private void NavFrame_Navigated(object sender, NavigationEventArgs e) + { + appTitleBar.IsBackButtonVisible = NavFrame.CanGoBack; + } +} diff --git a/components/TitleBar/samples/TitleBar.Samples.csproj b/components/TitleBar/samples/TitleBar.Samples.csproj index cc9099b4e..6d58d58db 100644 --- a/components/TitleBar/samples/TitleBar.Samples.csproj +++ b/components/TitleBar/samples/TitleBar.Samples.csproj @@ -6,10 +6,20 @@ + + - + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + diff --git a/components/TitleBar/samples/TitleBar.md b/components/TitleBar/samples/TitleBar.md index 656fb9916..d293e4d47 100644 --- a/components/TitleBar/samples/TitleBar.md +++ b/components/TitleBar/samples/TitleBar.md @@ -1,7 +1,7 @@ --- title: TitleBar author: niels9001 -description: TODO: Your experiment's description here +description: A control that provides a modern TitleBar keywords: TitleBar, Control, Layout dev_langs: - csharp @@ -12,22 +12,8 @@ issue-id: 0 icon: assets/icon.png --- - - - - - +The `TitleBar` provides an easy way to display a modern titlebar experience. The control handles all the required APIs to extend content into the titlebar area and custom drag regions. - - -# TitleBar - -TODO: Fill in information about this experiment and how to get started here... - -## Custom Control - -You can inherit from an existing component as well, like `Panel`, this example shows a control without a -XAML Style that will be more light-weight to consume by an app developer: - -> [!Sample TitleBarCustomSample] +> [!Sample TitleBarConfigSample] +> [!Sample TitleBarFullSample] diff --git a/components/TitleBar/samples/TitleBarConfigSample.xaml b/components/TitleBar/samples/TitleBarConfigSample.xaml new file mode 100644 index 000000000..49736cb03 --- /dev/null +++ b/components/TitleBar/samples/TitleBarConfigSample.xaml @@ -0,0 +1,104 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/components/TitleBar/samples/TitleBarConfigSample.xaml.cs b/components/TitleBar/samples/TitleBarConfigSample.xaml.cs new file mode 100644 index 000000000..645efe4eb --- /dev/null +++ b/components/TitleBar/samples/TitleBarConfigSample.xaml.cs @@ -0,0 +1,26 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +using CommunityToolkit.WinUI.Controls; + +namespace TitleBarExperiment.Samples; + +/// +/// An example sample page of a custom control inheriting from Panel. +/// +[ToolkitSampleTextOption("TitleText", "Contoso", Title = "Title")] +[ToolkitSampleTextOption("SubtitleText", "Preview", Title = "Subtitle")] +[ToolkitSampleBoolOption("ShowBackButtonSetting", false, Title = "ShowBackButton")] +[ToolkitSampleBoolOption("ShowPaneButtonSetting", false, Title = "ShowPaneButton")] + +[ToolkitSample(id: nameof(TitleBarConfigSample), "Full titlebar sample", description: $"A sample for showing how to create and use a {nameof(TitleBar)} in a window.")] +public sealed partial class TitleBarConfigSample : Page +{ + public TitleBarConfigSample() + { + this.InitializeComponent(); + } + + +} diff --git a/components/TitleBar/samples/TitleBarFullSample.xaml b/components/TitleBar/samples/TitleBarFullSample.xaml new file mode 100644 index 000000000..be8724932 --- /dev/null +++ b/components/TitleBar/samples/TitleBarFullSample.xaml @@ -0,0 +1,19 @@ + + + + + +