Ejemplo n.º 1
0
        internal void Touch_FrameReported(FrameInfo frameInfo)
        {
            // Raw data, frame changed
            if (FrameChanged != null)
                FrameChanged(this, frameInfo);

            // Get active touch points including stoke data
            List<TouchPoint2> touchPoints = base.UpdateActiveTouchPoints(frameInfo.Touches);

            // Determine touch source for any new touch point
            foreach (var touchPoint in touchPoints)
            {
                if (touchPoint.Action == TouchAction.Down)
                {
                    touchPoint.UpdateSource();
                }
            }

            // Creating one callback for each touch point
            if (SingleTouchChanged != null)
            {
                foreach (TouchPoint2 point in touchPoints)
                {
                    SingleTouchChanged(this, new SingleTouchEventArgs(point));
                }
            }

            // Sending all points in one callback
            if (MultiTouchChanged != null)
            {
                MultiTouchChanged(this, new MultiTouchEventArgs(touchPoints));
            }
        }
        private void Touch_FrameReported(object sender, TouchFrameEventArgs e)
        {
            /* If ui-control-specific gesture detection is enabled,
             * on touch down, update touch ID & Gesture mapping: Which gestures we need to detect for this touch
             *
             * NOTE: While this is useful when application wants ui-control specific gestures but not so good in
             * terms of performance application uses root canvas level gestures
             */

            // Update stroke records of each active touch
            TouchPointCollection slPoints = e.GetTouchPoints(GestureFramework.LayoutRoot);
            List<TouchInfo> touchInfos = slPoints.ToTouchInfo();
            List<TouchPoint2> touchPoints = base.UpdateActiveTouchPoints(touchInfos);

            // Determine touch source for any new touch point
            foreach (var touchPoint in touchPoints)
            {
                if (touchPoint.Action == TouchAction.Down)
                {
                    touchPoint.UpdateSource();
                }
            }

            // Raw data, frame changed
            if (FrameChanged != null)
            {
                FrameInfo fi = new FrameInfo();
                fi.Touches = touchInfos;
                fi.TimeStamp = e.Timestamp;
                fi.WaitTime = (lastTimeStamp == 0 ? 0 : e.Timestamp - lastTimeStamp);
                FrameChanged(this, fi);
            }

            // Creating one callback for each touch point
            if (SingleTouchChanged != null)
            {
                foreach (TouchPoint2 p in touchPoints)
                {
                    SingleTouchChanged(this, new SingleTouchEventArgs(p));
                }
            }

            // Sending all points in one callback
            if (MultiTouchChanged != null)
            {
                MultiTouchChanged(this, new MultiTouchEventArgs(touchPoints));
            }

            lastTimeStamp = e.Timestamp;
        }
Ejemplo n.º 3
0
        private void Touch_FrameReported(object sender, TouchFrameEventArgs e)
        {
            // Update stroke records of each active touch
            TouchPointCollection slPoints = e.GetTouchPoints(GestureFramework.LayoutRoot);
            List<TouchInfo> touchInfos = slPoints.ToTouchInfo();
            List<TouchPoint2> touchPoints = base.UpdateActiveTouchPoints(touchInfos);

            // Determine touch source for any new touch point
            foreach (var touchPoint in touchPoints)
            {
                if (touchPoint.Action == TouchAction.Down)
                {
                    touchPoint.UpdateSource();
                }
            }

            // Raw data, frame changed
            if (FrameChanged != null)
            {
                FrameInfo fi = new FrameInfo();
                fi.Touches = touchInfos;
                fi.TimeStamp = e.Timestamp;
                fi.WaitTime = (lastTimeStamp == 0 ? 0 : e.Timestamp - lastTimeStamp);
                FrameChanged(this, fi);
            }

            // Creating one callback for each touch point
            if (SingleTouchChanged != null)
            {
                foreach (TouchPoint2 p in touchPoints)
                {
                    SingleTouchChanged(this, new SingleTouchEventArgs(p));
                }
            }

            // Sending all points in one callback
            if (MultiTouchChanged != null)
            {
                MultiTouchChanged(this, new MultiTouchEventArgs(touchPoints));
            }

            lastTimeStamp = e.Timestamp;
        }
Ejemplo n.º 4
0
        void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            TouchInfo info = new TouchInfo() { ActionType = TouchAction2.Down, GroupId = 0, Position = new Point(1, 1), TouchDeviceId = 14 };
            info.Tags.Add("size", "20");

            FrameInfo fi = new FrameInfo() { TimeStamp = 123121, WaitTime = 10 };
            fi.Touches.Add(info);

            List<FrameInfo> frames = new List<FrameInfo>();
            frames.Add(fi);

            string content = TouchToolkit.Framework.Utility.SerializationHelper.Serialize(frames);

            // Initialize Gesture Framework
            TouchInputProvider inputProvider = new SilverlightTouchInputProvider();
            GestureFramework.Initialize(inputProvider, LayoutRoot, Assembly.GetExecutingAssembly());
            //GestureFramework.ShowDebugPanel(GestureFramework.DebugPanels.GestureRecorder);

            // Add touch feedbacks
            GestureFramework.AddTouchFeedback(typeof(BubblesPath));

            // Add gesture feedbacks
            GestureFramework.AddGesturFeedback("lasso", typeof(HighlightSelectedArea));

            // Load UI
            LoadImages(false);
        }
