// Find a phrase at a given point, for mouse collision etc. PhraseRect GetPhraseAtPoint(Point Location) { // It's important to select the last occurrance in the list, since that'll be the one most recently // added or clicked, thus it's on the top of the Z stack. if (PhraseRects.Count() < 1) { return(null); } List <PhraseRect> FoundRects = PhraseRects.FindAll(x => x.Location.Contains(Location)); if (FoundRects.Count() < 1) { return(null); } return(FoundRects.Last()); }
// Use the above code to generate phraserects public void MakeAutoPhrases() { if (PhraseRects.Count() > 0) { switch (MessageBox.Show("Do you want to clear phrases before running the autophraser?", "Existing phrases", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning)) { case (DialogResult.Yes): PhraseRects.Clear(); break; case (DialogResult.Cancel): return; } } foreach (Rectangle rect in AutoPhraseRects(OCRResult.smallBoxes)) { PhraseRects.Add(new PhraseRect(rect, OCRResult, PhraseRectMode.contains, this, AsyncTranslation_callback)); } }