diff --git a/XLAB.sln b/XLAB.sln index 50ba80c..9379f38 100644 --- a/XLAB.sln +++ b/XLAB.sln @@ -5,20 +5,54 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XLAB.DATA", "XLAB.DATA\XLAB EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XLAB", "XLAB\XLAB.csproj", "{B8DAAB84-777A-4274-8452-E602DB1AF587}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XLAB2", "XLAB2\XLAB2.csproj", "{6B248955-05FF-43E9-B038-5CD501D21442}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {AE0E35D7-DFA4-4150-9889-255043B232BB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {AE0E35D7-DFA4-4150-9889-255043B232BB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AE0E35D7-DFA4-4150-9889-255043B232BB}.Debug|x64.ActiveCfg = Debug|Any CPU + {AE0E35D7-DFA4-4150-9889-255043B232BB}.Debug|x64.Build.0 = Debug|Any CPU + {AE0E35D7-DFA4-4150-9889-255043B232BB}.Debug|x86.ActiveCfg = Debug|Any CPU + {AE0E35D7-DFA4-4150-9889-255043B232BB}.Debug|x86.Build.0 = Debug|Any CPU {AE0E35D7-DFA4-4150-9889-255043B232BB}.Release|Any CPU.ActiveCfg = Release|Any CPU {AE0E35D7-DFA4-4150-9889-255043B232BB}.Release|Any CPU.Build.0 = Release|Any CPU + {AE0E35D7-DFA4-4150-9889-255043B232BB}.Release|x64.ActiveCfg = Release|Any CPU + {AE0E35D7-DFA4-4150-9889-255043B232BB}.Release|x64.Build.0 = Release|Any CPU + {AE0E35D7-DFA4-4150-9889-255043B232BB}.Release|x86.ActiveCfg = Release|Any CPU + {AE0E35D7-DFA4-4150-9889-255043B232BB}.Release|x86.Build.0 = Release|Any CPU {B8DAAB84-777A-4274-8452-E602DB1AF587}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B8DAAB84-777A-4274-8452-E602DB1AF587}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B8DAAB84-777A-4274-8452-E602DB1AF587}.Debug|x64.ActiveCfg = Debug|Any CPU + {B8DAAB84-777A-4274-8452-E602DB1AF587}.Debug|x64.Build.0 = Debug|Any CPU + {B8DAAB84-777A-4274-8452-E602DB1AF587}.Debug|x86.ActiveCfg = Debug|Any CPU + {B8DAAB84-777A-4274-8452-E602DB1AF587}.Debug|x86.Build.0 = Debug|Any CPU {B8DAAB84-777A-4274-8452-E602DB1AF587}.Release|Any CPU.ActiveCfg = Release|Any CPU {B8DAAB84-777A-4274-8452-E602DB1AF587}.Release|Any CPU.Build.0 = Release|Any CPU + {B8DAAB84-777A-4274-8452-E602DB1AF587}.Release|x64.ActiveCfg = Release|Any CPU + {B8DAAB84-777A-4274-8452-E602DB1AF587}.Release|x64.Build.0 = Release|Any CPU + {B8DAAB84-777A-4274-8452-E602DB1AF587}.Release|x86.ActiveCfg = Release|Any CPU + {B8DAAB84-777A-4274-8452-E602DB1AF587}.Release|x86.Build.0 = Release|Any CPU + {6B248955-05FF-43E9-B038-5CD501D21442}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6B248955-05FF-43E9-B038-5CD501D21442}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6B248955-05FF-43E9-B038-5CD501D21442}.Debug|x64.ActiveCfg = Debug|Any CPU + {6B248955-05FF-43E9-B038-5CD501D21442}.Debug|x64.Build.0 = Debug|Any CPU + {6B248955-05FF-43E9-B038-5CD501D21442}.Debug|x86.ActiveCfg = Debug|Any CPU + {6B248955-05FF-43E9-B038-5CD501D21442}.Debug|x86.Build.0 = Debug|Any CPU + {6B248955-05FF-43E9-B038-5CD501D21442}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6B248955-05FF-43E9-B038-5CD501D21442}.Release|Any CPU.Build.0 = Release|Any CPU + {6B248955-05FF-43E9-B038-5CD501D21442}.Release|x64.ActiveCfg = Release|Any CPU + {6B248955-05FF-43E9-B038-5CD501D21442}.Release|x64.Build.0 = Release|Any CPU + {6B248955-05FF-43E9-B038-5CD501D21442}.Release|x86.ActiveCfg = Release|Any CPU + {6B248955-05FF-43E9-B038-5CD501D21442}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/XLAB.slnx b/XLAB.slnx index 5b5d087..6da51ee 100644 --- a/XLAB.slnx +++ b/XLAB.slnx @@ -1,4 +1,5 @@ + diff --git a/XLAB2/App.xaml b/XLAB2/App.xaml new file mode 100644 index 0000000..f66582e --- /dev/null +++ b/XLAB2/App.xaml @@ -0,0 +1,189 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/XLAB2/App.xaml.cs b/XLAB2/App.xaml.cs new file mode 100644 index 0000000..4da3e08 --- /dev/null +++ b/XLAB2/App.xaml.cs @@ -0,0 +1,72 @@ +using System; +using System.Globalization; +using System.Threading; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Markup; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using XLAB2.Infrastructure; + +namespace XLAB2 +{ + public partial class App : Application + { + private IHost _host; + + public App() + { + ApplyRussianCulture(); + } + + protected override async void OnStartup(StartupEventArgs e) + { + base.OnStartup(e); + + try + { + _host = AppHost.Create(); + await _host.StartAsync().ConfigureAwait(true); + + MainWindow = _host.Services.GetRequiredService(); + MainWindow.Show(); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "XLAB2", MessageBoxButton.OK, MessageBoxImage.Error); + Shutdown(-1); + } + } + + protected override async void OnExit(ExitEventArgs e) + { + if (_host != null) + { + try + { + await _host.StopAsync(TimeSpan.FromSeconds(5)).ConfigureAwait(true); + } + finally + { + _host.Dispose(); + } + } + + base.OnExit(e); + } + + private static void ApplyRussianCulture() + { + var culture = new CultureInfo("ru-RU"); + + CultureInfo.DefaultThreadCurrentCulture = culture; + CultureInfo.DefaultThreadCurrentUICulture = culture; + Thread.CurrentThread.CurrentCulture = culture; + Thread.CurrentThread.CurrentUICulture = culture; + + FrameworkElement.LanguageProperty.OverrideMetadata( + typeof(FrameworkElement), + new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(culture.IetfLanguageTag))); + } + } +} diff --git a/XLAB2/AppHost.cs b/XLAB2/AppHost.cs new file mode 100644 index 0000000..c1d748f --- /dev/null +++ b/XLAB2/AppHost.cs @@ -0,0 +1,36 @@ +using System; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using XLAB2.Infrastructure; + +namespace XLAB2 +{ + internal static class AppHost + { + public static IHost Create() + { + return Host.CreateDefaultBuilder() + .UseContentRoot(AppContext.BaseDirectory) + .ConfigureAppConfiguration((context, config) => + { + config.Sources.Clear(); + config.SetBasePath(AppContext.BaseDirectory); + config.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true); + config.AddEnvironmentVariables(); + }) + .ConfigureServices((_, services) => + { + services.AddSingleton(_ => SqlServerConnectionFactory.Current); + services.AddTransient(); + services.AddTransient(provider => new MainWindow(provider.GetRequiredService())); + }) + .UseDefaultServiceProvider((_, options) => + { + options.ValidateOnBuild = true; + options.ValidateScopes = true; + }) + .Build(); + } + } +} diff --git a/XLAB2/AssemblyInfo.cs b/XLAB2/AssemblyInfo.cs new file mode 100644 index 0000000..cc29e7f --- /dev/null +++ b/XLAB2/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/XLAB2/CloneVerificationWindow.xaml b/XLAB2/CloneVerificationWindow.xaml new file mode 100644 index 0000000..dec575d --- /dev/null +++ b/XLAB2/CloneVerificationWindow.xaml @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + + + + +