121 lines
2.9 KiB
C#
121 lines
2.9 KiB
C#
using System.ComponentModel;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
|
|
using CamBooth.App.Core.AppSettings;
|
|
using CamBooth.App.Core.Camera;
|
|
using CamBooth.App.Core.Logging;
|
|
using CamBooth.App.DebugConsole;
|
|
using CamBooth.App.LiveView;
|
|
using CamBooth.App.PictureGallery;
|
|
|
|
namespace CamBooth.App;
|
|
|
|
/// <summary>
|
|
/// Interaction logic for MainWindow.xaml
|
|
/// </summary>
|
|
public partial class MainWindow : Window
|
|
{
|
|
private readonly Logger _logger;
|
|
|
|
private readonly AppSettingsService _appSettings;
|
|
|
|
private readonly PictureGalleryService _pictureGalleryService;
|
|
|
|
private readonly CameraService _cameraService;
|
|
|
|
private bool _isDebugConsoleVisible = true;
|
|
|
|
private bool _isPicturePanelVisible = false;
|
|
|
|
private LiveViewPage? _liveViewPage;
|
|
|
|
|
|
public MainWindow(Logger logger,
|
|
AppSettingsService appSettings,
|
|
PictureGalleryService pictureGalleryService,
|
|
CameraService cameraService)
|
|
{
|
|
this._logger = logger;
|
|
this._appSettings = appSettings;
|
|
this._pictureGalleryService = pictureGalleryService;
|
|
this._cameraService = cameraService;
|
|
InitializeComponent();
|
|
this.SetVisibilityDebugConsole(this._isDebugConsoleVisible);
|
|
this.LoadPicturePanelAsync();
|
|
this.SetVisibilityPicturePanel(this._isPicturePanelVisible);
|
|
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)
|
|
{
|
|
this.PicturePanel.Navigate(new PictureGalleryPage(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();
|
|
}
|
|
|
|
|
|
private void NavToLiveView(object sender, RoutedEventArgs e)
|
|
{
|
|
_liveViewPage = new LiveViewPage(this._logger, this._appSettings, this._cameraService);
|
|
MainFrame.Navigate(this._liveViewPage);
|
|
}
|
|
|
|
|
|
private void SetVisibilityDebugConsole(object sender, RoutedEventArgs e)
|
|
{
|
|
this.SetVisibilityDebugConsole(this._isDebugConsoleVisible);
|
|
}
|
|
|
|
|
|
private void SetVisibilityDebugConsole(bool visibility)
|
|
{
|
|
if (visibility)
|
|
{
|
|
this.DebugFrame.Navigate(new DebugConsolePage(this._logger));
|
|
}
|
|
else
|
|
{
|
|
this.DebugFrame.ClearValue(MainWindow.ContentProperty);
|
|
}
|
|
|
|
this._isDebugConsoleVisible = !visibility;
|
|
}
|
|
|
|
|
|
private void TakePhoto(object sender, RoutedEventArgs e)
|
|
{
|
|
this._liveViewPage?.TakePhoto();
|
|
}
|
|
|
|
|
|
private void SetVisibilityPicturePanel(object sender, RoutedEventArgs e)
|
|
{
|
|
this.SetVisibilityPicturePanel(this._isPicturePanelVisible);
|
|
}
|
|
} |