Base class for gesture recognizers' configuration objects. A configuration contains all the informations to parametrize the behaviour of the GR, or to make it access some resources.
示例#1
0
 /// <summary>
 /// Registers a handler for a gesture event. The GR will be configured with the given configuration.
 /// </summary>
 /// <param name="grType">Type of the gesture recognizer.</param>
 /// <param name="grConf">The GR's configuration.</param>
 /// <param name="e">The event as string.</param>
 /// <param name="handler">The listener's function that will be called when the event is raised.</param>
 public static void RegisterHandler(Type grType, GRConfiguration grConf, string ev, GestureEventHandler handler)
 {
     lock (s_lock)
     {
         GestureEventRegistry.RegisterHandler(grType, grConf, ev, handler);
     }
 }
示例#2
0
        internal static void RegisterHandler(Type grType, GRConfiguration grConf, string ev, GestureEventHandler handler)
        {
            System.Diagnostics.Debug.Assert(handler.Target is IGestureListener,
                "Attempting to register a handler for an instance of class " +
                handler.Target.GetType().ToString() +
                " which doesn't implement the interface IGestureListener.");

            int priorityNumber;
            if (!s_priorityNumbersTable.ContainsKeys(grType, grConf))
            {
                priorityNumber = 0;
                s_priorityNumbersTable[grType, grConf] = priorityNumber;
            }
            else
                priorityNumber = s_priorityNumbersTable[grType, grConf];

            RegistrationInfo grInfo = new RegistrationInfo(grType, grConf, priorityNumber, ev, handler);

            if (grType.IsSubclassOf(typeof(GlobalGestureRecognizer)))
            {
                s_ggrRegistry.Add(grInfo);

                // update subscribed GRManagers
                foreach (GroupGRManager grManager in s_subscribedGRManagers)
                    grManager.UpdateGGR(grInfo);
            }
            else
            {
                s_lgrRegistry.Add(grInfo);

                // TODO: if LGRs are associated to the group's FINAL target list then dynamic update should be done
            }
        }
 public GlobalGestureRecognizer(GRConfiguration configuration)
     : base(configuration)
 {
     m_handlerTable = new DoubleDictionary<EventInfo, object, List<GestureEventHandler>>();
     m_temporaryHandlerTable = new DoubleDictionary<TargetList, EventInfo, List<GestureEventHandler>>();
     m_temporaryTargetSingletonList = new List<IGestureListener>(1);
 }
示例#4
0
 public RemovingLinkGR(GRConfiguration configuration)
     : base(configuration)
 {
     RemovingLinkGRConfiguration conf = (RemovingLinkGRConfiguration)Configuration;
     m_demoObjectManager = conf.DemoObjectManager;
     DefaultEvents = new string[] { "RemoveLinks" };
     m_linksToRemove = new List<DemoObjectLink>();
 }
示例#5
0
 public LazoGR(GRConfiguration configuration)
     : base(configuration)
 {
     LazoGRConfiguration conf = (LazoGRConfiguration)Configuration;
     m_currentTuioObjects = conf.CurrentTuioObjects;
     m_threshold = conf.Threshold;
     DefaultEvents = new string[] { "Lazo" };
 }
示例#6
0
        public CircleGR(GRConfiguration configuration)
            : base(configuration)
        {
            if (!(configuration is CircleGRConfiguration))
                Configuration = CircleGRConfiguration.DEFAULT_Configuration;

            m_configuration = (CircleGRConfiguration)Configuration;
            m_threshold = m_configuration.Threshold;
            m_startingTime = -1;

            DefaultEvents = new string[] { "Circle" };

            m_left = Settings.InputDevResolutionRatio;
            m_right = 0;
            m_top = 1;
            m_bottom = 0;
        }
示例#7
0
 /// <summary>
 /// Sets the priority number to associate with the given gesture recognizer class and the
 /// given configuration.
 /// Note that once a priority number is set it can't be changed.
 /// </summary>
 /// <param name="grType">Type of the gesture recognizer.</param>
 /// <param name="configuration">Configuration of the gesture recognizer.</param>
 /// <param name="priorityNumber">Priority number.</param>
 public static void SetPriorityNumber(Type grType, GRConfiguration configuration, int priorityNumber)
 {
     lock (s_lock)
     {
         GestureEventRegistry.SetPriorityNumber(grType, configuration, priorityNumber);
     }
 }
 public LocalGestureRecognizer(GRConfiguration configuration)
     : base(configuration)
 {
 }
