private void openToolStripMenuItem_Click(object sender, EventArgs e) { DialogResult result = LibraryFolderDialog.ShowDialog(); if (result != DialogResult.OK) { return; } ClearInterface(); ImageList.Images.Clear(); _indexList.Clear(); _LImageList.Clear(); PreviewListView.VirtualListSize = 0; PreviewListView.Items.Clear(); DebugBox.Clear(); folderName = LibraryFolderDialog.SelectedPath; LoadSettings form = new LoadSettings(); form.ShowDialog(); showFrontSide = form.GetFrontSide(); string Prefix = ""; if (form.GetManualPrefix()) { Prefix = form.GetPrefix(); } else { foreach (string file in Directory.EnumerateFiles(folderName, "*.lib")) { Prefix = Path.GetFileNameWithoutExtension(file); break; } } //DebugBox.Text += "Showfront: "+showFrontSide.ToString() + "\r\n"; //DebugBox.Text += "Prefix: "+Prefix + "\r\n"; Program.LoadFailed = false; MessageBox.Show("This can take a while.\n Press 'OK' to Start."); Stopwatch sw = Stopwatch.StartNew();//Timing int folderLength = Directory.GetFiles(folderName, "*.lib").Length; for (int i = 0; i < folderLength; i++) { string PathName = folderName + Path.DirectorySeparatorChar; string flName = i.ToString(Prefix) + ".lib"; string fullname = PathName + flName; if (File.Exists(fullname)) { //DebugBox.Text += fullname + "\r\n"; if (_library != null) { _library.Close(); } _library = new MLibraryV2(fullname); if (Program.LoadFailed) { break; } _NameList.Add(Path.GetFileName(fullname)); PreviewListView.VirtualListSize = ImageList.Images.Count + 1; } } sw.Stop();//Timing LibCountLabel.Text = ImageList.Images.Count.ToString(); if (ImageList.Images.Count < 1) { MessageBox.Show("No images seem to be found.\nMake sure you choose the right prefix!"); } else { MessageBox.Show("Folder processing finally finished.\nTime Taken: " + sw.Elapsed.TotalMilliseconds + "ms"); } }
private void openToolStripMenuItem_Click(object sender, EventArgs e) { DialogResult result = LibraryFolderDialog.ShowDialog(); if (result != DialogResult.OK) { return; } ClearInterface(); ImageList.Images.Clear(); _indexList.Clear(); _LImageList.Clear(); PreviewListView.VirtualListSize = 0; PreviewListView.Items.Clear(); DebugBox.Clear(); folderName = LibraryFolderDialog.SelectedPath; LoadSettings form = new LoadSettings(); form.ShowDialog(); showFrontSide = form.GetFrontSide(); string Prefix = ""; if (form.GetManualPrefix()) { Prefix = form.GetPrefix(); } else { foreach (string file in Directory.EnumerateFiles(folderName, "*.lib")) { Prefix = Path.GetFileNameWithoutExtension(file); break; } } //DebugBox.Text += "Showfront: "+showFrontSide.ToString() + "\r\n"; //DebugBox.Text += "Prefix: "+Prefix + "\r\n"; Program.LoadFailed = false; MessageBox.Show("这可能需要一段时间.\n 按“确定”开始."); Stopwatch sw = Stopwatch.StartNew();//Timing int folderLength = Directory.GetFiles(folderName, "*.lib").Length; for (int i = 0; i < folderLength; i++) { string PathName = folderName + Path.DirectorySeparatorChar; string flName = i.ToString(Prefix) + ".lib"; string fullname = PathName + flName; if (File.Exists(fullname)) { //DebugBox.Text += fullname + "\r\n"; if (_library != null) { _library.Close(); } _library = new MLibrary(fullname); if (Program.LoadFailed) { break; } _NameList.Add(Path.GetFileName(fullname)); PreviewListView.VirtualListSize = ImageList.Images.Count + 1; } } sw.Stop();//Timing LibCountLabel.Text = ImageList.Images.Count.ToString(); if (ImageList.Images.Count < 1) { MessageBox.Show("似乎没有找到任何图像.\n确保选择了正确的前缀!"); } else { MessageBox.Show("文件夹处理终于完成了.\n所用时: " + sw.Elapsed.TotalMilliseconds + "毫秒"); } }