Exemple #1
0
 protected void MouseCapture_PointCaptured(object sender, PointsCapturedEventArgs e)
 {
     if (Properties.Settings.Default.VisualFeedbackWidth > 0 && e.State == CaptureState.Capturing)
     {
         this.DrawSegments(e.Points);
     }
 }
Exemple #2
0
        private void PointCapture_PointCaptured(object sender, PointsCapturedEventArgs e)
        {
            if (PointCapture.Instance.State != CaptureState.Capturing || e.Points.Count < 2)
            {
                return;
            }
            var actionsWithContinuousGesture = ApplicationManager.Instance.GetRecognizedDefinedAction(a => a != null && a.ContinuousGesture != null);

            if (actionsWithContinuousGesture == null || actionsWithContinuousGesture.Count == 0)
            {
                return;
            }
            if (_lastPoints == null || _lastPoints.Count != e.FirstCapturedPoints.Count)
            {
                _startPoint = e.FirstCapturedPoints[0];
                _lastPoints = e.FirstCapturedPoints;
                _stopwatch.Restart();
                return;
            }

            int deltaX = 0, deltaY = 0;

            for (int i = 0; i < _lastPoints.Count; i++)
            {
                deltaX += e.FirstCapturedPoints[i].X - _lastPoints[i].X;
                deltaY += e.FirstCapturedPoints[i].Y - _lastPoints[i].Y;
            }
            deltaX /= _lastPoints.Count;
            deltaY /= _lastPoints.Count;
            int  deltaXAbs    = Math.Abs(deltaX);
            int  deltaYAbs    = Math.Abs(deltaY);
            bool isHorizontal = deltaXAbs > deltaYAbs;

            if (isHorizontal)
            {
                var rate = GetRateOfFire(deltaXAbs);
                if (rate >= 1)
                {
                    for (int i = 1; i < rate; i++)
                    {
                        OnGesturerRecognized(_lastPoints.Count, deltaX > 0 ? Gestures.Right : Gestures.Left);
                    }
                    _stopwatch.Restart();
                    _lastPoints = e.FirstCapturedPoints;
                }
            }
            else
            {
                var rate = GetRateOfFire(deltaYAbs);
                if (rate >= 1)
                {
                    for (int i = 1; i < rate; i++)
                    {
                        OnGesturerRecognized(_lastPoints.Count, deltaY > 0 ? Gestures.Down : Gestures.Up);
                    }
                    _stopwatch.Restart();
                    _lastPoints = e.FirstCapturedPoints;
                }
            }
        }
Exemple #3
0
 protected void MouseCapture_CaptureCanceled(object sender, PointsCapturedEventArgs e)
 {
     if (Properties.Settings.Default.VisualFeedbackWidth > 0)
     {
         this.EndDraw();
     }
 }
 protected void PointCapture_CaptureStarted(object sender, PointsCapturedEventArgs e)
 {
     if (_lastGestureTime != null && Environment.TickCount - _lastGestureTime.Value > GestureStackTimeout)
     {
         _isGestureStackTimeout = true;
     }
 }
Exemple #5
0
        //public event RecognitionEventHandler GestureNotRecognized;

        protected virtual void OnAfterPointsCaptured(PointsCapturedEventArgs e)
        {
            if (AfterPointsCaptured != null)
            {
                AfterPointsCaptured(this, e);
            }
        }
Exemple #6
0
 protected void PointCapture_CaptureCanceled(object sender, PointsCapturedEventArgs e)
 {
     if (AppConfig.VisualFeedbackWidth > 0)
     {
         EndDraw();
     }
 }
Exemple #7
0
 protected virtual void OnBeforePointsCaptured(PointsCapturedEventArgs e)
 {
     if (BeforePointsCaptured != null)
     {
         BeforePointsCaptured(this, e);
     }
 }
Exemple #8
0
 protected virtual void OnPointCaptured(PointsCapturedEventArgs e)
 {
     if (PointCaptured != null)
     {
         PointCaptured(this, e);
     }
 }
