public ModalLogManagementInterface(
     IConfigurationSource configurationSource,
     IModalDisplay modalDisplay,
     IPowerLogManager powerLogManager,
     IEventDispatcher viewEventDispatcher)
 {
     _configurationSource = configurationSource.Require(nameof(configurationSource));
     _modalDisplay        = modalDisplay.Require(nameof(modalDisplay));
     _powerLogManager     = powerLogManager.Require(nameof(powerLogManager));
     _viewEventDispatcher = viewEventDispatcher.Require(nameof(viewEventDispatcher));
 }
Beispiel #2
0
        public LogManagementModalViewModel(
            IConfigurationSource configurationSource,
            IPowerLogManager powerLogManager,
            IEventDispatcher viewEventDispatcher)
        {
            _configurationSource = configurationSource.Require(nameof(configurationSource));
            _powerLogManager     = powerLogManager.Require(nameof(powerLogManager));
            _viewEventDispatcher = viewEventDispatcher.Require(nameof(viewEventDispatcher));

            Task.Run(
                async() =>
            {
                _logViewModels =
                    new ObservableCollection <SavedLogViewModel>(
                        (await _powerLogManager.GetSavedLogs().ConfigureAwait(false))
                        .OrderByDescending(__savedLog => __savedLog.Timestamp)
                        .Select(__savedLog => CreateSavedLogViewModel(__savedLog)));

                PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(LogViewModels)));
            });

            _viewEventHandlers.Add(
                new DelegateEventHandler <ViewCommands.DeleteSavedLog>(
                    async __event =>
            {
                try
                {
                    await _powerLogManager.DeleteSavedLog(__event.SavedLogID);
                }
                catch (Exception)
                {
                    // error message?

                    return;
                }

                SavedLogViewModel viewModel =
                    _logViewModels
                    .FirstOrDefault(__viewModel => __viewModel.ID == __event.SavedLogID);
                if (viewModel == null)
                {
                    return;
                }

                _logViewModels.Remove(viewModel);
            }));

            _viewEventHandlers.ForEach(__handler => _viewEventDispatcher.RegisterHandler(__handler));
        }
Beispiel #3
0
        public SavedLogViewModel(
            IConfigurationSource configurationSource,
            IPowerLogManager powerLogManager,
            IEventDispatcher viewEventDispatcher,
            Guid id,
            string title,
            DateTimeOffset timestamp,
            string filePath)
        {
            configurationSource.Require(nameof(configurationSource));

            _powerLogManager     = powerLogManager.Require(nameof(powerLogManager));
            _viewEventDispatcher = viewEventDispatcher.Require(nameof(viewEventDispatcher));

            ID        = id;
            Title     = title ?? string.Empty;
            Timestamp = timestamp;
            _filePath = filePath;

            _textEditorFilePath = configurationSource.GetSettings().TextEditorFilePath;
        }