public MarkdownAccessoryViewModel(
            IImgurService imgurService,
            IMediaPickerFactory mediaPicker,
            IAlertDialogFactory alertDialogFactory,
            IDefaultValueService defaultValueService)
        {
            PostToImgurCommand = ReactiveCommand.CreateAsyncTask(async _ => {
                if (!defaultValueService.GetOrDefault(IMGUR_UPLOAD_WARN, false))
                {
                    defaultValueService.Set(IMGUR_UPLOAD_WARN, true);
                    await alertDialogFactory.Alert("Please Read!", IMGUR_UPLOAD_WARN_MESSAGE);
                }

                var photo        = await mediaPicker.PickPhoto();
                var memoryStream = new MemoryStream();
                await photo.Save(Splat.CompressedBitmapFormat.Jpeg, 0.8f, memoryStream);
                using (alertDialogFactory.Activate("Uploading..."))
                {
                    var model = await imgurService.SendImage(memoryStream.ToArray());
                    if (model == null || model.Data == null || model.Data.Link == null)
                    {
                        throw new InvalidOperationException("Unable to upload to Imgur. Please try again later.");
                    }
                    return(model.Data.Link);
                }
            });

            PostToImgurCommand.ThrownExceptions
            .Where(x => !(x is TaskCanceledException))
            .Subscribe(x => alertDialogFactory.Alert("Upload Error", x.Message));
        }
        public MarkdownAccessoryViewModel(
            IImgurService imgurService, 
            IMediaPickerFactory mediaPicker, 
            IAlertDialogFactory alertDialogFactory,
            IDefaultValueService defaultValueService)
        {
            PostToImgurCommand = ReactiveCommand.CreateAsyncTask(async _ => {
                if (!defaultValueService.GetOrDefault(IMGUR_UPLOAD_WARN, false))
                {
                    defaultValueService.Set(IMGUR_UPLOAD_WARN, true);
                    await alertDialogFactory.Alert("Please Read!", IMGUR_UPLOAD_WARN_MESSAGE);
                }

                var photo = await mediaPicker.PickPhoto();
                var memoryStream = new MemoryStream();
                await photo.Save(Splat.CompressedBitmapFormat.Jpeg, 0.8f, memoryStream);
                using (alertDialogFactory.Activate("Uploading..."))
                {
                    var model = await imgurService.SendImage(memoryStream.ToArray());
                    if (model == null || model.Data == null || model.Data.Link == null)
                        throw new InvalidOperationException("Unable to upload to Imgur. Please try again later.");
                    return model.Data.Link;
                }
            });

            PostToImgurCommand.ThrownExceptions
                .Where(x => !(x is TaskCanceledException))
                .Subscribe(x => alertDialogFactory.Alert("Upload Error", x.Message));
        }
示例#3
0
 public ChefController(
     IChefService chefService,
     IMapper mapper,
     IImgurService imgurService)
 {
     this._chefService  = chefService;
     this._mapper       = mapper;
     this._imgurService = imgurService;
 }
示例#4
0
 public GistCommentViewModel(IApplicationService applicationService, IImgurService imgurService,
                             IMediaPickerFactory mediaPicker, IAlertDialogFactory alertDialogFactory)
     : base(imgurService, mediaPicker, alertDialogFactory)
 {
     Title       = "Add Comment";
     SaveCommand = ReactiveCommand.CreateAsyncTask(
         this.WhenAnyValue(x => x.Text).Select(x => !string.IsNullOrEmpty(x)),
         async t => await applicationService.GitHubClient.Gist.Comment.Create(int.Parse(Id), Text));
     SaveCommand.Subscribe(x => Dismiss());
 }
示例#5
0
 public IssueCommentViewModel(IApplicationService applicationService, IImgurService imgurService,
                              IMediaPickerFactory mediaPicker, IAlertDialogFactory alertDialogFactory)
     : base(imgurService, mediaPicker, alertDialogFactory)
 {
     Title       = "Add Comment";
     SaveCommand = ReactiveCommand.CreateAsyncTask(
         this.WhenAnyValue(x => x.Text).Select(x => !string.IsNullOrEmpty(x)),
         t => applicationService.GitHubClient.Issue.Comment.Create(RepositoryOwner, RepositoryName, Id, Text));
     SaveCommand.Subscribe(x => Dismiss());
 }
