Beispiel #1
0
        public async Task HandleAsync(DomainCommandContext context, LoadTextureFilesCommand command)
        {
            IEnumerable <TextureFile> files;

            try
            {
                files = _textureService.GetTextureFiles(command.DirectoryPath);
            }
            catch (DirectoryNotFoundException)
            {
                await context.EmitAsync(new ErrorOccuredNotification());

                return;
            }
            catch (PathTooLongException)
            {
                await context.EmitAsync(new ErrorOccuredNotification());

                return;
            }
            catch (SecurityException)
            {
                await context.EmitAsync(new ErrorOccuredNotification());

                return;
            }
            catch (UnauthorizedAccessException)
            {
                await context.EmitAsync(new ErrorOccuredNotification());

                return;
            }

            await context.EmitAsync(new TextureFilesLoadedNotification(files));
        }
Beispiel #2
0
        public async Task HandleAsync(DomainCommandContext context, GenerateTexturePreviewCommand command)
        {
            var settings = new TextureConversionSettings
            {
                ColorSpace   = command.ColorSpace,
                FileType     = FileType.WIC,
                MaxHeight    = command.MaxSize,
                MaxWidth     = command.MaxSize,
                OutputFormat = command.OutputFormat,
                KeepMipmaps  = false
            };

            var metadata = _textureService.GetMetadata(command.FilePath);

            if (metadata == null)
            {
                await context.EmitAsync(new ErrorOccuredNotification());
            }

            var texture = _textureService.Convert(command.FilePath, settings);

            if (texture?.Metadata == null)
            {
                await context.EmitAsync(new ErrorOccuredNotification());
            }

            await context.EmitAsync(new GeneratedTexturePreviewNotification(texture, metadata));
        }
        public async Task HandleAsync(DomainCommandContext context, ConvertTextureCommand command)
        {
            Texture texture = null;

            try
            {
                texture = _textureService.Convert(
                    Path.Combine(command.SourceDirectoryPath, command.FileName),
                    command.Settings);
            }
            catch (Exception exception)
            {
                _logger.Log(LogLevel.Error, $"texture conversion failed; exception: {exception}");
            }

            if (texture?.Metadata == null)
            {
                await context.EmitAsync(new ErrorOccuredNotification());

                return;
            }

            var directory = await _directoryRepository.LoadAsync(command.DestinationDirectoryPath);

            directory.AddFile(command.FileName, texture.Buffer);

            await _directoryRepository.SaveAsync(directory);

            await context.EmitAsync(new ActionSucceededNotification());
        }
        public async Task HandleAsync(DomainCommandContext context, AddGameProfileCommand command)
        {
            var game = await _gameRepository.LoadAsync(command.GameId);

            if (game == null)
            {
                await context.EmitAsync(new ErrorOccuredNotification());

                return;
            }

            var gameProfileTemplate = game.Profiles.SingleOrDefault(entity => entity.Id == (AggregateId)command.BasedOnGameProfileId);

            if (gameProfileTemplate == null)
            {
                await context.EmitAsync(new ErrorOccuredNotification());

                return;
            }

            var gameProfile = game.AddGameProfile(
                AggregateId.Generate(),
                command.Name,
                gameProfileTemplate.ProxyDirectoryPath,
                gameProfileTemplate.LogsDirectoryPath,
                gameProfileTemplate.PluginType,
                gameProfileTemplate.Direct3D11Settings);

            await _gameRepository.SaveAsync(game);

            await _processWatcher.WatchAsync(game.Id);

            var @event = new GameProfileAddedEvent(
                game.Id,
                game.ProfileId,
                gameProfile.Map <GameProfile>());

            await context.PublishAsync(@event);
        }
        public async Task HandleAsync(DomainCommandContext context, UpdateProxySettingsCommand command)
        {
            if (await UpdateAsync(command.ProxyPluginSettings))
            {
                var settings = await GetProxySettingsAsync();

                if (settings != null)
                {
                    await context.PublishAsync(new SharedEvent.ProxySettingsLoadedEvent(settings));

                    return;
                }
            }

            await context.EmitAsync(new ErrorOccuredNotification());
        }
Beispiel #6
0
        public async Task HandleAsync(DomainCommandContext context, LoadProxySettingsCommand command)
        {
            using (var communicator = _communicatorFactory.Create())
            {
                var result = await communicator.GetProxySettingsAsync();

                if (result.IsCompleted)
                {
                    await context.PublishAsync(new ProxySettingsLoadedEvent(result.Response.Map <ProxySettings>()));

                    return;
                }

                await context.EmitAsync(new ErrorOccuredNotification());
            }
        }