From f2ff0470c947832adc528a65f6fc67ae92d8aa03 Mon Sep 17 00:00:00 2001
From: Jay <65828559+Jay-o-Way@users.noreply.github.com>
Date: Mon, 9 Dec 2024 22:35:23 +0100
Subject: [PATCH] init CommandBar
---
WinUIGallery/Controls/PageHeader.xaml | 324 +++++++++++------------
WinUIGallery/Controls/PageHeader.xaml.cs | 58 +++-
WinUIGallery/ItemPage.xaml | 90 +++----
WinUIGallery/ItemPage.xaml.cs | 8 +-
4 files changed, 240 insertions(+), 240 deletions(-)
diff --git a/WinUIGallery/Controls/PageHeader.xaml b/WinUIGallery/Controls/PageHeader.xaml
index 8205084a5..f4ee983ef 100644
--- a/WinUIGallery/Controls/PageHeader.xaml
+++ b/WinUIGallery/Controls/PageHeader.xaml
@@ -22,179 +22,146 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
+
@@ -202,19 +169,38 @@
-
-
-
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
diff --git a/WinUIGallery/Controls/PageHeader.xaml.cs b/WinUIGallery/Controls/PageHeader.xaml.cs
index 9543a56e0..7fe0f4d6f 100644
--- a/WinUIGallery/Controls/PageHeader.xaml.cs
+++ b/WinUIGallery/Controls/PageHeader.xaml.cs
@@ -2,10 +2,12 @@
// Licensed under the MIT License.
using System;
-using WinUIGallery.Data;
-using WinUIGallery.Helper;
+using System.Runtime.InteropServices;
+using System.Runtime.InteropServices.Marshalling;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
+using WinUIGallery.Data;
+using WinUIGallery.Helper;
using Uri = System.Uri;
namespace WinUIGallery.DesktopWap.Controls
@@ -43,8 +45,8 @@ public void SetSamplePageSourceLinks(string BaseUri, string PageName)
// Pagetype is not null!
// So lets generate the github links and set them!
var pageName = PageName + ".xaml";
- PageCodeGitHubLink.NavigateUri = new Uri(BaseUri + pageName + ".cs");
PageMarkupGitHubLink.NavigateUri = new Uri(BaseUri + pageName);
+ PageCodeGitHubLink.NavigateUri = new Uri(BaseUri + pageName + ".cs");
}
public void SetControlSourceLink(string BaseUri, string SourceLink)
@@ -63,11 +65,11 @@ public void SetControlSourceLink(string BaseUri, string SourceLink)
private void OnCopyLinkButtonClick(object sender, RoutedEventArgs e)
{
- this.CopyLinkAction?.Invoke();
+ CopyLinkAction?.Invoke();
if (ProtocolActivationClipboardHelper.ShowCopyLinkTeachingTip)
{
- this.CopyLinkButtonTeachingTip.IsOpen = true;
+ CopyLinkButtonTeachingTip.IsOpen = true;
}
}
@@ -80,16 +82,58 @@ public void OnThemeButtonClick(object sender, RoutedEventArgs e)
private void OnCopyDontShowAgainButtonClick(TeachingTip sender, object args)
{
ProtocolActivationClipboardHelper.ShowCopyLinkTeachingTip = false;
- this.CopyLinkButtonTeachingTip.IsOpen = false;
+ CopyLinkButtonTeachingTip.IsOpen = false;
}
private void OnCopyLink()
{
- ProtocolActivationClipboardHelper.Copy(this.Item);
+ ProtocolActivationClipboardHelper.Copy(Item);
}
+
public async void OnFeedBackButtonClick(object sender, RoutedEventArgs e)
{
await Windows.System.Launcher.LaunchUriAsync(new Uri("https://github.com/microsoft/WinUI-Gallery/issues/new/choose"));
}
+
+ [GeneratedComInterface]
+ [Guid("3A3DCD6C-3EAB-43DC-BCDE-45671CE800C8")]
+ [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
+ public partial interface IDataTransferManagerInterop
+ {
+ IntPtr GetForWindow(in IntPtr appWindow, in Guid riid);
+ void ShowShareUIForWindow(IntPtr appWindow);
+ }
+
+ private static Guid _dtm_iid =
+ new(0xa5caee9b, 0x8708, 0x49d1, 0x8d, 0x36, 0x67, 0xd2, 0x5a, 0x8d, 0xa0, 0x0c);
+
+ public void ShareButton_Click(object sender, RoutedEventArgs e)
+ {
+ // https://learn.microsoft.com/windows/apps/develop/ui-input/display-ui-objects#for-classes-that-implement-idatatransfermanagerinterop
+
+ return; // CODE DOESN'T WORK -- GetWindowHandle(this) -- 'this' should equal MainWindow.Xaml.cs
+
+ // Retrieve the window handle (HWND) of the current WinUI 3 window.
+ var hWnd = WinRT.Interop.WindowNative.GetWindowHandle(this);
+
+ IDataTransferManagerInterop interop =
+ Windows.ApplicationModel.DataTransfer.DataTransferManager.As
+ ();
+
+ IntPtr result = interop.GetForWindow(hWnd, riid: in _dtm_iid);
+ var dataTransferManager = WinRT.MarshalInterface
+ .FromAbi(result);
+
+ dataTransferManager.DataRequested += (sender, args) =>
+ {
+ args.Request.Data.Properties.Title = "In a desktop app...";
+ args.Request.Data.SetText("...display WinRT UI objects that depend on CoreWindow.");
+ args.Request.Data.RequestedOperation =
+ Windows.ApplicationModel.DataTransfer.DataPackageOperation.Copy;
+ };
+
+ // Show the Share UI
+ interop.ShowShareUIForWindow(hWnd);
+ }
}
}
diff --git a/WinUIGallery/ItemPage.xaml b/WinUIGallery/ItemPage.xaml
index f1bfc4f64..d9696bb7e 100644
--- a/WinUIGallery/ItemPage.xaml
+++ b/WinUIGallery/ItemPage.xaml
@@ -29,11 +29,40 @@
EmptyValue="Collapsed"
NotEmptyValue="Visible" />
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -62,64 +91,5 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/WinUIGallery/ItemPage.xaml.cs b/WinUIGallery/ItemPage.xaml.cs
index 17852e68c..ef09de2e8 100644
--- a/WinUIGallery/ItemPage.xaml.cs
+++ b/WinUIGallery/ItemPage.xaml.cs
@@ -34,8 +34,8 @@ namespace WinUIGallery
///
public sealed partial class ItemPage : Page
{
- private static string WinUIBaseUrl = string.Format("https://github.com/microsoft/microsoft-ui-xaml/tree/winui3/release/{0}.{1}-stable/controls/dev", WASDK.Release.Major, WASDK.Release.Minor);
- private static string GalleryBaseUrl = "https://github.com/microsoft/WinUI-Gallery/tree/main/WinUIGallery/ControlPages/";
+ private static readonly string WinUIBaseUrl = "https://github.com/microsoft/microsoft-ui-xaml/tree/main/src/controls/dev";
+ private static readonly string GalleryBaseUrl = "https://github.com/microsoft/WinUI-Gallery/tree/main/WinUIGallery/ControlPages/";
public ControlInfoDataItem Item
{
@@ -59,7 +59,7 @@ public void SetInitialVisuals()
{
pageHeader.ToggleThemeAction = OnToggleTheme;
navigationRootPage.NavigationViewLoaded = OnNavigationViewLoaded;
-
+
this.Focus(FocusState.Programmatic);
}
}
@@ -155,7 +155,7 @@ private void SetControlExamplesTheme(ElementTheme theme)
{
controlExample.RequestedTheme = theme;
}
- if(controlExamples.Count() == 0)
+ if (!controlExamples.Any())
{
this.RequestedTheme = theme;
}