diff --git a/src/CamBooth/CamBooth.App/App.xaml.cs b/src/CamBooth/CamBooth.App/App.xaml.cs
index 3b5a2bd..709e6e2 100644
--- a/src/CamBooth/CamBooth.App/App.xaml.cs
+++ b/src/CamBooth/CamBooth.App/App.xaml.cs
@@ -1,9 +1,9 @@
using System.Windows;
using CamBooth.App.Core.AppSettings;
-using CamBooth.App.Camera;
using CamBooth.App.Core.Logging;
-using CamBooth.App.PictureGallery;
+using CamBooth.App.Features.Camera;
+using CamBooth.App.Features.PictureGallery;
using Microsoft.Extensions.DependencyInjection;
diff --git a/src/CamBooth/CamBooth.App/CamBooth.App.csproj b/src/CamBooth/CamBooth.App/CamBooth.App.csproj
index 3d66261..320efae 100644
--- a/src/CamBooth/CamBooth.App/CamBooth.App.csproj
+++ b/src/CamBooth/CamBooth.App/CamBooth.App.csproj
@@ -30,6 +30,7 @@
+
@@ -41,4 +42,16 @@
+
+
+ MSBuild:Compile
+
+
+ MSBuild:Compile
+
+
+ MSBuild:Compile
+
+
+
diff --git a/src/CamBooth/CamBooth.App/Camera/CameraService.cs b/src/CamBooth/CamBooth.App/Features/Camera/CameraService.cs
similarity index 76%
rename from src/CamBooth/CamBooth.App/Camera/CameraService.cs
rename to src/CamBooth/CamBooth.App/Features/Camera/CameraService.cs
index dbabcd2..f331368 100644
--- a/src/CamBooth/CamBooth.App/Camera/CameraService.cs
+++ b/src/CamBooth/CamBooth.App/Features/Camera/CameraService.cs
@@ -1,46 +1,42 @@
using System.IO;
using System.Windows;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Threading;
using CamBooth.App.Core.AppSettings;
using CamBooth.App.Core.Logging;
-using CamBooth.App.LiveView;
-using CamBooth.App.PictureGallery;
+using CamBooth.App.Features.PictureGallery;
using EOSDigital.API;
using EOSDigital.SDK;
-namespace CamBooth.App.Camera;
+namespace CamBooth.App.Features.Camera;
public class CameraService : IDisposable
{
- private readonly Logger _logger;
-
private readonly AppSettingsService _appSettings;
+ private readonly Logger _logger;
+
private readonly PictureGalleryService _pictureGalleryService;
- CanonAPI APIHandler;
+ private readonly CanonAPI APIHandler;
+
+ private CameraValue[] AvList;
+
+ private int BulbTime = 30;
+
+ private List CamList;
+
+ private int ErrCount;
+
+ private object ErrLock = new();
+
+ private bool IsInit;
+
+ private CameraValue[] ISOList;
public EOSDigital.API.Camera MainCamera;
- bool IsInit = false;
-
- List CamList;
-
- CameraValue[] AvList;
-
- CameraValue[] TvList;
-
- CameraValue[] ISOList;
-
- int BulbTime = 30;
-
- int ErrCount;
-
- object ErrLock = new object();
+ private CameraValue[] TvList;
public CameraService(Logger logger, AppSettingsService appSettings, PictureGalleryService pictureGalleryService)
@@ -50,8 +46,8 @@ public class CameraService : IDisposable
this._pictureGalleryService = pictureGalleryService;
try
{
- APIHandler = new CanonAPI();
- IsInit = true;
+ this.APIHandler = new CanonAPI();
+ this.IsInit = true;
}
catch (DllNotFoundException)
{
@@ -64,12 +60,22 @@ public class CameraService : IDisposable
}
+ /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
+ public void Dispose()
+ {
+ this.CloseSession();
+ this.IsInit = false;
+ this.APIHandler.Dispose();
+ this.MainCamera.Dispose();
+ }
+
+
public void ConnectCamera()
{
- ErrorHandler.SevereErrorHappened += ErrorHandler_SevereErrorHappened;
- ErrorHandler.NonSevereErrorHappened += ErrorHandler_NonSevereErrorHappened;
+ ErrorHandler.SevereErrorHappened += this.ErrorHandler_SevereErrorHappened;
+ ErrorHandler.NonSevereErrorHappened += this.ErrorHandler_NonSevereErrorHappened;
- RefreshCamera();
+ this.RefreshCamera();
List cameraList = this.APIHandler.GetCameraList();
if (cameraList.Any())
{
@@ -79,20 +85,20 @@ public class CameraService : IDisposable
}
string cameraDeviceNames = string.Join(", ", cameraList.Select(cam => cam.DeviceName));
- _logger.Info(cameraDeviceNames == string.Empty ? "No cameras / devices found" : cameraDeviceNames);
+ this._logger.Info(cameraDeviceNames == string.Empty ? "No cameras / devices found" : cameraDeviceNames);
}
private void SetSettingSaveToComputer()
{
- MainCamera.SetSetting(PropertyID.SaveTo, (int)SaveTo.Host);
- MainCamera.SetCapacity(4096, int.MaxValue);
+ this.MainCamera.SetSetting(PropertyID.SaveTo, (int)SaveTo.Host);
+ this.MainCamera.SetCapacity(4096, int.MaxValue);
}
public void CloseSession()
{
- MainCamera.CloseSession();
+ this.MainCamera.CloseSession();
// AvCoBox.Items.Clear();
// TvCoBox.Items.Clear();
@@ -108,7 +114,7 @@ public class CameraService : IDisposable
private void RefreshCamera()
{
// CameraListBox.Items.Clear();
- CamList = APIHandler.GetCameraList();
+ this.CamList = this.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);
@@ -118,17 +124,17 @@ public class CameraService : IDisposable
private void OpenSession()
{
- MainCamera = CamList[0];
- MainCamera.OpenSession();
+ this.MainCamera = this.CamList[0];
+ this.MainCamera.OpenSession();
//MainCamera.ProgressChanged += MainCamera_ProgressChanged;
- MainCamera.StateChanged += MainCamera_StateChanged;
- MainCamera.DownloadReady += MainCamera_DownloadReady;
+ this.MainCamera.StateChanged += this.MainCamera_StateChanged;
+ this.MainCamera.DownloadReady += this.MainCamera_DownloadReady;
//SessionLabel.Content = MainCamera.DeviceName;
- AvList = MainCamera.GetSettingsList(PropertyID.Av);
- TvList = MainCamera.GetSettingsList(PropertyID.Tv);
- ISOList = MainCamera.GetSettingsList(PropertyID.ISO);
+ this.AvList = this.MainCamera.GetSettingsList(PropertyID.Av);
+ this.TvList = this.MainCamera.GetSettingsList(PropertyID.Tv);
+ this.ISOList = this.MainCamera.GetSettingsList(PropertyID.ISO);
// foreach (var Av in AvList) AvCoBox.Items.Add(Av.StringValue);
// foreach (var Tv in TvList) TvCoBox.Items.Add(Tv.StringValue);
@@ -151,13 +157,13 @@ public class CameraService : IDisposable
{
try
{
- if (!MainCamera.IsLiveViewOn)
+ if (!this.MainCamera.IsLiveViewOn)
{
- MainCamera.StartLiveView();
+ this.MainCamera.StartLiveView();
}
else
{
- MainCamera.StopLiveView();
+ this.MainCamera.StopLiveView();
//LVCanvas.Background = Brushes.LightGray;
}
@@ -169,6 +175,20 @@ public class CameraService : IDisposable
}
+ public void TakePhoto()
+ {
+ try
+ {
+ this.MainCamera.TakePhoto();
+ }
+ catch (Exception ex)
+ {
+ this.ReportError(ex.Message);
+ throw;
+ }
+ }
+
+
#region API Events
// private void APIHandler_CameraAdded(CanonAPI sender)
@@ -187,7 +207,7 @@ public class CameraService : IDisposable
{
try
{
- if (eventID == StateEventID.Shutdown && IsInit)
+ if (eventID == StateEventID.Shutdown && this.IsInit)
{
Application.Current.Dispatcher.Invoke(() => this.CloseSession());
@@ -266,28 +286,4 @@ public class CameraService : IDisposable
}
#endregion
-
-
- public void TakePhoto()
- {
- try
- {
- MainCamera.TakePhoto();
- }
- catch (Exception ex)
- {
- this.ReportError(ex.Message);
- throw;
- }
- }
-
-
- /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
- public void Dispose()
- {
- this.CloseSession();
- IsInit = false;
- this.APIHandler.Dispose();
- this.MainCamera.Dispose();
- }
}
\ No newline at end of file
diff --git a/src/CamBooth/CamBooth.App/DebugConsole/DebugConsolePage.xaml b/src/CamBooth/CamBooth.App/Features/DebugConsole/DebugConsolePage.xaml
similarity index 83%
rename from src/CamBooth/CamBooth.App/DebugConsole/DebugConsolePage.xaml
rename to src/CamBooth/CamBooth.App/Features/DebugConsole/DebugConsolePage.xaml
index 6197be4..4840de0 100644
--- a/src/CamBooth/CamBooth.App/DebugConsole/DebugConsolePage.xaml
+++ b/src/CamBooth/CamBooth.App/Features/DebugConsole/DebugConsolePage.xaml
@@ -1,9 +1,8 @@
-
diff --git a/src/CamBooth/CamBooth.App/DebugConsole/DebugConsolePage.xaml.cs b/src/CamBooth/CamBooth.App/Features/DebugConsole/DebugConsolePage.xaml.cs
similarity index 75%
rename from src/CamBooth/CamBooth.App/DebugConsole/DebugConsolePage.xaml.cs
rename to src/CamBooth/CamBooth.App/Features/DebugConsole/DebugConsolePage.xaml.cs
index 9cde885..37353db 100644
--- a/src/CamBooth/CamBooth.App/DebugConsole/DebugConsolePage.xaml.cs
+++ b/src/CamBooth/CamBooth.App/Features/DebugConsole/DebugConsolePage.xaml.cs
@@ -3,15 +3,15 @@ using System.Windows.Media;
using CamBooth.App.Core.Logging;
-namespace CamBooth.App.DebugConsole;
+namespace CamBooth.App.Features.DebugConsole;
public partial class DebugConsolePage : Page
{
public DebugConsolePage(Logger logger)
{
- logger.InfoLog += Logger_OnInfoLog;
- logger.ErrorLog += Logger_OnErrorLog;
- InitializeComponent();
+ logger.InfoLog += this.Logger_OnInfoLog;
+ logger.ErrorLog += this.Logger_OnErrorLog;
+ this.InitializeComponent();
}
diff --git a/src/CamBooth/CamBooth.App/LiveView/LiveViewPage.xaml b/src/CamBooth/CamBooth.App/Features/LiveView/LiveViewPage.xaml
similarity index 74%
rename from src/CamBooth/CamBooth.App/LiveView/LiveViewPage.xaml
rename to src/CamBooth/CamBooth.App/Features/LiveView/LiveViewPage.xaml
index 7fe5f46..2469aea 100644
--- a/src/CamBooth/CamBooth.App/LiveView/LiveViewPage.xaml
+++ b/src/CamBooth/CamBooth.App/Features/LiveView/LiveViewPage.xaml
@@ -1,13 +1,12 @@
-
-
+
-
+
\ No newline at end of file
diff --git a/src/CamBooth/CamBooth.App/LiveView/LiveViewPage.xaml.cs b/src/CamBooth/CamBooth.App/Features/LiveView/LiveViewPage.xaml.cs
similarity index 59%
rename from src/CamBooth/CamBooth.App/LiveView/LiveViewPage.xaml.cs
rename to src/CamBooth/CamBooth.App/Features/LiveView/LiveViewPage.xaml.cs
index 9a20e5e..e23a283 100644
--- a/src/CamBooth/CamBooth.App/LiveView/LiveViewPage.xaml.cs
+++ b/src/CamBooth/CamBooth.App/Features/LiveView/LiveViewPage.xaml.cs
@@ -1,31 +1,26 @@
-using System.ComponentModel;
-using System.Configuration;
-using System.IO;
+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.Camera;
using CamBooth.App.Core.Logging;
+using CamBooth.App.Features.Camera;
-using EOSDigital.API;
-using EOSDigital.SDK;
-
-namespace CamBooth.App.LiveView;
+namespace CamBooth.App.Features.LiveView;
public partial class LiveViewPage : Page
{
- private readonly Logger _logger;
-
private readonly AppSettingsService _appSettings;
private readonly CameraService _cameraService;
- Action SetImageAction;
+ private readonly Logger _logger;
- private ImageBrush bgbrush = new ImageBrush();
+ private readonly ImageBrush bgbrush = new();
+
+ private readonly Action SetImageAction;
public LiveViewPage(Logger logger, AppSettingsService appSettings, CameraService cameraService)
@@ -33,11 +28,11 @@ public partial class LiveViewPage : Page
this._logger = logger;
this._appSettings = appSettings;
this._cameraService = cameraService;
- InitializeComponent();
- SetImageAction = (BitmapImage img) => { bgbrush.ImageSource = img; };
- LVCanvas.Background = bgbrush;
+ this.InitializeComponent();
+ this.SetImageAction = img => { this.bgbrush.ImageSource = img; };
+ this.LVCanvas.Background = this.bgbrush;
cameraService.ConnectCamera();
- cameraService.MainCamera.LiveViewUpdated += MainCamera_OnLiveViewUpdated;
+ cameraService.MainCamera.LiveViewUpdated += this.MainCamera_OnLiveViewUpdated;
}
@@ -45,24 +40,24 @@ public partial class LiveViewPage : Page
{
try
{
- using (WrapStream s = new WrapStream(img))
+ using (WrapStream s = new(img))
{
img.Position = 0;
- BitmapImage EvfImage = new BitmapImage();
+ BitmapImage EvfImage = new();
EvfImage.BeginInit();
EvfImage.StreamSource = s;
EvfImage.CacheOption = BitmapCacheOption.OnLoad;
EvfImage.EndInit();
EvfImage.Freeze();
- Application.Current.Dispatcher.BeginInvoke(SetImageAction, EvfImage);
+ Application.Current.Dispatcher.BeginInvoke(this.SetImageAction, EvfImage);
}
}
catch (Exception ex)
{
- _logger.Error(ex.Message);
+ this._logger.Error(ex.Message);
}
}
-
+
public void Dispose()
{
diff --git a/src/CamBooth/CamBooth.App/Features/LiveView/WrappingStream.cs b/src/CamBooth/CamBooth.App/Features/LiveView/WrappingStream.cs
new file mode 100644
index 0000000..a74b9a6
--- /dev/null
+++ b/src/CamBooth/CamBooth.App/Features/LiveView/WrappingStream.cs
@@ -0,0 +1,127 @@
+using System.IO;
+
+namespace CamBooth.App.Features.LiveView;
+
+///
+/// A stream that does nothing more but wrap another stream (needed for a WPF memory leak)
+///
+public sealed class WrapStream : Stream
+{
+ private readonly Stream Base;
+
+
+ ///
+ /// Creates a new instance of the class.
+ ///
+ /// The stream that gets wrapped
+ public WrapStream(Stream inStream)
+ {
+ this.Base = inStream;
+ }
+
+
+ ///
+ /// Gets a value indicating whether the current stream supports reading.
+ ///
+ public override bool CanRead => this.Base.CanRead;
+
+ ///
+ /// Gets a value indicating whether the current stream supports seeking.
+ ///
+ public override bool CanSeek => this.Base.CanSeek;
+
+ ///
+ /// Gets a value indicating whether the current stream supports writing.
+ ///
+ public override bool CanWrite => this.Base.CanWrite;
+
+ ///
+ /// Gets the length in bytes of the stream.
+ ///
+ public override long Length => this.Base.Length;
+
+ ///
+ /// Gets or sets the position within the current stream.
+ ///
+ public override long Position
+ {
+ get => this.Base.Position;
+ set => this.Base.Position = value;
+ }
+
+
+ ///
+ /// reads a sequence of bytes from the current stream and advances
+ /// the position within the stream by the number of bytes read.
+ ///
+ ///
+ /// An array of bytes. When this method returns, the buffer contains the specified
+ /// byte array with the values between offset and (offset + count - 1) replaced
+ /// by the bytes read from the current source.
+ ///
+ ///
+ /// The zero-based byte offset in buffer at which to begin storing the data read
+ /// from the current stream.
+ ///
+ /// The maximum number of bytes to be read from the current stream.
+ ///
+ /// The total number of bytes read into the buffer. This can be less than the
+ /// number of bytes requested if that many bytes are not currently available,
+ /// or zero (0) if the end of the stream has been reached.
+ ///
+ public override int Read(byte[] buffer, int offset, int count)
+ {
+ return this.Base.Read(buffer, offset, count);
+ }
+
+
+ ///
+ /// When overridden in a derived class, writes a sequence of bytes to the current
+ /// stream and advances the current position within this stream by the number
+ /// of bytes written.
+ ///
+ /// An array of bytes. This method copies count bytes from buffer to the current stream.
+ ///
+ /// The zero-based byte offset in buffer at which to begin copying bytes to the
+ /// current stream.
+ ///
+ /// The number of bytes to be written to the current stream.
+ public override void Write(byte[] buffer, int offset, int count)
+ {
+ this.Base.Write(buffer, offset, count);
+ }
+
+
+ ///
+ /// sets the position within the current stream.
+ ///
+ /// A byte offset relative to the origin parameter.
+ ///
+ /// A value of type System.IO.SeekOrigin indicating the reference point used
+ /// to obtain the new position.
+ ///
+ /// The new position within the current stream.
+ public override long Seek(long offset, SeekOrigin origin)
+ {
+ return this.Base.Seek(offset, origin);
+ }
+
+
+ ///
+ /// Clears all buffers for this stream and causes any buffered data to be written to the underlying device.
+ ///
+ public override void Flush()
+ {
+ this.Base.Flush();
+ }
+
+
+ ///
+ /// Sets the length of the current stream.
+ ///
+ /// The desired length of the current stream in bytes.
+ public override void SetLength(long value)
+ {
+ this.Base.SetLength(value);
+ }
+}
\ No newline at end of file
diff --git a/src/CamBooth/CamBooth.App/PictureGallery/PictureGalleryPage.xaml b/src/CamBooth/CamBooth.App/Features/PictureGallery/PictureGalleryPage.xaml
similarity index 75%
rename from src/CamBooth/CamBooth.App/PictureGallery/PictureGalleryPage.xaml
rename to src/CamBooth/CamBooth.App/Features/PictureGallery/PictureGalleryPage.xaml
index 39696bf..f07ff41 100644
--- a/src/CamBooth/CamBooth.App/PictureGallery/PictureGalleryPage.xaml
+++ b/src/CamBooth/CamBooth.App/Features/PictureGallery/PictureGalleryPage.xaml
@@ -1,12 +1,10 @@
-
diff --git a/src/CamBooth/CamBooth.App/PictureGallery/PictureGalleryPage.xaml.cs b/src/CamBooth/CamBooth.App/Features/PictureGallery/PictureGalleryPage.xaml.cs
similarity index 84%
rename from src/CamBooth/CamBooth.App/PictureGallery/PictureGalleryPage.xaml.cs
rename to src/CamBooth/CamBooth.App/Features/PictureGallery/PictureGalleryPage.xaml.cs
index 5386fd4..704a83c 100644
--- a/src/CamBooth/CamBooth.App/PictureGallery/PictureGalleryPage.xaml.cs
+++ b/src/CamBooth/CamBooth.App/Features/PictureGallery/PictureGalleryPage.xaml.cs
@@ -1,8 +1,6 @@
-using System.IO;
-using System.Windows;
+using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
-using System.Windows.Media;
using System.Windows.Media.Imaging;
using CamBooth.App.Core.AppSettings;
@@ -10,12 +8,11 @@ using CamBooth.App.Core.Logging;
using Wpf.Ui.Controls;
-using Button = Wpf.Ui.Controls.Button;
using Image = Wpf.Ui.Controls.Image;
using MessageBox = System.Windows.MessageBox;
using TextBlock = Wpf.Ui.Controls.TextBlock;
-namespace CamBooth.App.PictureGallery;
+namespace CamBooth.App.Features.PictureGallery;
public partial class PictureGalleryPage : Page
{
@@ -31,7 +28,7 @@ public partial class PictureGalleryPage : Page
this._appSettingsService = appSettingsService;
this._logger = logger;
this._pictureGalleryService = pictureGalleryService;
- InitializeComponent();
+ this.InitializeComponent();
this.Initialize();
}
@@ -40,7 +37,7 @@ public partial class PictureGalleryPage : Page
{
try
{
- LoadPictures(12);
+ this.LoadPictures(12);
}
catch (Exception e)
{
@@ -69,12 +66,12 @@ public partial class PictureGalleryPage : Page
{
BitmapImage thumbnail = this._pictureGalleryService.ThumbnailsOrderedByNewestDescending[loop];
- var textBlock = new TextBlock();
- var hyperlink = new Hyperlink();
- hyperlink.Click += Hyperlink_OnClick;
+ TextBlock? textBlock = new();
+ Hyperlink? hyperlink = new();
+ hyperlink.Click += this.Hyperlink_OnClick;
hyperlink.Tag = thumbnail.UriSource;
hyperlink.TextDecorations = null;
- var imageControl = new Wpf.Ui.Controls.Image
+ Image? imageControl = new()
{
Source = thumbnail,
Width = 381,
@@ -97,24 +94,26 @@ public partial class PictureGalleryPage : Page
Application.Current.Dispatcher.BeginInvoke(
async () =>
{
- var contentDialog = new ContentDialog(RootContentDialogPresenter);
- var imageToShow = new Image
+ ContentDialog? contentDialog = new(this.RootContentDialogPresenter);
+ Image? imageToShow = new()
{
VerticalAlignment = VerticalAlignment.Center,
Source = PictureGalleryService.CreateThumbnail(picturePathUri.AbsolutePath, 499, 300)
};
-
+
contentDialog.DialogWidth = 940;
contentDialog.PrimaryButtonAppearance = ControlAppearance.Success;
contentDialog.CloseButtonAppearance = ControlAppearance.Primary;
+
//contentDialog.SetCurrentValue(ContentDialog.TitleProperty, "Hello World");
contentDialog.SetCurrentValue(ContentControl.ContentProperty, imageToShow);
contentDialog.SetCurrentValue(ContentDialog.CloseButtonTextProperty, "Schließen");
contentDialog.SetCurrentValue(ContentDialog.PrimaryButtonTextProperty, "Drucken");
+
// contentDialog.SetCurrentValue(ContentDialog.PrimaryButtonIconProperty, PictureGalleryService.CreateRegularSymbolIcon(SymbolRegular.Print48, Colors.Tomato));
-
+
contentDialog.Tag = picturePathUri.AbsolutePath;
- contentDialog.ButtonClicked += ContentDialog_OnButtonClicked;
+ contentDialog.ButtonClicked += this.ContentDialog_OnButtonClicked;
await contentDialog.ShowAsync();
});
diff --git a/src/CamBooth/CamBooth.App/PictureGallery/PictureGalleryService.cs b/src/CamBooth/CamBooth.App/Features/PictureGallery/PictureGalleryService.cs
similarity index 87%
rename from src/CamBooth/CamBooth.App/PictureGallery/PictureGalleryService.cs
rename to src/CamBooth/CamBooth.App/Features/PictureGallery/PictureGalleryService.cs
index 2bd0a3b..c810f4d 100644
--- a/src/CamBooth/CamBooth.App/PictureGallery/PictureGalleryService.cs
+++ b/src/CamBooth/CamBooth.App/Features/PictureGallery/PictureGalleryService.cs
@@ -1,5 +1,4 @@
using System.IO;
-using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Imaging;
@@ -8,7 +7,7 @@ using CamBooth.App.Core.Logging;
using Wpf.Ui.Controls;
-namespace CamBooth.App.PictureGallery;
+namespace CamBooth.App.Features.PictureGallery;
public class PictureGalleryService
{
@@ -16,12 +15,7 @@ public class PictureGalleryService
private readonly Logger _logger;
- public List ThumbnailsOrderedByNewestDescending =>
- this.thumbnails.OrderByDescending(map => map.Key)
- .Select(ordered => ordered.Value)
- .ToList();
-
- private Dictionary thumbnails = new();
+ private readonly Dictionary thumbnails = new();
public PictureGalleryService(AppSettingsService appSettings, Logger logger)
@@ -31,6 +25,12 @@ public class PictureGalleryService
}
+ public List ThumbnailsOrderedByNewestDescending =>
+ this.thumbnails.OrderByDescending(map => map.Key)
+ .Select(ordered => ordered.Value)
+ .ToList();
+
+
public async Task LoadThumbnailsToCache(int cacheSize = 0)
{
this._logger.Info("Start load thumbnails into cache");
@@ -51,7 +51,7 @@ public class PictureGalleryService
// add if not exists
if (!this.thumbnails.ContainsKey(creationTime))
{
- this.thumbnails.Add(creationTime, CreateThumbnail(picturePath, 244, 0));
+ this.thumbnails.Add(creationTime, PictureGalleryService.CreateThumbnail(picturePath, 244, 0));
this._logger.Info($"Thumbnail '{picturePath}' successfully created");
}
@@ -65,7 +65,7 @@ public class PictureGalleryService
public static BitmapImage CreateThumbnail(string filePath, int maxWidth, int maxHeight)
{
- var bitmap = new BitmapImage();
+ BitmapImage? bitmap = new();
bitmap.BeginInit();
bitmap.UriSource = new Uri(filePath);
bitmap.DecodePixelWidth = maxWidth; // Größe des ThumbnailsOrderedByNewestDescending direkt beim Dekodieren festlegen
@@ -75,16 +75,17 @@ public class PictureGalleryService
bitmap.Freeze(); // Threadsicher machen
return bitmap;
}
-
+
+
public static SymbolIcon CreateRegularSymbolIcon(SymbolRegular symbolRegular, Color foregroundColor = default)
{
return new SymbolIcon
{
- Symbol = symbolRegular,
+ Symbol = symbolRegular,
Foreground = new SolidColorBrush(foregroundColor),
- Width = 24,
+ Width = 24,
Height = 24,
FontSize = 24
};
- }
+ }
}
\ No newline at end of file
diff --git a/src/CamBooth/CamBooth.App/LiveView/WrappingStream.cs b/src/CamBooth/CamBooth.App/LiveView/WrappingStream.cs
deleted file mode 100644
index bba5fcb..0000000
--- a/src/CamBooth/CamBooth.App/LiveView/WrappingStream.cs
+++ /dev/null
@@ -1,120 +0,0 @@
-
-using System.IO;
-
-namespace CamBooth.App.LiveView
-{
- ///
- /// A stream that does nothing more but wrap another stream (needed for a WPF memory leak)
- ///
- public sealed class WrapStream : Stream
- {
- ///
- /// Gets a value indicating whether the current stream supports reading.
- ///
- public override bool CanRead
- {
- get { return this.Base.CanRead; }
- }
- ///
- /// Gets a value indicating whether the current stream supports seeking.
- ///
- public override bool CanSeek
- {
- get { return this.Base.CanSeek; }
- }
- ///
- /// Gets a value indicating whether the current stream supports writing.
- ///
- public override bool CanWrite
- {
- get { return this.Base.CanWrite; }
- }
- ///
- /// Gets the length in bytes of the stream.
- ///
- public override long Length
- {
- get { return this.Base.Length; }
- }
- ///
- /// Gets or sets the position within the current stream.
- ///
- public override long Position
- {
- get { return this.Base.Position; }
- set { this.Base.Position = value; }
- }
-
- private Stream Base;
-
- ///
- /// Creates a new instance of the class.
- ///
- /// The stream that gets wrapped
- public WrapStream(Stream inStream)
- {
- this.Base = inStream;
- }
-
- ///
- /// reads a sequence of bytes from the current stream and advances
- /// the position within the stream by the number of bytes read.
- ///
- /// An array of bytes. When this method returns, the buffer contains the specified
- /// byte array with the values between offset and (offset + count - 1) replaced
- /// by the bytes read from the current source.
- /// The zero-based byte offset in buffer at which to begin storing the data read
- /// from the current stream.
- /// The maximum number of bytes to be read from the current stream.
- /// The total number of bytes read into the buffer. This can be less than the
- /// number of bytes requested if that many bytes are not currently available,
- /// or zero (0) if the end of the stream has been reached.
- public override int Read(byte[] buffer, int offset, int count)
- {
- return this.Base.Read(buffer, offset, count);
- }
-
- ///
- /// When overridden in a derived class, writes a sequence of bytes to the current
- /// stream and advances the current position within this stream by the number
- /// of bytes written.
- ///
- /// An array of bytes. This method copies count bytes from buffer to the current stream.
- /// The zero-based byte offset in buffer at which to begin copying bytes to the
- /// current stream.
- /// The number of bytes to be written to the current stream.
- public override void Write(byte[] buffer, int offset, int count)
- {
- this.Base.Write(buffer, offset, count);
- }
-
- ///
- /// sets the position within the current stream.
- ///
- /// A byte offset relative to the origin parameter.
- /// A value of type System.IO.SeekOrigin indicating the reference point used
- /// to obtain the new position.
- /// The new position within the current stream.
- public override long Seek(long offset, System.IO.SeekOrigin origin)
- {
- return this.Base.Seek(offset, origin);
- }
-
- ///
- /// Clears all buffers for this stream and causes any buffered data to be written to the underlying device.
- ///
- public override void Flush()
- {
- this.Base.Flush();
- }
-
- ///
- /// Sets the length of the current stream.
- ///
- /// The desired length of the current stream in bytes.
- public override void SetLength(long value)
- {
- this.Base.SetLength(value);
- }
- }
-}
\ 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 e65eedd..12df279 100644
--- a/src/CamBooth/CamBooth.App/MainWindow.xaml.cs
+++ b/src/CamBooth/CamBooth.App/MainWindow.xaml.cs
@@ -1,12 +1,12 @@
using System.ComponentModel;
using System.Windows;
-using CamBooth.App.Camera;
using CamBooth.App.Core.AppSettings;
using CamBooth.App.Core.Logging;
-using CamBooth.App.DebugConsole;
-using CamBooth.App.LiveView;
-using CamBooth.App.PictureGallery;
+using CamBooth.App.Features.Camera;
+using CamBooth.App.Features.DebugConsole;
+using CamBooth.App.Features.LiveView;
+using CamBooth.App.Features.PictureGallery;
namespace CamBooth.App;