Esempio n. 1
0
        // Directory processing progress change events...
        private void ProcessDirectory_ProgressChanged(object sender, ProgressChangedEventArgs e)
        {
            // Convert UserStatet and calculate progress...
            PackageProgress progress      = e.UserState as PackageProgress;
            double          ProgressValue = (((double)e.ProgressPercentage / ProgressMaxCounter) * 100);

            // Send progress to ProgressBar...
            UpdateProgressBar1(ProgressValue);

            // Update Progress TextLabel...
            UpdateProgressTextLabel("Processing: " + progress.FileInfos.Name);

            List <IResourceIndexEntry> indexEntries = progress.Package.GetResourceList;

            // Update the fileviewer...
            foreach (var resource in indexEntries)
            {
                string[] TGI = resource.ToString().Split('-');
                UpdatePackageView(new PackageViewList()
                {
                    PackageName      = Path.GetFileNameWithoutExtension(progress.FileInfos.Name),
                    PackageType      = progress.FileInfos.Extension,
                    PackageCreated   = progress.FileInfos.CreationTime,
                    PackageEdited    = progress.FileInfos.LastWriteTime,
                    ResourceTag      = resource.ToString(),
                    ResourceType     = TGI[0],
                    ResourceGroup    = TGI[1],
                    ResourceInstance = TGI[2],
                    ConflictDetected = progress.Conflict
                });
            }
        }
Esempio n. 2
0
        private void ProcessDirectory_DoWork(object sender, DoWorkEventArgs e)
        {
            // Reset counters and progress bar...
            ProgressCurrentCounter = 0;
            ProgressMaxCounter     = 0;

            // Check selected path for files and index them...
            try
            {
                // Add all files from selected patch and subfolders to FileInfo List...
                SourceFilesList = new DirectoryInfo(SourcePath).GetFiles("*.*", SearchOption.AllDirectories).ToList();

                // Count files for the progress calculation...
                ProgressMaxCounter = SourceFilesList.Count;

                // Index files and resources...
                foreach (FileInfo file in SourceFilesList)
                {
                    if ((file.Attributes & FileAttributes.Directory) != 0)
                    {
                        continue;
                    }
                    {
                        // Index all Sims Package files...
                        if (file.Extension == ".package" | file.Extension == ".sim3pack")
                        {
                            IPackage package = Package.OpenPackage(1, file.FullName);
                            PackageFilesList.Add(file);
                            ProgressCurrentCounter++;

                            PackageProgress progress = new PackageProgress()
                            {
                                Package   = package,
                                FileInfos = file,
                                Conflict  = "Nej"
                            };

                            (sender as BackgroundWorker).ReportProgress(ProgressCurrentCounter, progress);
                        }

                        // Index all Sims 4 script files and count...
                        else if (file.Extension == ".ts4script")
                        {
                            ScriptFilesList.Add(file);
                            ProgressCurrentCounter++;
                            (sender as BackgroundWorker).ReportProgress(ProgressCurrentCounter,
                                                                        new PackageProgress()
                            {
                                FileInfos = file,
                                Conflict  = "Nej"
                            });
                        }

                        // Index all not accepted files...
                        else
                        {
                            NotAcceptedFileTypes.Add(file);
                            ProgressCurrentCounter++;
                        }
                    }
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Der opstod en uventet fejl!");
            }
        }