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.Data;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
|
||||||
|
using CamBooth.App.Core.AppSettings;
|
||||||
using CamBooth.App.Core.Logging;
|
using CamBooth.App.Core.Logging;
|
||||||
|
using CamBooth.App.DebugConsole;
|
||||||
using CamBooth.App.LiveView;
|
using CamBooth.App.LiveView;
|
||||||
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
@ -29,11 +32,12 @@ public partial class App : Application
|
|||||||
mainWindow.Show();
|
mainWindow.Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void ConfigureServices(IServiceCollection services)
|
private void ConfigureServices(IServiceCollection services)
|
||||||
{
|
{
|
||||||
// Register your services and view models here
|
// Register your services and view models here
|
||||||
services.AddTransient<MainWindow>();
|
services.AddTransient<MainWindow>();
|
||||||
services.AddTransient<LiveViewPage>();
|
|
||||||
services.AddSingleton<Logger>();
|
services.AddSingleton<Logger>();
|
||||||
|
services.AddSingleton<AppSettingsService>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -21,6 +21,8 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<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.DependencyInjection.Abstractions" Version="9.0.1" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="9.0.1" />
|
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="9.0.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
@ -29,4 +31,13 @@
|
|||||||
<Folder Include="Core\Models\" />
|
<Folder Include="Core\Models\" />
|
||||||
</ItemGroup>
|
</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>
|
</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 class Logger
|
||||||
{
|
{
|
||||||
public void LogInfo(string message)
|
public event LoggingEventHandler? InfoLog;
|
||||||
|
public delegate void LoggingEventHandler(string text);
|
||||||
|
|
||||||
|
public void Info(string message)
|
||||||
{
|
{
|
||||||
|
Application.Current.Dispatcher.Invoke(() =>
|
||||||
|
{
|
||||||
|
message = DateTime.Now.ToString("dd.MM.yyyy HH:MM:ss", CultureInfo.InvariantCulture) + ": " + message;
|
||||||
|
InfoLog?.Invoke(message);
|
||||||
Console.WriteLine(message);
|
Console.WriteLine(message);
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -5,8 +5,11 @@
|
|||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:local="clr-namespace:CamBooth.App.DebugConsole"
|
xmlns:local="clr-namespace:CamBooth.App.DebugConsole"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
Title="DebugConsolePage" Height="100" Width="800">
|
Title="DebugConsolePage" Width="1600" Height="170" HorizontalAlignment="Stretch">
|
||||||
<Grid>
|
<StackPanel>
|
||||||
<TextBlock>Debug Console</TextBlock>
|
<TextBlock>Debug Console</TextBlock>
|
||||||
</Grid>
|
<ScrollViewer Height="160" VerticalScrollBarVisibility="Auto">
|
||||||
|
<TextBox Name="tbDebugOutput" AcceptsReturn="True" Background="Gainsboro" TextWrapping="Wrap" />
|
||||||
|
</ScrollViewer>
|
||||||
|
</StackPanel>
|
||||||
</Page>
|
</Page>
|
||||||
@ -1,11 +1,19 @@
|
|||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
|
|
||||||
|
using CamBooth.App.Core.Logging;
|
||||||
|
|
||||||
namespace CamBooth.App.DebugConsole;
|
namespace CamBooth.App.DebugConsole;
|
||||||
|
|
||||||
public partial class DebugConsolePage : Page
|
public partial class DebugConsolePage : Page
|
||||||
{
|
{
|
||||||
public DebugConsolePage()
|
public DebugConsolePage(Logger logger)
|
||||||
{
|
{
|
||||||
|
logger.InfoLog += Logger_OnInfoLog;
|
||||||
InitializeComponent();
|
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:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:local="clr-namespace:CamBooth.App.LiveView"
|
xmlns:local="clr-namespace:CamBooth.App.LiveView"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
Title="LiveViewPage" Height="550" Width="780"
|
Title="LiveViewPage" Width="1600" Height="800"
|
||||||
Background="PaleVioletRed">
|
Background="PaleVioletRed">
|
||||||
<Grid>
|
<Grid HorizontalAlignment="Stretch" >
|
||||||
<TextBlock>LiveView CamBooth</TextBlock>
|
<Canvas x:Name="LVCanvas" Background="Bisque" />
|
||||||
<Canvas x:Name="LVCanvas" Background="LightGray" />
|
|
||||||
</Grid>
|
</Grid>
|
||||||
</Page>
|
</Page>
|
||||||
|
|||||||
@ -1,9 +1,14 @@
|
|||||||
using System.IO;
|
using System.ComponentModel;
|
||||||
|
using System.Configuration;
|
||||||
|
using System.IO;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
|
|
||||||
|
using CamBooth.App.Core.AppSettings;
|
||||||
|
using CamBooth.App.Core.Logging;
|
||||||
|
|
||||||
using EOSDigital.API;
|
using EOSDigital.API;
|
||||||
using EOSDigital.SDK;
|
using EOSDigital.SDK;
|
||||||
|
|
||||||
@ -11,6 +16,10 @@ namespace CamBooth.App.LiveView;
|
|||||||
|
|
||||||
public partial class LiveViewPage : Page
|
public partial class LiveViewPage : Page
|
||||||
{
|
{
|
||||||
|
private readonly Logger _logger;
|
||||||
|
|
||||||
|
private readonly AppSettingsService _appSettings;
|
||||||
|
|
||||||
CanonAPI APIHandler;
|
CanonAPI APIHandler;
|
||||||
|
|
||||||
Camera MainCamera;
|
Camera MainCamera;
|
||||||
@ -36,19 +45,31 @@ public partial class LiveViewPage : Page
|
|||||||
object ErrLock = new object();
|
object ErrLock = new object();
|
||||||
|
|
||||||
|
|
||||||
public LiveViewPage()
|
public LiveViewPage(Logger logger, AppSettingsService appSettings)
|
||||||
{
|
{
|
||||||
|
this._logger = logger;
|
||||||
|
this._appSettings = appSettings;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
APIHandler = new CanonAPI();
|
APIHandler = new CanonAPI();
|
||||||
APIHandler.CameraAdded += APIHandler_CameraAdded;
|
|
||||||
ErrorHandler.SevereErrorHappened += ErrorHandler_SevereErrorHappened;
|
ErrorHandler.SevereErrorHappened += ErrorHandler_SevereErrorHappened;
|
||||||
ErrorHandler.NonSevereErrorHappened += ErrorHandler_NonSevereErrorHappened;
|
ErrorHandler.NonSevereErrorHappened += ErrorHandler_NonSevereErrorHappened;
|
||||||
|
|
||||||
//SavePathTextBox.Text = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures), "RemotePhoto");
|
//SavePathTextBox.Text = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures), "RemotePhoto");
|
||||||
SetImageAction = (BitmapImage img) => { bgbrush.ImageSource = img; };
|
SetImageAction = (BitmapImage img) => { bgbrush.ImageSource = img; };
|
||||||
RefreshCamera();
|
RefreshCamera();
|
||||||
IsInit = true;
|
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)
|
catch (DllNotFoundException)
|
||||||
{
|
{
|
||||||
@ -60,10 +81,16 @@ public partial class LiveViewPage : Page
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SetCameraSaveToComputer()
|
||||||
|
{
|
||||||
|
MainCamera.SetSetting(PropertyID.SaveTo, (int)SaveTo.Host);
|
||||||
|
MainCamera.SetCapacity(4096, int.MaxValue);
|
||||||
|
}
|
||||||
|
|
||||||
private void CloseSession()
|
public void CloseSession()
|
||||||
{
|
{
|
||||||
MainCamera.CloseSession();
|
MainCamera.CloseSession();
|
||||||
|
|
||||||
// AvCoBox.Items.Clear();
|
// AvCoBox.Items.Clear();
|
||||||
// TvCoBox.Items.Clear();
|
// TvCoBox.Items.Clear();
|
||||||
// ISOCoBox.Items.Clear();
|
// ISOCoBox.Items.Clear();
|
||||||
@ -74,30 +101,32 @@ public partial class LiveViewPage : Page
|
|||||||
// StarLVButton.Content = "Start LV";
|
// StarLVButton.Content = "Start LV";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void RefreshCamera()
|
private void RefreshCamera()
|
||||||
{
|
{
|
||||||
// CameraListBox.Items.Clear();
|
// CameraListBox.Items.Clear();
|
||||||
CamList = APIHandler.GetCameraList();
|
CamList = APIHandler.GetCameraList();
|
||||||
|
|
||||||
// foreach (Camera cam in CamList) CameraListBox.Items.Add(cam.DeviceName);
|
// foreach (Camera cam in CamList) CameraListBox.Items.Add(cam.DeviceName);
|
||||||
// if (MainCamera?.SessionOpen == true) CameraListBox.SelectedIndex = CamList.FindIndex(t => t.ID == MainCamera.ID);
|
// if (MainCamera?.SessionOpen == true) CameraListBox.SelectedIndex = CamList.FindIndex(t => t.ID == MainCamera.ID);
|
||||||
// else if (CamList.Count > 0) CameraListBox.SelectedIndex = 0;
|
// else if (CamList.Count > 0) CameraListBox.SelectedIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void OpenSession()
|
private void OpenSession()
|
||||||
{
|
{
|
||||||
|
|
||||||
MainCamera = CamList[0];
|
MainCamera = CamList[0];
|
||||||
MainCamera.OpenSession();
|
MainCamera.OpenSession();
|
||||||
MainCamera.LiveViewUpdated += MainCamera_LiveViewUpdated;
|
MainCamera.LiveViewUpdated += MainCamera_LiveViewUpdated;
|
||||||
MainCamera.ProgressChanged += MainCamera_ProgressChanged;
|
//MainCamera.ProgressChanged += MainCamera_ProgressChanged;
|
||||||
MainCamera.StateChanged += MainCamera_StateChanged;
|
MainCamera.StateChanged += MainCamera_StateChanged;
|
||||||
MainCamera.DownloadReady += MainCamera_DownloadReady;
|
MainCamera.DownloadReady += MainCamera_DownloadReady;
|
||||||
|
|
||||||
|
|
||||||
//SessionLabel.Content = MainCamera.DeviceName;
|
//SessionLabel.Content = MainCamera.DeviceName;
|
||||||
AvList = MainCamera.GetSettingsList(PropertyID.Av);
|
AvList = MainCamera.GetSettingsList(PropertyID.Av);
|
||||||
TvList = MainCamera.GetSettingsList(PropertyID.Tv);
|
TvList = MainCamera.GetSettingsList(PropertyID.Tv);
|
||||||
ISOList = MainCamera.GetSettingsList(PropertyID.ISO);
|
ISOList = MainCamera.GetSettingsList(PropertyID.ISO);
|
||||||
|
|
||||||
// foreach (var Av in AvList) AvCoBox.Items.Add(Av.StringValue);
|
// foreach (var Av in AvList) AvCoBox.Items.Add(Av.StringValue);
|
||||||
// foreach (var Tv in TvList) TvCoBox.Items.Add(Tv.StringValue);
|
// foreach (var Tv in TvList) TvCoBox.Items.Add(Tv.StringValue);
|
||||||
// foreach (var ISO in ISOList) ISOCoBox.Items.Add(ISO.StringValue);
|
// foreach (var ISO in ISOList) ISOCoBox.Items.Add(ISO.StringValue);
|
||||||
@ -106,40 +135,52 @@ public partial class LiveViewPage : Page
|
|||||||
// ISOCoBox.SelectedIndex = ISOCoBox.Items.IndexOf(ISOValues.GetValue(MainCamera.GetInt32Setting(PropertyID.ISO)).StringValue);
|
// ISOCoBox.SelectedIndex = ISOCoBox.Items.IndexOf(ISOValues.GetValue(MainCamera.GetInt32Setting(PropertyID.ISO)).StringValue);
|
||||||
// SettingsGroupBox.IsEnabled = true;
|
// SettingsGroupBox.IsEnabled = true;
|
||||||
// LiveViewGroupBox.IsEnabled = true;
|
// LiveViewGroupBox.IsEnabled = true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void ReportError(string message, bool lockdown)
|
private void ReportError(string message, bool lockdown)
|
||||||
{
|
{
|
||||||
int errc;
|
int errc;
|
||||||
lock (ErrLock) { errc = ++ErrCount; }
|
lock (ErrLock)
|
||||||
|
|
||||||
if (lockdown) EnableUI(false);
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
lock (ErrLock) { ErrCount--; }
|
|
||||||
}
|
|
||||||
|
|
||||||
private void EnableUI(bool enable)
|
|
||||||
{
|
{
|
||||||
if (!Dispatcher.CheckAccess()) Dispatcher.Invoke((Action)delegate { EnableUI(enable); });
|
errc = ++ErrCount;
|
||||||
else
|
}
|
||||||
|
|
||||||
|
if (lockdown)
|
||||||
{
|
{
|
||||||
// SettingsGroupBox.IsEnabled = enable;
|
//this.EnableUI(false);
|
||||||
// InitGroupBox.IsEnabled = enable;
|
}
|
||||||
// LiveViewGroupBox.IsEnabled = enable;
|
|
||||||
|
switch (errc)
|
||||||
|
{
|
||||||
|
case < 4:
|
||||||
|
this._logger.Info(message);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
this._logger.Info("Many errors happened!");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
lock (ErrLock)
|
||||||
|
{
|
||||||
|
ErrCount--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#region API Events
|
private void StarLiveView()
|
||||||
|
|
||||||
private void APIHandler_CameraAdded(CanonAPI sender)
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
if (!MainCamera.IsLiveViewOn)
|
||||||
|
{
|
||||||
|
LVCanvas.Background = bgbrush;
|
||||||
|
MainCamera.StartLiveView();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MainCamera.StopLiveView();
|
||||||
|
LVCanvas.Background = Brushes.LightGray;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
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)
|
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)
|
// private void MainCamera_ProgressChanged(object sender, int progress)
|
||||||
{
|
// {
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
//MainProgressBar.Dispatcher.Invoke((Action)delegate { MainProgressBar.Value = progress; });
|
// //MainProgressBar.Dispatcher.Invoke((Action)delegate { MainProgressBar.Value = progress; });
|
||||||
}
|
// }
|
||||||
catch (Exception ex)
|
// catch (Exception ex)
|
||||||
{
|
// {
|
||||||
ReportError(ex.Message, false);
|
// ReportError(ex.Message, false);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
private void MainCamera_LiveViewUpdated(Camera sender, Stream img)
|
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)
|
private void MainCamera_DownloadReady(Camera sender, DownloadInfo Info)
|
||||||
{
|
{
|
||||||
|
this._logger.Info("MainCamera_DownloadReady called");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string dir = null;
|
string dir = this._appSettings.PictureLocation;
|
||||||
//SavePathTextBox.Dispatcher.Invoke((Action)delegate { dir = SavePathTextBox.Text; });
|
|
||||||
sender.DownloadFile(Info, dir);
|
sender.DownloadFile(Info, dir);
|
||||||
|
this._logger.Info("Download complete: " + Path.Combine(dir, Info.FileName));
|
||||||
//MainProgressBar.Dispatcher.Invoke((Action)delegate { MainProgressBar.Value = 0; });
|
//MainProgressBar.Dispatcher.Invoke((Action)delegate { MainProgressBar.Value = 0; });
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -215,7 +270,6 @@ public partial class LiveViewPage : Page
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void ErrorHandler_NonSevereErrorHappened(object sender, ErrorCode ex)
|
private void ErrorHandler_NonSevereErrorHappened(object sender, ErrorCode ex)
|
||||||
{
|
{
|
||||||
ReportError($"SDK Error code: {ex} ({((int)ex).ToString("X")})", false);
|
ReportError($"SDK Error code: {ex} ({((int)ex).ToString("X")})", false);
|
||||||
@ -228,4 +282,25 @@ public partial class LiveViewPage : Page
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:local="clr-namespace:CamBooth.App"
|
xmlns:local="clr-namespace:CamBooth.App"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
Title="MainWindow" Height="650" Width="800">
|
Title="MainWindow" Width="1600" Height="900" HorizontalAlignment="Stretch">
|
||||||
<Grid>
|
<Grid>
|
||||||
|
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="Auto"/> <!-- Erste Zeile (Auto-Höhe) -->
|
<RowDefinition Height="*"/> <!-- Erste Zeile (Auto-Höhe) -->
|
||||||
<RowDefinition Height="*"/> <!-- Zweite Zeile (flexibler Platz) -->
|
<RowDefinition Height="Auto"/> <!-- Zweite Zeile (flexibler Platz) -->
|
||||||
<RowDefinition Height="Auto"/> <!-- Dritte Zeile (Auto-Höhe) -->
|
<RowDefinition Height="Auto"/> <!-- Dritte Zeile (Auto-Höhe) -->
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
<!-- Inhalt der ersten Zeile -->
|
<!-- Inhalt der ersten Zeile -->
|
||||||
<Frame Grid.Row="0"
|
<Frame Grid.Row="0"
|
||||||
x:Name="MainFrame"
|
x:Name="MainFrame"
|
||||||
|
Margin="5 5 5 0"
|
||||||
NavigationUIVisibility="Hidden"
|
NavigationUIVisibility="Hidden"
|
||||||
HorizontalAlignment="Center"
|
HorizontalAlignment="Center"
|
||||||
Background="LightBlue"
|
Background="LightBlue"
|
||||||
@ -26,17 +27,18 @@
|
|||||||
<!-- Inhalt der zweiten Zeile (nimmt den verbleibenden Platz ein) -->
|
<!-- Inhalt der zweiten Zeile (nimmt den verbleibenden Platz ein) -->
|
||||||
<Frame Grid.Row="1"
|
<Frame Grid.Row="1"
|
||||||
x:Name="DebugFrame"
|
x:Name="DebugFrame"
|
||||||
|
Margin="5"
|
||||||
NavigationUIVisibility="Hidden"
|
NavigationUIVisibility="Hidden"
|
||||||
HorizontalAlignment="Center"
|
HorizontalAlignment="Center"
|
||||||
Height="100"
|
|
||||||
Background="LightGreen"
|
Background="LightGreen"
|
||||||
VerticalAlignment="Bottom"
|
VerticalAlignment="Bottom"
|
||||||
Panel.ZIndex="1" />
|
Panel.ZIndex="1" />
|
||||||
|
|
||||||
<!-- Inhalt der dritten Zeile -->
|
<!-- 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="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="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>
|
</StackPanel>
|
||||||
|
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
using System.Windows;
|
using System.ComponentModel;
|
||||||
using System.Windows.Controls;
|
using System.Windows;
|
||||||
using System.Windows.Media;
|
|
||||||
|
|
||||||
|
using CamBooth.App.Core.AppSettings;
|
||||||
using CamBooth.App.Core.Logging;
|
using CamBooth.App.Core.Logging;
|
||||||
using CamBooth.App.DebugConsole;
|
using CamBooth.App.DebugConsole;
|
||||||
using CamBooth.App.LiveView;
|
using CamBooth.App.LiveView;
|
||||||
@ -15,19 +15,32 @@ public partial class MainWindow : Window
|
|||||||
{
|
{
|
||||||
private readonly Logger _logger;
|
private readonly Logger _logger;
|
||||||
|
|
||||||
|
private readonly AppSettingsService _appSettings;
|
||||||
|
|
||||||
private bool _isDebugConsoleVisible;
|
private bool _isDebugConsoleVisible;
|
||||||
|
|
||||||
public MainWindow(Logger logger)
|
private LiveViewPage _liveViewPage;
|
||||||
|
|
||||||
|
public MainWindow(Logger logger, AppSettingsService appSettings)
|
||||||
{
|
{
|
||||||
this._logger = logger;
|
this._logger = logger;
|
||||||
|
this._appSettings = appSettings;
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
logger.LogInfo("MainWindow initialized");
|
|
||||||
ToggleDebugConsole();
|
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)
|
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)
|
private void ToggleDebugConsole(object sender, RoutedEventArgs e)
|
||||||
@ -39,13 +52,18 @@ public partial class MainWindow : Window
|
|||||||
{
|
{
|
||||||
if (_isDebugConsoleVisible)
|
if (_isDebugConsoleVisible)
|
||||||
{
|
{
|
||||||
this.DebugFrame.ClearValue(Frame.ContentProperty);
|
this.DebugFrame.ClearValue(MainWindow.ContentProperty);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.DebugFrame.Navigate(new DebugConsolePage());
|
this.DebugFrame.Navigate(new DebugConsolePage(this._logger));
|
||||||
}
|
}
|
||||||
|
|
||||||
this._isDebugConsoleVisible = !this._isDebugConsoleVisible;
|
this._isDebugConsoleVisible = !this._isDebugConsoleVisible;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void TakePhoto(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
this._liveViewPage.TakePhoto();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user