示例#1
0
        public virtual void ApplySizeTheme(IDataSizeTheme theme)
        {
            if (LayerData.GeoType == VectorLayer.GEOTYPE_POINT)
            {
                for (int i = 0; i < Features.Count; i++)
                {
                    var feature = LayerData.Features[i];
                    var shape   = Features[feature];

                    double size = MapControl.Current.GetMagFactor(MapControl.Current.InitialScale) * theme.GetSize(feature);
                    ElementPositionHelper.CenterElementInCanvas(shape, size, size);
                }
            }
            else if (LayerData.GeoType == VectorLayer.GEOTYPE_LINEAR)
            {
                // done: 流量图
                for (int i = 0; i < Features.Count; i++)
                {
                    var feature = LayerData.Features[i];
                    var shape   = Features[feature];

                    double size = theme.GetSize(feature);
                    (shape as Polyline).StrokeThickness = size;
                }
            }
            _hasSizeTheme = true;
            _sizeTheme    = theme;
        }
示例#2
0
        protected virtual void AddSpot(Point pos, IFeature f)
        {
            var result = new Ellipse
            {
                Width           = LayerStyle.SpotSize,
                Height          = LayerStyle.SpotSize,
                Stroke          = LayerStyle.Stroke,
                StrokeThickness = LayerStyle.StrokeWeight,
                Fill            = LayerStyle.GetFill()
            };

            ElementPositionHelper.SetElementDesignPosition(result, pos);
            ElementPositionHelper.CenterElementInCanvas(result, LayerStyle.SpotSize, LayerStyle.SpotSize);
            this.AddFeatureChildren(f, result);
        }
示例#3
0
 public virtual void ClearSizeTheme()
 {
     for (int i = 0; i < Features.Count; i++)
     {
         var feature = LayerData.Features[i];
         var shape   = Features[feature];
         if (LayerData.GeoType == VectorLayer.GEOTYPE_POINT)
         {
             double size = MapControl.Current.GetMagFactor(MapControl.Current.InitialScale) * LayerStyle.SpotSize;
             ElementPositionHelper.CenterElementInCanvas(shape, size, size);
         }
         else if (LayerData.GeoType == VectorLayer.GEOTYPE_LINEAR)
         {
             double size = MapControl.Current.GetMagFactor(MapControl.Current.InitialScale) * LayerStyle.StrokeWeight;
             (shape as Polyline).StrokeThickness = size;
         }
     }
     _hasSizeTheme = false;
 }
示例#4
0
        protected virtual void AddLable(Point pos, string text, double angle = 0)
        {
            if (!string.IsNullOrEmpty(text)) // 20120315优化
            {
                TextBlock tb = new TextBlock {
                    Text = text
                };                                            //此处与silverlight不同
                tb.FontSize   = LayerStyle.FontSize;
                tb.Foreground = LayerStyle.FontBrush;
                double actualWidth  = LayerStyle.FontSize * 5;
                double actualHeight = LayerStyle.FontSize;

                ElementPositionHelper.SetElementData(tb, "Type", LayerData.GeoType);
                ElementPositionHelper.SetElementData(tb, "Size", LayerStyle.FontSize);
                ElementPositionHelper.SetElementData(tb, "Angle", angle);
                ElementPositionHelper.SetElementDesignPosition(tb, pos);
                //ElementPositionHelper.CenterElementInCanvas(tb, actualWidth, actualHeight);

                Canvas.SetLeft(tb, pos.X - actualWidth / 2);
                Canvas.SetTop(tb, pos.Y - actualHeight / 2);

                var trans1 = new ScaleTransform {
                    ScaleX = 1, ScaleY = -1, CenterX = actualWidth / 2, CenterY = actualHeight / 2
                };
                var trans2 = new RotateTransform {
                    Angle = angle, CenterX = actualWidth / 2, CenterY = actualHeight / 2
                };
                var trans = new TransformGroup();
                trans.Children.Add(trans1);
                trans.Children.Add(trans2);
                if (LayerData.GeoType == VectorLayer.GEOTYPE_POINT)
                {
                    trans.Children.Add(new TranslateTransform {
                        X = actualWidth / 1.5
                    });
                }
                tb.RenderTransform = trans;

                LabelLayer.Children.Add(tb);
            }
        }
示例#5
0
 public virtual void SetMagFactor(double magFactor)
 {
     if (this.LayerData.GeoType == VectorLayer.GEOTYPE_POINT && !_hasSizeTheme)
     {
         foreach (Ellipse ep in this.Features.Values)
         {
             double size = this.LayerStyle.SpotSize * magFactor;
             ep.StrokeThickness = this.LayerStyle.StrokeWeight * magFactor;
             ElementPositionHelper.CenterElementInCanvas(ep, size, size);
         }
     }
     else if (this.LayerData.GeoType == VectorLayer.GEOTYPE_LINEAR && !IsRoad())
     {
         if (_hasSizeTheme)
         {
             foreach (var feature in this.Features)
             {
                 feature.Value.StrokeThickness = _sizeTheme.GetSize(feature.Key) * magFactor;
             }
         }
         else
         {
             foreach (var poly in this.Features.Values)
             {
                 poly.StrokeThickness = this.LayerStyle.StrokeWeight * magFactor;
             }
         }
     }
     else if (this.LayerData.GeoType == VectorLayer.GEOTYPE_REGION)
     {
         foreach (Polygon poly in this.Features.Values)
         {
             poly.StrokeThickness = this.LayerStyle.StrokeWeight * magFactor;
         }
     }
 }