/// <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); }
/// <summary> /// Unloads a Menu, preferably only provide this /// function with the menu that is currently loaded /// </summary> /// <param name="menu"></param> public void UnloadMenu(Menu menu) { foreach (GUIRegion region in menu.GetRegions()) { Interaction.RemoveRegion(region.RegionIdentifier); } if (menu.leftOff != null) { Interaction.RemoveRegion(menu.leftOff.region.RegionIdentifier); } if (menu.rightOff != null) { Interaction.RemoveRegion(menu.rightOff.region.RegionIdentifier); } if (menu.botOff != null) { Interaction.RemoveRegion(menu.botOff.region.RegionIdentifier); } if (menu.topOff != null) { Interaction.RemoveRegion(menu.topOff.region.RegionIdentifier); } }