コード例 #1
0
ファイル: SymbolUtils.cs プロジェクト: esride-jts/ProSuite
        public static CIMMarker CreateMarker(CIMColor color, double size, MarkerStyle style)
        {
            var geometry = CreateMarkerGeometry(style);
            var symbol   = CreatePolygonSymbol(color);

            var graphic = new CIMMarkerGraphic {
                Geometry = geometry, Symbol = symbol
            };

            var marker = new CIMVectorMarker();

            marker.ColorLocked                = false;
            marker.Enable                     = true;
            marker.Size                       = size >= 0 ? size : DefaultMarkerSize;
            marker.AnchorPointUnits           = SymbolUnits.Relative;
            marker.BillboardMode3D            = BillboardMode.FaceNearPlane;
            marker.DominantSizeAxis3D         = DominantSizeAxis.Y;
            marker.ScaleSymbolsProportionally = true;
            marker.RespectFrame               = true;
            marker.MarkerGraphics             = new[] { graphic };
            marker.Frame                      = style == MarkerStyle.Circle
                                               ? GeometryFactory.CreateEnvelope(-5, -5, 5, 5)
                                               : graphic.Geometry.Extent;

            return(marker);
        }
コード例 #2
0
        private void SetFramePrimitiveNames(CIMPointSymbol symbol, string key)
        {
            if (symbol == null)
            {
                return;
            }

            // verify that the point symbol has only one vector marker layer

            if (symbol.SymbolLayers == null)
            {
                return;
            }
            if (symbol.SymbolLayers.Length != 1)
            {
                return;
            }
            CIMVectorMarker marker = symbol.SymbolLayers[0] as CIMVectorMarker;

            if (marker == null)
            {
                return;
            }
            if (marker.MarkerGraphics == null)
            {
                return;
            }

            // find the fill marker
            CIMMarkerGraphic fill      = null;
            CIMMarkerGraphic outline   = null;
            double           maxArea   = 0;
            double           maxLength = 0;

            foreach (var graphic in marker.MarkerGraphics)
            {
                if (graphic == null)
                {
                    continue;
                }
                var hasFill   = SymbolUtil.HasFill(graphic.Symbol as CIMMultiLayerSymbol);
                var hasStroke = SymbolUtil.IsStroke(graphic.Symbol as CIMMultiLayerSymbol);
                if (graphic.Geometry is ArcGIS.Core.Geometry.Multipart geom)
                {
                    if (hasFill)
                    {
                        double area = Math.Abs(geom.Area);
                        if (area > maxArea)
                        {
                            maxArea = area;
                            fill    = graphic;
                        }
                    }
                    if (hasStroke)
                    {
                        double length = Math.Abs(geom.Length);
                        if (length > maxLength)
                        {
                            maxLength = length;
                            outline   = graphic;
                        }
                    }
                }
            }

            // add the primitive names
            foreach (var graphic in marker.MarkerGraphics)
            {
                if (graphic == fill)
                {
                    SymbolUtil.SetPrimitiveNames(graphic.Symbol as CIMMultiLayerSymbol, "frame_fill", "frame_outline", false, false);
                }
                else if (graphic == outline)
                {
                    SymbolUtil.SetPrimitiveNames(graphic.Symbol as CIMMultiLayerSymbol, "frame_outline", "frame_outline", false, false);
                }
                else
                {
                    SymbolUtil.SetPrimitiveNames(graphic.Symbol as CIMMultiLayerSymbol, "frame_outline", "frame_outline", false, false);
                }
            }

            ++_updatedSymbols;
        }