Esempio n. 1
0
        private void Start()
        {
            if (IsRunning_)
            {
                MessageBox.Show("Please Wait Compress Process...", "System", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (string.IsNullOrWhiteSpace(InputDirectoryPath_))
            {
                MessageBox.Show("Please Select Input Directory Path", "System", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (string.IsNullOrWhiteSpace(OutputDirectoryPath_))
            {
                MessageBox.Show("Please Select Output Directory Path", "System", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            IsRunning_           = true;
            TotalFileCount_      = 1;
            CompressedFileCount_ = 1;
            TotalFileSize_       = 1;
            CompressedFileSize_  = 1;
            SetLabel(LabelInfo, "Waiting...");

            ListFiles.Items.Clear();
            Log("Begin");

            var InputFileList = new List <string>();

            StartStatisticsFile(InputDirectoryPath_, InputFileList, () =>
            {
                if (InputFileList.Count == 0)
                {
                    Log("End");
                    IsRunning_ = false;
                    return;
                }

                var TempDirectoryPath = $"{OutputDirectoryPath_}temp/";
                Log($"Copy {InputDirectoryPath_} -> {TempDirectoryPath}");

                StartCopyFileList(InputDirectoryPath_, TempDirectoryPath, InputFileList, () =>
                {
                    var TempFileList = new List <string>();
                    foreach (var FilePath in InputFileList)
                    {
                        TempFileList.Add(PathHelper.GetFilePathWithRootPath(FilePath, InputDirectoryPath_, TempDirectoryPath));
                    }

                    StartCompressed(TempDirectoryPath, OutputDirectoryPath_, TempFileList, () =>
                    {
                        PathHelper.DeleteDirectory(TempDirectoryPath);
                        Log("End");
                        SetLabel(LabelInfo, "Done");
                        IsRunning_ = false;
                        ConfigHelper.SaveConfig();
                        MessageBox.Show($"Compressed Succeed\nCompressed File Count: {CompressedFileCount_}/{TotalFileCount_}\nCompressed File Size : {CompressedFileSize_}/{TotalFileSize_} - {((double)CompressedFileSize_ / (double)TotalFileSize_ * 100.0d):00.00}%");
                    });
                });
            });
        }