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)); }
public PowerLogEventStreamFactory( IConfigurationSource configurationSource, IEnumerable <IGameStateDebugEventParser> eventParsers, IEventDispatcher viewEventDispatcher, bool seekEndWhenFileChanges) { _configurationSource = configurationSource.Require(nameof(configurationSource)); _eventParsers = eventParsers.Require(nameof(eventParsers)); _viewEventDispatcher = viewEventDispatcher.Require(nameof(viewEventDispatcher)); _seekEndWhenFileChanges = seekEndWhenFileChanges; }
public WindowedPlayerDeckTrackerInterface( ICardInfoProvider cardInfoProvider, IConfigurationSource configurationSource, IEventDispatcherFactory eventDispatcherFactory, IEventStreamFactory eventStreamFactory, IEventDispatcher viewEventDispatcher) { _cardInfoProvider = cardInfoProvider.Require(nameof(cardInfoProvider)); _configurationSource = configurationSource.Require(nameof(configurationSource)); _eventDispatcherFactory = eventDispatcherFactory.Require(nameof(eventDispatcherFactory)); _eventStreamFactory = eventStreamFactory.Require(nameof(eventStreamFactory)); _viewEventDispatcher = viewEventDispatcher.Require(nameof(viewEventDispatcher)); }
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)); }
public ConfigurationSettingsViewModel( IBackgroundWorkInterface backgroundWorkInterface, IConfigurationSource configurationSource, IConfigurationStorage configurationStorage) { _backgroundWorkInterface = backgroundWorkInterface.Require(nameof(backgroundWorkInterface)); _configurationSource = configurationSource.Require(nameof(configurationSource)); _configurationStorage = configurationStorage.Require(nameof(configurationStorage)); Models.Client.ConfigurationSettings configurationSettings = _configurationSource.GetSettings(); CardTextOffset = configurationSettings.CardTextOffset; FontSize = configurationSettings.FontSize; _powerLogFilePath = configurationSettings.PowerLogFilePath; }
public CachingConfigurationSource( IConfigurationSource configurationSource, IEventDispatcher eventDispatcher) { _configurationSource = configurationSource.Require(nameof(configurationSource)); _eventDispatcher = eventDispatcher.Require(nameof(eventDispatcher)); _eventDispatcher.RegisterHandler( new DelegateEventHandler <ViewEvents.ConfigurationSettingsSaved>( __ => { lock (_lock) _cachedConfigurationSettings = null; })); }
public PowerLogEventStream( IConfigurationSource configurationSource, IPowerLogEventParser powerLogEventParser, IEventDispatcher viewEventDispatcher, bool seekEndWhenFileChanges) { _configurationSource = configurationSource.Require(nameof(configurationSource)); _powerLogEventParser = powerLogEventParser.Require(nameof(powerLogEventParser)); _viewEventDispatcher = viewEventDispatcher.Require(nameof(viewEventDispatcher)); _seekEndWhenFileChanges = seekEndWhenFileChanges; _filePath = _configurationSource.GetSettings().PowerLogFilePath; _eventHandlers.Add( new DelegateEventHandler <ViewEvents.ConfigurationSettingsSaved>( __event => { string newFilePath = _configurationSource.GetSettings().PowerLogFilePath; if (!newFilePath.Eq(_filePath)) { Task.Run( () => { lock (_lock) { _remainingText = null; _streamPosition = 0L; _filePath = newFilePath; if (_seekEndWhenFileChanges) { SeekEnd_(); } } }); } })); _eventHandlers.ForEach(__eventHandler => _viewEventDispatcher.RegisterHandler(__eventHandler)); }
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; }
public FileBasedPowerLogManager( AsyncSemaphore asyncMutex, IConfigurationSource configurationSource, string directoryPath, string manifestFileName, ICollectionSerializer <Models.Data.SavedLog> savedLogCollectionSerializer, IEventDispatcher viewEventDispatcher) { _asyncMutex = asyncMutex.Require(nameof(asyncMutex)); _configurationSource = configurationSource.Require(nameof(configurationSource)); _directoryPath = directoryPath.Require(nameof(directoryPath)); _manifestFileName = manifestFileName.Require(nameof(manifestFileName)); _savedLogCollectionSerializer = savedLogCollectionSerializer.Require(nameof(savedLogCollectionSerializer)); _viewEventDispatcher = viewEventDispatcher.Require(nameof(viewEventDispatcher)); _powerLogFilePath = _configurationSource.GetSettings().PowerLogFilePath; _eventHandlers.Add( new DelegateEventHandler <ViewEvents.ConfigurationSettingsSaved>( __event => _powerLogFilePath = _configurationSource.GetSettings().PowerLogFilePath)); _eventHandlers.ForEach(__eventHandler => _viewEventDispatcher.RegisterHandler(__eventHandler)); }
public TrackedCardViewModel( ICardInfoProvider cardInfoProvider, IConfigurationSource configurationSource, IEventDispatcher gameEventDispatcher, IEventDispatcher viewEventDispatcher, string cardID, int count, int?playerID = null) { _cardInfoProvider = cardInfoProvider.Require(nameof(cardInfoProvider)); _configurationSource = configurationSource.Require(nameof(configurationSource)); _gameEventDispatcher = gameEventDispatcher.Require(nameof(gameEventDispatcher)); _viewEventDispatcher = viewEventDispatcher.Require(nameof(viewEventDispatcher)); CardID = cardID; _count = count; PlayerID = playerID; _gameEventHandlers.Add( new DelegateEventHandler <GameEvents.CardAddedToDeck>( __event => { if (PlayerID.Equals(__event.PlayerID) && __event.CardID == CardID) { Count++; } })); _gameEventHandlers.Add( new DelegateEventHandler <GameEvents.CardDrawnFromDeck>( __event => { if (PlayerID.Equals(__event.PlayerID) && __event.CardID == CardID) { Count--; } })); _gameEventHandlers.Add( new DelegateEventHandler <GameEvents.CardEnteredPlayFromDeck>( __event => { if (PlayerID.Equals(__event.PlayerID) && __event.CardID == CardID) { Count--; } })); _gameEventHandlers.Add( new DelegateEventHandler <GameEvents.CardOverdrawnFromDeck>( __event => { if (PlayerID.Equals(__event.PlayerID) && __event.CardID == CardID) { Count--; } })); _gameEventHandlers.Add( new DelegateEventHandler <GameEvents.CardRemovedFromDeck>( __event => { if (PlayerID.Equals(__event.PlayerID) && __event.CardID == CardID) { Count--; } })); _gameEventHandlers.Add( new DelegateEventHandler <GameEvents.CardReturnedToDeckFromHand>( __event => { if (PlayerID.Equals(__event.PlayerID) && __event.CardID == CardID) { Count++; } })); _gameEventHandlers.Add( new DelegateEventHandler <GameEvents.MulliganOptionPresented>( __event => { if (__event.CardID == CardID) { Count--; } })); _gameEventHandlers.Add( new DelegateEventHandler <GameEvents.PlayerDetermined>( __event => PlayerID = __event.PlayerID)); _gameEventHandlers.ForEach(__handler => _gameEventDispatcher.RegisterHandler(__handler)); _viewEventHandlers.Add( new DelegateEventHandler <ViewEvents.ConfigurationSettingsSaved>( __event => { PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(CardTextOffset))); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(FontSize))); })); _viewEventHandlers.ForEach(__handler => _viewEventDispatcher.RegisterHandler(__handler)); }
public PlayerDeckTrackerViewModel( ICardInfoProvider cardInfoProvider, IConfigurationSource configurationSource, IEventDispatcher gameEventDispatcher, IEventDispatcher viewEventDispatcher, Models.Client.Decklist decklist) { _cardInfoProvider = cardInfoProvider.Require(nameof(cardInfoProvider)); _configurationSource = configurationSource.Require(nameof(configurationSource)); _gameEventDispatcher = gameEventDispatcher.Require(nameof(gameEventDispatcher)); _viewEventDispatcher = viewEventDispatcher.Require(nameof(viewEventDispatcher)); _decklist = decklist; Reset(); _gameEventHandlers.Add( new DelegateEventHandler <GameEvents.CardAddedToDeck>( __event => { if (!_playerID.Equals(__event.PlayerID)) { return; } if (_trackedCardViewModels.Any(__trackedCardViewModel => __trackedCardViewModel.CardID.Eq(__event.CardID))) { return; } int?playerID = _trackedCardViewModels.First()?.PlayerID; _trackedCardViewModels.Add(CreateCardViewModel(__event.CardID, 1, playerID)); _trackedCardViewModels = _trackedCardViewModels .OrderBy(__trackedCardViewModel => __trackedCardViewModel.Cost) .ThenBy(__trackedCardViewModel => __trackedCardViewModel.Name) .ToList(); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(TrackedCardViewModels))); PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(Count))); })); _gameEventHandlers.Add( new DelegateEventHandler <GameEvents.GameStarted>( __ => Reset())); _gameEventHandlers.Add( new DelegateEventHandler <GameEvents.OpponentCoinLost>( __ => OpponentCoinStatus = false)); _gameEventHandlers.Add( new DelegateEventHandler <GameEvents.OpponentReceivedCoin>( __ => OpponentCoinStatus = true)); _gameEventHandlers.Add( new DelegateEventHandler <GameEvents.PlayerDetermined>( __event => _playerID = __event.PlayerID)); _gameEventHandlers.ForEach(__handler => _gameEventDispatcher.RegisterHandler(__handler)); _viewEventHandlers.Add( new DelegateEventHandler <ViewEvents.ConfigurationSettingsSaved>( __ => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(FontSize))))); _viewEventHandlers.ForEach(__handler => _viewEventDispatcher.RegisterHandler(__handler)); }