示例#1
0
        private FrameworkElement GetLayerNodeHeader(MapLayer layer)
        {
            var stackPanel = new StackPanel
            {
                Orientation = Orientation.Horizontal
            };

            var checkBox = new CheckBox
            {
                Content   = layer.LayerData.Name,
                IsChecked = layer.Visibility == Visibility.Visible
            };

            checkBox.Checked   += (sender, e) => LayerVisible(layer, true);
            checkBox.Unchecked += (sender, e) => LayerVisible(layer, false);

            var slider = new Slider
            {
                Minimum = 0,
                Maximum = 1,
                Width   = 40,
                Margin  = new Thickness(10, 0, 0, 0)
            };

            slider.SetBinding(
                dp: Slider.ValueProperty,
                binding: new Binding("Opacity")
            {
                Source = layer,
                Mode   = BindingMode.TwoWay
            });

            stackPanel.Children.Add(checkBox);
            stackPanel.Children.Add(slider);
            return(stackPanel);
        }
示例#2
0
        public virtual void SetData(VectorLayer layer)
        {
            LayerData       = layer;
            LayerStyle      = GetLayerStyle(layer);
            LayerLableStyle = GetLabelStyle(layer);
            Features.Clear();
            Overlays.Clear();
            Children.Clear();
            LabelLayer = new MapLayer();

            if (layer.GeoType == VectorLayer.GEOTYPE_POINT)
            {
                foreach (Feature feature in layer.Features)
                {
                    var pos = feature.GeoData[0];
                    AddSpot(new Point(pos.X, pos.Y), feature);
                    AddLable(new Point(pos.X, pos.Y), LayerLableStyle.GetLable(feature));
                }
            }
            else if (layer.GeoType == VectorLayer.GEOTYPE_LINEAR)
            {
                if (IsRoad())
                {
                    foreach (Feature feature in layer.Features)
                    {
                        var polyline = new PointString(feature.GeoData);
                        AddRoadStroke(polyline.Points.Select(p => new Point(p.X, p.Y)).ToArray(), feature);
                    }
                }
                foreach (Feature feature in layer.Features)
                {
                    var poly = new PointString(feature.GeoData);
                    if (!IsRoad())
                    {
                        AddPolyline(poly.Points.Select(p => new Point(p.X, p.Y)).ToArray(), feature);
                    }
                    else
                    {
                        AddRoadFill(poly.Points.Select(p => new Point(p.X, p.Y)).ToArray(), feature);
                    }
                }
                foreach (Feature feature in layer.Features) // mod 20130516 最后统一加标签
                {
                    var    poly = new PointString(feature.GeoData);
                    string text = LayerLableStyle.GetLable(feature);
                    double linearRepeatInterval = LayerLableStyle.LinearRepeatInterval;
                    double length = poly.Length();
                    //double scale = 4;  // 这个时候出现主窗口的Scale是不合适的。
                    List <double> positions = new List <double>(); // mod 20130528 与SVG同步
                    if (length > 0 && length < 2 * linearRepeatInterval)
                    {
                        positions.Add(length / 2);
                    }
                    else
                    {
                        int index = 1;
                        while (index * linearRepeatInterval < length)
                        {
                            positions.Add(index * linearRepeatInterval);
                            index++;
                        }
                    }
                    foreach (double position in positions)
                    {
                        var    tempPt   = poly.GetPointAtDist(position);
                        double rotation = poly.Dir(position).Heading();
                        double angle    = 180 / Math.PI * rotation;
                        AddLable(new Point(tempPt.X, tempPt.Y), text, angle);
                    }
                }
            }
            else if (layer.GeoType == VectorLayer.GEOTYPE_REGION)
            {
                foreach (Feature feature in layer.Features)
                {
                    var poly   = new PointString(feature.GeoData);
                    var center = poly.Centroid();
                    AddPolygon(poly.Points.Select(p => new Point(p.X, p.Y)).ToArray(), feature);
                    AddLable(new Point(center.X, center.Y), LayerLableStyle.GetLable(feature));
                }
            }
        }