Esempio n. 1
0
        private FrameworkElement GetLayerNodeHeader(MapLayer layer)
        {
            StackPanel sp = new StackPanel {
                Orientation = Orientation.Horizontal
            };
            CheckBox cb = new CheckBox {
                Content = layer.LayerData.Name
            };

            cb.IsChecked  = layer.Visibility == System.Windows.Visibility.Visible;
            cb.Checked   += (sender, e) => LayerVisible(layer, true);
            cb.Unchecked += (sender, e) => LayerVisible(layer, false);
            Slider slider = new Slider {
                Minimum = 0, Maximum = 1, Width = 40, Margin = new Thickness(10, 0, 0, 0)
            };

            slider.SetBinding(Slider.ValueProperty, new System.Windows.Data.Binding("Opacity")
            {
                Source = layer, Mode = System.Windows.Data.BindingMode.TwoWay
            });
            sp.Children.Add(cb);
            sp.Children.Add(slider);
            return(sp);
        }
Esempio n. 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 == "1")
            {
                foreach (Feature feature in layer.Features)
                {
                    Geometry.Point2D pos = new Geometry.Point2D(feature.GeoData);
                    AddSpot(new Point(pos.x, pos.y), feature);
                    AddLable(new Point(pos.x, pos.y), LayerLableStyle.GetLable(feature));
                }
            }
            else if (layer.GeoType == "2")
            {
                if (IsRoad())
                {
                    foreach (Feature feature in layer.Features)
                    {
                        Geometry.Polyline polyline = new Geometry.Polyline(feature.GeoData);
                        AddRoadStroke(polyline.Points.Select(p => new Point(p.x, p.y)).ToArray(), feature);
                    }
                }
                foreach (Feature feature in layer.Features)
                {
                    Geometry.Polyline poly = new Geometry.Polyline(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 最后统一加标签
                {
                    Geometry.Polyline poly = new Geometry.Polyline(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)
                    {
                        Geometry.Point2D tempPt   = poly.GetPointAtDist(position);
                        double           tanVal   = poly.GetFirstDerivative(position);
                        double           rotation = Math.Atan(tanVal);
                        double           angle    = 180 / Math.PI * rotation;
                        AddLable(new Point(tempPt.x, tempPt.y), text, angle);
                    }
                }
            }
            else if (layer.GeoType == "4")
            {
                foreach (Feature feature in layer.Features)
                {
                    Geometry.Polygon poly   = new Geometry.Polygon(feature.GeoData);
                    Geometry.Point2D 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));
                }
            }
        }