Example #1
0
        protected override void RenderFeatureLayer(IFeatureLayer layer, RenderPhase phase)
        {
            IFeatureRenderer renderer = GetRenderer <IFeatureRenderer>(layer);

            renderer.RenderTransform = ToViewTransform;

            Debug.Assert(renderer != null);

            Debug.Assert(layer.Style is FeatureStyle);
            FeatureStyle layerStyle = layer.Style as FeatureStyle;

            switch (phase)
            {
            case RenderPhase.Normal:
                IEnumerable <FeatureDataRow> features
                    =
                        EnumerateWhileMonitoringClientConnection(layer.Features.Select(ViewEnvelopeInternal.ToGeometry()));

                foreach (FeatureDataRow feature in features)
                {
                    FeatureStyle style = getStyleForFeature(layer, feature, layerStyle);

                    IEnumerable renderedFeature = renderer.RenderFeature(feature,
                                                                         style,
                                                                         RenderState.Normal,
                                                                         layer);
                    View.ShowRenderedObjects(renderedFeature);
                }
                break;

            case RenderPhase.Selected:
                IEnumerable <FeatureDataRow> selectedRows =
                    EnumerateWhileMonitoringClientConnection(layer.SelectedFeatures);

                foreach (FeatureDataRow selectedFeature in selectedRows)
                {
                    FeatureStyle style = getStyleForFeature(layer, selectedFeature, layerStyle);

                    IEnumerable renderedFeature = renderer.RenderFeature(selectedFeature,
                                                                         style,
                                                                         RenderState.Selected,
                                                                         layer);
                    View.ShowRenderedObjects(renderedFeature);
                }
                break;

            case RenderPhase.Highlighted:
                IEnumerable <FeatureDataRow> highlightedRows =
                    EnumerateWhileMonitoringClientConnection(layer.HighlightedFeatures);

                foreach (FeatureDataRow highlightedFeature in highlightedRows)
                {
                    FeatureStyle style = getStyleForFeature(layer, highlightedFeature, layerStyle);

                    IEnumerable renderedFeature = renderer.RenderFeature(highlightedFeature,
                                                                         style,
                                                                         RenderState.Highlighted,
                                                                         layer);
                    View.ShowRenderedObjects(renderedFeature);
                }
                break;

            default:
                break;
            }

            renderer.CleanUp();
        }