private void OnGotInputCapture(InputEventArgs e)
        {
            InputDevice      inputDevice = e.Device;
            DependencyObject captured    = inputDevice.GetCaptured() as DependencyObject;

            if (this.Owner.IsManipulationEnabled && GetAllowsParentToStealCapture(captured))
            {
                NThiefData userData = inputDevice.GetUserData(s_strThiefDataKey) as NThiefData;
                if ((this.Owner.TouchesCapturedWithin.Count <TouchDevice>() >= GetInputToStealThreshold(this.m_refOwner)) && (inputDevice is TouchDevice))
                {
                    if (userData == null)
                    {
                        userData = new NThiefData(this.m_refThiefID, inputDevice.GetPosition(this.Owner));
                        inputDevice.SetUserData(s_strThiefDataKey, userData);
                        foreach (TouchDevice device2 in this.Owner.TouchesCapturedWithin.ToList <TouchDevice>())
                        {
                            if (device2.Captured != this.Owner)
                            {
                                NThiefData data2 = device2.GetUserData(s_strThiefDataKey) as NThiefData;
                                if (data2 != null)
                                {
                                    data2.MustBeStealed = true;
                                }
                            }
                        }
                    }
                }
                else if (((userData == null) && (captured != this.Owner)) && (captured != null))
                {
                    inputDevice.SetUserData(s_strThiefDataKey, new NThiefData(this.m_refThiefID, inputDevice.GetPosition(this.Owner)));
                }
            }
        }
        private void OnInputMove(InputEventArgs e)
        {
            InputDevice      inputDevice = e.Device;
            DependencyObject captured    = inputDevice.GetCaptured() as DependencyObject;
            NThiefData       userData    = inputDevice.GetUserData(s_strThiefDataKey) as NThiefData;

            if (((userData != null) && ((captured == null) || (userData.ThiefID == this.m_refThiefID))) && (userData.MustBeStealed && (inputDevice.GetCaptured() != this.Owner)))
            {
                inputDevice.Capture(this.Owner);
            }
            else if (((captured != null) && (userData != null)) && (userData.ThiefID == this.m_refThiefID))
            {
                int maxInputToSteal = GetMaxInputToSteal(captured);
                if (captured is FrameworkElement)
                {
                    FrameworkElement element = captured as FrameworkElement;
                    if (element.TouchesCaptured.Count <TouchDevice>() > maxInputToSteal)
                    {
                        return;
                    }
                }
                bool?nullable = GetParentStealCaptureOrientation(captured).CheckValidMovementForOrientation(userData.OriginPosition, inputDevice.GetPosition(this.Owner), GetParentStealCaptureRadiusThreshold(captured), GetParentStealCaptureWrongDirectionThreshold(captured));
                if (nullable.HasValue && nullable.Value)
                {
                    inputDevice.SetUserData(s_strThiefDataKey, null);
                    inputDevice.Capture(this.Owner);
                }
                else if (!nullable.HasValue)
                {
                    inputDevice.SetUserData(s_strThiefDataKey, null);
                }
            }
        }