wip
This commit is contained in:
parent
1287af3314
commit
c3b3d3e673
@ -6,6 +6,7 @@ namespace CamBooth.App.Core.Logging;
|
|||||||
public class Logger
|
public class Logger
|
||||||
{
|
{
|
||||||
public event LoggingEventHandler? InfoLog;
|
public event LoggingEventHandler? InfoLog;
|
||||||
|
public event LoggingEventHandler? ErrorLog;
|
||||||
public delegate void LoggingEventHandler(string text);
|
public delegate void LoggingEventHandler(string text);
|
||||||
|
|
||||||
public void Info(string message)
|
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.Controls;
|
||||||
|
using System.Windows.Media;
|
||||||
|
|
||||||
using CamBooth.App.Core.Logging;
|
using CamBooth.App.Core.Logging;
|
||||||
|
|
||||||
@ -9,9 +10,18 @@ public partial class DebugConsolePage : Page
|
|||||||
public DebugConsolePage(Logger logger)
|
public DebugConsolePage(Logger logger)
|
||||||
{
|
{
|
||||||
logger.InfoLog += Logger_OnInfoLog;
|
logger.InfoLog += Logger_OnInfoLog;
|
||||||
|
logger.ErrorLog += Logger_OnErrorLog;
|
||||||
InitializeComponent();
|
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)
|
private void Logger_OnInfoLog(string text)
|
||||||
{
|
{
|
||||||
this.tbDebugOutput.Text = this.tbDebugOutput.Text.Insert(0, text + "\n");
|
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.Visibility = Visibility.Hidden;
|
||||||
//this.PicturePanel.Navigate(new PicturePanel(this._appSettings, this._logger));
|
//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));
|
//this.DebugFrame.Navigate(new DebugConsolePage(this._logger));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -19,16 +19,18 @@ public class PictureGalleryService
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
List<Image> tmp = new List<Image>();
|
// List<Image> tmp = new List<Image>();
|
||||||
foreach (var image in imageControls)
|
// foreach (var image in imageControls)
|
||||||
{
|
// {
|
||||||
tmp.Add(image);
|
// tmp.Add(image);
|
||||||
}
|
// }
|
||||||
return tmp;
|
// 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)
|
public PictureGalleryService(AppSettingsService appSettings, Logger logger)
|
||||||
@ -70,7 +72,6 @@ public class PictureGalleryService
|
|||||||
bitmap.BeginInit();
|
bitmap.BeginInit();
|
||||||
bitmap.UriSource = new Uri(filePath);
|
bitmap.UriSource = new Uri(filePath);
|
||||||
bitmap.DecodePixelWidth = maxWidth; // Größe des Thumbnails direkt beim Dekodieren festlegen
|
bitmap.DecodePixelWidth = maxWidth; // Größe des Thumbnails direkt beim Dekodieren festlegen
|
||||||
// bitmap.DecodePixelHeight = maxHeight;
|
|
||||||
bitmap.CacheOption = BitmapCacheOption.OnLoad;
|
bitmap.CacheOption = BitmapCacheOption.OnLoad;
|
||||||
bitmap.EndInit();
|
bitmap.EndInit();
|
||||||
return bitmap;
|
return bitmap;
|
||||||
|
|||||||
@ -10,7 +10,7 @@ using Image = Wpf.Ui.Controls.Image;
|
|||||||
|
|
||||||
namespace CamBooth.App.PictureGallery;
|
namespace CamBooth.App.PictureGallery;
|
||||||
|
|
||||||
public partial class PicturePanel : Page
|
public partial class PicturePanel : Page, IDisposable
|
||||||
{
|
{
|
||||||
private readonly AppSettingsService _appSettingsService;
|
private readonly AppSettingsService _appSettingsService;
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ public partial class PicturePanel : Page
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
this._logger.Info(e.Message);
|
this._logger.Error(e.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,7 +46,17 @@ public partial class PicturePanel : Page
|
|||||||
{
|
{
|
||||||
foreach (Image ctl in this._pictureGalleryService.ImageControls)
|
foreach (Image ctl in this._pictureGalleryService.ImageControls)
|
||||||
{
|
{
|
||||||
this.PicturesPanel.Children.Add(ctl);
|
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