Пример #1
0
        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;
            }

            ILayer newLayer = LayerFactory.Create(((IDatasetElement)element).Class);

            if (newLayer is IFeatureLayer && element is IFeatureLayer)
            {
                if (((IFeatureLayer)element).Joins != null)
                {
                    ((IFeatureLayer)newLayer).Joins = ((IFeatureLayer)element).Joins.Clone() as FeatureLayerJoins;
                }
                if (((IFeatureLayer)element).FilterQuery != null)
                {
                    QueryFilter filter = new QueryFilter();
                    filter.WhereClause = ((IFeatureLayer)element).FilterQuery.WhereClause;
                    ((IFeatureLayer)newLayer).FilterQuery = filter;
                }
            }
            if (newLayer == null)
            {
                return;
            }

            _doc.FocusMap.AddLayer(newLayer);

            if (_doc.Application is IMapApplication)
            {
                ((IMapApplication)_doc.Application).RefreshActiveMap(Framework.Carto.DrawPhase.All);
            }
        }
Пример #2
0
        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);
                }
            }
        }
Пример #3
0
        public Task <bool> OnEvent(object element, object dataset)
        {
            if (!(element is IDatasetElement) || !(dataset is IDataset))
            {
                return(Task.FromResult(true));
            }

            TOC toc = _doc.FocusMap.TOC as TOC;

            if (toc == null)
            {
                return(Task.FromResult(true));
            }

            ITOCElement tocElement = toc.GetTOCElement(((IDatasetElement)element).Class);

            if (tocElement == null)
            {
                return(Task.FromResult(true));
            }

            ILayer newLayer = LayerFactory.Create(((IDatasetElement)element).Class);

            if (newLayer is IFeatureLayer && element is IFeatureLayer)
            {
                if (((IFeatureLayer)element).Joins != null)
                {
                    ((IFeatureLayer)newLayer).Joins = ((IFeatureLayer)element).Joins.Clone() as FeatureLayerJoins;
                }
                if (((IFeatureLayer)element).FilterQuery != null)
                {
                    QueryFilter filter = new QueryFilter();
                    filter.WhereClause = ((IFeatureLayer)element).FilterQuery.WhereClause;
                    ((IFeatureLayer)newLayer).FilterQuery = filter;
                }

                ((IFeatureLayer)newLayer).FeatureRenderer = ((IFeatureLayer)element).FeatureRenderer.Clone() as IFeatureRenderer ?? ((IFeatureLayer)newLayer).FeatureRenderer;
                ((IFeatureLayer)newLayer).LabelRenderer   = ((IFeatureLayer)element).LabelRenderer?.Clone() as ILabelRenderer ?? ((IFeatureLayer)newLayer).LabelRenderer;

                ((IFeatureLayer)newLayer).MinimumScale = ((IFeatureLayer)element).MinimumScale;
                ((IFeatureLayer)newLayer).MaximumScale = ((IFeatureLayer)element).MaximumScale;

                ((IFeatureLayer)newLayer).MinimumLabelScale = ((IFeatureLayer)element).MinimumLabelScale;
                ((IFeatureLayer)newLayer).MaximumLabelScale = ((IFeatureLayer)element).MaximumLabelScale;

                ((IFeatureLayer)newLayer).MaxRefScaleFactor      = ((IFeatureLayer)element).MaxRefScaleFactor;
                ((IFeatureLayer)newLayer).MaxLabelRefScaleFactor = ((IFeatureLayer)element).MaxLabelRefScaleFactor;
            }
            if (newLayer == null)
            {
                return(Task.FromResult(true));
            }

            _doc.FocusMap.AddLayer(newLayer);

            if (_doc.Application is IMapApplication)
            {
                ((IMapApplication)_doc.Application).RefreshActiveMap(Framework.Carto.DrawPhase.All);
            }

            return(Task.FromResult(true));
        }