open image direct after photo taken
This commit is contained in:
parent
bd2e388fd0
commit
b1054d08b2
@ -1,4 +1,4 @@
|
||||
using System.Windows;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Media;
|
||||
@ -117,16 +117,9 @@ public partial class PictureGalleryPage : Page
|
||||
}
|
||||
|
||||
|
||||
private void Hyperlink_OnClick(object sender, RoutedEventArgs e)
|
||||
public async Task ShowPhotoDialogAsync(string picturePath)
|
||||
{
|
||||
Uri? picturePathUri = ((Hyperlink)sender).Tag as Uri;
|
||||
if (picturePathUri is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
string picturePath = Uri.UnescapeDataString(picturePathUri.AbsolutePath);
|
||||
Application.Current.Dispatcher.BeginInvoke(
|
||||
await Application.Current.Dispatcher.InvokeAsync(
|
||||
async () =>
|
||||
{
|
||||
this.CloseOpenDialog();
|
||||
@ -145,13 +138,10 @@ public partial class PictureGalleryPage : Page
|
||||
contentDialog.CloseButtonAppearance = ControlAppearance.Light;
|
||||
contentDialog.Background = new SolidColorBrush(Colors.White);
|
||||
contentDialog.Foreground = new SolidColorBrush(Colors.White);
|
||||
// contentDialog.SetCurrentValue(ContentDialog.TitleProperty, "Hello World");
|
||||
contentDialog.SetCurrentValue(ContentControl.ContentProperty, imageToShow);
|
||||
contentDialog.SetCurrentValue(ContentDialog.CloseButtonTextProperty, "Schließen");
|
||||
contentDialog.SetCurrentValue(ContentDialog.PrimaryButtonTextProperty, "Drucken");
|
||||
|
||||
// contentDialog.SetCurrentValue(ContentDialog.PrimaryButtonIconProperty, PictureGalleryService.CreateRegularSymbolIcon(SymbolRegular.Print48, Colors.Tomato));
|
||||
|
||||
contentDialog.Tag = picturePath;
|
||||
contentDialog.ButtonClicked += this.ContentDialog_OnButtonClicked;
|
||||
|
||||
@ -169,6 +159,18 @@ public partial class PictureGalleryPage : Page
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void Hyperlink_OnClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
Uri? picturePathUri = ((Hyperlink)sender).Tag as Uri;
|
||||
if (picturePathUri is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
string picturePath = Uri.UnescapeDataString(picturePathUri.AbsolutePath);
|
||||
_ = this.ShowPhotoDialogAsync(picturePath);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
@ -332,10 +332,58 @@ public partial class MainWindow : Window
|
||||
this.GalleryPrompt.Visibility = Visibility.Collapsed;
|
||||
}
|
||||
|
||||
private void OpenGalleryFromPrompt(object sender, RoutedEventArgs e)
|
||||
private async void OpenGalleryFromPrompt(object sender, RoutedEventArgs e)
|
||||
{
|
||||
this.HideGalleryPrompt();
|
||||
this.SetVisibilityPicturePanel(true);
|
||||
|
||||
// Wait a bit for the page to load before showing the dialog
|
||||
await Task.Delay(300);
|
||||
|
||||
// Show the latest photo in a dialog
|
||||
await this.ShowLatestPhotoDialogAsync();
|
||||
}
|
||||
|
||||
private async Task ShowLatestPhotoDialogAsync()
|
||||
{
|
||||
try
|
||||
{
|
||||
// Get the latest photo path
|
||||
await this._pictureGalleryService.LoadThumbnailsToCache(1);
|
||||
var latestPhotos = this._pictureGalleryService.ThumbnailsOrderedByNewestDescending;
|
||||
|
||||
if (latestPhotos.Count == 0)
|
||||
{
|
||||
this._logger.Error("No photos found in gallery");
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the file path from the BitmapImage source
|
||||
var latestPhoto = latestPhotos[0];
|
||||
if (latestPhoto.UriSource == null)
|
||||
{
|
||||
this._logger.Error("Latest photo UriSource is null");
|
||||
return;
|
||||
}
|
||||
|
||||
string photoPath = Uri.UnescapeDataString(latestPhoto.UriSource.AbsolutePath);
|
||||
this._logger.Info($"Opening photo dialog for: {photoPath}");
|
||||
|
||||
// Get the current gallery page
|
||||
if (this.PicturePanel.Content is PictureGalleryPage galleryPage)
|
||||
{
|
||||
// Show the photo dialog
|
||||
await galleryPage.ShowPhotoDialogAsync(photoPath);
|
||||
}
|
||||
else
|
||||
{
|
||||
this._logger.Error("PicturePanel content is not a PictureGalleryPage");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
this._logger.Error($"Error showing photo dialog: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
private void PictureGalleryService_NewPhotoCountChanged(object? sender, int newPhotoCount)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user