示例#1
0
        public static async Task ApplyPreviewsAsync([NotNull] string acRoot, [NotNull] string carName, [NotNull] string source, bool resize,
                                                    [CanBeNull] AcPreviewImageInformation information,
                                                    IProgress <Tuple <string, double?> > progress = null, CancellationToken cancellation = default(CancellationToken))
        {
            var files = Directory.GetFiles(source, "*.bmp");

            for (var i = 0; i < files.Length; i++)
            {
                var file          = files[i];
                var id            = Path.GetFileNameWithoutExtension(file);
                var skinDirectory = AcPaths.GetCarSkinDirectory(acRoot, carName, id);
                if (!Directory.Exists(skinDirectory))
                {
                    continue;
                }

                progress?.Report(new Tuple <string, double?>(id, (double)i / files.Length));
                await Task.Run(() => { ApplyPreview(file, Path.Combine(skinDirectory, "preview.jpg"), resize, information); }, cancellation);

                if (cancellation.IsCancellationRequested)
                {
                    return;
                }
            }

            try {
                Directory.Delete(source);
            } catch (Exception) {
                // ignored
            }
        }
示例#2
0
 public static void ApplyPreviews([NotNull] string acRoot, [NotNull] string carName, [NotNull] string source, bool resize,
                                  [CanBeNull] AcPreviewImageInformation information)
 {
     foreach (var file in Directory.GetFiles(source, "*.bmp"))
     {
         var skinDirectory = AcPaths.GetCarSkinDirectory(acRoot, carName,
                                                         Path.GetFileNameWithoutExtension(file));
         if (!Directory.Exists(skinDirectory))
         {
             continue;
         }
         ApplyPreview(file, Path.Combine(skinDirectory, "preview.jpg"), resize, information);
     }
 }
示例#3
0
 public static string GetSfxGuidsFilename(string acRoot)
 {
     return(AcPaths.GetSfxGuidsFilename(acRoot));
 }
示例#4
0
        private static bool IsGameProcess(Process process)
        {
            var directory = Path.GetDirectoryName(process.GetFilenameSafe());

            return(directory == null || AcPaths.IsAcRoot(directory));
        }