Beispiel #1
0
    protected override void OnStartup(StartupEventArgs e)
    {
        if (e == null)
        {
            throw new ArgumentNullException(nameof(e));
        }

        try
        {
            base.OnStartup(e);

            var appSettingsService = new AppSettingsService();
            var processSignal      = new CrossProcessSignal(IAppSettingsService.ReloadEventName);

            if (e.Args.FirstOrDefault() == "deskband-test")
            {
                this._loggerFactory = LoggerConfiguration.CreateLoggerFactory(
                    LogLevel.Information,
                    appSettingsService.GetLogFilePath("DeskbandTest"),
                    this._logLevelSignal);
                this._log = this._loggerFactory.CreateLogger(this.GetType().Name);

                this.MainWindow = new DeskbandTestWindow(
                    this._loggerFactory,
                    this._logLevelSignal,
                    appSettingsService,
                    processSignal);
            }
            else
            {
                this._loggerFactory = LoggerConfiguration.CreateLoggerFactory(
                    LogLevel.Information,
                    appSettingsService.GetLogFilePath("Settings"),
                    this._logLevelSignal);
                this._log = this._loggerFactory.CreateLogger(this.GetType().Name);

                this.MainWindow = new SettingsWindow(
                    this._loggerFactory,
                    this._logLevelSignal,
                    appSettingsService,
                    processSignal);
            }

            this.MainWindow.Show();
        }
        catch (Exception ex)
        {
            this._log?.LogError(ex, "MonBand initialization failed");
            MessageBox.Show(
                ex.Message,
                "MonBand initialization failed",
                MessageBoxButton.OK,
                MessageBoxImage.Error);
        }
    }