Exemple #9
0
 protected virtual void OnCaptureCanceled(PointsCapturedEventArgs e)
 {
     if (CaptureCanceled != null)
     {
         CaptureCanceled(this, e);
     }
 }
        protected void PointCapture_CaptureStarted(object sender, PointsCapturedEventArgs e)
        {
            var pointCapture = (IPointCapture)sender;

            if (pointCapture.Mode == CaptureMode.Training)
            {
                return;
            }

            if (VersionHelper.IsWindows8OrGreater() && !VersionHelper.IsWindows10OrGreater())
            {
                IntPtr hwndCharmBar = FindWindow("NativeHWNDHost", "Charm Bar");
                var    window       = SystemWindow.FromPointEx(SystemWindow.DesktopWindow.Rectangle.Right - 1, 1, true, true);

                if (window != null && window.HWnd.Equals(hwndCharmBar))
                {
                    e.Cancel = false;
                    e.BlockTouchInputThreshold = 0;
                    return;
                }
            }

            CaptureWindow          = GetWindowFromPoint(e.FirstCapturedPoints.FirstOrDefault());
            _recognizedApplication = GetApplicationFromWindow(CaptureWindow);

            int maxThreshold = 0, maxLimitNumber = 1;

            foreach (IApplication app in _recognizedApplication)
            {
                switch (app)
                {
                case GlobalApp a:
                    maxLimitNumber = a.LimitNumberOfFingers > maxLimitNumber ? a.LimitNumberOfFingers : maxLimitNumber;
                    if (AppConfig.IgnoreFullScreen && IsFullScreenWindow(e.FirstCapturedPoints.FirstOrDefault()))
                    {
                        e.Cancel = true;
                        return;
                    }
                    break;

                case UserApp a:
                    maxThreshold   = a.BlockTouchInputThreshold > maxThreshold ? a.BlockTouchInputThreshold : maxThreshold;
                    maxLimitNumber = a.LimitNumberOfFingers > maxLimitNumber ? a.LimitNumberOfFingers : maxLimitNumber;
                    break;

                case IgnoredApp a:
                    if (a.IsEnabled)
                    {
                        e.Cancel = true;
                        return;
                    }
                    break;

                default:
                    return;
                }
            }
            e.Cancel = (pointCapture.SourceDevice & Devices.TouchDevice) != 0 && (e.Points.Count < maxLimitNumber);
            e.BlockTouchInputThreshold = maxThreshold;
        }
Exemple #11
0
        protected void PointCapture_BeforePointsCaptured(object sender, PointsCapturedEventArgs e)
        {
            var pointCapture = (IPointCapture)sender;

            if (pointCapture.Mode == CaptureMode.Training)
            {
                _gestureLevel       = 0;
                _gestureMatchResult = null;
            }

            if (e.GestureTimeout)
            {
                _gestureLevel       = 0;
                _gestureMatchResult = null;
            }

            var sourceGesture = _gestureLevel == 0 ? _Gestures : _gestureMatchResult;

            GestureName = GetGestureSetNameMatch(e.Points, sourceGesture, _gestureLevel, out _gestureMatchResult);

            if (pointCapture.Mode != CaptureMode.Training)
            {
                if (_gestureMatchResult != null && _gestureMatchResult.Count != 0)
                {
                    _gestureLevel++;
                    e.Delay = true;
                }
                else
                {
                    _gestureLevel       = 0;
                    _gestureMatchResult = null;
                }
            }
        }
Exemple #12
0
        private async Task EndCapture()
        {
            // Create points capture event args, to be used to send off to event subscribers or to simulate original Touch event
            PointsCapturedEventArgs pointsInformation = new PointsCapturedEventArgs(new List <List <Point> >(_pointsCaptured.Values));

            // Notify subscribers that capture has ended (draw end)
            OnCaptureEnded();
            State = CaptureState.Ready;

            if (_gestureTimeout)
            {
                _gestureTimeout = false;
                pointsInformation.GestureTimeout = true;
            }
            // Notify PointsCaptured event subscribers that points have been captured.
            //CaptureWindow GetGestureName
            OnBeforePointsCaptured(pointsInformation);

            if (pointsInformation.Cancel)
            {
                return;
            }

            if (pointsInformation.Delay)
            {
                _timeoutTimer.Interval = AppConfig.GestureTimeout;
                _timeoutTimer.Start();
            }
            else if (Mode == CaptureMode.Training && !(_pointsCaptured.Count == 1 && _pointsCaptured.Values.First().Count == 1))
            {
                if (StackUpGesture)
                {
                    StackUpGesture = false;
                }
                else
                {
                    _pointPatternCache.Clear();
                }
                _pointPatternCache.Add(new PointPattern(new List <List <Point> >(_pointsCaptured.Values)));

                var message = new Tuple <string, List <List <List <Point> > > >(GestureManager.Instance.GestureName, _pointPatternCache.Select(p => p.Points).ToList());
                if (!await NamedPipe.SendMessageAsync(message, "GestureSignControlPanel"))
                {
                    Mode = CaptureMode.Normal;
                }
            }

            // Fire recognized event if we found a gesture match, otherwise throw not recognized event
            if (GestureManager.Instance.GestureName != null)
            {
                OnGestureRecognized(new RecognitionEventArgs(GestureManager.Instance.GestureName, pointsInformation.Points, pointsInformation.FirstCapturedPoints, _pointsCaptured.Keys.ToList()));
            }
            //else
            //    OnGestureNotRecognized(new RecognitionEventArgs(pointsInformation.Points, pointsInformation.FirstCapturedPoints, _pointsCaptured.Keys.ToList()));

            OnAfterPointsCaptured(pointsInformation);

            _pointsCaptured.Clear();
        }
Exemple #13
0
 protected void MouseCapture_CaptureStarted(object sender, PointsCapturedEventArgs e)
 {
     CaptureWindow = GetWindowFromPoint(e.CapturePoint);
     if (GetApplicationFromWindow(CaptureWindow) is IgnoredApplication)
     {
         e.Cancel = true;
     }
 }
        protected void PointCapture_CaptureStarted(object sender, PointsCapturedEventArgs e)
        {
            var pointCapture = (IPointCapture)sender;

            if (pointCapture.Mode == CaptureMode.Training)
            {
                return;
            }

            if (Environment.OSVersion.Version.Major == 6)
            {
                IntPtr hwndCharmBar = FindWindow("NativeHWNDHost", "Charm Bar");
                var    window       = SystemWindow.FromPointEx(SystemWindow.DesktopWindow.Rectangle.Right - 1, 1, true, true);

                if (window != null && window.HWnd.Equals(hwndCharmBar))
                {
                    e.Cancel = false;
                    e.BlockTouchInputThreshold = 0;
                    return;
                }
            }

            CaptureWindow          = GetWindowFromPoint(e.FirstCapturedPoints.FirstOrDefault());
            _recognizedApplication = GetApplicationFromWindow(CaptureWindow);

            int  maxThreshold    = 0;
            bool?limitNumberFlag = null;

            foreach (IApplication app in _recognizedApplication)
            {
                var userApplication = app as UserApp;
                if (userApplication != null)
                {
                    maxThreshold = userApplication.BlockTouchInputThreshold > maxThreshold ? userApplication.BlockTouchInputThreshold : maxThreshold;

                    //Got UserApplication
                    if (limitNumberFlag == null)
                    {
                        limitNumberFlag = e.Points.Count < userApplication.LimitNumberOfFingers;
                    }
                    else
                    {
                        limitNumberFlag |= e.Points.Count < userApplication.LimitNumberOfFingers;
                    }
                }
                else
                {
                    var ignoredApplication = app as IgnoredApp;
                    if (ignoredApplication != null && ignoredApplication.IsEnabled)
                    {
                        e.Cancel = true;
                        return;
                    }
                }
            }
            e.Cancel = pointCapture.SourceDevice == Device.Touch && (limitNumberFlag ?? e.Points.Count == 1);
            e.BlockTouchInputThreshold = maxThreshold;
        }
        private bool TryBeginCapture(List <InputPoint> firstPoint)
        {
            // Create capture args so we can notify subscribers that capture has started and allow them to cancel if they want.
            PointsCapturedEventArgs captureStartedArgs;

            if (SourceDevice == Devices.TouchPad)
            {
                _touchPadStartPoint = System.Windows.Forms.Cursor.Position;
                captureStartedArgs  = new PointsCapturedEventArgs(firstPoint.Select(p => new List <Point>()
                {
                    p.Point
                }).ToList(), new List <Point>()
                {
                    _touchPadStartPoint
                });
            }
            else
            {
                captureStartedArgs = new PointsCapturedEventArgs(firstPoint.Select(p => p.Point).ToList());
            }
            OnCaptureStarted(captureStartedArgs);

            UpdateBlockTouchInputThreshold(Mode == CaptureMode.Normal ? captureStartedArgs.BlockTouchInputThreshold : 0);

            if (captureStartedArgs.Cancel)
            {
                return(false);
            }

            State = CaptureState.CapturingInvalid;

            // Clear old gesture from point list so we can start adding the new captures points to the list
            _pointsCaptured = new Dictionary <int, List <Point> >(firstPoint.Count);
            if (AppConfig.IsOrderByLocation)
            {
                foreach (var rawData in firstPoint.OrderBy(p => p.Point.X))
                {
                    if (!_pointsCaptured.ContainsKey(rawData.ContactIdentifier))
                    {
                        _pointsCaptured.Add(rawData.ContactIdentifier, new List <Point>(30));
                    }
                }
            }
            else
            {
                foreach (var rawData in firstPoint.OrderBy(p => p.ContactIdentifier))
                {
                    if (!_pointsCaptured.ContainsKey(rawData.ContactIdentifier))
                    {
                        _pointsCaptured.Add(rawData.ContactIdentifier, new List <Point>(30));
                    }
                }
            }
            AddPoint(firstPoint);
            return(true);
        }
 protected void Instance_AfterPointsCaptured(object sender, PointsCapturedEventArgs e)
 {
     if (Properties.Settings.Default.Teaching)
     {
         _CapturedPoints = e.Points;
         this.Show();
         this.Activate();
         PopulateForm();
     }
 }
Exemple #17
0
        private void EndCapture()
        {
            // Create points capture event args, to be used to send off to event subscribers or to simulate original Point event
            PointsCapturedEventArgs pointsInformation = SourceDevice == Devices.TouchPad ?
                                                        new PointsCapturedEventArgs(_pointsCaptured.Values.ToList(), new List <Point>()
            {
                _touchPadStartPoint
            }) :
                                                        new PointsCapturedEventArgs(new List <List <Point> >(_pointsCaptured.Values), _pointsCaptured.Values.Select(p => p.FirstOrDefault()).ToList());

            // Notify subscribers that capture has ended (draw end)
            OnCaptureEnded();
            State = CaptureState.Ready;

            // Notify PointsCaptured event subscribers that points have been captured.
            //CaptureWindow GetGestureName
            OnBeforePointsCaptured(pointsInformation);

            if (pointsInformation.Cancel)
            {
                return;
            }

            if (Mode == CaptureMode.Training && !(_pointsCaptured.Count == 1 && _pointsCaptured.Values.First().Count == 1))
            {
                _pointPatternCache.Clear();
                _pointPatternCache.Add(new PointPattern(_pointsCaptured.Values));

                if (!NamedPipe.SendMessageAsync(IpcCommands.GotGesture, Constants.ControlPanel, _pointPatternCache.Select(p => p.Points).ToArray(), false).Result)
                {
                    Mode = CaptureMode.Normal;
                }
            }

            // Fire recognized event if we found a gesture match, otherwise throw not recognized event
            if (GestureManager.Instance.GestureName != null)
            {
                List <Point> capturedPoints = SourceDevice == Devices.TouchPad ? new List <Point>()
                {
                    _touchPadStartPoint
                } : pointsInformation.FirstCapturedPoints;
                OnGestureRecognized(new RecognitionEventArgs(GestureManager.Instance.GestureName, pointsInformation.Points, capturedPoints, _pointsCaptured.Keys.ToList()));
            }
            //else
            //    OnGestureNotRecognized(new RecognitionEventArgs(pointsInformation.Points, pointsInformation.FirstCapturedPoints, _pointsCaptured.Keys.ToList()));

            OnAfterPointsCaptured(pointsInformation);

            _pointsCaptured.Clear();
        }
Exemple #18
0
        private void Instance_CaptureStarted(object sender, PointsCapturedEventArgs e)
        {
            var pointCapture = (IPointCapture)sender;

            if (AppConfig.VisualFeedbackWidth <= 0 || pointCapture.Mode == CaptureMode.UserDisabled)
            {
                return;
            }

            if (_settingsChanged)
            {
                _settingsChanged = false;
                InitializeForm();
            }

            ClearSurfaces();
        }
Exemple #19
0
        protected void PointCapture_PointCaptured(object sender, PointsCapturedEventArgs e)
        {
            var pointCapture = (IPointCapture)sender;

            if (pointCapture.Mode != CaptureMode.UserDisabled &&
                pointCapture.State == CaptureState.Capturing &&
                AppConfig.VisualFeedbackWidth > 0 &&
                !(e.Points.Count == 1 && e.Points.First().Count == 1))
            {
                if (_bitmap == null || _lastStroke == null)
                {
                    ClearSurfaces();
                    _bitmap = new DiBitmap(this.Size);
                }
                DrawSegments(e.Points);
            }
        }
