public void OnEvent(object element, object dataset) { if (!(element is IDatasetElement) || !(dataset is IDataset)) { return; } TOC toc = _doc.FocusMap.TOC as TOC; if (toc == null) { return; } ITOCElement tocElement = toc.GetTOCElement(((IDatasetElement)element).Class); if (tocElement == null) { return; } ITOCElement parentTocElement = tocElement.ParentGroup; //IDatasetElement e = ((IDataset)dataset)[((IDatasetElement)element).Title]; //if (e == null) return; if (!(element is ILayer)) { return; } FormSplitLayerWithFilter dlg = new FormSplitLayerWithFilter(_doc, element as ILayer); if (dlg.ShowDialog() == DialogResult.OK) { foreach (FormSplitLayerWithFilter.FilterExpessionItem expression in dlg.FilterExpressions) { ILayer newLayer = LayerFactory.Create(((IDatasetElement)element).Class); if (newLayer is IFeatureLayer && element is IFeatureLayer && ((IFeatureLayer)element).Joins != null) { ((IFeatureLayer)newLayer).Joins = ((IFeatureLayer)element).Joins.Clone() as FeatureLayerJoins; } if (newLayer is IFeatureLayer) { QueryFilter filter = new QueryFilter(); filter.WhereClause = expression.Filter; ((IFeatureLayer)newLayer).FilterQuery = filter; _doc.FocusMap.AddLayer(newLayer); tocElement = toc.GetTOCElement(newLayer); tocElement.Name = expression.Text; toc.Add2Group(tocElement, parentTocElement); } } if (_doc.Application is IMapApplication) { ((IMapApplication)_doc.Application).RefreshActiveMap(Framework.Carto.DrawPhase.All); } } }