Ejemplo n.º 1
0
        private void gestureSurface_Click(object sender, EventArgs e)
        {
            _recording = !_recording;

            if (_recording)
            {
                _factory = new GestureFactory();
                _factory.Start(_mousePos);
                _path = new GraphicsPath();
                gestureSurface.BackColor = Color.OrangeRed;
                eventList.Items.Clear();
            }
            else
            {
                _gesture = _factory.Finish();
                _recognition = new Recognition(_gesture);
                gestureSurface.BackColor = Color.White;

                _path.ClearMarkers();

                var minX = _gesture.Points.Min(g => g.X);
                var maxX = _gesture.Points.Max(g => g.X);
                var minY = _gesture.Points.Min(g => g.Y);
                var maxY = _gesture.Points.Max(g => g.Y);

                var centerX = (gestureSurface.Width - (minX + maxX)) / 2;
                var centerY = (gestureSurface.Height - (minY + maxY)) / 2;

                GesturePoint? prev = null;

                foreach (var point in _gesture.Points)
                {
                    _path.AddEllipse(point.X + centerX - point.threshold, point.Y + centerY - point.threshold, point.threshold * 2, point.threshold * 2);

                    if (prev != null)
                    {
                        _path.AddLine(prev.Value.X + centerX, prev.Value.Y + centerY, point.X + centerX, point.Y + centerY);
                    }
                    prev = point;
                }
                gestureSurface.Refresh();
            }
        }
Ejemplo n.º 2
0
 private void button1_Click(object sender, EventArgs e)
 {
     _gesture = Gesture.Load("Gesture.xml");
 }
Ejemplo n.º 3
0
 public Recognition(Gesture gesture)
 {
     this._gesture = gesture;
 }