private async void UpdatePreview() { await Task.Run(() => { const string sphereId = "__sphere"; var sphereDirectory = CarsManager.Instance.Directories.GetLocation(sphereId, true); try { using (CarsManager.Instance.IgnoreChanges()) { if (!Directory.Exists(sphereDirectory)) { Directory.CreateDirectory(sphereDirectory); using (var stream = new MemoryStream(BinaryResources.ShowroomPreviewSphere)) using (var archive = new ZipArchive(stream)) { archive.ExtractToDirectory(sphereDirectory); } } var resultDirectory = Showroom.Shot(new Showroom.ShotProperties { AcRoot = AcRootDirectory.Instance.Value, CarId = sphereId, ShowroomId = SelectedObject.Id, SkinIds = new[] { @"0" }, Filter = @"default", Mode = Showroom.ShotMode.Fixed, UseBmp = true, DisableWatermark = true, DisableSweetFx = true, MaximizeVideoSettings = true, SpecialResolution = false, Fxaa = true, FixedCameraPosition = @"-1.8,0.8,3", FixedCameraLookAt = @"0,0.5,0", FixedCameraFov = 40, TemporaryDirectory = SettingsHolder.Content.TemporaryFilesLocationValue, }); if (resultDirectory == null) { throw new Exception(AppStrings.Common_ShootingCancelled); } ImageUtils.ApplyPreview(Path.Combine(resultDirectory, "0.bmp"), SelectedObject.PreviewImage, true, null); } } catch (Exception e) { NonfatalError.Notify(AppStrings.Showroom_CannotUpdatePreview, e); } finally { if (Directory.Exists(sphereDirectory)) { Directory.Delete(sphereDirectory, true); } } }); }