From 6a1b1a9f9bbb35a1185d9070344c33f580607256 Mon Sep 17 00:00:00 2001 From: Tobias Wohlleben Date: Mon, 20 Jan 2025 17:08:21 +0100 Subject: [PATCH] wip --- .../Core/GenericOverlayWindow.xaml | 14 +++++++ .../Core/GenericOverlayWindow.xaml.cs | 17 +++++++++ .../LiveView/LiveViewPage.xaml.cs | 22 +++-------- src/CamBooth/CamBooth.App/MainWindow.xaml | 15 +++++--- src/CamBooth/CamBooth.App/MainWindow.xaml.cs | 37 ++++++++++++------- 5 files changed, 70 insertions(+), 35 deletions(-) create mode 100644 src/CamBooth/CamBooth.App/Core/GenericOverlayWindow.xaml create mode 100644 src/CamBooth/CamBooth.App/Core/GenericOverlayWindow.xaml.cs diff --git a/src/CamBooth/CamBooth.App/Core/GenericOverlayWindow.xaml b/src/CamBooth/CamBooth.App/Core/GenericOverlayWindow.xaml new file mode 100644 index 0000000..5498f61 --- /dev/null +++ b/src/CamBooth/CamBooth.App/Core/GenericOverlayWindow.xaml @@ -0,0 +1,14 @@ + + + Hoppla + Sorry, da ging was schief! + + + diff --git a/src/CamBooth/CamBooth.App/Core/GenericOverlayWindow.xaml.cs b/src/CamBooth/CamBooth.App/Core/GenericOverlayWindow.xaml.cs new file mode 100644 index 0000000..4bad565 --- /dev/null +++ b/src/CamBooth/CamBooth.App/Core/GenericOverlayWindow.xaml.cs @@ -0,0 +1,17 @@ +using System.Windows; + +namespace CamBooth.App.Core; + +public partial class GenericOverlayWindow : Window +{ + public GenericOverlayWindow() + { + InitializeComponent(); + } + + + private void ButtonBase_OnClick(object sender, RoutedEventArgs e) + { + this.Close(); + } +} \ No newline at end of file diff --git a/src/CamBooth/CamBooth.App/LiveView/LiveViewPage.xaml.cs b/src/CamBooth/CamBooth.App/LiveView/LiveViewPage.xaml.cs index 75a9a99..c632022 100644 --- a/src/CamBooth/CamBooth.App/LiveView/LiveViewPage.xaml.cs +++ b/src/CamBooth/CamBooth.App/LiveView/LiveViewPage.xaml.cs @@ -22,11 +22,12 @@ public partial class LiveViewPage : Page private readonly AppSettingsService _appSettings; private readonly CameraService _cameraService; - + Action SetImageAction; - + private ImageBrush bgbrush = new ImageBrush(); - + + public LiveViewPage(Logger logger, AppSettingsService appSettings, CameraService cameraService) { this._logger = logger; @@ -61,20 +62,7 @@ public partial class LiveViewPage : Page _logger.Error(ex.Message); } } - - - public void TakePhoto() - { - try - { - this._cameraService.TakePhoto(); - } - catch (Exception e) - { - MessageBox.Show("Sorry, das hat leider nicht geklappt!"); - } - } - + public void Dispose() { diff --git a/src/CamBooth/CamBooth.App/MainWindow.xaml b/src/CamBooth/CamBooth.App/MainWindow.xaml index d1ee414..86e94e8 100644 --- a/src/CamBooth/CamBooth.App/MainWindow.xaml +++ b/src/CamBooth/CamBooth.App/MainWindow.xaml @@ -13,10 +13,10 @@ - - - - + + + + @@ -48,7 +48,12 @@ Background="Blue" VerticalAlignment="Bottom" Panel.ZIndex="1" /> - + + + + diff --git a/src/CamBooth/CamBooth.App/MainWindow.xaml.cs b/src/CamBooth/CamBooth.App/MainWindow.xaml.cs index 7d4b478..c534d30 100644 --- a/src/CamBooth/CamBooth.App/MainWindow.xaml.cs +++ b/src/CamBooth/CamBooth.App/MainWindow.xaml.cs @@ -2,6 +2,7 @@ using System.Windows; using System.Windows.Controls; +using CamBooth.App.Core; using CamBooth.App.Core.AppSettings; using CamBooth.App.Core.Camera; using CamBooth.App.Core.Logging; @@ -9,6 +10,10 @@ using CamBooth.App.DebugConsole; using CamBooth.App.LiveView; using CamBooth.App.PictureGallery; +using Wpf.Ui.Controls; + +using MessageBox = Wpf.Ui.Controls.MessageBox; + namespace CamBooth.App; /// @@ -42,23 +47,13 @@ public partial class MainWindow : Window this._cameraService = cameraService; InitializeComponent(); this.SetVisibilityDebugConsole(this._isDebugConsoleVisible); - this.LoadPicturePanelAsync(); this.SetVisibilityPicturePanel(this._isPicturePanelVisible); + _ = this._pictureGalleryService.LoadThumbnailsToCache(); + CreateMessageBox(); this.Closing += OnClosing; logger.Info("MainWindow initialized"); } - - private async void LoadPicturePanelAsync() - { - //this.PictureGalleryPage.Visibility = Visibility.Hidden; - //this.PictureGalleryPage.Navigate(new PictureGalleryPage(this._appSettings, this._logger)); - // this._pictureGalleryService.LoadThumbnailsToCache(); - await this._pictureGalleryService.LoadThumbnailsToCache(); - //this.DebugFrame.Navigate(new DebugConsolePage(this._logger)); - } - - private void SetVisibilityPicturePanel(bool visibility) { if (visibility) @@ -110,7 +105,23 @@ public partial class MainWindow : Window private void TakePhoto(object sender, RoutedEventArgs e) { - this._liveViewPage?.TakePhoto(); + try + { + this._cameraService.TakePhoto(); + } + catch (Exception exception) + { + this.CreateMessageBox(); + this._logger.Info(exception.Message); + } + } + + + private void CreateMessageBox() + { + // + // + // }