Archived
adjusted namespaces and made separate data dir
This commit is contained in:
+16
-17
@@ -3,25 +3,24 @@ using GUI.Views;
|
||||
using Serilog;
|
||||
using System.Windows;
|
||||
|
||||
namespace GUI
|
||||
namespace GUI;
|
||||
|
||||
/// <summary>
|
||||
/// Interaction logic for App.xaml
|
||||
/// </summary>
|
||||
public partial class App : Application
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for App.xaml
|
||||
/// </summary>
|
||||
public partial class App : Application
|
||||
/// <inheritdoc />
|
||||
protected override void OnStartup(StartupEventArgs e)
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void OnStartup(StartupEventArgs e)
|
||||
{
|
||||
base.OnStartup(e);
|
||||
base.OnStartup(e);
|
||||
|
||||
var loggingCollection = new LoggingCollection(100);
|
||||
Log.Logger = new LoggerConfiguration()
|
||||
.WriteTo.Sink(loggingCollection)
|
||||
.CreateLogger();
|
||||
var loggingCollection = new LoggingCollection(100);
|
||||
Log.Logger = new LoggerConfiguration()
|
||||
.WriteTo.Sink(loggingCollection)
|
||||
.CreateLogger();
|
||||
|
||||
new LogView(loggingCollection).Show();
|
||||
new ImageView().Show();
|
||||
}
|
||||
new LogView(loggingCollection).Show();
|
||||
new ImageView().Show();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,44 +2,43 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace GUI.Controls
|
||||
namespace GUI.Controls;
|
||||
|
||||
/// <summary>
|
||||
/// Interaction logic for ImageControl.xaml
|
||||
/// </summary>
|
||||
public partial class ImageControl : UserControl
|
||||
{
|
||||
/// <inheritdoc cref="Image"/>
|
||||
public static readonly DependencyProperty ImageProperty = DependencyProperty.Register(
|
||||
nameof(Image), typeof(MagickImage), typeof(ImageControl), new PropertyMetadata(default(MagickImage)));
|
||||
|
||||
/// <summary>
|
||||
/// Interaction logic for ImageControl.xaml
|
||||
/// The <see cref="MagickImage"/> displayed in this <see cref="ImageControl"/>
|
||||
/// </summary>
|
||||
public partial class ImageControl : UserControl
|
||||
public MagickImage Image
|
||||
{
|
||||
/// <inheritdoc cref="Image"/>
|
||||
public static readonly DependencyProperty ImageProperty = DependencyProperty.Register(
|
||||
nameof(Image), typeof(MagickImage), typeof(ImageControl), new PropertyMetadata(default(MagickImage)));
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="MagickImage"/> displayed in this <see cref="ImageControl"/>
|
||||
/// </summary>
|
||||
public MagickImage Image
|
||||
{
|
||||
get => (MagickImage)GetValue(ImageProperty);
|
||||
set => SetValue(ImageProperty, value);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="ImageName"/>
|
||||
public static readonly DependencyProperty ImageNameProperty = DependencyProperty.Register(
|
||||
nameof(ImageName), typeof(object), typeof(ImageControl),
|
||||
new PropertyMetadata(default(object)));
|
||||
|
||||
/// <summary>
|
||||
/// The name of the loaded image
|
||||
/// </summary>
|
||||
public object ImageName
|
||||
{
|
||||
get => (object)GetValue(ImageNameProperty);
|
||||
set => SetValue(ImageNameProperty, value);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public ImageControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
get => (MagickImage)GetValue(ImageProperty);
|
||||
set => SetValue(ImageProperty, value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="ImageName"/>
|
||||
public static readonly DependencyProperty ImageNameProperty = DependencyProperty.Register(
|
||||
nameof(ImageName), typeof(object), typeof(ImageControl),
|
||||
new PropertyMetadata(default(object)));
|
||||
|
||||
/// <summary>
|
||||
/// The name of the loaded image
|
||||
/// </summary>
|
||||
public object ImageName
|
||||
{
|
||||
get => (object)GetValue(ImageNameProperty);
|
||||
set => SetValue(ImageNameProperty, value);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public ImageControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
@@ -6,49 +6,48 @@ using System.IO;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Media.Imaging;
|
||||
|
||||
namespace GUI.Converters
|
||||
namespace GUI.Converters;
|
||||
|
||||
internal class ImageConverter : IValueConverter
|
||||
{
|
||||
internal class ImageConverter : IValueConverter
|
||||
#region Implementation of IValueConverter
|
||||
|
||||
/// <inheritdoc />
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
#region Implementation of IValueConverter
|
||||
|
||||
/// <inheritdoc />
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
if (value is not MagickImage image)
|
||||
{
|
||||
if (value is not MagickImage image)
|
||||
{
|
||||
return Binding.DoNothing;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
using var stream = new MemoryStream();
|
||||
|
||||
// Save image to stream
|
||||
image.Write(stream, MagickFormat.Png);
|
||||
|
||||
// Build Bitmap from stream
|
||||
var imageSource = new BitmapImage();
|
||||
imageSource.BeginInit();
|
||||
imageSource.StreamSource = stream;
|
||||
imageSource.CacheOption = BitmapCacheOption.OnLoad;
|
||||
imageSource.EndInit();
|
||||
|
||||
return imageSource;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Error($"{e.Message}");
|
||||
return Binding.DoNothing;
|
||||
}
|
||||
return Binding.DoNothing;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
try
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
using var stream = new MemoryStream();
|
||||
|
||||
#endregion
|
||||
// Save image to stream
|
||||
image.Write(stream, MagickFormat.Png);
|
||||
|
||||
// Build Bitmap from stream
|
||||
var imageSource = new BitmapImage();
|
||||
imageSource.BeginInit();
|
||||
imageSource.StreamSource = stream;
|
||||
imageSource.CacheOption = BitmapCacheOption.OnLoad;
|
||||
imageSource.EndInit();
|
||||
|
||||
return imageSource;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Error($"{e.Message}");
|
||||
return Binding.DoNothing;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -1,12 +1,11 @@
|
||||
namespace GUI.ViewModels
|
||||
{
|
||||
public class LogViewModel
|
||||
{
|
||||
public LoggingCollection LoggingCollection { get; }
|
||||
namespace GUI.ViewModels;
|
||||
|
||||
public LogViewModel(LoggingCollection loggingCollection)
|
||||
{
|
||||
LoggingCollection = loggingCollection;
|
||||
}
|
||||
public class LogViewModel
|
||||
{
|
||||
public LoggingCollection LoggingCollection { get; }
|
||||
|
||||
public LogViewModel(LoggingCollection loggingCollection)
|
||||
{
|
||||
LoggingCollection = loggingCollection;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,44 +5,43 @@ using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Controls.Primitives;
|
||||
|
||||
namespace GUI.Views
|
||||
namespace GUI.Views;
|
||||
|
||||
/// <summary>
|
||||
/// Interaction logic for MainWindow.xaml
|
||||
/// </summary>
|
||||
public partial class ImageView : Window
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for MainWindow.xaml
|
||||
/// </summary>
|
||||
public partial class ImageView : Window
|
||||
private ImageViewModel ViewModel => (ImageViewModel)DataContext;
|
||||
|
||||
public ImageView()
|
||||
{
|
||||
private ImageViewModel ViewModel => (ImageViewModel)DataContext;
|
||||
|
||||
public ImageView()
|
||||
{
|
||||
DataContext = new ImageViewModel();
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public ImageView(MagickImage image)
|
||||
{
|
||||
DataContext = new ImageViewModel(image);
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void SldThreshold1_OnDragCompleted(object sender, DragCompletedEventArgs args)
|
||||
{
|
||||
var vm = ViewModel;
|
||||
vm.ProcessorConfig.ThresholdWidth = (int)Math.Round(((Slider)sender).Value);
|
||||
}
|
||||
|
||||
private void SldThreshold2_OnDragCompleted(object sender, DragCompletedEventArgs args)
|
||||
{
|
||||
var vm = ViewModel;
|
||||
vm.ProcessorConfig.ThresholdHeight = (int)Math.Round(((Slider)sender).Value);
|
||||
}
|
||||
|
||||
|
||||
private void SldBorder_OnDragCompleted(object sender, DragCompletedEventArgs e)
|
||||
{
|
||||
var vm = ViewModel;
|
||||
vm.ProcessorConfig.Border = (int)Math.Round(((Slider)sender).Value);
|
||||
}
|
||||
DataContext = new ImageViewModel();
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
|
||||
public ImageView(MagickImage image)
|
||||
{
|
||||
DataContext = new ImageViewModel(image);
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void SldThreshold1_OnDragCompleted(object sender, DragCompletedEventArgs args)
|
||||
{
|
||||
var vm = ViewModel;
|
||||
vm.ProcessorConfig.ThresholdWidth = (int)Math.Round(((Slider)sender).Value);
|
||||
}
|
||||
|
||||
private void SldThreshold2_OnDragCompleted(object sender, DragCompletedEventArgs args)
|
||||
{
|
||||
var vm = ViewModel;
|
||||
vm.ProcessorConfig.ThresholdHeight = (int)Math.Round(((Slider)sender).Value);
|
||||
}
|
||||
|
||||
|
||||
private void SldBorder_OnDragCompleted(object sender, DragCompletedEventArgs e)
|
||||
{
|
||||
var vm = ViewModel;
|
||||
vm.ProcessorConfig.Border = (int)Math.Round(((Slider)sender).Value);
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,16 @@
|
||||
using GUI.ViewModels;
|
||||
using System.Windows;
|
||||
|
||||
namespace GUI.Views
|
||||
namespace GUI.Views;
|
||||
|
||||
/// <summary>
|
||||
/// Interaction logic for LogView.xaml
|
||||
/// </summary>
|
||||
public partial class LogView : Window
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for LogView.xaml
|
||||
/// </summary>
|
||||
public partial class LogView : Window
|
||||
public LogView(LoggingCollection loggingCollection)
|
||||
{
|
||||
public LogView(LoggingCollection loggingCollection)
|
||||
{
|
||||
InitializeComponent();
|
||||
DataContext = new LogViewModel(loggingCollection);
|
||||
}
|
||||
InitializeComponent();
|
||||
DataContext = new LogViewModel(loggingCollection);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user