public MainWindowViewModel() { obSettingsService = SP.GetService <OpenBulletSettingsService>(); configService = SP.GetService <ConfigService>(); configService.OnConfigSelected += (sender, config) => { OnPropertyChanged(nameof(IsConfigSelected)); ConfigSelected?.Invoke(config); }; }
public MainWindow() { vm = new MainWindowViewModel(); DataContext = vm; Closing += vm.OnWindowClosing; InitializeComponent(); labels = new TextBlock[] { menuOptionAbout, menuOptionConfigs, menuOptionConfigSettings, menuOptionCSharpCode, menuOptionHits, menuOptionHome, menuOptionJobs, menuOptionLoliCode, menuOptionLoliScript, menuOptionMetadata, menuOptionMonitor, menuOptionOBSettings, menuOptionPlugins, menuOptionProxies, menuOptionReadme, menuOptionRLSettings, menuOptionStacker, menuOptionWordlists }; // Pages to initialize as soon as the program starts. This is done to reduce the loading time // when clicking on them, as it can be frustrating for the user on specific pages. configsPage = new(); updateService = SP.GetService <UpdateService>(); Title = $"OpenBullet 2 - {updateService.CurrentVersion} [{updateService.CurrentVersionType}]"; // Set the theme var obSettingsService = SP.GetService <OpenBulletSettingsService>(); var customization = obSettingsService.Settings.CustomizationSettings; SetTheme(customization); }
public App() { Dispatcher.UnhandledException += OnDispatcherUnhandledException; TaskScheduler.UnobservedTaskException += OnTaskException; Directory.CreateDirectory("UserData"); var builder = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true); var serviceCollection = new ServiceCollection(); serviceCollection.AddTransient <IConfiguration>(_ => builder.Build()); ConfigureServices(serviceCollection); serviceProvider = serviceCollection.BuildServiceProvider(); SP.Init(serviceProvider); config = SP.GetService <IConfiguration>(); var workerThreads = config.GetSection("Resources").GetValue("WorkerThreads", 1000); var ioThreads = config.GetSection("Resources").GetValue("IOThreads", 1000); var connectionLimit = config.GetSection("Resources").GetValue("ConnectionLimit", 1000); ThreadPool.SetMinThreads(workerThreads, ioThreads); ServicePointManager.DefaultConnectionLimit = connectionLimit; // Apply DB migrations or create a DB if it doesn't exist using (var serviceScope = serviceProvider.GetService <IServiceScopeFactory>().CreateScope()) { var context = serviceScope.ServiceProvider.GetRequiredService <ApplicationDbContext>(); context.Database.Migrate(); } // Load the configs var configService = serviceProvider.GetService <ConfigService>(); configService.ReloadConfigs().Wait(); AutocompletionProvider.Init(); }