/// <summary> /// Initializes a new instance of the <see cref="LogInfoPanelViewModel"/> class /// </summary> public LogInfoPanelViewModel(IDialogNavigationService dialogNavigationService) { this.dialogNavigationService = dialogNavigationService; this.Identifier = Guid.NewGuid(); this.LogEventInfo = new ReactiveList <LogInfoRowViewModel>(); this.data = new ListCollectionView(this.LogEventInfo); this.data.Filter = this.LogLevelFilter; this.IsInfoLogelSelected = true; this.InitializePossibleLoglevels(); this.SelectedLogLevel = LogLevel.Warn; this.logTarget = new MemoryEventTarget(); this.logTarget.EventReceived += this.LogEventReceived; CDP4SimpleConfigurator.AddTarget(this.ToString(), this.logTarget, this.SelectedLogLevel); this.WhenAnyValue(vm => vm.SelectedLogLevel) .Subscribe(logLevel => CDP4SimpleConfigurator.ChangeTargetRule(this.logTarget, this.SelectedLogLevel)); var canClear = this.LogEventInfo.CountChanged.Select(count => count > 0); this.ClearCommand = ReactiveCommand.Create(canClear); this.ClearCommand.Subscribe(_ => this.ExecuteClearLog()); var canExport = this.LogEventInfo.CountChanged.Select(count => count > 0); this.ExportCommand = ReactiveCommand.Create(canExport); this.ExportCommand.Subscribe(_ => this.ExecuteExportCommand()); this.ShowDetailsDialogCommand = ReactiveCommand.Create(); this.ShowDetailsDialogCommand.Subscribe(_ => this.ExecuteShowDetailsDialogCommand()); Observable.Merge( this.WhenAnyValue(vm => vm.IsFatalLogelSelected), this.WhenAnyValue(vm => vm.IsErrorLogelSelected), this.WhenAnyValue(vm => vm.IsWarnLogelSelected), this.WhenAnyValue(vm => vm.IsInfoLogelSelected), this.WhenAnyValue(vm => vm.IsDebugLogelSelected), this.WhenAnyValue(vm => vm.IsTraceLogelSelected)) .Subscribe(_ => { this.data.Filter = this.LogLevelFilter; }); }
public ShellViewModel(IDialogNavigationService dialogNavigationService, DockLayoutViewModel dockViewModel) { if (dialogNavigationService == null) { throw new ArgumentNullException(nameof(dialogNavigationService), "The dialogNavigationService may not be null"); } this.OpenSessions = new ReactiveList <ISession>(); this.OpenSessions.ChangeTrackingEnabled = true; this.OpenSessions.CountChanged.Select(x => x != 0).ToProperty(this, x => x.HasSession, out this.hasSession); CDPMessageBus.Current.Listen <SessionEvent>().Subscribe(this.SessionChangeEventHandler); this.dialogNavigationService = dialogNavigationService; this.DockViewModel = dockViewModel; this.Title = "COMET IME - Community Edition"; this.logTarget = new MemoryEventTarget(); this.logTarget.EventReceived += this.LogEventReceived; // Shall be done only once in the whole application CDP4SimpleConfigurator.AddTarget(this.ToString(), this.logTarget, LogLevel.Info); this.Sessions = new ReactiveList <SessionViewModel>(); this.Sessions.ChangeTrackingEnabled = true; this.Sessions.ItemChanged.Where(x => x.PropertyName == "IsClosed" && x.Sender.IsClosed) .Subscribe(x => this.Sessions.Remove(x.Sender)); this.Sessions.ItemChanged.Where(x => x.PropertyName == "IsClosed" && x.Sender.IsClosed) .Subscribe(x => this.CheckIfItIsSelectedSession(x.Sender)); this.Sessions.CountChanged.Subscribe(x => this.HasSessions = x != 0); this.OpenDataSourceCommand = ReactiveCommand.Create(); this.OpenDataSourceCommand.Subscribe(_ => this.ExecuteOpenDataSourceRequest()); this.SaveSessionCommand = ReactiveCommand.Create(); this.SaveSessionCommand.Subscribe(_ => this.ExecuteSaveSessionCommand()); this.OpenProxyConfigurationCommand = ReactiveCommand.Create(); this.OpenProxyConfigurationCommand.Subscribe(_ => this.ExecuteOpenProxyConfigurationCommand()); this.OpenUriManagerCommand = ReactiveCommand.Create(); this.OpenUriManagerCommand.Subscribe(_ => this.ExecuteOpenUriManagerRequest()); this.OpenPluginManagerCommand = ReactiveCommand.Create(); this.OpenPluginManagerCommand.Subscribe(_ => this.ExecuteOpenPluginManagerRequest()); this.OpenSelectIterationsCommand = ReactiveCommand.Create(this.WhenAnyValue(x => x.HasSessions)); this.OpenSelectIterationsCommand.Subscribe(s => this.ExecuteOpenSelectIterationsCommand(s as ISession)); this.CloseIterationsCommand = ReactiveCommand.Create(this.WhenAnyValue(x => x.HasOpenIterations)); this.CloseIterationsCommand.Subscribe(_ => this.ExecuteCloseIterationsCommand()); this.OpenDomainSwitchDialogCommand = ReactiveCommand.Create(this.WhenAnyValue(x => x.HasOpenIterations)); this.OpenDomainSwitchDialogCommand.Subscribe(_ => this.ExecuteOpenDomainSwitchDialogCommand()); this.WhenAnyValue(x => x.SelectedSession) .Select(x => (x != null)) .ToProperty(this, x => x.IsSessionSelected, out this.isSessionSelected); this.SelectedSession = null; this.OpenLogDialogCommand = ReactiveCommand.Create(); this.OpenLogDialogCommand.Subscribe(_ => this.ExecuteOpenLogDialog()); this.OpenAboutCommand = ReactiveCommand.Create(); this.OpenAboutCommand.Subscribe(_ => this.ExecuteOpenAboutRequest()); this.subscription = CDPMessageBus.Current.Listen <IsBusyEvent>() .ObserveOn(RxApp.MainThreadScheduler) .Subscribe(x => { this.IsBusy = x.IsBusy; this.LoadingMessage = x.Message; }); this.CheckForUpdateCommand = ReactiveCommand.Create(); this.CheckForUpdateCommand.Subscribe(_ => this.ExecuteCheckForUpdateCommand()); this.OnClosingCommand = ReactiveCommand.CreateAsyncTask(async x => this.OnClosing(x as CancelEventArgs), RxApp.MainThreadScheduler); logger.Info("Welcome in the COMET Application"); }