Example #1
0
        // Summary:
        //     Set the GraphicsLayer display options according to the definition
        //     which is specified in the LocalELayer.
        //     The display options include selection color, renderer, and labelling
        //
        void setGraphicLayerDisplayOptions(LayerDef layerDef, IS3GraphicsLayer gLayer)
        {
            if (layerDef == null || gLayer == null)
            {
                return;
            }

            gLayer.IsVisible = layerDef.IsVisible;

            gLayer.SelectionColor = layerDef.SelectionColor;
            ISymbol symbol = GraphicsUtil.GenerateLayerSymbol(layerDef, gLayer.geometryType);

            gLayer.renderer = Runtime.graphicEngine.newSimpleRenderer(symbol);

            //if (layerDef.RendererDef == null)
            //{
            //
            //}
            //else
            //{
            //    gLayer.renderer = Runtime.graphicEngine.newRenderer(layerDef.RendererDef);
            //}

            if (layerDef.EnableLabel == true)
            {
                AttributeLabelClass labelClass = generateLayerAttributeLable(layerDef, gLayer.geometryType);
                gLayer.Labeling.LabelClasses.Add(labelClass);
            }
        }
Example #2
0
        private LabelProperties GenerateLabelProperties(LabelListSetting listSetting)
        {
            LabelProperties labels = new LabelProperties();

            if (listSetting != null)
            {
                listSetting.RelatedLabelProperties = labels;
                foreach (var setting in listSetting.LabelSettings)
                {
                    var labelClass = new AttributeLabelClass
                    {
                        TextExpression = setting.TextExpression,
                        LabelPlacement = setting.Placement,
                        LabelPosition  = setting.Position,
                        IsVisible      = setting.IsVisible,
                        Symbol         = new TextSymbol
                        {
                            Color = setting.LabelColor
                        },
                        WhereClause = setting.WhereClause
                    };
                    labels.LabelClasses.Add(labelClass);
                    setting.RelatedAttributeLabelClass = labelClass;
                }
            }

            return(labels);
        }
Example #3
0
        private LabelProperties GenerateLabelProperties(LabelListSetting listSetting)
        {
            LabelProperties labels = new LabelProperties();

            if (listSetting != null)
            {
                listSetting.RelatedLabelProperties = labels;
                foreach (var setting in listSetting.LabelSettings)
                {
                    var labelClass = new AttributeLabelClass
                    {
                        TextExpression = setting.TextExpression,
                        LabelPlacement = setting.Placement,
                        LabelPosition  = setting.Position,
                        IsVisible      = setting.IsVisible,
                        Symbol         = new TextSymbol
                        {
                            Color = setting.LabelColor
                        }
                    };
                    labelClass.Symbol.Font.FontFamily = "微软雅黑";
                    labelClass.Symbol.Font.FontSize   = 14; //12 default
                    labels.LabelClasses.Add(labelClass);
                    setting.RelatedAttributeLabelClass = labelClass;
                }
            }

            return(labels);
        }
Example #4
0
        private GraphicsLayer GenerateLayer(Diamond14Entity entity, List <double> latList, List <double> lonList)
        {
            var graphics = new List <Graphic>();

            foreach (var line in entity.Lines)
            {
                var tmp = GenerateGraphics(line, Diamond14Attributes.LineTypeLine, Colors.Red);
                graphics.AddRange(tmp);
            }
            foreach (var line in entity.Contours)
            {
                var tmp = GenerateGraphics(line, Diamond14Attributes.LineTypeContour, Colors.Purple);
                graphics.AddRange(tmp);
            }

            for (int i = 0; i < latList.Count; i++)
            {
                var tmp = GenerateGraphic(latList[i], lonList[i]);
                graphics.Add(tmp);
            }

            var layer = new GraphicsLayer
            {
                //GraphicsSource = graphics,
                DisplayName = entity.Description,
                ID          = new Guid().ToString()
            };

            foreach (var graphic in graphics)
            {
                layer.Graphics.Add(graphic);
            }

            // Add Label
            var labelClass = new AttributeLabelClass
            {
                TextExpression = $"[{Diamond14Attributes.LineValue}]",
                LabelPlacement = LabelPlacement.LineAboveStart,
                LabelPosition  = LabelPosition.FixedPositionWithOverlaps,
                IsVisible      = true,
                Symbol         = new TextSymbol
                {
                    Color = Colors.Blue
                }
            };

            layer.Labeling.LabelClasses.Add(labelClass);

            return(layer);
        }
