コード例 #1
0
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                String currentContuor = comboBox1.SelectedItem.ToString();

                if (currentContuor == "Triangles")
                {
                    imageBox2.Image = Drawer.drawContour(imageBox1.Image,
                                                         ContourFinder.getTriangles(
                                                             ContourFinder.findApproxContours(imageBox1.Image, int.Parse(textBox1.Text)),
                                                             int.Parse(textBox2.Text)
                                                             )
                                                         );
                }
                if (currentContuor == "Rectangles")
                {
                    imageBox2.Image = Drawer.drawContour(imageBox1.Image,
                                                         ContourFinder.getRectangles(
                                                             ContourFinder.findApproxContours(imageBox1.Image, int.Parse(textBox1.Text)),
                                                             int.Parse(textBox2.Text)
                                                             )
                                                         );
                }
                if (currentContuor == "Circles")
                {
                    imageBox2.Image = Drawer.drawContour(imageBox1.Image, ContourFinder.getCircles(imageBox1.Image, int.Parse(textBox1.Text)));
                }
            }
            catch (FormatException ex)
            {
                MessageBox.Show(ex.Message, "Fromat Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            catch (NullReferenceException ex)
            {
                MessageBox.Show(ex.Message, "Null Reference Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }