Пример #1
0
        private void imageButton_Click(object sender, EventArgs e)
        {
            if (ip != null)
            {
                ip.Dispose();
            }

            string filePath = "";

            using (var openFileDialog = new OpenFileDialog())
            {
                openFileDialog.Filter           = "Pictures (*.jpg)|*.jpg|All files (*.*)|*.*";
                openFileDialog.FilterIndex      = 1;
                openFileDialog.RestoreDirectory = true;

                if (openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    filePath = openFileDialog.FileName;
                }
            }

            ip = new ImageProcessor();
            ip.CaptureChanged += myEventHandler;
            ip.startCapture(ImageProcessor.LOAD_IMG);
            ip.FrameWidth = 40;
            ip.ImgPath    = filePath;
            label2.Text   = "" + ip.FrameWidth;
            currentWalls  = new Wall[]
            {
                new Wall {
                    StartPosition = new Point()
                    {
                        X = 100, Y = 100
                    }, EndPosition = new Point()
                    {
                        X = 600, Y = 700
                    }
                },
                new Wall {
                    StartPosition = new Point()
                    {
                        X = 100, Y = 100
                    }, EndPosition = new Point()
                    {
                        X = 600, Y = 700
                    }
                },
                new Wall {
                    StartPosition = new Point()
                    {
                        X = 100, Y = 100
                    }, EndPosition = new Point()
                    {
                        X = 600, Y = 700
                    }
                },
                new Wall {
                    StartPosition = new Point()
                    {
                        X = 100, Y = 100
                    }, EndPosition = new Point()
                    {
                        X = 600, Y = 700
                    }
                },
                new Wall {
                    StartPosition = new Point()
                    {
                        X = 100, Y = 100
                    }, EndPosition = new Point()
                    {
                        X = 600, Y = 700
                    }
                },
            };
            currentGems = new Gem[]
            {
                new Gem {
                    Position = new Point {
                        X = 100, Y = 100
                    }
                },
                new Gem {
                    Position = new Point {
                        X = 100, Y = 100
                    }
                },
            };
        }
Пример #2
0
        private void cameraButton_Click(object sender, EventArgs e)
        {
            if (ip != null)
            {
                ip.Dispose();
            }
            if (cameraPicker.Items.Count == 0)
            {
                System.Windows.Forms.MessageBox.Show("Please, connect a camera!");
                return;
            }

            int selectedCamera = cameraPicker.SelectedIndex;

            if (cameraPicker.Items.Count < 0)
            {
                System.Windows.Forms.MessageBox.Show("Please, select a camera!");
                return;
            }
            ip = new ImageProcessor();
            ip.CaptureChanged += myEventHandler;
            ip.startCapture(ImageProcessor.LOAD_FROM_CAMERA);
            ip.FrameWidth  = 40;
            ip.CameraIndex = selectedCamera;

            label2.Text  = "" + ip.FrameWidth;
            currentWalls = new Wall[]
            {
                new Wall {
                    StartPosition = new Point()
                    {
                        X = 100, Y = 100
                    }, EndPosition = new Point()
                    {
                        X = 600, Y = 700
                    }
                },
                new Wall {
                    StartPosition = new Point()
                    {
                        X = 100, Y = 100
                    }, EndPosition = new Point()
                    {
                        X = 600, Y = 700
                    }
                },
                new Wall {
                    StartPosition = new Point()
                    {
                        X = 100, Y = 100
                    }, EndPosition = new Point()
                    {
                        X = 600, Y = 700
                    }
                },
                new Wall {
                    StartPosition = new Point()
                    {
                        X = 100, Y = 100
                    }, EndPosition = new Point()
                    {
                        X = 600, Y = 700
                    }
                },
                new Wall {
                    StartPosition = new Point()
                    {
                        X = 100, Y = 100
                    }, EndPosition = new Point()
                    {
                        X = 600, Y = 700
                    }
                },
            };
            currentGems = new Gem[]
            {
                new Gem {
                    Position = new Point {
                        X = 100, Y = 100
                    }
                },
                new Gem {
                    Position = new Point {
                        X = 100, Y = 100
                    }
                },
            };
        }