Пример #1
0
    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;
    }
Пример #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);
        }
    }
Пример #3
0
    public SettingsWindow(
        ILoggerFactory loggerFactory,
        LogLevelSignal logLevelSignal,
        IAppSettingsService appSettingsService,
        CrossProcessSignal processSignal)
    {
        this.LoggerFactory = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory));

        if (appSettingsService == null)
        {
            throw new ArgumentNullException(nameof(appSettingsService));
        }

        if (processSignal == null)
        {
            throw new ArgumentNullException(nameof(processSignal));
        }

        this.Settings = appSettingsService.LoadOrCreate <SettingsModel>();
        logLevelSignal.Update(this.Settings.LogLevel);

        this.LogLevels = Enum.GetValues(typeof(LogLevel)).Cast <LogLevel>().ToList();

        this.SaveAndApplyConfigurationCommand = new DelegateCommand(
            _ =>
        {
            this.Settings.SnmpPollers = this.SnmpMonitors.Pollers.ToList();
            this.Settings.PerformanceCounterPollers = this.PerformanceCounterMonitors.Pollers.ToList();
            appSettingsService.Save(this.Settings);
            logLevelSignal.Update(this.Settings.LogLevel);
            processSignal.Signal();
            this.Close();
        });
        this.ExitCommand = new DelegateCommand(_ => this.Close());

        this.InitializeComponent();

        this.SnmpMonitors.Pollers = new ObservableCollection <SnmpPollerConfig>(this.Settings.SnmpPollers);
        this.PerformanceCounterMonitors.Pollers =
            new ObservableCollection <PerformanceCounterPollerConfig>(this.Settings.PerformanceCounterPollers);
    }
Пример #4
0
 public App()
 {
     this._logLevelSignal = new LogLevelSignal();
 }