Beispiel #1
0
 private void LbCamerasSelectedIndexChanged(object sender, EventArgs e)
 {
     if (lbCameras.SelectedIndex < 0)
     {
         curDescriptor = null;
     }
     curDescriptor = (CameraSnapshotDescriptor)lbCameras.SelectedItem;
 }
Beispiel #2
0
        private void BtnAddCameraClick(object sender, EventArgs e)
        {
            if (captureInProcess)
            {
                return;
            }
            // открыть диалог выбора камеры и мишени
            // в диалоге запретить уже выбранные камеры
            var camUsed = snapshots.Select(s => s.cameraName).ToList();
            var dlg     = new PickCameraDialog(camUsed);

            if (dlg.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }

            const int markerPadding = 40;

            var snap = new CameraSnapshotDescriptor
            {
                cameraName     = dlg.SelectedCamera,
                spotDescriptor = new LazerSpot(panelSpot.BackColor, tbSpotTolerance.Text.ToInt(),
                                               tbPixelsInSpot.Text.ToInt(), tbMaxSizeOfDot.Text.ToInt()),
                resolution = dlg.FrameSize,
                ptCentre   = new Point(dlg.FrameSize.Width / 2, dlg.FrameSize.Height / 2),
                target     = targets.First(t => t.name == dlg.SelectedTarget),
                points     = new []
                {
                    new Point(markerPadding, markerPadding),
                    new Point(dlg.FrameSize.Width - markerPadding, markerPadding),
                    new Point(dlg.FrameSize.Width - markerPadding,
                              dlg.FrameSize.Height - markerPadding),
                    new Point(markerPadding, dlg.FrameSize.Height - markerPadding)
                }
            };

            snap.RecalculateCentre();
            snapshots.Add(snap);
            lbCameras.Items.Add(snap);
            lbCameras.SelectedItem = snap;
            pbFrame.Size           = dlg.FrameSize;
        }