示例#9
0
        public BasicMultiFingerGR(GRConfiguration configuration)
            : base(configuration)
        {
            if (!(configuration is BasicMultiFingerGRConfiguration))
                Configuration = new BasicMultiFingerGRConfiguration();

            BasicMultiFingerGRConfiguration conf = (BasicMultiFingerGRConfiguration)Configuration;
            TAP_TIME = conf.TAP_TIME;
            HOVER_SIZE = conf.HOVER_SIZE;
            HOVER_TIME = conf.HOVER_TIME;
            IS_TRIPLE_TAP_ENABLED = conf.IS_TRIPLE_TAP_ENABLED;

            ClosestCurrentEvents = new string[] { "Down", "Up", "Tap", "DoubleTap", "TripleTap", "Hover", "EndHover", "Move" }; // add, remove?
            ClosestEnteringEvents = new string[] { "Enter" };
            ClosestLeavingEvents = new string[] { "Leave" };
            UnionEvents = new string[] { "Removed", "Terminated" };

            m_hoverThread = new Thread(new ThreadStart(HoverLoop));
            m_hoverThread.Start();
            m_tapSpatialConstraintsOk = true;
            m_numberOfCurrentFingers = 0;
            m_tapNumberOfFingers = 0;
        }
示例#10
0
            private readonly int m_priorityNumber; // priority number of the GR

            #endregion Fields

            #region Constructors

            internal RegistrationInfo(Type grType, GRConfiguration grConf, int pn, string ev, GestureEventHandler handler)
            {
                m_grType = grType;
                m_grConf = grConf;
                m_priorityNumber = pn;
                m_event = ev;
                m_handler = handler;
            }
示例#11
0
        internal static void UnregisterHandler(Type grType, GRConfiguration grConf, string ev, GestureEventHandler handler)
        {
            List<RegistrationInfo> registry;
            if (grType.IsSubclassOf(typeof(GlobalGestureRecognizer)))
                registry = s_ggrRegistry;
            else
                registry = s_lgrRegistry;

            bool removed = registry.Remove(registry.Find(delegate(RegistrationInfo ggrInfo)
            {
                return
                    ggrInfo.GRType == grType &&
                    ggrInfo.GRConfiguration == grConf &&
                    ggrInfo.Event == ev &&
                    ggrInfo.Handler == handler;
            }));

            System.Diagnostics.Debug.WriteLineIf(!removed, "Warning: GRRegistry.UnregisterHandler did not find the handler to remove.");
        }
示例#12
0
 internal static void SetPriorityNumber(Type grType, GRConfiguration configuration, int priorityNumber)
 {
     if (!s_priorityNumbersTable.ContainsKeys(grType, configuration))
         s_priorityNumbersTable[grType, configuration] = priorityNumber;
     else
         System.Diagnostics.Debug.Assert(s_priorityNumbersTable[grType, configuration] == priorityNumber,
             "Attempting to reset a priority number to a different value than the one previously set.");
 }
示例#13
0
        public MultiTraceGR(GRConfiguration configuration)
            : base(configuration)
        {
            m_conf = (MultiTraceGRConfiguration)Configuration;

            ClosestInitialEvents  = new string[] { "MultiTraceStarted" };
            ClosestEnteringEvents = new string[] { "MultiTraceEnter" };
            ClosestLeavingEvents  = new string[] { "MultiTraceLeave" };
            ClosestCurrentEvents  = new string[] { "MultiTraceDown", "MultiTraceMove", "MultiTraceUp" };
            ClosestFinalEvents    = new string[] { "MultiTraceEnd" };
            DefaultEvents         = new string[] { "MultiTraceFromTo" };

            m_startingTime = -1;
            m_startingTraces = new List<Trace>();
            m_nOfFingers = 0;
        }
示例#14
0
 public PinchingGR(GRConfiguration configuration)
     : base(configuration)
 {
     PinchingGRConfiguration conf = (PinchingGRConfiguration)configuration;
     m_clientWindow = conf.ClientWindow;
     m_relativeScaling = conf.RelativeScaling;
 }
示例#15
0
        public GestureRecognizer(GRConfiguration configuration)
        {
            m_configuration = configuration;
            m_armed = false;
            m_bufferedHandlers = new List<GestureEventHandler>();
            m_bufferedArgs = new List<GestureEventArgs>();

            m_recognizing = true;
            m_successful = false;
            m_confidence = 1;
            m_processing = true;
        }