private void newToolStripMenuItem_Click(object sender, EventArgs e) { if (SaveLibraryDialog.ShowDialog() != DialogResult.OK) { return; } if (_library != null) { _library.Close(); } _library = new MLibrary(SaveLibraryDialog.FileName); PreviewListView.VirtualListSize = 0; }
private void countBlanksToolStripMenuItem_Click(object sender, EventArgs e) { OpenLibraryDialog.Multiselect = true; if (OpenLibraryDialog.ShowDialog() != DialogResult.OK) { OpenLibraryDialog.Multiselect = false; return; } OpenLibraryDialog.Multiselect = false; MLibrary.Load = false; int count = 0; for (int i = 0; i < OpenLibraryDialog.FileNames.Length; i++) { MLibrary library = new MLibrary(OpenLibraryDialog.FileNames[i]); for (int x = 0; x < library.Count; x++) { if (library.Images[x].Length <= 8) { count++; } } library.Close(); } MLibrary.Load = true; MessageBox.Show(count.ToString()); }
public static void ProcessDir(string sourceDir, int recursionLvl, string outputDir) { if (recursionLvl <= HowDeepToScan) { // Process the list of files found in the directory. string[] fileEntries = Directory.GetFiles(sourceDir); foreach (string fileName in fileEntries) { if (Directory.Exists(outputDir) != true) Directory.CreateDirectory(outputDir); MLibraryv0 OldLibrary = new MLibraryv0(fileName); MLibrary NewLibrary = new MLibrary(outputDir + Path.GetFileName(fileName)) { Images = new List<MLibrary.MImage>(), IndexList = new List<int>(), Count = OldLibrary.Images.Count }; ; for (int i = 0; i < OldLibrary.Images.Count; i++) NewLibrary.Images.Add(null); for (int j = 0; j < OldLibrary.Images.Count; j++) { MLibraryv0.MImage oldimage = OldLibrary.GetMImage(j); NewLibrary.Images[j] = new MLibrary.MImage(oldimage.FBytes,oldimage.Width, oldimage.Height) { X = oldimage.X, Y = oldimage.Y }; } NewLibrary.Save(); for (int i = 0; i < NewLibrary.Images.Count; i++) { if (NewLibrary.Images[i].Preview != null) NewLibrary.Images[i].Preview.Dispose(); if (NewLibrary.Images[i].Image != null) NewLibrary.Images[i].Image.Dispose(); if (NewLibrary.Images[i].MaskImage != null) NewLibrary.Images[i].MaskImage.Dispose(); } for (int i = 0; i < OldLibrary.Images.Count; i++) { if (OldLibrary.Images[i].Preview != null) OldLibrary.Images[i].Preview.Dispose(); if (OldLibrary.Images[i].Image != null) OldLibrary.Images[i].Image.Dispose(); } NewLibrary.Images.Clear(); NewLibrary.IndexList.Clear(); OldLibrary.Images.Clear(); OldLibrary.IndexList.Clear(); NewLibrary.Close(); OldLibrary.Close(); NewLibrary = null; OldLibrary = null; } // Recurse into subdirectories of this directory. string[] subdirEntries = Directory.GetDirectories(sourceDir); foreach (string subdir in subdirEntries) { // Do not iterate through reparse points if (Path.GetFileName(Path.GetFullPath(subdir).TrimEnd(Path.DirectorySeparatorChar)) == Path.GetFileName(Path.GetFullPath(outputDir).TrimEnd(Path.DirectorySeparatorChar))) continue; if ((File.GetAttributes(subdir) & FileAttributes.ReparsePoint) != FileAttributes.ReparsePoint) ProcessDir(subdir, recursionLvl + 1, outputDir + " \\" + Path.GetFileName(Path.GetFullPath(subdir).TrimEnd(Path.DirectorySeparatorChar)) + "\\"); } } }
private void countBlanksToolStripMenuItem_Click(object sender, EventArgs e) { OpenLibraryDialog.Multiselect = true; if (OpenLibraryDialog.ShowDialog() != DialogResult.OK) { OpenLibraryDialog.Multiselect = false; return; } OpenLibraryDialog.Multiselect = false; MLibrary.Load = false; int count = 0; for (int i = 0; i < OpenLibraryDialog.FileNames.Length; i++) { MLibrary library = new MLibrary(OpenLibraryDialog.FileNames[i]); for (int x = 0; x < library.Count; x++) { if (library.Images[x].Length <= 8) count++; } library.Close(); } MLibrary.Load = true; MessageBox.Show(count.ToString()); }
public static void ProcessDir(string sourceDir, int recursionLvl, string outputDir) { if (recursionLvl <= HowDeepToScan) { // Process the list of files found in the directory. string[] fileEntries = Directory.GetFiles(sourceDir); foreach (string fileName in fileEntries) { if (Path.GetExtension(fileName) != ".lib") { continue; } if (Directory.Exists(outputDir) != true) { Directory.CreateDirectory(outputDir); } MLibraryv0 OldLibrary = new MLibraryv0(fileName); MLibrary NewLibrary = new MLibrary(outputDir + Path.GetFileName(fileName)) { Images = new List <MLibrary.MImage>(), IndexList = new List <int>(), Count = OldLibrary.Images.Count };; for (int i = 0; i < OldLibrary.Images.Count; i++) { NewLibrary.Images.Add(null); } for (int j = 0; j < OldLibrary.Images.Count; j++) { MLibraryv0.MImage oldimage = OldLibrary.GetMImage(j); NewLibrary.Images[j] = new MLibrary.MImage(oldimage.FBytes, oldimage.Width, oldimage.Height) { X = oldimage.X, Y = oldimage.Y }; } NewLibrary.Save(); for (int i = 0; i < NewLibrary.Images.Count; i++) { if (NewLibrary.Images[i].Preview != null) { NewLibrary.Images[i].Preview.Dispose(); } if (NewLibrary.Images[i].Image != null) { NewLibrary.Images[i].Image.Dispose(); } if (NewLibrary.Images[i].MaskImage != null) { NewLibrary.Images[i].MaskImage.Dispose(); } } for (int i = 0; i < OldLibrary.Images.Count; i++) { if (OldLibrary.Images[i].Preview != null) { OldLibrary.Images[i].Preview.Dispose(); } if (OldLibrary.Images[i].Image != null) { OldLibrary.Images[i].Image.Dispose(); } } NewLibrary.Images.Clear(); NewLibrary.IndexList.Clear(); OldLibrary.Images.Clear(); OldLibrary.IndexList.Clear(); NewLibrary.Close(); OldLibrary.Close(); NewLibrary = null; OldLibrary = null; } // Recurse into subdirectories of this directory. string[] subdirEntries = Directory.GetDirectories(sourceDir); foreach (string subdir in subdirEntries) { // Do not iterate through reparse points if (Path.GetFileName(Path.GetFullPath(subdir).TrimEnd(Path.DirectorySeparatorChar)) == Path.GetFileName(Path.GetFullPath(outputDir).TrimEnd(Path.DirectorySeparatorChar))) { continue; } if ((File.GetAttributes(subdir) & FileAttributes.ReparsePoint) != FileAttributes.ReparsePoint) { ProcessDir(subdir, recursionLvl + 1, outputDir + " \\" + Path.GetFileName(Path.GetFullPath(subdir).TrimEnd(Path.DirectorySeparatorChar)) + "\\"); } } } }
private void Form1_DragDrop(object sender, DragEventArgs e) { string[] files = (string[])e.Data.GetData(DataFormats.FileDrop); if (Path.GetExtension(files[0]).ToUpper() == ".WIL" || Path.GetExtension(files[0]).ToUpper() == ".WZL" || Path.GetExtension(files[0]).ToUpper() == ".MIZ") { try { ParallelOptions options = new ParallelOptions { MaxDegreeOfParallelism = 8 }; Parallel.For(0, files.Length, options, i => { if (Path.GetExtension(files[i]) == ".wtl") { WTLLibrary WTLlib = new WTLLibrary(files[i]); WTLlib.ToMLibrary(); } else { WeMadeLibrary WILlib = new WeMadeLibrary(files[i]); WILlib.ToMLibrary(); } toolStripProgressBar.Value++; }); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } toolStripProgressBar.Value = 0; MessageBox.Show( string.Format("Successfully converted {0} {1}", (OpenWeMadeDialog.FileNames.Length).ToString(), (OpenWeMadeDialog.FileNames.Length > 1) ? "libraries" : "library")); } else if (Path.GetExtension(files[0]).ToUpper() == ".LIB") { ClearInterface(); ImageList.Images.Clear(); PreviewListView.Items.Clear(); _indexList.Clear(); if (_library != null) { _library.Close(); } _library = new MLibrary(files[0]); PreviewListView.VirtualListSize = _library.Images.Count; PreviewListView.RedrawItems(0, PreviewListView.Items.Count - 1, true); // Show .Lib path in application title. this.Text = files[0].ToString(); } else { return; } }