wip
This commit is contained in:
parent
1287af3314
commit
c3b3d3e673
@ -6,6 +6,7 @@ namespace CamBooth.App.Core.Logging;
|
||||
public class Logger
|
||||
{
|
||||
public event LoggingEventHandler? InfoLog;
|
||||
public event LoggingEventHandler? ErrorLog;
|
||||
public delegate void LoggingEventHandler(string text);
|
||||
|
||||
public void Info(string message)
|
||||
@ -18,4 +19,14 @@ public class Logger
|
||||
});
|
||||
|
||||
}
|
||||
public void Error(string message)
|
||||
{
|
||||
Application.Current.Dispatcher.Invoke(() =>
|
||||
{
|
||||
message = DateTime.Now.ToString("dd.MM.yyyy HH:MM:ss", CultureInfo.InvariantCulture) + ": " + message;
|
||||
ErrorLog?.Invoke(message);
|
||||
Console.WriteLine(message);
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
@ -1,4 +1,5 @@
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
|
||||
using CamBooth.App.Core.Logging;
|
||||
|
||||
@ -9,9 +10,18 @@ public partial class DebugConsolePage : Page
|
||||
public DebugConsolePage(Logger logger)
|
||||
{
|
||||
logger.InfoLog += Logger_OnInfoLog;
|
||||
logger.ErrorLog += Logger_OnErrorLog;
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
|
||||
private void Logger_OnErrorLog(string text)
|
||||
{
|
||||
this.tbDebugOutput.Text = this.tbDebugOutput.Text.Insert(0, text + "\n");
|
||||
this.tbDebugOutput.Background = new SolidColorBrush(Colors.Tomato);
|
||||
}
|
||||
|
||||
|
||||
private void Logger_OnInfoLog(string text)
|
||||
{
|
||||
this.tbDebugOutput.Text = this.tbDebugOutput.Text.Insert(0, text + "\n");
|
||||
|
||||
@ -46,7 +46,7 @@ public partial class MainWindow : Window
|
||||
{
|
||||
//this.PicturePanel.Visibility = Visibility.Hidden;
|
||||
//this.PicturePanel.Navigate(new PicturePanel(this._appSettings, this._logger));
|
||||
Task.Run(() => this._pictureGalleryService.LoadThumbnailsToCache(12));
|
||||
this._pictureGalleryService.LoadThumbnailsToCache(12);
|
||||
//this.DebugFrame.Navigate(new DebugConsolePage(this._logger));
|
||||
}
|
||||
|
||||
|
||||
@ -19,16 +19,18 @@ public class PictureGalleryService
|
||||
{
|
||||
get
|
||||
{
|
||||
List<Image> tmp = new List<Image>();
|
||||
foreach (var image in imageControls)
|
||||
{
|
||||
tmp.Add(image);
|
||||
}
|
||||
return tmp;
|
||||
// List<Image> tmp = new List<Image>();
|
||||
// foreach (var image in imageControls)
|
||||
// {
|
||||
// tmp.Add(image);
|
||||
// }
|
||||
// return tmp;
|
||||
|
||||
return this.imageControls;
|
||||
}
|
||||
}
|
||||
|
||||
public List<Image> imageControls = new List<Image>();
|
||||
private List<Image> imageControls = new List<Image>();
|
||||
|
||||
|
||||
public PictureGalleryService(AppSettingsService appSettings, Logger logger)
|
||||
@ -70,7 +72,6 @@ public class PictureGalleryService
|
||||
bitmap.BeginInit();
|
||||
bitmap.UriSource = new Uri(filePath);
|
||||
bitmap.DecodePixelWidth = maxWidth; // Größe des Thumbnails direkt beim Dekodieren festlegen
|
||||
// bitmap.DecodePixelHeight = maxHeight;
|
||||
bitmap.CacheOption = BitmapCacheOption.OnLoad;
|
||||
bitmap.EndInit();
|
||||
return bitmap;
|
||||
|
||||
@ -10,7 +10,7 @@ using Image = Wpf.Ui.Controls.Image;
|
||||
|
||||
namespace CamBooth.App.PictureGallery;
|
||||
|
||||
public partial class PicturePanel : Page
|
||||
public partial class PicturePanel : Page, IDisposable
|
||||
{
|
||||
private readonly AppSettingsService _appSettingsService;
|
||||
|
||||
@ -37,7 +37,7 @@ public partial class PicturePanel : Page
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
this._logger.Info(e.Message);
|
||||
this._logger.Error(e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
@ -45,8 +45,18 @@ public partial class PicturePanel : Page
|
||||
private void LoadPictures(int howManyPictures)
|
||||
{
|
||||
foreach (Image ctl in this._pictureGalleryService.ImageControls)
|
||||
{
|
||||
if(!this.PicturesPanel.Children.Contains(ctl))
|
||||
{
|
||||
this.PicturesPanel.Children.Add(ctl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.</summary>
|
||||
public void Dispose()
|
||||
{
|
||||
this.PicturesPanel.Children.Clear();
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user