public Point GetPosition(IInputElement relativeTo)
        {
            __IInputElement _relativeTo = (__IInputElement)(object)relativeTo;

            var p = _relativeTo.InternalGetDisplayObjectDirect().globalToLocal(
                new flash.geom.Point(Internal_stageX, Internal_stageY)
                );

            return(new Point {
                X = p.x, Y = p.y
            });
        }
Exemplo n.º 2
0
        // Implementation not found for type import :
        // type: System.Windows.Input.TouchEventArgs
        // method: System.Windows.Input.TouchPoint GetTouchPoint(System.Windows.IInputElement)

        public TouchPoint GetTouchPoint(IInputElement relativeTo)
        {
            // X:\jsc.svn\examples\actionscript\MultitouchExample\MultitouchFingerTools.FlashLAN\ApplicationCanvas.cs

            __IInputElement _relativeTo = (__IInputElement)(object)relativeTo;

            var p = _relativeTo.InternalGetDisplayObjectDirect().globalToLocal(
                new flash.geom.Point(this.InternalValue.stageX, this.InternalValue.stageY)
                );


            return(new __TouchPoint
            {
                TouchDevice = TouchDevice,
                Position = new Point(
                    p.x,
                    p.y
                    )
            });
        }
        public TouchPoint GetTouchPoint(IInputElement relativeTo)
        {
            __IInputElement _relativeTo = (__IInputElement)(object)relativeTo;

            #region magic, yet works

            var pp = new Point(0, 0);

            if (this.InternalValue != null)
            {
                pp.X = this.InternalValue.pageX;
                pp.Y = this.InternalValue.pageY;
            }
            ;


            var a = GetPositionData.Of(_relativeTo.InternalGetDisplayObjectDirect());
            var b = GetPositionData.Of(this.InternalElement);


            if (b.Count > 0)
            {
                var item = b.Last();

                pp.X -= item.X;
                pp.Y -= item.Y;
            }


            // top elements might be the same so we remove them
            var loop = true;

            while (loop)
            {
                loop = false;

                if (a.Count > 0)
                {
                    if (b.Count > 0)
                    {
                        if (a[a.Count - 1].Element == b[b.Count - 1].Element)
                        {
                            a.RemoveAt(a.Count - 1);
                            b.RemoveAt(b.Count - 1);

                            loop = true;
                        }
                    }
                }
            }

            if (a.Count > 0)
            {
                var itembb = a.Last();

                pp.X -= itembb.X;
                pp.Y -= itembb.Y;
            }

            if (b.Count > 0)
            {
                var item = b.Last();

                pp.X += item.X;
                pp.Y += item.Y;
            }

            #endregion



            return(new __TouchPoint
            {
                TouchDevice = TouchDevice,
                Position = pp
            });
        }