private bool ResolveEnabled(FeatureId featureId, IConfigurationSection section) { if (!featureId.ParentFeatureId.Equals(FeatureId.Empty)) { var parentState = GetFeatureState(featureId.ParentFeatureId); if (parentState == null || !parentState.Enabled) { return(false); } } if (bool.TryParse(section["Enabled"], out bool enabled)) { return(enabled); } if (bool.TryParse(section.Value, out enabled)) { return(enabled); } if (_rootScope != null) { return(_rootScope.ResolveEnabled(featureId, _rootScope._section)); } var feature = _featureProvider.GetFeature(featureId); if (feature != null) { return(feature.EnabledByDefault); } return(false); }
public override void OnMouseDown(ICoordinate worldPosition, MouseEventArgs e) { MapControl.SnapTool.Reset(); SelectTool selectTool = MapControl.SelectTool; IFeature oldSelectedFeature = null; IList <ITrackerFeature> focusedTrackers = new List <ITrackerFeature>(); ITrackerFeature trackerFeature = selectTool.GetTrackerAtCoordinate(worldPosition); if (null != trackerFeature) { oldSelectedFeature = trackerFeature.FeatureEditor.SourceFeature; focusedTrackers = trackerFeature.FeatureEditor.GetFocusedTrackers(); } // Let the selecttool handle the mouse event unless multiple trackers have focus and // there is no key pressed. In this case the user expects to move the focused trackers // and SelectTool will reset them if (!((focusedTrackers.Count > 1) && (!selectTool.KeyToggleSelection) && (!selectTool.KeyExtendSelection) /* && (trackerFeature.Selected)*/)) { selectTool.OnMouseDown(worldPosition, e); // did we just deselect out only selected tracker? if (null != trackerFeature) { int focusedTrackersCount = trackerFeature.FeatureEditor.GetFocusedTrackers().Count; if ((focusedTrackers.Count != focusedTrackersCount) && (0 == focusedTrackersCount)) { return; } } } if (e.Button != MouseButtons.Left) { return; } if (1 != selectTool.FeatureEditors.Count) { return; } dragSource = null; if (selectTool.FeatureEditors.Count == 1) { isBusy = true; IFeature feature = selectTool.FeatureEditors[0].SourceFeature; if (oldSelectedFeature != feature) { if (!selectTool.FeatureEditors[0].AllowSingleClickAndMove()) { isBusy = false; return; } } if (!selectTool.FeatureEditors[0].AllowMove()) { isBusy = false; return; } // TODO: this code looks too complicated //IFeatureProvider featureProvider = selectTool.MultiSelection[0].Layer.DataSource; IFeatureProvider featureProvider = selectTool.FeatureEditors[0].Layer.DataSource; // IndexOf doesn;'t work on shapefiles; featurerows are recreated during each read int dragIndex = featureProvider.Features.IndexOf(feature); if (-1 == dragIndex) { isBusy = false; return; } dragSource = StartDragging(worldPosition, featureProvider.GetFeature(dragIndex)); if (null == dragSource) { isBusy = false; return; } } else { return; } MouseDownLocation = worldPosition; snappingSource = null; IList <ITrackerFeature> list = selectTool.FeatureEditors[0].GetFocusedTrackers(); if (null == list) { return; } if (list.Count <= 0) { return; } if (list.Count == 1) { snappingSource = list[0]; } return; }
public IFeatureStateProvider OfType <TFeature>() where TFeature : class, IFeature { var feature = _provider.GetFeature <TFeature>(); return(new ConfigurationDrivenFeatureAdapter(feature)); }