public TfmPreviewFolderWBGWorker( String Dir, Common.FolderType Folder = Common.FolderType.None, Common.Gender Gender = Common.Gender.None, Common.Direction Direction = Common.Direction.None, bool CropImage = false, bool SleepThread = true, Common.OfficialMirType OfficialMirType = Common.OfficialMirType.None) { InitializeComponent(); // Cast signature variables to shared variables _dir = Dir; lbDirectory.Caption = _dir; _folder = Folder; _gender = Gender; _direction = Direction; _cropImage = CropImage; _sleepThread = SleepThread; _officialMirType = OfficialMirType; // Log output listLog.Items.Add(string.Format("<b>[{0}]</b> Process started.", DateTime.Now, _dir)); listLog.Items.Add(string.Format("Directory: <color=blue>{0}</color>", _dir)); listLog.Items.Add(string.Format("Folder Type: <color=blue>{0}</color> Gender: <color=blue>{1}</color> Direction: <color=blue>{2}</color> Official Mir Type: <color=blue>{3}</color>", _folder.ToString(), _gender.ToString(), Direction.ToString(), _officialMirType.ToString())); listLog.Items.Add(string.Format("Crop Images: <color=red>{0}</color> Sleep Thread: <color=red>{1}</color>", _cropImage.ToString(), _sleepThread.ToString())); listLog.TopIndex = listLog.Items.Count - 1; // Decide to load structured format or generic if (_folder != Common.FolderType.None && _folder != Common.FolderType.Data) { FilesCount = (ushort)Directory.GetFiles(_dir).Length; } else { Files.AddRange(Directory.GetFiles(_dir)); } // Start the asynchronous operation. if (backgroundWorker1.IsBusy != true) { startTime = DateTime.Now; // Log time for time taken log backgroundWorker1.RunWorkerAsync(); } GC.Collect(); }
private void btnPreview_Click(object sender, EventArgs e) { // Error handle if (tbDir.Text.Length == 0) { MessageBox.Show("Please select a valid folder."); return; } if (cbType.Text == string.Empty) { MessageBox.Show("Please select a valid folder type"); return; } LibraryFolder = tbDir.Text; FolderType = (Common.FolderType)Enum.Parse(typeof(Common.FolderType), cbType.Text); Gender = (Common.Gender)radioGender.EditValue; Direction = (Common.Direction)radioDirection.EditValue; CropImage = (cbListAdditional.Items[0].CheckState == CheckState.Checked) ? true : false; SleepThread = (cbListAdditional.Items[1].CheckState == CheckState.Checked) ? true : false; ReturnType = Common.ReturnTye.Preview; this.Close(); }
public TfmPreviewFolder(String Dir, Common.FolderType Folder = Common.FolderType.None, Common.Gender Gender = Common.Gender.None, Common.Direction Direction = Common.Direction.None) { InitializeComponent(); backgroundWorker1.WorkerReportsProgress = true; backgroundWorker1.WorkerSupportsCancellation = true; if (backgroundWorker1.IsBusy != true) { // Start the asynchronous operation. backgroundWorker1.RunWorkerAsync(); } FilesCount = (ushort)Directory.GetFiles(Dir).Length; // Files = Directory.GetFiles(Dir); for (int i = 0; i < FilesCount; i++) { try { //if (Files[i].EndsWith(".LIB", StringComparison.OrdinalIgnoreCase)) //{ _tempLibrary = new FileStructures.MLibraryV2(Dir + "//" + i.ToString("00") + ".Lib"); switch (Folder) { case Common.FolderType.None: // TODO: Add break; case Common.FolderType.CHumEffect: switch (Gender) { case Common.Gender.None: //string.Format("Library: {0}.Lib\r\nDatabase Effect Number: {1}", i.ToString("00"), (i+1).ToString("00")); ImageListBox.Items.Add(new ImageListBoxItem(null, string.Format("Library: {0}.Lib\r\nDatabase Effect Number: {1}", i.ToString("00"), (i + 1).ToString("00")), i, "", _tempLibrary.Images[0 + ((byte)Direction * 8)].Image)); break; case Common.Gender.Male: ImageListBox.Items.Add(new ImageListBoxItem(null, string.Format("Library: {0}.Lib\r\nDatabase Effect Number: {1}\r\nGender: Male", i.ToString("00"), (i + 1).ToString("00")), i, "", _tempLibrary.Images[0 + ((byte)Direction * 8)].Image)); break; case Common.Gender.Female: ImageListBox.Items.Add(new ImageListBoxItem(null, string.Format("Library: {0}.Lib\r\nDatabase Effect Number: {1}\r\nGender: Female", i.ToString("00"), (i + 1).ToString("00")), i, "", _tempLibrary.Images[0 + ((byte)Direction * 8) + ArmourOffset].Image)); break; case Common.Gender.Both: ImageListBox.Items.Add(new ImageListBoxItem(null, string.Format("Library: {0}.Lib\r\nDatabase Effect Number: {1}\r\nGender: Male", i.ToString("00"), (i + 1).ToString("00")), i, "", _tempLibrary.Images[0 + ((byte)Direction * 8)].Image)); ImageListBox.Items.Add(new ImageListBoxItem(null, string.Format("Library: {0}.Lib\r\nDatabase Effect Number: {1}\r\nGender: Female", i.ToString("00"), (i + 1).ToString("00")), i, "", _tempLibrary.Images[0 + ((byte)Direction * 8) + ArmourOffset].Image)); break; default: break; } break; case Common.FolderType.CArmour: switch (Gender) { case Common.Gender.None: ImageListBox.Items.Add(new ImageListBoxItem(null, "Library: " + i.ToString("00") + ".Lib", i, "", _tempLibrary.Images[0 + ((byte)Direction * 4)].Image)); break; case Common.Gender.Male: ImageListBox.Items.Add(new ImageListBoxItem(null, "Library: " + i.ToString("00") + ".Lib" + "\r\nGender: Male", i, "", _tempLibrary.Images[0 + ((byte)Direction * 4)].Image)); break; case Common.Gender.Female: ImageListBox.Items.Add(new ImageListBoxItem(null, "Library: " + i.ToString("00") + ".Lib" + "\r\nGender: Female", i, "", _tempLibrary.Images[0 + ((byte)Direction * 4) + ArmourOffset].Image)); break; case Common.Gender.Both: ImageListBox.Items.Add(new ImageListBoxItem(null, "Library: " + i.ToString("00") + ".Lib" + "\r\nGender: Male", i, "", _tempLibrary.Images[0 + ((byte)Direction * 4)].Image)); ImageListBox.Items.Add(new ImageListBoxItem(null, "Library: " + i.ToString("00") + ".Lib" + "\r\nGender: Female", i, "", _tempLibrary.Images[0 + ((byte)Direction * 4) + ArmourOffset].Image)); break; default: break; } break; case Common.FolderType.CWeapon: // TODO: Add break; case Common.FolderType.CShields: // TODO: Add break; case Common.FolderType.CWeaponEffect: // TODO: Add break; case Common.FolderType.AArmour: // TODO: Add break; case Common.FolderType.AHumEffect: // TODO: Add break; case Common.FolderType.AWeapon: // TODO: Add break; case Common.FolderType.AWeaponEffect: // TODO: Add break; case Common.FolderType.ARArmour: // TODO: Add break; case Common.FolderType.ARHumEffect: // TODO: Add break; case Common.FolderType.ARWeapon: // TODO: Add break; case Common.FolderType.ARWeaponEffect: // TODO: Add break; case Common.FolderType.NPC: ImageListBox.Items.Add(new ImageListBoxItem(null, "Library: " + i.ToString("00") + ".Lib", i, i.ToString("00"), Functions.CropImage.CropTransparent(_tempLibrary.Images[0].Image).Image)); break; default: break; } //} } catch (Exception ex) { //ErrorFiles.Add(Files[i]); continue; } finally { if (ErrorFiles.Count > 0) { MessageBox.Show(ErrorFiles.ToString()); } } GC.Collect(); } this.Text += " " + ImageListBox.Items.Count.ToString(); }