/// <summary> /// Treats an event in the UI Thread. It calls the method corresponding to the event type /// </summary> /// <param name="e">event arguments</param> private void TreatFilenameTestEvent(nsHashCreator.MYPFilenameTestEventArgs e) { switch (e.State) { case Event_FilenameTestType.TestFinished: { hashCreator.event_FilenameTest -= FilenameTestEventHandler; OperationFinished(); if (e.Value != 0) MessageBox.Show("You just found " + e.Value + " new filenames.", "Newly found filenames!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); else MessageBox.Show("No new filenames.", "No new filenames", MessageBoxButtons.OK, MessageBoxIcon.Information); break; } case Event_FilenameTestType.TestRunning: { statusPB.Value += (int)e.Value; break; } case Event_FilenameTestType.PatternRunning: { lblGeneratePat.Text = e.Value.ToString() + " %"; break; } case Event_FilenameTestType.PatternFinished: { lblGeneratePat.Text = "Done"; if (e.Value != 0) { patternDic.SaveHashList("Hash/PatternDic.txt"); hashDic.MergeHashList("Hash/PatternDic.txt"); MessageBox.Show("Pattern Matching just found " + e.Value + " new filenames.", "Newly found filenames!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else MessageBox.Show("No new filenames through Pattern matching.", "No new filenames", MessageBoxButtons.OK, MessageBoxIcon.Information); hashCreator.event_FilenameTest -= FilenameTestEventHandler; t_GeneratePat = null; break; } } }
/// <summary> /// Receive all events related to the file table entries /// </summary> /// <param name="sender">sender</param> /// <param name="e">event args</param> private void FilenameTestEventHandler(object sender, nsHashCreator.MYPFilenameTestEventArgs e) { //Check if an invoke is required by selecting a random component //that might be updated by this event if (label_NumOfFiles_Value.InvokeRequired) { Invoke(OnNewFilenameTestEvent, e); } else { TreatFilenameTestEvent(e); } }