Exemple #20
0
        private void EndCapture()
        {
            // Create points capture event args, to be used to send off to event subscribers or to simulate original mouse event
            PointsCapturedEventArgs pointsInformation = new PointsCapturedEventArgs(InputPoints, State);

            // We've completed a successful capture, set state back to ready
            State = CaptureState.Ready;

            // Notify subscribers that capture has ended
            OnCaptureEnded(pointsInformation);

            // Notify PointsCaptured event subscribers that points have been captured.
            OnBeforePointsCaptured(pointsInformation);

            if (!pointsInformation.Cancel)
            {
                OnAfterPointsCaptured(pointsInformation);
            }
        }
Exemple #21
0
        protected void TouchCapture_CaptureStarted(object sender, PointsCapturedEventArgs e)
        {
            var touchCapture = (ITouchCapture)sender;

            if (touchCapture.Mode == CaptureMode.Training)
            {
                return;
            }

            if (Environment.OSVersion.Version.Major == 6)
            {
                IntPtr hwndCharmBar = FindWindow("NativeHWNDHost", "Charm Bar");
                var    window       = SystemWindow.FromPointEx(SystemWindow.DesktopWindow.Rectangle.Right - 1, 1, true, true);

                if (window != null && window.HWnd.Equals(hwndCharmBar))
                {
                    e.Cancel = e.InterceptTouchInput = false;
                    return;
                }
            }

            CaptureWindow = GetWindowFromPoint(e.LastCapturedPoints.FirstOrDefault());
            IApplication[] applicationFromWindow = GetApplicationFromWindow(CaptureWindow);
            foreach (IApplication app in applicationFromWindow)
            {
                e.InterceptTouchInput |= (app is UserApplication && (app as UserApplication).InterceptTouchInput);
                if ((app is IgnoredApplication) && (app as IgnoredApplication).IsEnabled)
                {
                    e.Cancel = true;
                    return;
                }
                else if (e.Points.Count == 1)
                {
                    e.Cancel = true;
                    UserApplication userApplication = app as UserApplication;
                    if (userApplication != null && userApplication.AllowSingleStroke)
                    {
                        e.Cancel = false;
                        return;
                    }
                }
            }
        }
Exemple #22
0
        private bool TryBeginCapture(List <RawTouchData> firstTouch)
        {
            // Create capture args so we can notify subscribers that capture has started and allow them to cancel if they want.
            PointsCapturedEventArgs captureStartedArgs = new PointsCapturedEventArgs(firstTouch.Select(p => p.RawPoints).ToList());

            OnCaptureStarted(captureStartedArgs);

            _pointerInputTargetWindow.BlockTouchInputThreshold = Mode == CaptureMode.Normal ? captureStartedArgs.BlockTouchInputThreshold : 0;

            if (captureStartedArgs.Cancel)
            {
                return(false);
            }

            State = CaptureState.Capturing;

            // Clear old gesture from point list so we can start adding the new captures points to the list
            _pointsCaptured = new Dictionary <int, List <Point> >(firstTouch.Count);
            if (AppConfig.IsOrderByLocation)
            {
                foreach (var rawTouchData in firstTouch.OrderBy(p => p.RawPoints.X))
                {
                    if (!_pointsCaptured.ContainsKey(rawTouchData.ContactIdentifier))
                    {
                        _pointsCaptured.Add(rawTouchData.ContactIdentifier, new List <Point>(30));
                    }
                }
            }
            else
            {
                foreach (var rawTouchData in firstTouch.OrderBy(p => p.ContactIdentifier))
                {
                    if (!_pointsCaptured.ContainsKey(rawTouchData.ContactIdentifier))
                    {
                        _pointsCaptured.Add(rawTouchData.ContactIdentifier, new List <Point>(30));
                    }
                }
            }
            AddPoint(firstTouch);
            return(true);
        }
        protected void PointCapture_BeforePointsCaptured(object sender, PointsCapturedEventArgs e)
        {
            var appsToMatch = Applications.Where(a => a is UserApp && a.MatchActivated);

            if (appsToMatch.Any())
            {
                CaptureWindow = SystemWindow.ForegroundWindow;
                string className, title, fileName;
                GetWindowInfo(CaptureWindow, out className, out title, out fileName);
                var matchedForegroundApps = FindMatchApplications(appsToMatch, className, title, fileName);

                if (matchedForegroundApps.Length != 0)
                {
                    _recognizedApplication = matchedForegroundApps;
                    return;
                }
            }

            // Derive capture window from capture point
            CaptureWindow          = GetWindowFromPoint(e.FirstCapturedPoints.FirstOrDefault());
            _recognizedApplication = GetApplicationFromWindow(CaptureWindow);
        }
