形状和绘图画布的比例是不同的

时间:2016-07-12 06:59:10

标签: c# .net wpf canvas shapes

我在驾驶时使用ZoomableCanvas来显示车辆的位置。为此,我使用比例因子,如下所示

  double xq = this.drawingCanvas.ActualWidth / maxX; // The maximum X 
  double yq = this.drawingCanvas.ActualHeight / maxY; // The maximum Y
  // use the smallest proportion quotient
  GlobalVar.DrawingQ = xq < yq ? xq : yq;

这用于显示Map并缩放Map中的所有Points和Important位置。地图上显示的所有点(位置)都在X和Y坐标中。 要显示车辆我使用Windows.Shapes.Rectangle。我知道车辆的长度和宽度,因此我以下面显示的方式分配矩形

double LenScaled = Length * GlobalVar.DrawingQ;
double WidthScaled = Width * GlobalVar.DrawingQ;
// Vehicle
Rectangle _rectangle = new Rectangle();
_rectangle.Width = LenScaled;
_rectangle.Height = WidthScaled;

请注意,点的坐标和车辆的尺寸在同一单位,但不知何故缩放不正确。车辆看起来更大(可以很容易地在视觉上确认,但我没有显示屏幕截图)。能否请您提供意见?

0 个答案:

没有答案