private void HandleBoundsProviderRemoved(IBoundsProvider removedBoundsProvider) { // Iterate over all our steps; if any use the removed bounds provider, set that reference to null. // Using reflection for this may seem hacky, but there are a lot of infrastructure overhead (and timing issues) with a more concrete approach. // The main advantage here is there is no need to enforce every consumer of a bounds provider // listening to the bounds provider repo or its individual bounds providers for removal handling. foreach (var step in RegisteredSteps) { var flags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic; var boundsProviderInfos = step.GetType() .GetProperties(flags) .Where(p => typeof(IBoundsProvider).IsAssignableFrom(p.PropertyType)); foreach (var boundsProviderInfo in boundsProviderInfos) { var boundsProvider = boundsProviderInfo.GetValue(step, null) as IBoundsProvider; if (boundsProvider == removedBoundsProvider) { boundsProviderInfo.SetValue(step, null, null); } } } }
private void HandleDropDownItemClicked(ControllableDropDownItemBehaviour item) { PropertyInfo.SetValue(PropertyResolutionObject, item.Model, null); CurrentProvider = item.Model as IBoundsProvider; HideDropDown(); }
private void HandleBoundsProviderRemoved(IBoundsProvider provider) { if (provider == CurrentProvider) { CurrentProvider = null; } RemoveDropDownItem(provider); }
private void AddDropDownItem(IBoundsProvider provider) { var go = Instantiate(DropDownItemPrefab); var item = go.GetComponent <ControllableDropDownItemBehaviour>(); item.Initialize(provider.BoundsProviderKey, provider); item.transform.SetParent(DropDownItemAttachmentPoint, false); item.Clicked += HandleDropDownItemClicked; DropDownItems.Add(item); }
public static void Remove(IBoundsProvider boundsProvider) { Debug.Log("Removing bounds provider " + boundsProvider.BoundsProviderKey); if (!BoundsProviders.Contains(boundsProvider)) { throw new InvalidOperationException("This BoundsProvider is not registered."); } BoundsProviders.Remove(boundsProvider); BoundsProviderRemoved(boundsProvider); }
public BoundsComparer(IBoundsProvider item, CompareType compareType = CompareType.CompareX) { _compareType = compareType; _boundedItem = item; if (compareType == CompareType.CompareX) { _compareFunction = (x) => CompareX(x, true); } else { _compareFunction = (x) => CompareY(x, true); } }
private void RemoveDropDownItem(IBoundsProvider provider) { var item = DropDownItems.FirstOrDefault(i => i.Model == provider); if (item == null) { return; } item.Clicked -= HandleDropDownItemClicked; Destroy(item.gameObject); DropDownItems.Remove(item); }
public static void Add(IBoundsProvider boundsProvider) { if (BoundsProviders.Contains(boundsProvider)) { throw new InvalidOperationException("This BoundsProvider is already registered. Key " + boundsProvider.BoundsProviderKey); } if (BoundsProviders.Any(p => p.BoundsProviderKey == boundsProvider.BoundsProviderKey)) { Debug.LogWarning("A different BoundsProvider with the same key is already registered. Key " + boundsProvider.BoundsProviderKey + ". Proceeding to register second BoundsProvider."); } // throw new InvalidOperationException("A different BoundsProvider with the same key is already registered. Key " + boundsProvider.BoundsProviderKey ); BoundsProviders.Add(boundsProvider); BoundsProviderAdded(boundsProvider); }
public Present Evaluate(Present[] paramList) { D.Assert(paramList.Length == 1); IBoundsProvider boundsProvider = (IBoundsProvider)paramList[0]; RenderRegion renderRegion = boundsProvider.GetRenderRegion(); IPointTransformer robustPointTransform = imageTransformer.getSourceToDestLatLonTransformer(); double num = 0.05; List<LatLon> asLatLonList = renderRegion.GetAsLatLonList(); List<LatLon> list = new List<LatLon>(); for (int i = 0; i < asLatLonList.Count; i++) { int index = (i + 1) % asLatLonList.Count; LatLon source = asLatLonList[i]; LatLon dest = asLatLonList[index]; ParametricLine parametricLine = new ParametricLine(source, dest); int numSteps = (int)Math.Max(1.0, parametricLine.Length() / num); List<LatLon> list2 = parametricLine.Interpolate(numSteps); list.AddRange(list2.ConvertAll<LatLon>((LatLon inp) => robustPointTransform.getTransformedPoint(inp))); } RenderRegion renderRegion2 = new RenderRegion(list, new DirtyEvent()); return new BoundsPresent(renderRegion2); }
private void HandleBoundsProviderAdded(IBoundsProvider provider) { AddDropDownItem(provider); }