Example #5
0
        /// <summary>
        /// 聚合标签
        /// </summary>
        /// <param name="labelField"></param>
        public void AddLabel(string labelField)
        {
            AttributeLabelClass alc = new AttributeLabelClass
            {
                TextExpression = "[" + labelField + "]",
                Symbol         = new TextSymbol
                {
                    Color = System.Windows.Media.Color.FromArgb(255, 0, 0, 255),
                    Font  = { FontFamily = "宋体" }
                }
            };

            //解决中文乱码
            Labeling.LabelClasses.Add(alc);
        }
Example #6
0
        // Summary:
        //     Generate a default label attributes according to the GeometryType
        //     The default labelling property of a feature is [Name]
        //
        AttributeLabelClass generateDefaultLayerAttributeLable(Core.Model.GeometryType geometryType)
        {
            IS3TextSymbol textSymbol = new IS3TextSymbol();

            textSymbol.Color = System.Windows.Media.Colors.Black;

            AttributeLabelClass labelClass = new AttributeLabelClass();

            labelClass.IsVisible      = true;
            labelClass.TextExpression = "[Name]";
            labelClass.Symbol         = textSymbol;

            if (geometryType == Core.Model.GeometryType.Polygon)
            {
                labelClass.LabelPlacement = LabelPlacement.PolygonAlwaysHorizontal;
            }

            return(labelClass);
        }
Example #7
0
        // Summary:
        //     Generate a label attributes according to the definition
        //     which is specified in the LayerDef
        //
        AttributeLabelClass generateLayerAttributeLable(LayerDef layerDef,
                                                        Core.Model.GeometryType geometryType)
        {
            if (layerDef == null)
            {
                return(generateDefaultLayerAttributeLable(geometryType));
            }

            IS3SymbolFont font = new IS3SymbolFont(
                layerDef.LabelFontFamily, double.Parse(layerDef.LabelFontSize.ToString()));

            font.FontStyle      = layerDef.LabelFontStyle;
            font.FontWeight     = layerDef.LabelFontWeight;
            font.TextDecoration = layerDef.LabelTextDecoration;

            IS3TextSymbol textSymbol = new IS3TextSymbol();

            textSymbol.Color           = layerDef.LabelColor;
            textSymbol.Font            = font;
            textSymbol.BorderLineColor = layerDef.LabelBorderLineColor;
            textSymbol.BorderLineSize  = double.Parse(layerDef.LabelBorderLineWidth.ToString());
            textSymbol.BackgroundColor = layerDef.LabelBackgroundColor;

            AttributeLabelClass labelClass = new AttributeLabelClass();

            labelClass.IsVisible      = true;
            labelClass.TextExpression = layerDef.LabelTextExpression;
            labelClass.WhereClause    = layerDef.LabelWhereClause;
            labelClass.Symbol         = textSymbol;

            if (geometryType == Core.Model.GeometryType.Polygon)
            {
                labelClass.LabelPlacement = LabelPlacement.PolygonAlwaysHorizontal;
            }

            return(labelClass);
        }
