diff --git a/src/CamBooth/CamBooth.App/App.xaml b/src/CamBooth/CamBooth.App/App.xaml
index 7bb60b2..cfcaa33 100644
--- a/src/CamBooth/CamBooth.App/App.xaml
+++ b/src/CamBooth/CamBooth.App/App.xaml
@@ -1,8 +1,14 @@
-
+
+
+
+
+
+
diff --git a/src/CamBooth/CamBooth.App/App.xaml.cs b/src/CamBooth/CamBooth.App/App.xaml.cs
index 2e49d9d..c25cd24 100644
--- a/src/CamBooth/CamBooth.App/App.xaml.cs
+++ b/src/CamBooth/CamBooth.App/App.xaml.cs
@@ -7,6 +7,7 @@ using CamBooth.App.Core.AppSettings;
using CamBooth.App.Core.Logging;
using CamBooth.App.DebugConsole;
using CamBooth.App.LiveView;
+using CamBooth.App.PictureGallery;
using Microsoft.Extensions.DependencyInjection;
@@ -39,5 +40,6 @@ public partial class App : Application
services.AddTransient();
services.AddSingleton();
services.AddSingleton();
+ services.AddSingleton();
}
}
\ No newline at end of file
diff --git a/src/CamBooth/CamBooth.App/CamBooth.App.csproj b/src/CamBooth/CamBooth.App/CamBooth.App.csproj
index 664bf85..3d66261 100644
--- a/src/CamBooth/CamBooth.App/CamBooth.App.csproj
+++ b/src/CamBooth/CamBooth.App/CamBooth.App.csproj
@@ -25,6 +25,7 @@
+
diff --git a/src/CamBooth/CamBooth.App/LiveView/LiveViewPage.xaml.cs b/src/CamBooth/CamBooth.App/LiveView/LiveViewPage.xaml.cs
index 9f1bf13..6fcba1f 100644
--- a/src/CamBooth/CamBooth.App/LiveView/LiveViewPage.xaml.cs
+++ b/src/CamBooth/CamBooth.App/LiveView/LiveViewPage.xaml.cs
@@ -65,7 +65,7 @@ public partial class LiveViewPage : Page
{
this.OpenSession();
this.StarLiveView();
- this.SetCameraSaveToComputer();
+ this.SetSettingSaveToComputer();
}
string cameraDeviceNames = string.Join(", ", cameraList.Select(cam => cam.DeviceName));
@@ -81,7 +81,7 @@ public partial class LiveViewPage : Page
}
}
- private void SetCameraSaveToComputer()
+ private void SetSettingSaveToComputer()
{
MainCamera.SetSetting(PropertyID.SaveTo, (int)SaveTo.Host);
MainCamera.SetCapacity(4096, int.MaxValue);
diff --git a/src/CamBooth/CamBooth.App/MainWindow.xaml b/src/CamBooth/CamBooth.App/MainWindow.xaml
index 30b3815..d1ee414 100644
--- a/src/CamBooth/CamBooth.App/MainWindow.xaml
+++ b/src/CamBooth/CamBooth.App/MainWindow.xaml
@@ -3,43 +3,64 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
xmlns:local="clr-namespace:CamBooth.App"
mc:Ignorable="d"
- Title="MainWindow" Width="1600" Height="900" HorizontalAlignment="Stretch">
+ Title="MainWindow"
+ Background="Black"
+ Width="1600" Height="900"
+ HorizontalAlignment="Stretch">
-
+
-
-
-
+
+
+
+
-
-
+
+
+
-
-
-
-
+
+
+
+
+
-
+
-
+
\ No newline at end of file
diff --git a/src/CamBooth/CamBooth.App/MainWindow.xaml.cs b/src/CamBooth/CamBooth.App/MainWindow.xaml.cs
index 07ff82f..72dae0a 100644
--- a/src/CamBooth/CamBooth.App/MainWindow.xaml.cs
+++ b/src/CamBooth/CamBooth.App/MainWindow.xaml.cs
@@ -1,10 +1,12 @@
using System.ComponentModel;
using System.Windows;
+using System.Windows.Controls;
using CamBooth.App.Core.AppSettings;
using CamBooth.App.Core.Logging;
using CamBooth.App.DebugConsole;
using CamBooth.App.LiveView;
+using CamBooth.App.PictureGallery;
namespace CamBooth.App;
@@ -17,23 +19,56 @@ public partial class MainWindow : Window
private readonly AppSettingsService _appSettings;
- private bool _isDebugConsoleVisible;
+ private readonly PictureGalleryService _pictureGalleryService;
- private LiveViewPage _liveViewPage;
+ private bool _isDebugConsoleVisible = true;
- public MainWindow(Logger logger, AppSettingsService appSettings)
+ private bool _isPicturePanelVisible = false;
+
+ private LiveViewPage? _liveViewPage;
+
+
+ public MainWindow(Logger logger, AppSettingsService appSettings, PictureGalleryService pictureGalleryService)
{
this._logger = logger;
this._appSettings = appSettings;
+ this._pictureGalleryService = pictureGalleryService;
InitializeComponent();
- ToggleDebugConsole();
+ this.SetVisibilityDebugConsole(this._isDebugConsoleVisible);
+ this.LoadPicturePanelAsync();
+ this.SetVisibilityPicturePanel(this._isPicturePanelVisible);
this.Closing += OnClosing;
logger.Info("MainWindow initialized");
}
+
+ private void LoadPicturePanelAsync()
+ {
+ //this.PicturePanel.Visibility = Visibility.Hidden;
+ //this.PicturePanel.Navigate(new PicturePanel(this._appSettings, this._logger));
+ Task.Run(() => this._pictureGalleryService.LoadThumbnailsToCache(12));
+ //this.DebugFrame.Navigate(new DebugConsolePage(this._logger));
+ }
+
+
+ private void SetVisibilityPicturePanel(bool visibility)
+ {
+ if (visibility)
+ {
+ this.PicturePanel.Navigate(new PicturePanel(this._appSettings, this._logger, this._pictureGalleryService));
+ }
+ else
+ {
+ this.PicturePanel.ClearValue(MainWindow.ContentProperty);
+ }
+
+ this._isPicturePanelVisible = !visibility;
+ }
+
+
private void OnClosing(object? sender, CancelEventArgs e)
{
- this._liveViewPage.Dispose();
+ this._liveViewPage?.Dispose();
}
@@ -43,27 +78,36 @@ public partial class MainWindow : Window
MainFrame.Navigate(this._liveViewPage);
}
- private void ToggleDebugConsole(object sender, RoutedEventArgs e)
+
+ private void SetVisibilityDebugConsole(object sender, RoutedEventArgs e)
{
- this.ToggleDebugConsole();
+ this.SetVisibilityDebugConsole(this._isDebugConsoleVisible);
}
-
- private void ToggleDebugConsole()
+
+
+ private void SetVisibilityDebugConsole(bool visibility)
{
- if (_isDebugConsoleVisible)
- {
- this.DebugFrame.ClearValue(MainWindow.ContentProperty);
- }
- else
+ if (visibility)
{
this.DebugFrame.Navigate(new DebugConsolePage(this._logger));
}
+ else
+ {
+ this.DebugFrame.ClearValue(MainWindow.ContentProperty);
+ }
- this._isDebugConsoleVisible = !this._isDebugConsoleVisible;
+ this._isDebugConsoleVisible = !visibility;
}
+
private void TakePhoto(object sender, RoutedEventArgs e)
{
- this._liveViewPage.TakePhoto();
+ this._liveViewPage?.TakePhoto();
+ }
+
+
+ private void SetVisibilityPicturePanel(object sender, RoutedEventArgs e)
+ {
+ this.SetVisibilityPicturePanel(this._isPicturePanelVisible);
}
}
\ No newline at end of file
diff --git a/src/CamBooth/CamBooth.App/PictureGallery/PictureGalleryService.cs b/src/CamBooth/CamBooth.App/PictureGallery/PictureGalleryService.cs
new file mode 100644
index 0000000..503640c
--- /dev/null
+++ b/src/CamBooth/CamBooth.App/PictureGallery/PictureGalleryService.cs
@@ -0,0 +1,78 @@
+using System.IO;
+using System.Windows;
+using System.Windows.Media.Imaging;
+
+using CamBooth.App.Core.AppSettings;
+using CamBooth.App.Core.Logging;
+
+using Wpf.Ui.Controls;
+
+namespace CamBooth.App.PictureGallery;
+
+public class PictureGalleryService
+{
+ private readonly AppSettingsService _appSettings;
+
+ private readonly Logger _logger;
+
+ public List ImageControls
+ {
+ get
+ {
+ List tmp = new List();
+ foreach (var image in imageControls)
+ {
+ tmp.Add(image);
+ }
+ return tmp;
+ }
+ }
+
+ public List imageControls = new List();
+
+
+ public PictureGalleryService(AppSettingsService appSettings, Logger logger)
+ {
+ this._appSettings = appSettings;
+ this._logger = logger;
+ }
+
+
+ public void LoadThumbnailsToCache(int howManyPictures)
+ {
+ string? pictureLocation = this._appSettings.PictureLocation;
+ int loop = 0;
+ var picturePaths = Directory.EnumerateFiles(pictureLocation).ToList();
+ do
+ {
+ string picturePath = picturePaths[loop];
+ this._logger.Info("load image: " + picturePath);
+
+ var imageControl = new Wpf.Ui.Controls.Image()
+ {
+ Source = CreateThumbnail(picturePath, 244, 200),
+ Width = 386, // Optional: Setze Breite
+ Margin = new Thickness(3) // Optional: Abstand zwischen Bildern
+ };
+
+
+ // Füge das Image-Control in ein StackPanel ein
+ this.imageControls.Add(imageControl);
+
+ loop++;
+ }
+ while (loop < howManyPictures && loop < picturePaths.Count);
+ }
+
+ public static BitmapImage CreateThumbnail(string filePath, int maxWidth, int maxHeight)
+ {
+ var bitmap = new BitmapImage();
+ bitmap.BeginInit();
+ bitmap.UriSource = new Uri(filePath);
+ bitmap.DecodePixelWidth = maxWidth; // Größe des Thumbnails direkt beim Dekodieren festlegen
+ // bitmap.DecodePixelHeight = maxHeight;
+ bitmap.CacheOption = BitmapCacheOption.OnLoad;
+ bitmap.EndInit();
+ return bitmap;
+ }
+}
\ No newline at end of file
diff --git a/src/CamBooth/CamBooth.App/PictureGallery/PicturePanel.xaml b/src/CamBooth/CamBooth.App/PictureGallery/PicturePanel.xaml
new file mode 100644
index 0000000..f86a4dc
--- /dev/null
+++ b/src/CamBooth/CamBooth.App/PictureGallery/PicturePanel.xaml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
diff --git a/src/CamBooth/CamBooth.App/PictureGallery/PicturePanel.xaml.cs b/src/CamBooth/CamBooth.App/PictureGallery/PicturePanel.xaml.cs
new file mode 100644
index 0000000..b44a907
--- /dev/null
+++ b/src/CamBooth/CamBooth.App/PictureGallery/PicturePanel.xaml.cs
@@ -0,0 +1,52 @@
+using System.IO;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Media.Imaging;
+
+using CamBooth.App.Core.AppSettings;
+using CamBooth.App.Core.Logging;
+
+using Image = Wpf.Ui.Controls.Image;
+
+namespace CamBooth.App.PictureGallery;
+
+public partial class PicturePanel : Page
+{
+ private readonly AppSettingsService _appSettingsService;
+
+ private readonly Logger _logger;
+
+ private readonly PictureGalleryService _pictureGalleryService;
+
+
+ public PicturePanel(AppSettingsService appSettingsService, Logger logger, PictureGalleryService pictureGalleryService)
+ {
+ this._appSettingsService = appSettingsService;
+ this._logger = logger;
+ this._pictureGalleryService = pictureGalleryService;
+ InitializeComponent();
+ this.Initialize();
+ }
+
+
+ private void Initialize()
+ {
+ try
+ {
+ LoadPictures(12);
+ }
+ catch (Exception e)
+ {
+ this._logger.Info(e.Message);
+ }
+ }
+
+
+ private void LoadPictures(int howManyPictures)
+ {
+ foreach (Image ctl in this._pictureGalleryService.ImageControls)
+ {
+ this.PicturesPanel.Children.Add(ctl);
+ }
+ }
+}
\ No newline at end of file