public static Task <IReadOnlyList <UpdatePreviewError> > Run(this IEnumerable <ToUpdatePreview> toUpdate, UpdatePreviewMode?mode = null, string presetFilename = null) { var list = toUpdate.ToIReadOnlyListIfItIsNot(); var actualMode = mode ?? GetAutoUpdatePreviewsDialogMode(); if (SettingsHolder.CustomShowroom.CustomShowroomPreviews) { switch (actualMode) { case UpdatePreviewMode.Options: return(CmPreviewsFormWrapper.Run(list, presetFilename)); case UpdatePreviewMode.StartManual: NonfatalError.Notify("Can’t update previews in Manual Mode with Custom Showroom", "Why would you need it anyway? Just open Custom Previews settings, locate camera the way you want and update one or all previews."); return(Task.FromResult <IReadOnlyList <UpdatePreviewError> >(null)); default: return(CmPreviewsTools.UpdatePreviewAsync(list, presetFilename)); } } var dialog = new CarUpdatePreviewsDialog(list, actualMode, presetFilename); return(Task.FromResult <IReadOnlyList <UpdatePreviewError> >(dialog.ShowDialog() ? dialog.Errors.ToList() : null)); }
private async Task PreparePreviewsAsync() { CarPreviews = Skins.ToDictionary(x => x.Id, x => Path.Combine(TemporaryLocation, $"preview_{x.Id}.jpg")); using (var op = Log?.BeginParallel("Generating previews with default look", @"Updating skin")) { await CmPreviewsTools.UpdatePreviewAsync(new[] { new ToUpdatePreview(Target, Skins.Where(x => !File.Exists(CarPreviews[x.Id])).ToList()) }, WorkshopCarSkinSubmittable.PreviewsOptions(), @"Kunos", destinationOverrideCallback : skin => CarPreviews[skin.Id], progress : op); } }