예제 #1
0
        private void pictureBoxDisplay_MouseUp(object sender, MouseEventArgs e)
        {
            // If we are adding a marker - get the marker radius on mouse up, add the marker
            if (_fAddingMarker)
            {
                int dx = e.X - _markerCenter.X;
                int dy = e.Y - _markerCenter.Y;
                _markerRadius = (float)Math.Sqrt(dx * dx + dy * dy);
                // Adjust for the image/display scaling (assumes proportional scaling)
                _markerCenter.X = (_markerCenter.X * _latestFrame.Width) / pictureBoxDisplay.Width;
                _markerCenter.Y = (_markerCenter.Y * _latestFrame.Height) / pictureBoxDisplay.Height;
                _markerRadius   = (_markerRadius * _latestFrame.Height) / pictureBoxDisplay.Height;
                // Add the marker
                Marker newMarker = _touchlessMgr.AddMarker("Marker #" + ++_addedMarkerCount, (Bitmap)_latestFrame, _markerCenter, _markerRadius);
                comboBoxMarkers.Items.Add(newMarker);

                // Restore the app to its normal state and clear the selection area adorment
                _fAddingMarker          = false;
                buttonMarkerAdd.Text    = "Add A New Marker";
                _markerCenter           = new Point();
                _drawSelectionAdornment = false;
                pictureBoxDisplay.Image = new Bitmap(pictureBoxDisplay.Width, pictureBoxDisplay.Height);

                // Enable the demo and marker editing
                radioButtonDemo.Enabled = true;
                buttonNext.Enabled      = true;
                comboBoxMarkers.Enabled = true;
            }
        }
예제 #2
0
파일: Form1.cs 프로젝트: gieroj/dyplom2
        private void pictureBoxDisplay_MouseUp(object sender, MouseEventArgs e)
        {
            // If we are adding a marker - get the marker radius on mouse up, add the marker
            if (_fAddingMarker)
            {
                int dx = e.X - _markerCenter.X;
                int dy = e.Y - _markerCenter.Y;
                _markerRadius = (float)Math.Sqrt(dx * dx + dy * dy);
                // Adjust for the image/display scaling (assumes proportional scaling)
                _markerCenter.X = (_markerCenter.X * _latestFrame.Width) / pictureBoxDisplay.Width;
                _markerCenter.Y = (_markerCenter.Y * _latestFrame.Height) / pictureBoxDisplay.Height;
                _markerRadius   = (_markerRadius * _latestFrame.Height) / pictureBoxDisplay.Height;
                // Add the marker
                Mark = _touchlessMgr.AddMarker("Marker #" + ++_addedMarkerCount, (Bitmap)_latestFrame, _markerCenter, _markerRadius);


                // Restore the app to its normal state and clear the selection area adorment
                _fAddingMarker          = false;
                _markerCenter           = new Point();
                _drawSelectionAdornment = false;
                pictureBoxDisplay.Image = new Bitmap(pictureBoxDisplay.Width, pictureBoxDisplay.Height);

                if (_markerSelected != null)
                {
                    // labelMarkerData.Text = _markerSelected.ToString();
                    _markerSelected.OnChange -= new EventHandler <MarkerEventArgs>(OnSelectedMouseUpdate);
                }
                //  else
                {
                    labelMarkerData.Text            = "Marker pobrał za małą gamme kolorów \nProsze sprubować ponownie dodać marker";
                    _markerSelected                 = (Marker)Mark;
                    _markerSelected.OnChange       += new EventHandler <MarkerEventArgs>(OnSelectedMouseUpdate);
                    numericUpDownMarkerThresh.Value = _markerSelected.Threshold;
                    checkBoxMarkerHighlight.Checked = Mark.Highlight;
                    checkBoxMarkerSmoothing.Checked = Mark.SmoothingEnabled;
                }
            }
        }