private void HandleTouchEventMessage(TouchEventMessage message)
        {
            Debug.WriteLineIf(DebugSettings.DEBUG_EVENTS, "Message: " + message.GetType().Name);
            Debug.WriteLineIf(DebugSettings.DEBUG_EVENTS, "X: " + message.X.ToString() + " Y: " + message.Y.ToString());
            Point? hitPoint = ((StreamingRectangleUserControl)MyContent).ConvertToPointTagVisualizer(this.Visualizer, message.X, message.Y);
            if (hitPoint != null)
            {
                Debug.WriteLineIf(DebugSettings.DEBUG_EVENTS, "Hitpoint != null " + hitPoint.ToString());
                List<HitTestResult> hitTestResults = HitTest((Point)hitPoint);

                foreach (HitTestResult hitTestResult in hitTestResults)
                {
                    if (hitTestResult != null && hitTestResult.VisualHit != null && hitTestResult.VisualHit is UIElement)
                    {
                        UIElement visualHit = hitTestResult.VisualHit as UIElement;
                        Debug.WriteLineIf(DebugSettings.DEBUG_EVENTS, "EVENT RISING!!!! on " + visualHit.GetType().Name + ". Name: " + (visualHit is FrameworkElement? ((FrameworkElement)visualHit).Name : "?"));
                        RaiseIdentifiedTouchEvent(message, visualHit, hitPoint);
                    }
                }
            }
        }
        private void RaiseIdentifiedTouchEvent(TouchEventMessage message, UIElement visualHit, Point? hitPoint)
        {
            if (message is TouchDownMessage)
            {
                RoutedIdentifiedTouchEventArgs args = new RoutedIdentifiedTouchEventArgs(IdentifiedEvents.PreviewIdentifiedTouchDownEvent, ClientId, this, (Point)hitPoint);
                RaiseEventPair(visualHit, IdentifiedEvents.IdentifiedTouchDownEvent, args);
                _previousMoveTargetElement = visualHit;
            }
            else if (message is TouchMoveMessage)
            {

                if (_previousMoveTargetElement != visualHit)
                {
                    if (!UIElementsRelated(_previousMoveTargetElement, visualHit))
                    {
                        if (_previousMoveTargetElement != null)
                        {
                            RaiseEventPair(_previousMoveTargetElement, IdentifiedEvents.IdentifiedTouchLeaveEvent, new RoutedIdentifiedTouchEventArgs(IdentifiedEvents.PreviewIdentifiedTouchLeaveEvent, ClientId, this, (Point)hitPoint));
                        }
                        if (visualHit != null)
                        {
                            RaiseEventPair(visualHit, IdentifiedEvents.IdentifiedTouchEnterEvent, new RoutedIdentifiedTouchEventArgs(IdentifiedEvents.PreviewIdentifiedTouchEnterEvent, ClientId, this, (Point)hitPoint));
                        }
                    }
                    else
                    {
                        RaiseEventPair(visualHit, IdentifiedEvents.IdentifiedTouchMoveEvent, new RoutedIdentifiedTouchEventArgs(IdentifiedEvents.PreviewIdentifiedTouchMoveEvent, ClientId, this, (Point)hitPoint));
                    }
                    _previousMoveTargetElement = visualHit;
                }
                else
                {
                    RaiseEventPair(visualHit, IdentifiedEvents.IdentifiedTouchMoveEvent, new RoutedIdentifiedTouchEventArgs(IdentifiedEvents.PreviewIdentifiedTouchMoveEvent, ClientId, this, (Point)hitPoint));
                }
            }
            else if (message is TouchUpMessage)
            {
                RaiseEventPair(visualHit, IdentifiedEvents.IdentifiedTouchUpEvent, new RoutedIdentifiedTouchEventArgs(IdentifiedEvents.PreviewIdentifiedTouchUpEvent, ClientId, this, (Point)hitPoint));
                _previousMoveTargetElement = null;
            }
        }
 internal void TouchEvent(TouchEventMessage message)
 {
     if (MyContent is StreamingRectangleUserControl)
     {
         this.Dispatcher.Invoke(new HandleTouchEventMessageDelegate(HandleTouchEventMessage), message as TouchEventMessage);
     }
 }