private void laadIn(object sender, EventArgs e) { Waterkiller.ListboxItem selected = (Waterkiller.ListboxItem)listBox1.SelectedItem; pictureBox1.ImageLocation = selected.Path; pictureBox1.SizeMode = PictureBoxSizeMode.Zoom; label1.Text = reader.ReadLevel(selected).ToString(); }
private void loadDirectory(string path) { string[] files = Directory.GetFiles(@path); List <Waterkiller.ListboxItem> formattedFiles = new List <Waterkiller.ListboxItem>(); foreach (string file in files) { Waterkiller.ListboxItem entry = new Waterkiller.ListboxItem(); entry.Title = Path.GetFileNameWithoutExtension(file); entry.Path = file; formattedFiles.Add(entry); } listBox1.DataSource = formattedFiles; }
public int ReadLevel(ListboxItem item) { Process.ProcessImage(new Image <Bgr, byte>((Bitmap)Bitmap.FromFile(item.Path))); var foundTemplates = Process.foundTemplates; int lowestNumbro = 0; int lowestNumbroBottomPosition = 0; bool orientation; // Store all them n****s List <int> bottomPositions = new List <int>(); List <String> names = new List <string>(); foreach (var found in foundTemplates) { string text = found.template.name; Rectangle foundRect = found.sample.contour.SourceBoundingRect; bottomPositions.Add(foundRect.Bottom); // Store the bottom position and name of every found object names.Add(text); if (IsDigitsOnly(text)) { int number = int.Parse(text); if ((number > 0 && number < lowestNumbro) || lowestNumbro == 0) // Look for the lowest found number that is not 0 { lowestNumbro = number; // Set the lowest number lowestNumbroBottomPosition = foundRect.Bottom; // Set the bottom position of the lowest number } } } if (lowestNumbro != 0) // If a lowest number has been found, check how many balkjes are visible beneath it { lowestNumbro *= 10; // Make it a multiple of 10 for (int i = 0; i < bottomPositions.Count; i++) // Now count how many balkjes are visible beneath it { if ((names[i].Contains("balkje") || names[i].Contains("streepje")) && bottomPositions[i] > lowestNumbroBottomPosition) { lowestNumbro -= 2; } } return(lowestNumbro); } return(000000); }