Add project files.
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using TheXamlGuy.Framework.Camera;
|
||||
using TheXamlGuy.Framework.Core;
|
||||
|
||||
namespace WeddingBooth.LifeCycles
|
||||
{
|
||||
public class CapturedHandler : IMediatorHandler<Captured>
|
||||
{
|
||||
private readonly IHostEnvironment hostEnvironment;
|
||||
|
||||
public CapturedHandler(IHostEnvironment hostEnvironment)
|
||||
{
|
||||
this.hostEnvironment = hostEnvironment;
|
||||
}
|
||||
|
||||
public void Handle(Captured request)
|
||||
{
|
||||
if (request.Photo is Bitmap bitmap)
|
||||
{
|
||||
using Bitmap writableBitmap = new(bitmap);
|
||||
string directory = Path.Combine(hostEnvironment.ContentRootPath, "Photos");
|
||||
Directory.CreateDirectory(directory);
|
||||
|
||||
ImageCodecInfo encoder = ImageCodecInfo.GetImageEncoders().First(x => x.FormatID == ImageFormat.Jpeg.Guid);
|
||||
EncoderParameters encoderParameters = new() { Param = new[] { new EncoderParameter(Encoder.Quality, 100L) } };
|
||||
writableBitmap.Save($"{directory}\\{DateTime.Now:MMddyyyy-HHmmss}.jpg", encoder, encoderParameters);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace WeddingBooth.LifeCycles
|
||||
{
|
||||
public class NavigationConfiguration : List<string>
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
using TheXamlGuy.Framework.Core;
|
||||
using TheXamlGuy.Framework.WPF;
|
||||
using WeddingBooth.Views;
|
||||
|
||||
namespace WeddingBooth.LifeCycles
|
||||
{
|
||||
|
||||
public class NavigationNavigatedHandler : IMediatorHandler<Navigated<NavigationView, NavigationViewModel>>
|
||||
{
|
||||
private readonly NavigationConfiguration configuration;
|
||||
|
||||
public NavigationNavigatedHandler(NavigationConfiguration configuration)
|
||||
{
|
||||
this.configuration = configuration;
|
||||
}
|
||||
|
||||
public void Handle(Navigated<NavigationView, NavigationViewModel> request)
|
||||
{
|
||||
foreach (string navigation in configuration)
|
||||
{
|
||||
switch (navigation)
|
||||
{
|
||||
case "Welcome":
|
||||
request.DataContext?.Add<WelcomeViewModel>();
|
||||
break;
|
||||
case "SeatingChart":
|
||||
request.DataContext?.Add<SeatingChartViewModel>();
|
||||
break;
|
||||
case "Camera":
|
||||
request.DataContext?.Add<CameraViewModel>();
|
||||
break;
|
||||
case "Gallery":
|
||||
request.DataContext?.Add<GalleryViewModel>();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using TheXamlGuy.Framework.Core;
|
||||
using WeddingBooth.Views;
|
||||
using WpfScreenHelper;
|
||||
|
||||
namespace WeddingBooth.LifeCycles
|
||||
{
|
||||
public class StartedHandler : IMediatorHandler<Started>
|
||||
{
|
||||
private readonly StartupConfiguration configuration;
|
||||
private readonly MainWindow window;
|
||||
private readonly MainWindowViewModel viewModel;
|
||||
|
||||
public StartedHandler(StartupConfiguration configuration,
|
||||
MainWindow window,
|
||||
MainWindowViewModel viewModel)
|
||||
{
|
||||
this.configuration = configuration;
|
||||
this.window = window;
|
||||
this.viewModel = viewModel;
|
||||
}
|
||||
|
||||
public void Handle(Started request)
|
||||
{
|
||||
window.DataContext = viewModel;
|
||||
window.Show();
|
||||
|
||||
if (configuration.Display is string display)
|
||||
{
|
||||
Screen? screen = Screen.AllScreens.FirstOrDefault(x => x.DeviceName.Contains(display, System.StringComparison.InvariantCultureIgnoreCase)) ?? Screen.AllScreens.FirstOrDefault();
|
||||
if (screen is not null)
|
||||
{
|
||||
window.Left = screen.Bounds.Left;
|
||||
window.Top = screen.Bounds.Top;
|
||||
window.Width = screen.Bounds.Width;
|
||||
window.Height = screen.Bounds.Height;
|
||||
}
|
||||
|
||||
if (configuration.FullScreen)
|
||||
{
|
||||
window.WindowState = WindowState.Maximized;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace WeddingBooth.LifeCycles
|
||||
{
|
||||
public class StartupConfiguration
|
||||
{
|
||||
public bool FullScreen { get; set; }
|
||||
|
||||
public string? Display { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace WeddingBooth.LifeCycles
|
||||
{
|
||||
public class Table
|
||||
{
|
||||
public string? Name { get; set; }
|
||||
|
||||
public List<string> Guests { get; set; } = new List<string>();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user