Exemple #24
0
        private bool TryBeginCapture(PointF FirstPoint)
        {
            // Create capture args so we can notify subscribers that capture has started and allow them to cancel if they want.
            PointsCapturedEventArgs captureStartedArgs = new PointsCapturedEventArgs(new PointF[] { FirstPoint });

            OnCaptureStarted(captureStartedArgs);
            if (captureStartedArgs.Cancel)
            {
                return(false);
            }

            // Beginning of new gesture, set to CapturingInvalid state because the capture isn't official yet,
            // if the user chooses to release the mouse button during the CapturingInvalid state, then we'll
            // simulate the original mouse event
            State = CaptureState.CapturingInvalid;
            // Clear old gesture from point list so we can start adding the new captures points to the list
            _PointsCaptured.Clear();

            // Add the first point to the newly emptied list
            AddPoint(FirstPoint);

            return(true);
        }
        protected void PointCapture_BeforePointsCaptured(object sender, PointsCapturedEventArgs e)
        {
            var pointCapture = (IPointCapture)sender;

            if (_isGestureStackTimeout)
            {
                _lastGestureTime       = null;
                _isGestureStackTimeout = false;

                _gestureLevel       = 0;
                _gestureMatchResult = null;
            }

            if (pointCapture.Mode == CaptureMode.Training)
            {
                _gestureLevel       = 0;
                _gestureMatchResult = null;
            }

            var sourceGesture = _gestureLevel == 0 ? _Gestures : _gestureMatchResult;

            GestureName = GetGestureSetNameMatch(e.Points.Select(l => l.ToArray()).ToArray(), sourceGesture, _gestureLevel, out _gestureMatchResult);

            if (pointCapture.Mode != CaptureMode.Training)
            {
                if (_gestureMatchResult != null && _gestureMatchResult.Count != 0)
                {
                    _gestureLevel++;
                    _lastGestureTime = Environment.TickCount;
                }
                else
                {
                    _gestureLevel       = 0;
                    _gestureMatchResult = null;
                }
            }
        }
 protected void MouseCapture_BeforePointsCaptured(object sender, PointsCapturedEventArgs e)
 {
     this.GestureName = GetGestureName(e.Points);
 }
 protected void MouseCapture_AfterPointsCaptured(object sender, PointsCapturedEventArgs e)
 {
     RecognizeGesture(e.Points, e.CapturePoint);
 }
Exemple #28
0
 protected void TouchCapture_BeforePointsCaptured(object sender, PointsCapturedEventArgs e)
 {
     // Derive capture window from capture point
     CaptureWindow         = GetWindowFromPoint(e.FirstCapturedPoints.FirstOrDefault());
     RecognizedApplication = GetApplicationFromWindow(CaptureWindow);
 }
