protected virtual void AddSpot(Point pos, IFeature f) { double size = LayerStyle.SpotSize; Ellipse result = new Ellipse { Width = size, Height = size }; ElementPositionHelper.SetElementDesignPosition(result, pos); ElementPositionHelper.CenterElementInCanvas(result, size, size); result.Stroke = LayerStyle.Stroke; result.StrokeThickness = LayerStyle.StrokeWeight; result.Fill = LayerStyle.GetFill(); this.AddFeatureChildren(f, result); }
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 == "1") { trans.Children.Add(new TranslateTransform { X = actualWidth / 1.5 }); } tb.RenderTransform = trans; LabelLayer.Children.Add(tb); } }