示例#6
0
 public TrickController(
     ITrickService trickService,
     IMapper mapper,
     IImgurService imgurService,
     UserManager <ApplicationUser> userManager)
     : base(userManager)
 {
     this._trickService = trickService;
     this._mapper       = mapper;
     this._imgurService = imgurService;
 }
        public FeedbackComposerViewModel(
            IApplicationService applicationService, IImgurService imgurService,
            IMediaPickerFactory mediaPicker, IAlertDialogFactory alertDialogService)
        {
            this.WhenAnyValue(x => x.IsFeature).Subscribe(x => Title = x ? "New Feature" : "Bug Report");

            SubmitCommand = ReactiveCommand.CreateAsyncTask(
                this.WhenAnyValue(x => x.Subject).Select(x => !string.IsNullOrEmpty(x)),
                async _ =>
            {
                if (string.IsNullOrEmpty(Subject))
                {
                    throw new ArgumentException(string.Format("You must provide a title for this {0}!", IsFeature ? "feature" : "bug"));
                }

                var labels       = await applicationService.GitHubClient.Issue.Labels.GetForRepository(CodeHubOwner, CodeHubName);
                var createLabels = labels.Where(x => string.Equals(x.Name, IsFeature ? "feature request" : "bug", StringComparison.OrdinalIgnoreCase)).Select(x => x.Name).Distinct();

                var createIssueRequest = new Octokit.NewIssue(Subject)
                {
                    Body = Description
                };
                foreach (var label in createLabels)
                {
                    createIssueRequest.Labels.Add(label);
                }
                var createdIssue = await applicationService.GitHubClient.Issue.Create(CodeHubOwner, CodeHubName, createIssueRequest);

                _createdIssueSubject.OnNext(createdIssue);
                Dismiss();
            });

            PostToImgurCommand = ReactiveCommand.CreateAsyncTask(async _ =>
            {
                var photo        = await mediaPicker.PickPhoto();
                var memoryStream = new MemoryStream();
                await photo.Save(Splat.CompressedBitmapFormat.Jpeg, 0.8f, memoryStream);
                using (alertDialogService.Activate("Uploading..."))
                {
                    var model = await imgurService.SendImage(memoryStream.ToArray());
                    if (model == null || model.Data == null || model.Data.Link == null)
                    {
                        throw new InvalidOperationException("Unable to upload to Imgur. Please try again later.");
                    }
                    return(model.Data.Link);
                }
            });

            PostToImgurCommand.ThrownExceptions
            .Where(x => !(x is TaskCanceledException))
            .Subscribe(x => alertDialogService.Alert("Upload Error", x.Message));
        }
 public RecipeController(
     ICategoryService categoryService,
     IRecipeService recipeService,
     IMapper mapper,
     IImgurService imgurService,
     UserManager <ApplicationUser> userManager)
     : base(userManager)
 {
     this._categoryService = categoryService;
     this._recipeService   = recipeService;
     this._mapper          = mapper;
     this._imgurService    = imgurService;
 }
示例#9
0
 public CommitCommentViewModel(IApplicationService applicationService, IImgurService imgurService,
                               IMediaPickerFactory mediaPicker, IAlertDialogFactory alertDialogFactory)
     : base(imgurService, mediaPicker, alertDialogFactory)
 {
     SaveCommand = ReactiveCommand.CreateAsyncTask(
         this.WhenAnyValue(x => x.Text).Select(x => !string.IsNullOrEmpty(x)),
         t =>
     {
         var commitComment = new Octokit.NewCommitComment(Text);
         return(applicationService.GitHubClient.Repository.RepositoryComments.Create(RepositoryOwner, RepositoryName, Node, commitComment));
     });
     SaveCommand.Subscribe(x => Dismiss());
 }
