From 569b18d4ec4dccd8edd9b147fc64b2414d942559 Mon Sep 17 00:00:00 2001 From: Sergey <53861218+Stan-Kudri@users.noreply.github.com> Date: Tue, 29 Oct 2024 00:24:27 +0300 Subject: [PATCH] WatchList.WPF - Create project and add first button. (#91) * WatchList.WPF - Create project and add first button. * WatchList.WPF - Fixed Linter. --- WatchList.WPF/App.xaml | 6 ++ WatchList.WPF/App.xaml.cs | 78 +++++++++++++++++++ WatchList.WPF/AssemblyInfo.cs | 10 +++ WatchList.WPF/CinemaWindow.xaml | 31 ++++++++ WatchList.WPF/CinemaWindow.xaml.cs | 22 ++++++ WatchList.WPF/WatchList.WPF.csproj | 27 +++++++ WatchList.WPF/WindowBox/MessageBoxPage.xaml | 11 +++ .../WindowBox/MessageBoxPage.xaml.cs | 47 +++++++++++ WatchList.sln | 8 +- 9 files changed, 239 insertions(+), 1 deletion(-) create mode 100644 WatchList.WPF/App.xaml create mode 100644 WatchList.WPF/App.xaml.cs create mode 100644 WatchList.WPF/AssemblyInfo.cs create mode 100644 WatchList.WPF/CinemaWindow.xaml create mode 100644 WatchList.WPF/CinemaWindow.xaml.cs create mode 100644 WatchList.WPF/WatchList.WPF.csproj create mode 100644 WatchList.WPF/WindowBox/MessageBoxPage.xaml create mode 100644 WatchList.WPF/WindowBox/MessageBoxPage.xaml.cs diff --git a/WatchList.WPF/App.xaml b/WatchList.WPF/App.xaml new file mode 100644 index 0000000..943ca27 --- /dev/null +++ b/WatchList.WPF/App.xaml @@ -0,0 +1,6 @@ + + + diff --git a/WatchList.WPF/App.xaml.cs b/WatchList.WPF/App.xaml.cs new file mode 100644 index 0000000..b65ef12 --- /dev/null +++ b/WatchList.WPF/App.xaml.cs @@ -0,0 +1,78 @@ +using System.IO; +using System.Windows; +using Microsoft.Extensions.DependencyInjection; +using Serilog; +using Serilog.Core; +using WatchList.Core.Extension; +using WatchList.Core.Repository; +using WatchList.Core.Service; +using WatchList.Core.Service.Component; +using WatchList.Core.Service.DataLoading; +using WatchList.Migrations.SQLite; +using WatchList.WPF.WindowBox; + +namespace WatchList.WPF +{ + /// + /// Interaction logic for App.xaml + /// + public partial class App : System.Windows.Application + { + private void Application_Startup(object sender, StartupEventArgs e) + { + Log.Logger = CreateLogger(); + + try + { + Log.Information("Starting WinForms applications"); + var serviceCollection = AppServiceDI(); + serviceCollection.AddSerilog(); + + using var contain = serviceCollection.BuildServiceProvider( + new ServiceProviderOptions + { + ValidateOnBuild = true, + ValidateScopes = true, + }); + + using var scope = contain.CreateScope(); + var serviceProvider = scope.ServiceProvider; + + // Create the startup window + CinemaWindow cinemaWindow = new CinemaWindow(serviceProvider); + // Show the window + cinemaWindow.Show(); + } + catch (Exception ex) + { + Log.Fatal(ex, "Application terminated unexpectedly"); + } + finally + { + Log.CloseAndFlush(); + } + } + + private static IServiceCollection AppServiceDI() + => new ServiceCollection().AddSingleton(new DbContextFactoryMigrator("app.db")) + .AddScoped(e => e.GetRequiredService().Create()) + .AddScoped() + .AddScoped() + .AddScoped() + .AddScoped() + .AddLogging(); + + private static Logger CreateLogger(string logDirectory = "log") + { + try + { + Directory.CreateDirectory(logDirectory); + } + catch + { + } + + return logDirectory.CreateLogger(); + } + } +} diff --git a/WatchList.WPF/AssemblyInfo.cs b/WatchList.WPF/AssemblyInfo.cs new file mode 100644 index 0000000..b0ec827 --- /dev/null +++ b/WatchList.WPF/AssemblyInfo.cs @@ -0,0 +1,10 @@ +using System.Windows; + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located + //(used if a resource is not found in the page, + // or application resource dictionaries) + ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) +)] diff --git a/WatchList.WPF/CinemaWindow.xaml b/WatchList.WPF/CinemaWindow.xaml new file mode 100644 index 0000000..99536cf --- /dev/null +++ b/WatchList.WPF/CinemaWindow.xaml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/WatchList.WPF/CinemaWindow.xaml.cs b/WatchList.WPF/CinemaWindow.xaml.cs new file mode 100644 index 0000000..79424dd --- /dev/null +++ b/WatchList.WPF/CinemaWindow.xaml.cs @@ -0,0 +1,22 @@ +using System.Windows; + +namespace WatchList.WPF +{ + /// + /// Interaction logic for MainWindow.xaml + /// + public partial class CinemaWindow : Window + { + private readonly IServiceProvider _serviceProvider; + + public CinemaWindow(IServiceProvider serviceProvider) + { + _serviceProvider = serviceProvider; + InitializeComponent(); + } + + private void Button_Click(object sender, RoutedEventArgs e) + { + } + } +} diff --git a/WatchList.WPF/WatchList.WPF.csproj b/WatchList.WPF/WatchList.WPF.csproj new file mode 100644 index 0000000..c56e355 --- /dev/null +++ b/WatchList.WPF/WatchList.WPF.csproj @@ -0,0 +1,27 @@ + + + + WinExe + net7.0-windows + enable + enable + true + True + true + + + + + + + + + + + + + + + + + diff --git a/WatchList.WPF/WindowBox/MessageBoxPage.xaml b/WatchList.WPF/WindowBox/MessageBoxPage.xaml new file mode 100644 index 0000000..a1e6162 --- /dev/null +++ b/WatchList.WPF/WindowBox/MessageBoxPage.xaml @@ -0,0 +1,11 @@ + + + diff --git a/WatchList.WPF/WindowBox/MessageBoxPage.xaml.cs b/WatchList.WPF/WindowBox/MessageBoxPage.xaml.cs new file mode 100644 index 0000000..ea905d3 --- /dev/null +++ b/WatchList.WPF/WindowBox/MessageBoxPage.xaml.cs @@ -0,0 +1,47 @@ +using System.Windows.Controls; +using WatchList.Core.Model.QuestionResult; +using WatchList.Core.Service.Component; + +namespace WatchList.WPF.WindowBox +{ + /// + /// Interaction logic for MessageBoxPage.xaml + /// + public partial class MessageBoxPage : Page, IMessageBox + { + public MessageBoxPage() + { + InitializeComponent(); + } + + public Task ShowDataReplaceQuestion(string titleItem) + { + throw new NotImplementedException(); + } + + public Task ShowError(string message) + { + throw new NotImplementedException(); + } + + public Task ShowInfo(string message) + { + throw new NotImplementedException(); + } + + public Task ShowQuestion(string message) + { + throw new NotImplementedException(); + } + + public Task ShowQuestionSaveItem(string message) + { + throw new NotImplementedException(); + } + + public Task ShowWarning(string message) + { + throw new NotImplementedException(); + } + } +} diff --git a/WatchList.sln b/WatchList.sln index 45b4942..c100ca8 100644 --- a/WatchList.sln +++ b/WatchList.sln @@ -16,7 +16,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WatchList.Migrations.SQLite EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WatchList.MudBlazors", "WatchList.MudBlazors\WatchList.MudBlazors.csproj", "{F1C2F716-B695-48AF-AAAA-C05D77D2868B}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WatchList.ASP.Net.Controllers", "WatchList.ASP.Net.Controllers\WatchList.ASP.Net.Controllers.csproj", "{BD4F2A24-8EDE-4C8F-A3B8-ECBEEF78F21B}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WatchList.ASP.Net.Controllers", "WatchList.ASP.Net.Controllers\WatchList.ASP.Net.Controllers.csproj", "{BD4F2A24-8EDE-4C8F-A3B8-ECBEEF78F21B}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WatchList.WPF", "WatchList.WPF\WatchList.WPF.csproj", "{FA27F47E-F9C6-48EE-AB8C-C46B18C53E15}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -48,6 +50,10 @@ Global {BD4F2A24-8EDE-4C8F-A3B8-ECBEEF78F21B}.Debug|Any CPU.Build.0 = Debug|Any CPU {BD4F2A24-8EDE-4C8F-A3B8-ECBEEF78F21B}.Release|Any CPU.ActiveCfg = Release|Any CPU {BD4F2A24-8EDE-4C8F-A3B8-ECBEEF78F21B}.Release|Any CPU.Build.0 = Release|Any CPU + {FA27F47E-F9C6-48EE-AB8C-C46B18C53E15}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FA27F47E-F9C6-48EE-AB8C-C46B18C53E15}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FA27F47E-F9C6-48EE-AB8C-C46B18C53E15}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FA27F47E-F9C6-48EE-AB8C-C46B18C53E15}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE