public DeskbandTestWindow(
        ILoggerFactory loggerFactory,
        LogLevelSignal logLevelSignal,
        IAppSettingsService appSettingsService,
        CrossProcessSignal processSignal)
    {
        if (loggerFactory == null)
        {
            throw new ArgumentNullException(nameof(loggerFactory));
        }

        this._logLevelSignal     = logLevelSignal ?? throw new ArgumentNullException(nameof(logLevelSignal));
        this._appSettingsService = appSettingsService
                                   ?? throw new ArgumentNullException(nameof(appSettingsService));
        this._processSignal = processSignal ?? throw new ArgumentNullException(nameof(processSignal));
        this._log           = loggerFactory.CreateLogger(this.GetType().Name);

        this.InitializeComponent();

        this._control = new DeskbandControl(loggerFactory);
        this.Content  = this._control;

        this.Reload();
        this._control.Loaded += this.HandleControlLoaded;
    }
Esempio n. 2
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);
        }
    }