示例#10
0
        public PullRequestCommentViewModel(IApplicationService applicationService, IImgurService imgurService,
                                           IMediaPickerFactory mediaPicker, IAlertDialogFactory alertDialogFactory)
            : base(imgurService, mediaPicker, alertDialogFactory)
        {
            Title       = "Add Comment";
            SaveCommand = ReactiveCommand.CreateAsyncTask(
                this.WhenAnyValue(x => x.Text).Select(x => !string.IsNullOrEmpty(x)),
                t =>
            {
                var req = new Octokit.PullRequestReviewCommentCreate(Text, null, null, 0);
                return(applicationService.GitHubClient.PullRequest.Comment.Create(RepositoryOwner, RepositoryName, Id, req));
            });

            SaveCommand.Subscribe(x => Dismiss());
        }
示例#11
0
 protected MarkdownComposerViewModel(IImgurService imgurService, IMediaPickerFactory mediaPicker, IAlertDialogFactory alertDialogFactory)
 {
     PostToImgurCommand = ReactiveCommand.CreateAsyncTask(async _ =>
     {
         var photo        = await mediaPicker.PickPhoto();
         var memoryStream = new MemoryStream();
         await photo.Save(Splat.CompressedBitmapFormat.Jpeg, 0.8f, memoryStream);
         using (alertDialogFactory.Activate("Uploading..."))
         {
             var model = await imgurService.SendImage(memoryStream.ToArray());
             if (model == null || model.Data == null || model.Data.Link == null)
             {
                 throw new InvalidOperationException("Unable to upload to Imgur. Please try again later.");
             }
             return(model.Data.Link);
         }
     });
 }
示例#12
0
 public BotService(
     IServiceScopeFactory scopeFactory,
     IRedditService redditService,
     IImageService imageService,
     IImgurService imgurService,
     IConfiguration configuration,
     ILogger <BotService> logger,
     IOptions <ThreadingConfiguration> options,
     IMapper mapper)
 {
     _scopeFactory  = scopeFactory;
     _redditService = redditService;
     _imageService  = imageService;
     _imgurService  = imgurService;
     _configuration = configuration;
     _options       = options.Value;
     _logger        = logger;
     _mapper        = mapper;
 }
示例#13
0
        public MarkdownAccessoryViewModel(
            IImgurService imgurService      = null,
            IMedia mediaPicker              = null,
            IAlertDialogService alertDialog = null)
        {
            imgurService = imgurService ?? Locator.Current.GetService <IImgurService>();
            mediaPicker  = mediaPicker ?? Plugin.Media.CrossMedia.Current;
            alertDialog  = alertDialog ?? Locator.Current.GetService <IAlertDialogService>();

            PostToImgurCommand = ReactiveCommand.CreateFromTask(async _ => {
                if (!Settings.HasSeenImgurUploadWarn)
                {
                    Settings.HasSeenImgurUploadWarn = true;
                    await alertDialog.Alert("Please Read!", IMGUR_UPLOAD_WARN_MESSAGE);
                }

                var photo = await mediaPicker.PickPhotoAsync(new PickMediaOptions
                {
                    CompressionQuality = 80
                });

                var memoryStream = new MemoryStream();
                await photo.GetStream().CopyToAsync(memoryStream);

                using (alertDialog.Activate("Uploading..."))
                {
                    var model = await imgurService.SendImage(memoryStream.ToArray());
                    if (model == null || model.Data == null || model.Data.Link == null)
                    {
                        throw new InvalidOperationException("Unable to upload to Imgur. Please try again later.");
                    }
                    return(model.Data.Link);
                }
            });

            PostToImgurCommand.ThrownExceptions
            .Where(x => !(x is TaskCanceledException))
            .Subscribe(x => alertDialog.Alert("Upload Error", x.Message));
        }
示例#14
0
 public ImageHandler(IBotService botService, IImgurService imgurService) : base(botService)
 {
     _imgurService = imgurService;
 }
示例#15
0
 public UpdateService(IBotService botService, IImgurService imgurService, ILogger <UpdateService> logger) : base(botService, imgurService, logger)
 {
     _botService   = botService;
     _imgurService = imgurService;
     _logger       = logger;
 }
 public AuthenticationController(ISettingsService settingsService, IImgurService imgurService)
 {
     this.settingsService = settingsService;
     this.imgurService = imgurService;
 }