Ejemplo n.º 5
0
        private void _contactTarget_FrameReceived(object sender, TouchFrameEventArgs e)
        {
            if (_activeTouchInfos.Values.Count > 0)
            {
                List<TouchInfo> touchInfoList = _activeTouchInfos.Values.ToList<TouchInfo>();
                List<TouchPoint2> touchPoints = _activeTouchPoints.Values.ToList<TouchPoint2>();

            /*    long now = DateTime.Now.Ticks;
                long ticksDelta = Math.Abs(now - oldTimeStamp);
                //Update image every 100 milliseconds.
                if ((IsThereAnyBlob(touchPoints)) && (ticksDelta > 30 * 10000))
                {
                //    getImage(e);
                    oldTimeStamp = now;
                }*/

                // Raise "SingleTouchChanged" event if necessary
                if (SingleTouchChanged != null)
                {
                    foreach (var touchPoint in touchPoints)
                    {
                        SingleTouchChanged(this, new SingleTouchEventArgs(touchPoint));
                    }
                }

                // Raise "MultiTouchChanged" event if necessary
                if (MultiTouchChanged != null)
                {
                    MultiTouchChanged(this, new MultiTouchEventArgs(touchPoints));
                }

                // Raise "MultiTouchChanged" event if necessary
                if (FrameChanged != null)
                {
                    var frameInfo = new FrameInfo() { TimeStamp = DateTime.Now.Ticks, Touches = touchInfoList };
                    FrameChanged(this, frameInfo);

                  //  Debug.WriteLine(touchInfoList[0].ActionType.ToString());
                }

                // Clean up local cache
                foreach (var touchInfo in touchInfoList)
                {
                    if (touchInfo.ActionType == TouchAction2.Up)
                    {
                        _activeTouchInfos.Remove(touchInfo.TouchDeviceId);
                        _activeTouchPoints.Remove(touchInfo.TouchDeviceId);

                    }
                }
            }
        }
Ejemplo n.º 6
0
 public void FrameChanged(FrameInfo frameInfo)
 {
     CreateProxyObjects(frameInfo.Touches);
 }
Ejemplo n.º 7
0
 //------------------------
 /// <summary>
 /// Determines whether specified objects are logically equal
 /// </summary>
 /// <param name="self"></param>
 /// <param name="itemToCheck"></param>
 /// <returns></returns>
 public static bool IsEqual(this FrameInfo self, FrameInfo itemToCheck)
 {
     if (self.TimeStamp == itemToCheck.TimeStamp &&
         self.Touches.IsEqual(itemToCheck.Touches) &&
         self.WaitTime == itemToCheck.WaitTime)
     {
         return true;
     }
     else
     {
         return false;
     }
 }
Ejemplo n.º 8
0
        private void anotoServer_OnStroke(object sender, AnotoPenEvent args)
        {
            // Initialize some variables onto the conoto converter will write to.
            string function; // function string of the area hit by the pen (as configured in configuration)
            long functionid; // function id of the area hit by the pen (as configured in configuration)
            double x, y; // converted x/y coordinates
            TouchInfo info = new TouchInfo();
            TouchAction2 actionType = TouchAction2.Move;

            // handle the type of event we got and call other handler functions
            switch (args.Type)
            {
                case AnotoPenEventType.StrokeStart: // = pen down
                    actionType = TouchAction2.Down;
                    break;
                case AnotoPenEventType.StrokeDrag: // = pen move/drag (there is no hover due the AnotoPen does not support it)
                    actionType = TouchAction2.Move;
                    break;
                case AnotoPenEventType.StrokeEnd: // = pen up
                    actionType = TouchAction2.Up;
                    break;
            }

            // convert AnotoPen coordiantes to the configured ones (in this case, screen coordinates)
            conoto.Convert((ulong)args.PageId, args.X, args.Y,
                           out function, out functionid, out x, out y);

            info.ActionType = actionType;
            info.Position = new Point(x, y);
            info.TouchDeviceId = (int)args.PenId;

            RemoveInactiveTouchPoints();
            UpdateActiveTouchPoint(info);
            foreach (var point in ActiveTouchPoints.Values)
            {
                if (actionType == TouchAction2.Down)
                {
                    point.UpdateSource();
                }
            }

            //Call the delegates
            if (SingleTouchChanged != null)
            {
                foreach (var point in ActiveTouchPoints.Values)
                {
                    SingleTouchChanged(this, new SingleTouchEventArgs(point));
                }
            }

            if (MultiTouchChanged != null)
            {
                MultiTouchChanged(this, new MultiTouchEventArgs(ActiveTouchPoints.Values.ToList<TouchPoint2>()));
            }

            if (FrameChanged != null)
            {
                FrameInfo finfo = new FrameInfo();
                List<TouchPoint2> points = ActiveTouchPoints.Values.ToList<TouchPoint2>();
                List<TouchInfo> infos = new List<TouchInfo>();
                foreach (var point in points)
                {
                    TouchInfo inf = new TouchInfo();
                    inf.ActionType = point.Action.ToTouchActions();
                    inf.Position = point.Position;
                    inf.TouchDeviceId = point.TouchDeviceId;
                    infos.Add(inf);
                }

                finfo.Touches = infos;
                finfo.TimeStamp = args.Timestamp;
                finfo.WaitTime = (int)args.Timestamp - (int)lastTimeStamp;
                FrameChanged(this, finfo);
            }
            lastTimeStamp = (int)args.Timestamp;
        }
