/// <summary>
 /// Publishes events.
 /// </summary>
 /// <param name="guiregion">The GUIRegion instance that triggered the event.</param>
 /// <param name="t">The type of event triggered.</param>
 public void Publish(GUIRegion guiregion, EventType t)
 {
     if (regionActivated != null)
     {
        regionActivated(this, new GUIRegionEvent(this, t));
     }
 }
Example #2
0
 /// <summary>
 /// Publishes events.
 /// </summary>
 /// <param name="guiregion">The GUIRegion instance that triggered the event.</param>
 /// <param name="t">The type of event triggered.</param>
 public void Publish(GUIRegion guiregion, EventType t)
 {
     if (regionActivated != null)
     {
         regionActivated(this, new GUIRegionEvent(this, t));
     }
 }
 //use only with offscreenregion!
 public MenuIcon(GUIRegion region)
 {
     this.region = region;
 }
        /// <summary>
        /// Blocking function that will, eventually, return an Event
        /// consisting of the GUIRegion that Published the event, and any EventArgs
        /// </summary>
        /// <returns></returns>
        public GUIRegion GetActivatedRegion()
        {
            for (; ; )
            {
                System.Threading.Thread.Sleep(200); // so I heard you like hogging cpu time                
                lastKBState = kBState;
                kBState = Recellection.publicKeyBoardState;
#if DEBUG
                if (kBState.IsKeyDown(Keys.W) && lastKBState.IsKeyUp(Keys.W))
                {
                    if (top != null)
                    {
                        top.Publish(top, new global::Recellection.Code.Utility.Events.EventType());
                    }
                }
                else if(kBState.IsKeyDown(Keys.S) && lastKBState.IsKeyUp(Keys.S))
                {
                    if (bot != null)
                    {                    
                        bot.Publish(bot, new global::Recellection.Code.Utility.Events.EventType());
                    }
                }
                else if(kBState.IsKeyDown(Keys.A) && lastKBState.IsKeyUp(Keys.A))
                {
                    if (left != null)
                    {
                        left.Publish(left, new global::Recellection.Code.Utility.Events.EventType());
                    }
                        
                }
                else if(kBState.IsKeyDown(Keys.D) && lastKBState.IsKeyUp(Keys.D))
                {
                    if (right != null)
                    {
                        right.Publish(right, new global::Recellection.Code.Utility.Events.EventType());
                    }
                }
#endif
                if (newActivatedRegion != null)
                {
                    GUIRegion temp = newActivatedRegion;
                    newActivatedRegion = null;
                    return temp;
                }
            }
        }
        /// <summary>
        /// Attempts to add a region
        /// Note that a region will be disabled by default
        /// </summary>
        /// <param name="newRegion"></param>
        /// <returns>
        /// will return an identifier to your newly created region
        /// should you want to fiddle with it later
        /// </returns>
        private WindowBoundInteractionRegionIdentifier AddRegion(GUIRegion newRegion)
        {                
                newRegion.CanActivate = true;
                if (newRegion.DwellTime == null)
                {
                    newRegion.DwellTime = new TimeSpan(0, 0, DEFAULT_TIME_SPAN);
                }
                newRegion.Enabled = false;

                //TODO: Figure out what these calls does
                //newRegion.AlwaysInteractive = true; 
                //newRegion.IsActivating = true; 
                //newRegion.UsesCoordinate = true; 

            try
            {
                logger.Info("about to add a new region");
                Interaction.AddRegion(newRegion); //this is what actually makes tobii start tracking our region
            }
            catch (Exception) //will occur if the region was already added, Interaction.AddRegion can throw stuff
            {
                logger.Warn("Failed to add a new region, region was most likely already added");
                return null;
            }
            logger.Info("Successfully added a new region");
            newRegion.regionActivated += newRegion_regionActivated;
            return newRegion.RegionIdentifier;
        }
 // the TobiiController subscribes to all regions Activate event
 void newRegion_regionActivated(object publisher, global::Recellection.Code.Utility.Events.Event<GUIRegion> ev)
 {
     newActivatedRegion = (GUIRegion)publisher;
 }
 void FocusEnter(object sender, RegionFocusEventArgs e)
 {
     newActivatedRegion = (GUIRegion)sender;
 }
 private void AddBotOffScreen(GUIRegion bot)
 {
     this.bot = bot;
     AddRegion(this.bot);
     this.bot.Enabled = true;
     this.bot.FocusEnter += new EventHandler<RegionFocusEventArgs>(FocusEnter);
 }
 private void AddTopOffScreen(GUIRegion top)
 {
     this.top = top;
     AddRegion(this.top);
     this.top.Enabled = true;
     this.top.FocusEnter += new EventHandler<RegionFocusEventArgs>(FocusEnter);
 }
 private void AddRightOffScreen(GUIRegion right)
 {
     this.right = right;
     AddRegion(this.right);
     this.right.Enabled = true;
     this.right.FocusEnter += new EventHandler<RegionFocusEventArgs>(FocusEnter);
 }
 //We'll just do them like this for now
 private void AddLeftOffScreen(GUIRegion left)
 {
     this.left = left;            
     AddRegion(left);
     this.left.Enabled = true;
     this.left.FocusEnter += new EventHandler<RegionFocusEventArgs>(FocusEnter);
 }