Example #8
0
        private LabelProperties GenerateLabelProperties(LabelListSetting listSetting)
        {
            LabelProperties labels = new LabelProperties();

            if (listSetting != null)
            {
                listSetting.RelatedLabelProperties = labels;
                foreach (var setting in listSetting.LabelSettings)
                {
                    var labelClass = new AttributeLabelClass
                    {
                        TextExpression = setting.TextExpression,
                        LabelPlacement = setting.Placement,
                        LabelPosition  = setting.Position,
                        IsVisible      = setting.IsVisible,
                        Symbol         = new TextSymbol
                        {
                            Color = setting.LabelColor
                        }
                    };
                    labels.LabelClasses.Add(labelClass);
                    setting.RelatedAttributeLabelClass = labelClass;
                }
            }

            //AttributeLabelClass label = new AttributeLabelClass
            //{
            //    TextExpression = $"[{Diamond2Attributes.Temperature}]",
            //    LabelPlacement = LabelPlacement.PointAboveLeft,
            //    Symbol = new TextSymbol
            //    {
            //        Color = Colors.Red
            //    },
            //    LabelPosition = LabelPosition.FixedPositionWithOverlaps,

            //};
            //labels.LabelClasses.Add(label);

            //label = new AttributeLabelClass
            //{
            //    TextExpression = $"[{Diamond2Attributes.TemperatureDiff}]",
            //    LabelPlacement = LabelPlacement.PointCenterLeft,
            //    Symbol = new TextSymbol
            //    {
            //        Color = Colors.Blue
            //    },
            //    LabelPosition = LabelPosition.FixedPositionWithOverlaps,
            //    IsVisible = false
            //};
            //labels.LabelClasses.Add(label);

            //label = new AttributeLabelClass
            //{
            //    TextExpression = $"[{Diamond2Attributes.DewPoint}]",
            //    LabelPlacement = LabelPlacement.PointBelowLeft,
            //    Symbol = new TextSymbol
            //    {
            //        Color = Colors.Blue
            //    },
            //    LabelPosition = LabelPosition.FixedPositionWithOverlaps,
            //    IsVisible = false
            //};
            //labels.LabelClasses.Add(label);

            //label = new AttributeLabelClass
            //{
            //    TextExpression = $"[{Diamond2Attributes.WindSpeed}]",
            //    LabelPlacement = LabelPlacement.PointAboveRight,
            //    Symbol = new TextSymbol
            //    {
            //        Color = Colors.Blue
            //    },
            //    LabelPosition = LabelPosition.FixedPositionWithOverlaps
            //};
            //labels.LabelClasses.Add(label);

            //label = new AttributeLabelClass
            //{
            //    TextExpression = $"[{Diamond2Attributes.Height}]",
            //    LabelPlacement = LabelPlacement.PointCenterRight,
            //    Symbol = new TextSymbol
            //    {
            //        Color = Colors.Blue
            //    },
            //    LabelPosition = LabelPosition.FixedPositionWithOverlaps,
            //    IsVisible = false
            //};
            //labels.LabelClasses.Add(label);

            //label = new AttributeLabelClass
            //{
            //    TextExpression = $"[{Diamond2Attributes.StationNumber}]",
            //    LabelPlacement = LabelPlacement.PointBelowRight,
            //    Symbol = new TextSymbol
            //    {
            //        Color = Colors.Blue
            //    },
            //    LabelPosition = LabelPosition.FixedPositionWithOverlaps,
            //    IsVisible = false
            //};
            //labels.LabelClasses.Add(label);

            return(labels);
        }
Example #9
0
        // Summary:
        //     Generate a label attributes according to the definition
        //     which is specified in the LayerDef
        //
        AttributeLabelClass generateLayerAttributeLable(LayerDef layerDef,
            Core.Geometry.GeometryType geometryType)
        {
            if (layerDef == null)
                return generateDefaultLayerAttributeLable(geometryType);

            IS3SymbolFont font = new IS3SymbolFont(
                layerDef.LabelFontFamily, layerDef.LabelFontSize);
            font.FontStyle = layerDef.LabelFontStyle;
            font.FontWeight = layerDef.LabelFontWeight;
            font.TextDecoration = layerDef.LabelTextDecoration;

            IS3TextSymbol textSymbol = new IS3TextSymbol();
            textSymbol.Color = layerDef.LabelColor;
            textSymbol.Font = font;
            textSymbol.BorderLineColor = layerDef.LabelBorderLineColor;
            textSymbol.BorderLineSize = layerDef.LabelBorderLineWidth;
            textSymbol.BackgroundColor = layerDef.LabelBackgroundColor;

            AttributeLabelClass labelClass = new AttributeLabelClass();
            labelClass.IsVisible = true;
            labelClass.TextExpression = layerDef.LabelTextExpression;
            labelClass.WhereClause = layerDef.LabelWhereClause;
            labelClass.Symbol = textSymbol;

            if (geometryType == Core.Geometry.GeometryType.Polygon)
                labelClass.LabelPlacement = LabelPlacement.PolygonAlwaysHorizontal;

            return labelClass;
        }
Example #10
0
        // Summary:
        //     Generate a default label attributes according to the GeometryType
        //     The default labelling property of a feature is [Name]
        //
        AttributeLabelClass generateDefaultLayerAttributeLable(Core.Geometry.GeometryType geometryType)
        {
            IS3TextSymbol textSymbol = new IS3TextSymbol();
            textSymbol.Color = System.Windows.Media.Colors.Black;

            AttributeLabelClass labelClass = new AttributeLabelClass();
            labelClass.IsVisible = true;
            labelClass.TextExpression = "[Name]";
            labelClass.Symbol = textSymbol;

            if (geometryType == Core.Geometry.GeometryType.Polygon)
                labelClass.LabelPlacement = LabelPlacement.PolygonAlwaysHorizontal;

            return labelClass;
        }