Ejemplo n.º 9
0
 private void ActiveHardware_FrameChanged(object sender, FrameInfo frameInfo)
 {
     foreach (var cb in GestureFramework.CommonBehaviors)
     {
         try
         {
             cb.FrameChanged(frameInfo);
         }
         catch (Exception ex)
         {
             System.Diagnostics.Debug.WriteLine(ex.Message);
         }
     }
 }
Ejemplo n.º 10
0
        private void ActiveHardware_FrameChanged(object sender, FrameInfo frameInfo)
        {
            if (isFirstFrame)
            {
                isFirstFrame = false;
                frameInfo.WaitTime = 0;
            }

            _recordedEvents.Add(frameInfo);
        }
Ejemplo n.º 11
0
        private void CallDelegates(TuioTime ftime)
        {
            if (SingleTouchChanged != null)
            {
                foreach (var point in ActiveTouchPoints.Values)
                {
                    SingleTouchChanged(this, new SingleTouchEventArgs(point));
                }
            }

            if (MultiTouchChanged != null)
            {
                List<TouchPoint2> list = ActiveTouchPoints.Values.ToList<TouchPoint2>();
                MultiTouchChanged(this, new MultiTouchEventArgs(list));
            }

            if (FrameChanged != null)
            {
                List<TouchPoint2> points = ActiveTouchPoints.Values.ToList<TouchPoint2>();
                List<TouchInfo> infos = new List<TouchInfo>();
                foreach (var point in points)
                {
                    TouchInfo info = new TouchInfo();
                    info.ActionType = point.Action.ToTouchActions();
                    info.Position = point.Position;
                    info.TouchDeviceId = point.TouchDeviceId;
                    infos.Add(info);
                }
                FrameInfo finfo = new FrameInfo();

                finfo.Touches = infos;
                finfo.TimeStamp = ftime.getMicroseconds();
                finfo.WaitTime = (int)ftime.getMicroseconds() - (int)lastTimeStamp;
                FrameChanged(this, finfo);
            }
            lastTimeStamp = (int)ftime.getMicroseconds();
        }
Ejemplo n.º 12
0
        private static List<GestureToken> GetGestureTokens()
        {
            List<GestureToken> tokens = new List<GestureToken>();

            /*
             * TODO: Temporary work around
             *
             * Currently, we can only load custom gestures from the main-app assembly
             */

            /*load definitions from the framework assembly */
            FrameInfo objectFromFramework = new FrameInfo();

            List<GestureToken> preDefinedGestureTokens = ContentHelper.GetEmbeddedGestureDefinition(objectFromFramework.GetType().Assembly, "gestures.gx");
            if (preDefinedGestureTokens != null && preDefinedGestureTokens.Count > 0)
                tokens.AddRange(preDefinedGestureTokens);

            /*load definitions from the executing assembly (user's app for custom gestures)*/
            if (GestureFramework.HostAssembly != null)
            {
                List<GestureToken> userDefinedGestureTokens = ContentHelper.GetEmbeddedGestureDefinition(GestureFramework.HostAssembly, "gestures.gx");
                if (userDefinedGestureTokens != null && userDefinedGestureTokens.Count > 0)
                    tokens.AddRange(userDefinedGestureTokens);

                //Loading definitions on-the-fly
                try
                {
                    string pathName = System.IO.Path.GetDirectoryName(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName);
                    pathName = pathName + "\\Resources\\Custom\\";
                    DirectoryInfo di = new DirectoryInfo(pathName);
                    FileInfo[] rgFiles = di.GetFiles("*.gx");

                    foreach (FileInfo fi in rgFiles)
                    {
                        List<GestureToken> onTheFlyGestures = ContentHelper.GetOnTheFlyGestureDefinition(GestureFramework.HostAssembly,fi.FullName);
                        if (onTheFlyGestures != null && onTheFlyGestures.Count > 0)
                            tokens.AddRange(onTheFlyGestures);
                    }
                }
                catch (Exception ex)
                {
                  //Do nothing for now.
                }

            }

            return tokens;
        }