///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// private void rightImage_MouseDown(object sender, MouseEventArgs e) { Color pointColor = ((Bitmap) rightImage.Image).GetPixel(e.X, e.Y); if (pointColor.ToArgb() == Color.Red.ToArgb()) { return; } colorToFill = generateNewColor(); int currentLineNumber = 0; bool found = false; foreach (int key in numberAndPointCorrespondence.Keys) { List<Point> currentList = numberAndPointCorrespondence[key]; foreach (Point currentPoint in currentList) { if ((e.X == currentPoint.X) && (e.Y == currentPoint.Y)) { currentLineNumber = key; found = true; break; } } if (found == true) { break; } } ImageProcessor.floodImage(e.X, e.Y, colorToFill, rightImage.Image, true, Color.Red); rightImage.Invalidate(); rightImage.Update(); newList = new List<Point>(); BitmapData imageData = ImageProcessor.getBitmapData((Bitmap) rightImage.Image); for (int x = 0; x < phaseMapImage.Image.Width; x++) { for (int y = 0; y < phaseMapImage.Image.Height; y++) { Color currentColor = ImageProcessor.getPixel(x, y, imageData); if (currentColor.ToArgb() == colorToFill.ToArgb()) { newList.Add(new Point(x, y)); } } } ((Bitmap) rightImage.Image).UnlockBits(imageData); if (found == true) { List<Point> result = numberAndPointCorrespondence[currentLineNumber].Except(newList).ToList(); numberAndPointCorrespondence[currentLineNumber] = result; } ChooseForm chooseForm = new ChooseForm(); chooseForm.oldValue = currentLineNumber; chooseForm.userChoosedNumber += newNumber; chooseForm.ShowDialog(); }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// private void rightImage_MouseDown(object sender, MouseEventArgs e) { Color pointColor = ((Bitmap)rightImage.Image).GetPixel(e.X, e.Y); if (pointColor.ToArgb() == Color.Red.ToArgb()) { return; } colorToFill = generateNewColor(); int currentLineNumber = 0; bool found = false; foreach (int key in numberAndPointCorrespondence.Keys) { List <Point> currentList = numberAndPointCorrespondence[key]; foreach (Point currentPoint in currentList) { if ((e.X == currentPoint.X) && (e.Y == currentPoint.Y)) { currentLineNumber = key; found = true; break; } } if (found == true) { break; } } ImageProcessor.floodImage(e.X, e.Y, colorToFill, rightImage.Image, true, Color.Red); rightImage.Invalidate(); rightImage.Update(); newList = new List <Point>(); BitmapData imageData = ImageProcessor.getBitmapData((Bitmap)rightImage.Image); for (int x = 0; x < phaseMapImage.Image.Width; x++) { for (int y = 0; y < phaseMapImage.Image.Height; y++) { Color currentColor = ImageProcessor.getPixel(x, y, imageData); if (currentColor.ToArgb() == colorToFill.ToArgb()) { newList.Add(new Point(x, y)); } } } ((Bitmap)rightImage.Image).UnlockBits(imageData); if (found == true) { List <Point> result = numberAndPointCorrespondence[currentLineNumber].Except(newList).ToList(); numberAndPointCorrespondence[currentLineNumber] = result; } ChooseForm chooseForm = new ChooseForm(); chooseForm.oldValue = currentLineNumber; chooseForm.userChoosedNumber += newNumber; chooseForm.ShowDialog(); }