示例#1
0
        protected IServiceProvider CreateServiceProvider()
        {
            var loggerFactory = LoggerConfiguration.CreateLoggerFactory(this.Verbosity);

            return(ClientServiceConfiguration.CreateServiceProvider(
                       this.ListenEndPoint,
                       loggerFactory,
                       this.ConfigureServices));
        }
示例#2
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);
        }
    }
示例#3
0
    public Deskband()
    {
        this._appSettingsService = new AppSettingsService();
        this._logLevelSignal     = new LogLevelSignal();
        this._loggerFactory      = LoggerConfiguration.CreateLoggerFactory(
            LogLevel.Information,
            this._appSettingsService.GetLogFilePath("Deskband"),
            this._logLevelSignal);
        this._log           = this._loggerFactory.CreateLogger(this.GetType().Name);
        this._processSignal = new CrossProcessSignal(IAppSettingsService.ReloadEventName);
        this._control       = null !;

        try
        {
            var appSettings = this._appSettingsService.LoadOrCreate <SettingsModel>();
            this._logLevelSignal.Update(appSettings.LogLevel);

            this._control  = new DeskbandControl(this._loggerFactory);
            this.UIElement = this._control;

            this.Options.MinHorizontalSize = new Size(150, 30);
            this.Options.HorizontalSize    = new Size(150, 30);
            this.Options.MinVerticalSize   = new Size(60, 150);
            this.Options.VerticalSize      = new Size(60, 150);
            this.Options.Title             = "MonBand";
            this.Options.ShowTitle         = false;
            this.Options.IsFixed           = false;
            this.Options.HeightIncrement   = 1;
            this.Options.HeightCanChange   = true;

            this.Reload();
            this._control.Loaded += this.HandleControlLoaded;
        }
        catch (Exception ex)
        {
            this._log.LogError(ex, "MonBand initialization failed");
            MessageBox.Show(
                ex.ToString(),
                "Failed to load MonBand Deskband",
                MessageBoxButton.OK,
                MessageBoxImage.Error);
        }
    }