private void SetMapElementProperty(string propertyName, object value) { PropertyInfo prop = ConcreteObject.GetType().GetProperty(propertyName); if (prop != null && prop.CanWrite) { prop.SetValue(ConcreteObject, value, null); } }
private void VisibilityChanged(bool value) { if (ConcreteObject is LayerOverlay && needRefresh) { foreach (var subEntity in Children) { subEntity.needRefresh = false; LayerPlugin layerPlugin = GisEditor.LayerManager.GetLayerPlugins(subEntity.ConcreteObject.GetType()).FirstOrDefault(); if (layerPlugin != null) { bool isDataSourceAvailable = layerPlugin.DataSourceResolveTool.IsDataSourceAvailable((Layer)subEntity.ConcreteObject); if (isDataSourceAvailable) { subEntity.IsChecked = IsChecked; ((Layer)subEntity.ConcreteObject).IsVisible = IsChecked; } } subEntity.needRefresh = true; } var tileOverlay = (TileOverlay)ConcreteObject; tileOverlay.IsVisible = isChecked; if (!isChecked) { RefreshOverlay(tileOverlay); } GisEditor.UIManager.InvokeRefreshPlugins(); } else if (ConcreteObject is Layer && needRefresh) { LayerPlugin layerPlugin = GisEditor.LayerManager.GetLayerPlugins(ConcreteObject.GetType()).FirstOrDefault(); if (layerPlugin != null) { bool isDataSourceAvailable = layerPlugin.DataSourceResolveTool.IsDataSourceAvailable((Layer)ConcreteObject); if (!isDataSourceAvailable) { ((Layer)ConcreteObject).IsVisible = false; isChecked = false; OnPropertyChanged("IsChecked"); return; } } if (!isChecked) { Image image = warningImages.FirstOrDefault(i => i.Name.Equals("InEditing", StringComparison.InvariantCultureIgnoreCase)); if (image != null) { warningImages.Remove(image); } } ((Layer)ConcreteObject).IsVisible = isChecked; Parent.needRefresh = false; Parent.IsChecked = Parent.Children.Any(m => m.IsChecked); Parent.needRefresh = true; TileOverlay tileOverlay = Parent.ConcreteObject as TileOverlay; if (tileOverlay != null) { //In this case, tileOverlay will execute Refresh() in default. if (!tileOverlay.IsVisible && Parent.IsChecked) { tileOverlay.IsVisible = Parent.IsChecked; } else { tileOverlay.IsVisible = Parent.IsChecked; tileOverlay.Invalidate(); RefreshOverlay(tileOverlay); } } GisEditor.UIManager.InvokeRefreshPlugins(); } if (!(ConcreteObject is Layer) && !(ConcreteObject is LayerOverlay)) { TryChangeIsVisiblePropertyOfMapElement(); } if (ConcreteObject is Styles.Style) { Styles.Style concreteStyle = (Styles.Style)ConcreteObject; concreteStyle.IsActive = value; Layer layer = LayerListHelper.FindMapElementInTree <Layer>(this); if (layer != null && layer.IsVisible) { LayerOverlay layerOverlay = LayerListHelper.FindMapElementInTree <LayerOverlay>(this); if (layerOverlay != null && layerOverlay.IsVisible) { layerOverlay.Invalidate(); RefreshOverlay(layerOverlay); } } } }