wip
This commit is contained in:
parent
e0ebb25f17
commit
f68af2d8c7
@ -55,11 +55,11 @@ public class CameraService : IDisposable
|
||||
}
|
||||
catch (DllNotFoundException)
|
||||
{
|
||||
ReportError("Canon DLLs not found!", true);
|
||||
this.ReportError("Canon DLLs not found!");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ReportError(ex.Message, true);
|
||||
this.ReportError(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
@ -141,33 +141,9 @@ public class CameraService : IDisposable
|
||||
}
|
||||
|
||||
|
||||
private void ReportError(string message, bool lockdown)
|
||||
private void ReportError(string message)
|
||||
{
|
||||
int errc;
|
||||
lock (ErrLock)
|
||||
{
|
||||
errc = ++ErrCount;
|
||||
}
|
||||
|
||||
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--;
|
||||
}
|
||||
this._logger.Info(message);
|
||||
}
|
||||
|
||||
|
||||
@ -188,7 +164,7 @@ public class CameraService : IDisposable
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ReportError(ex.Message, false);
|
||||
this.ReportError(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
@ -220,7 +196,7 @@ public class CameraService : IDisposable
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ReportError(ex.Message, false);
|
||||
this.ReportError(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
@ -273,20 +249,20 @@ public class CameraService : IDisposable
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ReportError(ex.Message, false);
|
||||
this.ReportError(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void ErrorHandler_NonSevereErrorHappened(object sender, ErrorCode ex)
|
||||
{
|
||||
ReportError($"SDK Error code: {ex} ({((int)ex).ToString("X")})", false);
|
||||
this.ReportError($"SDK Error code: {ex} ({((int)ex).ToString("X")})");
|
||||
}
|
||||
|
||||
|
||||
private void ErrorHandler_SevereErrorHappened(object sender, Exception ex)
|
||||
{
|
||||
ReportError(ex.Message, true);
|
||||
this.ReportError(ex.Message);
|
||||
}
|
||||
|
||||
#endregion
|
||||
@ -296,11 +272,11 @@ public class CameraService : IDisposable
|
||||
{
|
||||
try
|
||||
{
|
||||
MainCamera.TakePhotoAsync();
|
||||
MainCamera.TakePhoto();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ReportError(ex.Message, false);
|
||||
this.ReportError(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -65,7 +65,14 @@ public partial class LiveViewPage : Page
|
||||
|
||||
public void TakePhoto()
|
||||
{
|
||||
this._cameraService.TakePhoto();
|
||||
try
|
||||
{
|
||||
this._cameraService.TakePhoto();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
this._logger.Error(e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -49,11 +49,12 @@ public partial class MainWindow : Window
|
||||
}
|
||||
|
||||
|
||||
private void LoadPicturePanelAsync()
|
||||
private async void LoadPicturePanelAsync()
|
||||
{
|
||||
//this.PicturePanelPage.Visibility = Visibility.Hidden;
|
||||
//this.PicturePanelPage.Navigate(new PicturePanelPage(this._appSettings, this._logger));
|
||||
this._pictureGalleryService.LoadThumbnailsToCache();
|
||||
//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));
|
||||
}
|
||||
|
||||
@ -62,7 +63,7 @@ public partial class MainWindow : Window
|
||||
{
|
||||
if (visibility)
|
||||
{
|
||||
this.PicturePanel.Navigate(new PicturePanelPage(this._appSettings, this._logger, this._pictureGalleryService));
|
||||
this.PicturePanel.Navigate(new PictureGalleryPage(this._appSettings, this._logger, this._pictureGalleryService));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
<Page x:Class="CamBooth.App.PictureGallery.PicturePanelPage"
|
||||
<Page x:Class="CamBooth.App.PictureGallery.PictureGalleryPage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:CamBooth.App.PictureGallery"
|
||||
mc:Ignorable="d"
|
||||
Title="PicturePanelPage" Width="1600" Height="795"
|
||||
Title="PictureGalleryPage" Width="1600" Height="795"
|
||||
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
|
||||
Background="Magenta">
|
||||
<Grid>
|
||||
@ -10,7 +10,7 @@ using Image = Wpf.Ui.Controls.Image;
|
||||
|
||||
namespace CamBooth.App.PictureGallery;
|
||||
|
||||
public partial class PicturePanelPage : Page, IDisposable
|
||||
public partial class PictureGalleryPage : Page, IDisposable
|
||||
{
|
||||
private readonly AppSettingsService _appSettingsService;
|
||||
|
||||
@ -19,7 +19,7 @@ public partial class PicturePanelPage : Page, IDisposable
|
||||
private readonly PictureGalleryService _pictureGalleryService;
|
||||
|
||||
|
||||
public PicturePanelPage(AppSettingsService appSettingsService, Logger logger, PictureGalleryService pictureGalleryService)
|
||||
public PictureGalleryPage(AppSettingsService appSettingsService, Logger logger, PictureGalleryService pictureGalleryService)
|
||||
{
|
||||
this._appSettingsService = appSettingsService;
|
||||
this._logger = logger;
|
||||
@ -46,21 +46,25 @@ public partial class PicturePanelPage : Page, IDisposable
|
||||
{
|
||||
int loop = 0;
|
||||
|
||||
do
|
||||
{
|
||||
BitmapImage thumbnail = this._pictureGalleryService.ThumbnailsOrderedByNewestDescending[loop];
|
||||
|
||||
var imageControl = new Wpf.Ui.Controls.Image()
|
||||
this.Dispatcher.Invoke(
|
||||
() =>
|
||||
{
|
||||
Source = thumbnail,
|
||||
Width = 388,
|
||||
Margin = new Thickness(3)
|
||||
};
|
||||
do
|
||||
{
|
||||
BitmapImage thumbnail = this._pictureGalleryService.ThumbnailsOrderedByNewestDescending[loop];
|
||||
|
||||
this.PicturesPanel.Children.Add(imageControl);
|
||||
loop++;
|
||||
}
|
||||
while ((loop < howManyPictures || howManyPictures == 0) && loop < this._pictureGalleryService.ThumbnailsOrderedByNewestDescending.Count);
|
||||
var imageControl = new Wpf.Ui.Controls.Image()
|
||||
{
|
||||
Source = thumbnail,
|
||||
Width = 388,
|
||||
Margin = new Thickness(3)
|
||||
};
|
||||
|
||||
this.PicturesPanel.Children.Add(imageControl);
|
||||
loop++;
|
||||
}
|
||||
while ((loop < howManyPictures || howManyPictures == 0) && loop < this._pictureGalleryService.ThumbnailsOrderedByNewestDescending.Count);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -15,10 +15,10 @@ public class PictureGalleryService
|
||||
|
||||
private readonly Logger _logger;
|
||||
|
||||
public List<BitmapImage> ThumbnailsOrderedByNewestDescending => this.thumbnails.
|
||||
OrderByDescending(map => map.Key)
|
||||
.Select(ordered => ordered.Value)
|
||||
.ToList();
|
||||
public List<BitmapImage> ThumbnailsOrderedByNewestDescending =>
|
||||
this.thumbnails.OrderByDescending(map => map.Key)
|
||||
.Select(ordered => ordered.Value)
|
||||
.ToList();
|
||||
|
||||
private Dictionary<DateTime, BitmapImage> thumbnails = new();
|
||||
|
||||
@ -30,7 +30,7 @@ public class PictureGalleryService
|
||||
}
|
||||
|
||||
|
||||
public void LoadThumbnailsToCache(int cacheSize = 0)
|
||||
public async Task LoadThumbnailsToCache(int cacheSize = 0)
|
||||
{
|
||||
this._logger.Info("Start load thumbnails into cache");
|
||||
string? pictureLocation = this._appSettings.PictureLocation;
|
||||
@ -38,26 +38,30 @@ public class PictureGalleryService
|
||||
|
||||
List<string> picturePaths = Directory.EnumerateFiles(pictureLocation).ToList();
|
||||
|
||||
do
|
||||
{
|
||||
string picturePath = picturePaths[loop];
|
||||
|
||||
DateTime creationTime = File.GetCreationTime(picturePath);
|
||||
|
||||
// add if not exists
|
||||
if (!this.thumbnails.ContainsKey(creationTime))
|
||||
await Task.Run(
|
||||
() =>
|
||||
{
|
||||
this.thumbnails.Add(creationTime, CreateThumbnail(picturePath, 244, 200));
|
||||
this._logger.Info($"Thumbnail '{picturePath}' successfully created");
|
||||
}
|
||||
do
|
||||
{
|
||||
string picturePath = picturePaths[loop];
|
||||
|
||||
loop++;
|
||||
}
|
||||
while ((loop < cacheSize || cacheSize == 0) && loop < picturePaths.Count);
|
||||
DateTime creationTime = File.GetCreationTime(picturePath);
|
||||
|
||||
// add if not exists
|
||||
if (!this.thumbnails.ContainsKey(creationTime))
|
||||
{
|
||||
this.thumbnails.Add(creationTime, CreateThumbnail(picturePath, 244, 200));
|
||||
this._logger.Info($"Thumbnail '{picturePath}' successfully created");
|
||||
}
|
||||
|
||||
loop++;
|
||||
}
|
||||
while ((loop < cacheSize || cacheSize == 0) && loop < picturePaths.Count);
|
||||
});
|
||||
this._logger.Info("Loading thumbnails into cache completed");
|
||||
}
|
||||
|
||||
|
||||
public static BitmapImage CreateThumbnail(string filePath, int maxWidth, int maxHeight)
|
||||
{
|
||||
var bitmap = new BitmapImage();
|
||||
@ -66,6 +70,7 @@ public class PictureGalleryService
|
||||
bitmap.DecodePixelWidth = maxWidth; // Größe des ThumbnailsOrderedByNewestDescending direkt beim Dekodieren festlegen
|
||||
bitmap.CacheOption = BitmapCacheOption.OnLoad;
|
||||
bitmap.EndInit();
|
||||
bitmap.Freeze(); // Threadsicher machen
|
||||
return bitmap;
|
||||
}
|
||||
}
|
||||
@ -7,6 +7,8 @@
|
||||
<s:Boolean x:Key="/Default/AddReferences/RecentPaths/=C_003A_005CDev_005CRepos_005CPrivat_005CCamBooth_005Cmisc_005CCanonBinaries_005CMlib_002Edll/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/AddReferences/RecentPaths/=C_003A_005CDev_005CRepos_005CPrivat_005CCamBooth_005Cmisc_005CCanonBinaries_005CUcs32P_002Edll/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AApplication_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003FUsers_003Ftobia_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FSourcesCache_003F6665f2e3e843578225e3796b83c5342a58c3f72bfef19eeee7aa90d157d4949_003FApplication_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ADispatcher_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003FUsers_003Ftobia_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FSourcesCache_003F9ac32f819d6853e0a6eda168c52b7f38eef9ae75936fb85d96a15c39d115245_003FDispatcher_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AEventRoute_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003FUsers_003Ftobia_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FSourcesCache_003F4bda76b5cc453e1edf5d5c754c4a8215edbd3d3e4f80706dcf4f52a4f68979_003FEventRoute_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AExceptionDispatchInfo_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003FUsers_003Ftobia_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F793c644a163b4a9992123fa9cc1562efbf3908_003F4a_003Fd28af422_003FExceptionDispatchInfo_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AExceptionDispatchInfo_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003FUsers_003Ftobia_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FSourcesCache_003Fbd1d5c50194fea68ff3559c160230b0ab50f5acf4ce3061bffd6d62958e2182_003FExceptionDispatchInfo_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AWindow_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003FUsers_003Ftobia_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F0713c794b56e4feca091d5981a6f5967f60930_003Fc8_003F61b7e802_003FWindow_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user