From 97083feb7c19783a3b568d23c62ef0bd141602f4 Mon Sep 17 00:00:00 2001 From: iTob Date: Mon, 20 Jan 2025 20:31:00 +0100 Subject: [PATCH] wip --- .../PictureGallery/PictureGalleryPage.xaml | 7 ++- .../PictureGallery/PictureGalleryPage.xaml.cs | 46 +++++++++++++++++-- 2 files changed, 46 insertions(+), 7 deletions(-) diff --git a/src/CamBooth/CamBooth.App/PictureGallery/PictureGalleryPage.xaml b/src/CamBooth/CamBooth.App/PictureGallery/PictureGalleryPage.xaml index 659ed8c..648df4d 100644 --- a/src/CamBooth/CamBooth.App/PictureGallery/PictureGalleryPage.xaml +++ b/src/CamBooth/CamBooth.App/PictureGallery/PictureGalleryPage.xaml @@ -9,8 +9,7 @@ xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml" Background="Magenta"> - - - + + - + \ No newline at end of file diff --git a/src/CamBooth/CamBooth.App/PictureGallery/PictureGalleryPage.xaml.cs b/src/CamBooth/CamBooth.App/PictureGallery/PictureGalleryPage.xaml.cs index 7d51ecb..11e1324 100644 --- a/src/CamBooth/CamBooth.App/PictureGallery/PictureGalleryPage.xaml.cs +++ b/src/CamBooth/CamBooth.App/PictureGallery/PictureGalleryPage.xaml.cs @@ -1,12 +1,17 @@ using System.IO; using System.Windows; using System.Windows.Controls; +using System.Windows.Documents; using System.Windows.Media.Imaging; using CamBooth.App.Core.AppSettings; using CamBooth.App.Core.Logging; +using Wpf.Ui.Controls; + using Image = Wpf.Ui.Controls.Image; +using MessageBox = System.Windows.MessageBox; +using TextBlock = Wpf.Ui.Controls.TextBlock; namespace CamBooth.App.PictureGallery; @@ -29,7 +34,7 @@ public partial class PictureGalleryPage : Page, IDisposable } - private void Initialize() + private async void Initialize() { try { @@ -42,6 +47,15 @@ public partial class PictureGalleryPage : Page, IDisposable } + private void ContentDialog_OnButtonClicked(ContentDialog sender, ContentDialogButtonClickEventArgs args) + { + if (args.Button == ContentDialogButton.Primary) + { + MessageBox.Show($"Print the shit baby {sender.Tag}"); + } + } + + private void LoadPictures(int howManyPictures = 0) { int loop = 0; @@ -53,14 +67,20 @@ public partial class PictureGalleryPage : Page, IDisposable { BitmapImage thumbnail = this._pictureGalleryService.ThumbnailsOrderedByNewestDescending[loop]; - var imageControl = new Wpf.Ui.Controls.Image() + var textBlock = new TextBlock(); + var hyperlink = new Hyperlink(); + hyperlink.Click += Hyperlink_OnClick; + hyperlink.Tag = thumbnail.UriSource; + var imageControl = new Wpf.Ui.Controls.Image { Source = thumbnail, Width = 388, Margin = new Thickness(3) }; + hyperlink.Inlines.Add(new InlineUIContainer(imageControl)); - this.PicturesPanel.Children.Add(imageControl); + textBlock.Inlines.Add(hyperlink); + this.PicturesPanel.Children.Add(textBlock); loop++; } while ((loop < howManyPictures || howManyPictures == 0) && loop < this._pictureGalleryService.ThumbnailsOrderedByNewestDescending.Count); @@ -68,6 +88,26 @@ public partial class PictureGalleryPage : Page, IDisposable } + private void Hyperlink_OnClick(object sender, RoutedEventArgs e) + { + Uri? picturePathUri = ((Hyperlink)sender).Tag as Uri; + Application.Current.Dispatcher.BeginInvoke( + async () => + { + var contentDialog = new ContentDialog(RootContentDialogPresenter); + + contentDialog.SetCurrentValue(ContentDialog.TitleProperty, "Hello World"); + contentDialog.SetCurrentValue(ContentControl.ContentProperty, "This is a message"); + contentDialog.SetCurrentValue(ContentDialog.CloseButtonTextProperty, "Close this dialog"); + contentDialog.SetCurrentValue(ContentDialog.PrimaryButtonTextProperty, "Drucken"); + contentDialog.Tag = picturePathUri.AbsolutePath; + contentDialog.ButtonClicked += ContentDialog_OnButtonClicked; + + await contentDialog.ShowAsync(); + }); + } + + /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. public void Dispose() {