private void bwSortImageFolder_DoWork(object sender, DoWorkEventArgs e) { BackgroundWorker worker = sender as BackgroundWorker; var ex = new ImageMatcherSpeed(); files = ex.CheckDirDups(bwFold, ReportProgresshandler, e, worker); }
private string[] workingFolders = new string[64]; // 0-31 are source folders, 32 is dup folder, 33-63 are destination folders #endregion Fields #region Constructors //Main constructor for the form public SortImg() { InitializeComponent(); string version = Assembly.GetExecutingAssembly().GetName().Version.ToString(); this.Text = String.Format("SortImg (Ver. {0})", version); DoubleBuffered = true; is64bit = Utils.Is64BitOperatingSystem(); //Check address space for recycle bin strut construction diffrences. if (is64bit) { util64 = new Utils64(); } else { util32 = new Utils32(); } pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; tnb = new ThumbnailBuilder(); addImage = new DelegateAddImage(this.AddImage); thumbController = new ThumbnailController(); thumbController.OnStart += new ThumbnailControllerEventHandler(thumbControllerStart); thumbController.OnAdd += new ThumbnailControllerEventHandler(thumbControllerAdd); thumbController.OnEnd += new ThumbnailControllerEventHandler(thumbControllerEnd); this.KeyUp += new KeyEventHandler(Key); ImageInfo = new ToolTip(); imageMatcher = new ImageMatcherSpeed(); logger = new Logging(); buttonbuilder = new DynamicButtons(); this.Closing += new CancelEventHandler(SortImg_Closing); FileCopyedsource = new ArrayList(); FileCopyeddest = new ArrayList(); ButtonDispose = new ArrayList(); fileNameCreator = new FileNameBuilder(false); checkedTags = new List<string>(); currentTagsList = new List<string>(); selected = new List<ImageViewer>(); storedSettings = new SortImgSettings(Application.StartupPath, logger); storedSettings.loadSettings(true, true); sourceAdd = new SourceDialog(storedSettings); }
private void sortByMD5ToolStripMenuItem_Click(object sender, EventArgs e) { MessageBox.Show("Debugging Tool. MD5 hash groups will be returned on completion" + Environment.NewLine + "This might take a VERY long time with more than 100 files"); if (folderBrowserDialog1.ShowDialog() == DialogResult.OK) { if (Checkfolder(workingFolders, folderBrowserDialog1.SelectedPath) == false) { MessageBox.Show("Two chosen folders are the same. Please pick different folders"); } else { string fold = folderBrowserDialog1.SelectedPath; Dictionary<string, int> hashCounts = new Dictionary<string, int>(); ImageMatcherSpeed md5Matcher = new ImageMatcherSpeed(); ProcceingDialog proDialog = new ProcceingDialog(); ThreadStart threadDelegateMD5 = delegate { md5Matcher.CheckMD5s(fold); }; ThreadStart threadDelegateDialog = delegate { proDialog.ShowDialog(); }; Thread threadMD5 = new Thread(threadDelegateMD5); Thread threadDialog = new Thread(threadDelegateDialog); threadMD5.Start(); threadDialog.Start(); int once = 1; while (threadMD5.IsAlive) { Thread.Sleep(50); if (proDialog.cancel == true) { threadMD5.Abort(); threadDialog.Abort(); } if (once == 1 && md5Matcher.getProgressMax() >= 2) { proDialog.SetProgressMax(md5Matcher.getProgressMax()); once = 0; } proDialog.UpdateProgress(md5Matcher.getProgress()); if (md5Matcher.getProgress() == md5Matcher.getProgressMax()) { threadMD5.Join(); threadDialog.Join(); } } threadMD5.Abort(); threadDialog.Abort(); ArrayList fingerprints = md5Matcher.GetFingerprints(); int i = 0; foreach (string print in fingerprints) { int incer; if (hashCounts.TryGetValue(print, out incer)) { hashCounts[print] = incer + 1; } else { hashCounts.Add(print, 1); } i++; } ErrorDialog exp = new ErrorDialog(hashCounts); exp.StartPosition = FormStartPosition.CenterParent; if (exp.ShowDialog() == DialogResult.OK){} } } }