wip
This commit is contained in:
parent
e06aede5cd
commit
2ff3758596
@ -1,8 +1,11 @@
|
||||
using System.Configuration;
|
||||
using System.ComponentModel;
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.Windows;
|
||||
|
||||
using CamBooth.App.Core.AppSettings;
|
||||
using CamBooth.App.Core.Logging;
|
||||
using CamBooth.App.DebugConsole;
|
||||
using CamBooth.App.LiveView;
|
||||
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
@ -29,11 +32,12 @@ public partial class App : Application
|
||||
mainWindow.Show();
|
||||
}
|
||||
|
||||
|
||||
private void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
// Register your services and view models here
|
||||
services.AddTransient<MainWindow>();
|
||||
services.AddTransient<LiveViewPage>();
|
||||
services.AddSingleton<Logger>();
|
||||
services.AddSingleton<AppSettingsService>();
|
||||
}
|
||||
}
|
||||
@ -21,6 +21,8 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="9.0.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="9.0.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="9.0.1" />
|
||||
</ItemGroup>
|
||||
@ -29,4 +31,13 @@
|
||||
<Folder Include="Core\Models\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="Core\AppSettings\app.settings.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="Core\AppSettings\app.settings.dev.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@ -0,0 +1,30 @@
|
||||
namespace CamBooth.App.Core.AppSettings;
|
||||
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
public class AppSettingsService
|
||||
{
|
||||
IConfigurationRoot configuration;
|
||||
|
||||
public AppSettingsService()
|
||||
{
|
||||
this.Initialize();
|
||||
}
|
||||
|
||||
|
||||
private void Initialize()
|
||||
{
|
||||
var configFile = "Core/AppSettings/app.settings.json";
|
||||
#if DEBUG
|
||||
configFile = "Core/AppSettings/app.settings.dev.json";
|
||||
#endif
|
||||
configuration = new ConfigurationBuilder()
|
||||
.SetBasePath(AppContext.BaseDirectory)
|
||||
.AddJsonFile(configFile, optional: false, reloadOnChange: true)
|
||||
.Build();
|
||||
}
|
||||
|
||||
public string? AppName => configuration["AppSettings:AppName"];
|
||||
public string? PictureLocation => configuration["AppSettings:PictureLocation"];
|
||||
public string? ConnectionString => configuration.GetConnectionString("DefaultConnection");
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
{
|
||||
"AppSettings": {
|
||||
"AppName": "Meine Anwendung",
|
||||
"Version": "1.0.0",
|
||||
"PictureLocation": "C:\\tmp\\cambooth"
|
||||
},
|
||||
"ConnectionStrings": {
|
||||
"DefaultConnection": "Server=myServer;Database=myDB;User Id=myUser;Password=myPassword;"
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
{
|
||||
"AppSettings": {
|
||||
"AppName": "Meine Anwendung",
|
||||
"Version": "1.0.0"
|
||||
},
|
||||
"ConnectionStrings": {
|
||||
"DefaultConnection": "Server=myServer;Database=myDB;User Id=myUser;Password=myPassword;"
|
||||
}
|
||||
}
|
||||
@ -1,9 +1,21 @@
|
||||
namespace CamBooth.App.Core.Logging;
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
|
||||
namespace CamBooth.App.Core.Logging;
|
||||
|
||||
public class Logger
|
||||
{
|
||||
public void LogInfo(string message)
|
||||
public event LoggingEventHandler? InfoLog;
|
||||
public delegate void LoggingEventHandler(string text);
|
||||
|
||||
public void Info(string message)
|
||||
{
|
||||
Console.WriteLine(message);
|
||||
Application.Current.Dispatcher.Invoke(() =>
|
||||
{
|
||||
message = DateTime.Now.ToString("dd.MM.yyyy HH:MM:ss", CultureInfo.InvariantCulture) + ": " + message;
|
||||
InfoLog?.Invoke(message);
|
||||
Console.WriteLine(message);
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
@ -5,8 +5,11 @@
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:CamBooth.App.DebugConsole"
|
||||
mc:Ignorable="d"
|
||||
Title="DebugConsolePage" Height="100" Width="800">
|
||||
<Grid>
|
||||
Title="DebugConsolePage" Width="1600" Height="170" HorizontalAlignment="Stretch">
|
||||
<StackPanel>
|
||||
<TextBlock>Debug Console</TextBlock>
|
||||
</Grid>
|
||||
<ScrollViewer Height="160" VerticalScrollBarVisibility="Auto">
|
||||
<TextBox Name="tbDebugOutput" AcceptsReturn="True" Background="Gainsboro" TextWrapping="Wrap" />
|
||||
</ScrollViewer>
|
||||
</StackPanel>
|
||||
</Page>
|
||||
@ -1,11 +1,19 @@
|
||||
using System.Windows.Controls;
|
||||
|
||||
using CamBooth.App.Core.Logging;
|
||||
|
||||
namespace CamBooth.App.DebugConsole;
|
||||
|
||||
public partial class DebugConsolePage : Page
|
||||
{
|
||||
public DebugConsolePage()
|
||||
public DebugConsolePage(Logger logger)
|
||||
{
|
||||
logger.InfoLog += Logger_OnInfoLog;
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void Logger_OnInfoLog(string text)
|
||||
{
|
||||
this.tbDebugOutput.Text = this.tbDebugOutput.Text.Insert(0, text + "\n");
|
||||
}
|
||||
}
|
||||
@ -5,10 +5,9 @@
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:CamBooth.App.LiveView"
|
||||
mc:Ignorable="d"
|
||||
Title="LiveViewPage" Height="550" Width="780"
|
||||
Title="LiveViewPage" Width="1600" Height="800"
|
||||
Background="PaleVioletRed">
|
||||
<Grid>
|
||||
<TextBlock>LiveView CamBooth</TextBlock>
|
||||
<Canvas x:Name="LVCanvas" Background="LightGray" />
|
||||
<Grid HorizontalAlignment="Stretch" >
|
||||
<Canvas x:Name="LVCanvas" Background="Bisque" />
|
||||
</Grid>
|
||||
</Page>
|
||||
|
||||
@ -1,9 +1,14 @@
|
||||
using System.IO;
|
||||
using System.ComponentModel;
|
||||
using System.Configuration;
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
|
||||
using CamBooth.App.Core.AppSettings;
|
||||
using CamBooth.App.Core.Logging;
|
||||
|
||||
using EOSDigital.API;
|
||||
using EOSDigital.SDK;
|
||||
|
||||
@ -11,6 +16,10 @@ namespace CamBooth.App.LiveView;
|
||||
|
||||
public partial class LiveViewPage : Page
|
||||
{
|
||||
private readonly Logger _logger;
|
||||
|
||||
private readonly AppSettingsService _appSettings;
|
||||
|
||||
CanonAPI APIHandler;
|
||||
|
||||
Camera MainCamera;
|
||||
@ -36,19 +45,31 @@ public partial class LiveViewPage : Page
|
||||
object ErrLock = new object();
|
||||
|
||||
|
||||
public LiveViewPage()
|
||||
public LiveViewPage(Logger logger, AppSettingsService appSettings)
|
||||
{
|
||||
this._logger = logger;
|
||||
this._appSettings = appSettings;
|
||||
try
|
||||
{
|
||||
InitializeComponent();
|
||||
APIHandler = new CanonAPI();
|
||||
APIHandler.CameraAdded += APIHandler_CameraAdded;
|
||||
ErrorHandler.SevereErrorHappened += ErrorHandler_SevereErrorHappened;
|
||||
ErrorHandler.NonSevereErrorHappened += ErrorHandler_NonSevereErrorHappened;
|
||||
|
||||
//SavePathTextBox.Text = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures), "RemotePhoto");
|
||||
SetImageAction = (BitmapImage img) => { bgbrush.ImageSource = img; };
|
||||
RefreshCamera();
|
||||
IsInit = true;
|
||||
List<Camera> cameraList = this.APIHandler.GetCameraList();
|
||||
if (cameraList.Any())
|
||||
{
|
||||
this.OpenSession();
|
||||
this.StarLiveView();
|
||||
this.SetCameraSaveToComputer();
|
||||
}
|
||||
|
||||
string cameraDeviceNames = string.Join(", ", cameraList.Select(cam => cam.DeviceName));
|
||||
logger.Info(cameraDeviceNames == string.Empty ? "No cameras / devices found" : cameraDeviceNames);
|
||||
}
|
||||
catch (DllNotFoundException)
|
||||
{
|
||||
@ -60,86 +81,106 @@ public partial class LiveViewPage : Page
|
||||
}
|
||||
}
|
||||
|
||||
private void SetCameraSaveToComputer()
|
||||
{
|
||||
MainCamera.SetSetting(PropertyID.SaveTo, (int)SaveTo.Host);
|
||||
MainCamera.SetCapacity(4096, int.MaxValue);
|
||||
}
|
||||
|
||||
private void CloseSession()
|
||||
{
|
||||
MainCamera.CloseSession();
|
||||
// AvCoBox.Items.Clear();
|
||||
// TvCoBox.Items.Clear();
|
||||
// ISOCoBox.Items.Clear();
|
||||
// SettingsGroupBox.IsEnabled = false;
|
||||
// LiveViewGroupBox.IsEnabled = false;
|
||||
// SessionButton.Content = "Open Session";
|
||||
// SessionLabel.Content = "No open session";
|
||||
// StarLVButton.Content = "Start LV";
|
||||
}
|
||||
public void CloseSession()
|
||||
{
|
||||
MainCamera.CloseSession();
|
||||
|
||||
private void RefreshCamera()
|
||||
{
|
||||
// CameraListBox.Items.Clear();
|
||||
CamList = APIHandler.GetCameraList();
|
||||
// foreach (Camera cam in CamList) CameraListBox.Items.Add(cam.DeviceName);
|
||||
// if (MainCamera?.SessionOpen == true) CameraListBox.SelectedIndex = CamList.FindIndex(t => t.ID == MainCamera.ID);
|
||||
// else if (CamList.Count > 0) CameraListBox.SelectedIndex = 0;
|
||||
}
|
||||
|
||||
private void OpenSession()
|
||||
{
|
||||
|
||||
MainCamera = CamList[0];
|
||||
MainCamera.OpenSession();
|
||||
MainCamera.LiveViewUpdated += MainCamera_LiveViewUpdated;
|
||||
MainCamera.ProgressChanged += MainCamera_ProgressChanged;
|
||||
MainCamera.StateChanged += MainCamera_StateChanged;
|
||||
MainCamera.DownloadReady += MainCamera_DownloadReady;
|
||||
// AvCoBox.Items.Clear();
|
||||
// TvCoBox.Items.Clear();
|
||||
// ISOCoBox.Items.Clear();
|
||||
// SettingsGroupBox.IsEnabled = false;
|
||||
// LiveViewGroupBox.IsEnabled = false;
|
||||
// SessionButton.Content = "Open Session";
|
||||
// SessionLabel.Content = "No open session";
|
||||
// StarLVButton.Content = "Start LV";
|
||||
}
|
||||
|
||||
|
||||
//SessionLabel.Content = MainCamera.DeviceName;
|
||||
AvList = MainCamera.GetSettingsList(PropertyID.Av);
|
||||
TvList = MainCamera.GetSettingsList(PropertyID.Tv);
|
||||
ISOList = MainCamera.GetSettingsList(PropertyID.ISO);
|
||||
// foreach (var Av in AvList) AvCoBox.Items.Add(Av.StringValue);
|
||||
// foreach (var Tv in TvList) TvCoBox.Items.Add(Tv.StringValue);
|
||||
// foreach (var ISO in ISOList) ISOCoBox.Items.Add(ISO.StringValue);
|
||||
// AvCoBox.SelectedIndex = AvCoBox.Items.IndexOf(AvValues.GetValue(MainCamera.GetInt32Setting(PropertyID.Av)).StringValue);
|
||||
// TvCoBox.SelectedIndex = TvCoBox.Items.IndexOf(TvValues.GetValue(MainCamera.GetInt32Setting(PropertyID.Tv)).StringValue);
|
||||
// ISOCoBox.SelectedIndex = ISOCoBox.Items.IndexOf(ISOValues.GetValue(MainCamera.GetInt32Setting(PropertyID.ISO)).StringValue);
|
||||
// SettingsGroupBox.IsEnabled = true;
|
||||
// LiveViewGroupBox.IsEnabled = true;
|
||||
private void RefreshCamera()
|
||||
{
|
||||
// CameraListBox.Items.Clear();
|
||||
CamList = APIHandler.GetCameraList();
|
||||
|
||||
}
|
||||
// foreach (Camera cam in CamList) CameraListBox.Items.Add(cam.DeviceName);
|
||||
// if (MainCamera?.SessionOpen == true) CameraListBox.SelectedIndex = CamList.FindIndex(t => t.ID == MainCamera.ID);
|
||||
// else if (CamList.Count > 0) CameraListBox.SelectedIndex = 0;
|
||||
}
|
||||
|
||||
private void ReportError(string message, bool lockdown)
|
||||
{
|
||||
int errc;
|
||||
lock (ErrLock) { errc = ++ErrCount; }
|
||||
|
||||
if (lockdown) EnableUI(false);
|
||||
private void OpenSession()
|
||||
{
|
||||
MainCamera = CamList[0];
|
||||
MainCamera.OpenSession();
|
||||
MainCamera.LiveViewUpdated += MainCamera_LiveViewUpdated;
|
||||
//MainCamera.ProgressChanged += MainCamera_ProgressChanged;
|
||||
MainCamera.StateChanged += MainCamera_StateChanged;
|
||||
MainCamera.DownloadReady += MainCamera_DownloadReady;
|
||||
|
||||
if (errc < 4) MessageBox.Show(message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
else if (errc == 4) MessageBox.Show("Many errors happened!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
//SessionLabel.Content = MainCamera.DeviceName;
|
||||
AvList = MainCamera.GetSettingsList(PropertyID.Av);
|
||||
TvList = MainCamera.GetSettingsList(PropertyID.Tv);
|
||||
ISOList = MainCamera.GetSettingsList(PropertyID.ISO);
|
||||
|
||||
lock (ErrLock) { ErrCount--; }
|
||||
}
|
||||
// foreach (var Av in AvList) AvCoBox.Items.Add(Av.StringValue);
|
||||
// foreach (var Tv in TvList) TvCoBox.Items.Add(Tv.StringValue);
|
||||
// foreach (var ISO in ISOList) ISOCoBox.Items.Add(ISO.StringValue);
|
||||
// AvCoBox.SelectedIndex = AvCoBox.Items.IndexOf(AvValues.GetValue(MainCamera.GetInt32Setting(PropertyID.Av)).StringValue);
|
||||
// TvCoBox.SelectedIndex = TvCoBox.Items.IndexOf(TvValues.GetValue(MainCamera.GetInt32Setting(PropertyID.Tv)).StringValue);
|
||||
// ISOCoBox.SelectedIndex = ISOCoBox.Items.IndexOf(ISOValues.GetValue(MainCamera.GetInt32Setting(PropertyID.ISO)).StringValue);
|
||||
// SettingsGroupBox.IsEnabled = true;
|
||||
// LiveViewGroupBox.IsEnabled = true;
|
||||
}
|
||||
|
||||
private void EnableUI(bool enable)
|
||||
{
|
||||
if (!Dispatcher.CheckAccess()) Dispatcher.Invoke((Action)delegate { EnableUI(enable); });
|
||||
else
|
||||
{
|
||||
// SettingsGroupBox.IsEnabled = enable;
|
||||
// InitGroupBox.IsEnabled = enable;
|
||||
// LiveViewGroupBox.IsEnabled = enable;
|
||||
}
|
||||
}
|
||||
|
||||
#region API Events
|
||||
private void ReportError(string message, bool lockdown)
|
||||
{
|
||||
int errc;
|
||||
lock (ErrLock)
|
||||
{
|
||||
errc = ++ErrCount;
|
||||
}
|
||||
|
||||
private void APIHandler_CameraAdded(CanonAPI sender)
|
||||
if (lockdown)
|
||||
{
|
||||
//this.EnableUI(false);
|
||||
}
|
||||
|
||||
switch (errc)
|
||||
{
|
||||
case < 4:
|
||||
this._logger.Info(message);
|
||||
break;
|
||||
case 4:
|
||||
this._logger.Info("Many errors happened!");
|
||||
break;
|
||||
}
|
||||
|
||||
lock (ErrLock)
|
||||
{
|
||||
ErrCount--;
|
||||
}
|
||||
}
|
||||
|
||||
private void StarLiveView()
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
if (!MainCamera.IsLiveViewOn)
|
||||
{
|
||||
LVCanvas.Background = bgbrush;
|
||||
MainCamera.StartLiveView();
|
||||
}
|
||||
else
|
||||
{
|
||||
MainCamera.StopLiveView();
|
||||
LVCanvas.Background = Brushes.LightGray;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -147,6 +188,19 @@ public partial class LiveViewPage : Page
|
||||
}
|
||||
}
|
||||
|
||||
#region API Events
|
||||
|
||||
// private void APIHandler_CameraAdded(CanonAPI sender)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// ReportError(ex.Message, false);
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
private void MainCamera_StateChanged(Camera sender, StateEventID eventID, int parameter)
|
||||
{
|
||||
@ -164,17 +218,17 @@ public partial class LiveViewPage : Page
|
||||
}
|
||||
|
||||
|
||||
private void MainCamera_ProgressChanged(object sender, int progress)
|
||||
{
|
||||
try
|
||||
{
|
||||
//MainProgressBar.Dispatcher.Invoke((Action)delegate { MainProgressBar.Value = progress; });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ReportError(ex.Message, false);
|
||||
}
|
||||
}
|
||||
// private void MainCamera_ProgressChanged(object sender, int progress)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// //MainProgressBar.Dispatcher.Invoke((Action)delegate { MainProgressBar.Value = progress; });
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// ReportError(ex.Message, false);
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
private void MainCamera_LiveViewUpdated(Camera sender, Stream img)
|
||||
@ -202,11 +256,12 @@ public partial class LiveViewPage : Page
|
||||
|
||||
private void MainCamera_DownloadReady(Camera sender, DownloadInfo Info)
|
||||
{
|
||||
this._logger.Info("MainCamera_DownloadReady called");
|
||||
try
|
||||
{
|
||||
string dir = null;
|
||||
//SavePathTextBox.Dispatcher.Invoke((Action)delegate { dir = SavePathTextBox.Text; });
|
||||
string dir = this._appSettings.PictureLocation;
|
||||
sender.DownloadFile(Info, dir);
|
||||
this._logger.Info("Download complete: " + Path.Combine(dir, Info.FileName));
|
||||
//MainProgressBar.Dispatcher.Invoke((Action)delegate { MainProgressBar.Value = 0; });
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -215,7 +270,6 @@ public partial class LiveViewPage : Page
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void ErrorHandler_NonSevereErrorHappened(object sender, ErrorCode ex)
|
||||
{
|
||||
ReportError($"SDK Error code: {ex} ({((int)ex).ToString("X")})", false);
|
||||
@ -228,4 +282,25 @@ public partial class LiveViewPage : Page
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
public void TakePhoto()
|
||||
{
|
||||
try
|
||||
{
|
||||
MainCamera.TakePhotoAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ReportError(ex.Message, false);
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
this.CloseSession();
|
||||
IsInit = false;
|
||||
MainCamera?.Dispose();
|
||||
APIHandler?.Dispose();
|
||||
}
|
||||
}
|
||||
@ -5,18 +5,19 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:CamBooth.App"
|
||||
mc:Ignorable="d"
|
||||
Title="MainWindow" Height="650" Width="800">
|
||||
Title="MainWindow" Width="1600" Height="900" HorizontalAlignment="Stretch">
|
||||
<Grid>
|
||||
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/> <!-- Erste Zeile (Auto-Höhe) -->
|
||||
<RowDefinition Height="*"/> <!-- Zweite Zeile (flexibler Platz) -->
|
||||
<RowDefinition Height="*"/> <!-- Erste Zeile (Auto-Höhe) -->
|
||||
<RowDefinition Height="Auto"/> <!-- Zweite Zeile (flexibler Platz) -->
|
||||
<RowDefinition Height="Auto"/> <!-- Dritte Zeile (Auto-Höhe) -->
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- Inhalt der ersten Zeile -->
|
||||
<Frame Grid.Row="0"
|
||||
x:Name="MainFrame"
|
||||
Margin="5 5 5 0"
|
||||
NavigationUIVisibility="Hidden"
|
||||
HorizontalAlignment="Center"
|
||||
Background="LightBlue"
|
||||
@ -26,17 +27,18 @@
|
||||
<!-- Inhalt der zweiten Zeile (nimmt den verbleibenden Platz ein) -->
|
||||
<Frame Grid.Row="1"
|
||||
x:Name="DebugFrame"
|
||||
Margin="5"
|
||||
NavigationUIVisibility="Hidden"
|
||||
HorizontalAlignment="Center"
|
||||
Height="100"
|
||||
Background="LightGreen"
|
||||
VerticalAlignment="Bottom"
|
||||
Panel.ZIndex="1" />
|
||||
|
||||
<!-- Inhalt der dritten Zeile -->
|
||||
<StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
<StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0 0 5 5">
|
||||
<Button Content="Start" Click="NavToLiveView" Width="200" Background="LightCoral" Height="50" VerticalAlignment="Bottom"/>
|
||||
<Button Content="Hide Debug" Click="ToggleDebugConsole" Width="200" Background="LightCoral" Height="50" VerticalAlignment="Bottom"/>
|
||||
<Button Content="Take Photo" Click="TakePhoto" Width="200" Background="LightCoral" Height="50" VerticalAlignment="Bottom"/>
|
||||
</StackPanel>
|
||||
|
||||
</Grid>
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using System.ComponentModel;
|
||||
using System.Windows;
|
||||
|
||||
using CamBooth.App.Core.AppSettings;
|
||||
using CamBooth.App.Core.Logging;
|
||||
using CamBooth.App.DebugConsole;
|
||||
using CamBooth.App.LiveView;
|
||||
@ -15,19 +15,32 @@ public partial class MainWindow : Window
|
||||
{
|
||||
private readonly Logger _logger;
|
||||
|
||||
private readonly AppSettingsService _appSettings;
|
||||
|
||||
private bool _isDebugConsoleVisible;
|
||||
|
||||
public MainWindow(Logger logger)
|
||||
private LiveViewPage _liveViewPage;
|
||||
|
||||
public MainWindow(Logger logger, AppSettingsService appSettings)
|
||||
{
|
||||
this._logger = logger;
|
||||
this._appSettings = appSettings;
|
||||
InitializeComponent();
|
||||
logger.LogInfo("MainWindow initialized");
|
||||
ToggleDebugConsole();
|
||||
this.Closing += OnClosing;
|
||||
logger.Info("MainWindow initialized");
|
||||
}
|
||||
|
||||
private void OnClosing(object? sender, CancelEventArgs e)
|
||||
{
|
||||
this._liveViewPage.Dispose();
|
||||
}
|
||||
|
||||
|
||||
private void NavToLiveView(object sender, RoutedEventArgs e)
|
||||
{
|
||||
MainFrame.Navigate(new LiveViewPage());
|
||||
_liveViewPage = new LiveViewPage(this._logger, this._appSettings);
|
||||
MainFrame.Navigate(this._liveViewPage);
|
||||
}
|
||||
|
||||
private void ToggleDebugConsole(object sender, RoutedEventArgs e)
|
||||
@ -39,13 +52,18 @@ public partial class MainWindow : Window
|
||||
{
|
||||
if (_isDebugConsoleVisible)
|
||||
{
|
||||
this.DebugFrame.ClearValue(Frame.ContentProperty);
|
||||
this.DebugFrame.ClearValue(MainWindow.ContentProperty);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.DebugFrame.Navigate(new DebugConsolePage());
|
||||
this.DebugFrame.Navigate(new DebugConsolePage(this._logger));
|
||||
}
|
||||
|
||||
this._isDebugConsoleVisible = !this._isDebugConsoleVisible;
|
||||
}
|
||||
|
||||
private void TakePhoto(object sender, RoutedEventArgs e)
|
||||
{
|
||||
this._liveViewPage.TakePhoto();
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user