Exemple #29
0
        private async void EndCapture()
        {
            // Create points capture event args, to be used to send off to event subscribers or to simulate original Touch event
            PointsCapturedEventArgs pointsInformation = new PointsCapturedEventArgs(new List <List <Point> >(_pointsCaptured.Values));

            // Notify subscribers that capture has ended (draw end)
            OnCaptureEnded();
            State = CaptureState.Ready;

            if (_gestureTimeout)
            {
                _gestureTimeout = false;
                pointsInformation.GestureTimeout = true;
            }
            // Notify PointsCaptured event subscribers that points have been captured.
            //CaptureWindow GetGestureName
            OnBeforePointsCaptured(pointsInformation);

            if (pointsInformation.Cancel)
            {
                return;
            }

            if (pointsInformation.Delay)
            {
                _timeoutTimer.Interval = AppConfig.GestureTimeout;
                _timeoutTimer.Start();
            }
            else if (Mode == CaptureMode.Training && !(_pointsCaptured.Count == 1 && _pointsCaptured.Values.First().Count == 1))
            {
                try
                {
                    bool createdSetting;
                    using (new Mutex(false, "GestureSignControlPanel", out createdSetting)) { }
                    if (createdSetting)
                    {
                        string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "GestureSign.exe");
                        if (File.Exists(path))
                        {
                            using (Process daemon = new Process())
                            {
                                daemon.StartInfo.FileName  = path;
                                daemon.StartInfo.Arguments = "/L";
                                // pipeClient.StartInfo.Arguments =
                                //daemon.StartInfo.UseShellExecute = false;
                                daemon.Start();
                                daemon.WaitForInputIdle();
                            }
                        }
                    }
                }
                catch (Exception exception)
                {
                    Logging.LogException(exception);
                    MessageBox.Show(exception.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }

                if (OverlayGesture)
                {
                    OverlayGesture = false;
                }
                else
                {
                    _pointPatternCache.Clear();
                }
                _pointPatternCache.Add(new PointPattern(new List <List <Point> >(_pointsCaptured.Values)));

                var message = new Tuple <string, List <List <List <Point> > > >(GestureManager.Instance.GestureName, _pointPatternCache.Select(p => p.Points).ToList());
                if (await NamedPipe.SendMessageAsync(message, "GestureSignControlPanel"))
                {
                    DisableTouchCapture();
                }
            }

            // Fire recognized event if we found a gesture match, otherwise throw not recognized event
            if (GestureManager.Instance.GestureName != null)
            {
                OnGestureRecognized(new RecognitionEventArgs(GestureManager.Instance.GestureName, pointsInformation.Points, pointsInformation.LastCapturedPoints));
            }
            else
            {
                OnGestureNotRecognized(new RecognitionEventArgs(pointsInformation.Points, pointsInformation.LastCapturedPoints));
            }

            OnAfterPointsCaptured(pointsInformation);
        }
        private void EndCapture()
        {
            // Create points capture event args, to be used to send off to event subscribers or to simulate original Point event
            PointsCapturedEventArgs pointsInformation = SourceDevice == Devices.TouchPad ?
                                                        new PointsCapturedEventArgs(_pointsCaptured.Values.ToList(), new List <Point>()
            {
                _touchPadStartPoint
            }) :
                                                        new PointsCapturedEventArgs(new List <List <Point> >(_pointsCaptured.Values), _pointsCaptured.Values.Select(p => p.FirstOrDefault()).ToList());

            // Notify subscribers that capture has ended (draw end)
            OnCaptureEnded();
            State = CaptureState.Ready;

            if (_isGestureStackTimeout)
            {
                _lastGestureTime                 = null;
                _isGestureStackTimeout           = false;
                pointsInformation.GestureTimeout = true;
            }
            // Notify PointsCaptured event subscribers that points have been captured.
            //CaptureWindow GetGestureName
            OnBeforePointsCaptured(pointsInformation);

            if (pointsInformation.Cancel)
            {
                return;
            }

            if (pointsInformation.Delay)
            {
                _lastGestureTime = Environment.TickCount;
            }
            else if (Mode == CaptureMode.Training && !(_pointsCaptured.Count == 1 && _pointsCaptured.Values.First().Count == 1))
            {
                _pointPatternCache.Clear();
                _pointPatternCache.Add(new PointPattern(new List <List <Point> >(_pointsCaptured.Values)));

                if (!NamedPipe.SendMessageAsync(_pointPatternCache.Select(p => p.Points).ToList(), "GestureSignControlPanel").Result)
                {
                    Mode = CaptureMode.Normal;
                }
            }

            // Fire recognized event if we found a gesture match, otherwise throw not recognized event
            if (GestureManager.Instance.GestureName != null)
            {
                if (SourceDevice == Devices.TouchPad)
                {
                    OnGestureRecognized(new RecognitionEventArgs(GestureManager.Instance.GestureName,
                                                                 new List <List <Point> >()
                    {
                        new List <Point>()
                        {
                            _touchPadStartPoint
                        }
                    },
                                                                 new List <Point>()
                    {
                        _touchPadStartPoint
                    }, _pointsCaptured.Keys.ToList()));
                }
                else
                {
                    OnGestureRecognized(new RecognitionEventArgs(GestureManager.Instance.GestureName, pointsInformation.Points, pointsInformation.FirstCapturedPoints, _pointsCaptured.Keys.ToList()));
                }
            }
            //else
            //    OnGestureNotRecognized(new RecognitionEventArgs(pointsInformation.Points, pointsInformation.FirstCapturedPoints, _pointsCaptured.Keys.ToList()));

            OnAfterPointsCaptured(pointsInformation);

            _pointsCaptured.Clear();
        }