Background: I am currently busy with showing position of a Vehicle on a Zoomable Canvas based on the Position (X,Y) and Orientation (for Rotation). I use Rectangle for visualizing the vehicle. Everything works well but I got a bit greedy and now I want to replace the Rectangle with Top View Picture of the Vehicle, so it looks that the vehicle itself is moving instead a Rectangle.
Code Below:
private void PaintLocationVehicle(VehicleClass vc)
{
    IEnumerable<Rectangle> collection = vc.ZoomableCanvas.Children.OfType<Rectangle>().Where(x => x.Name == _vehicleobjectname);
    List<Rectangle> listE = collection.ToList<Rectangle>();
    for (int e = 0; e < listE.Count; e++)
        vc.ZoomableCanvas.Children.Remove(listE[e]);
    // Assign X and Y Position from Vehicle
    double drawingX = vc.gCurrentX * GlobalVar.DrawingQ;
    double drawingY = vc.gCurrentY * GlobalVar.DrawingQ;
    // Scale Length and Width of Vehicle
    double tractorWidthScaled = vc.tractorWidth * GlobalVar.DrawingQ;
    double tractorLengthScaled = vc.tractorLength * GlobalVar.DrawingQ;
    // Get Drawing Location
    double _locationX = drawingX - (tractorLengthScaled / 2);
    double _locationY = drawingY - ((tractorWidthScaled  / 2));
    RotateTransform rotation = new RotateTransform();
    // Angle in 10th of a Degree
    rotation.Angle = vc.gCurrentTheeta/10 ;
    double i = 0;
    //paint the node
    Rectangle _rectangle = new Rectangle();
    _rectangle.Stroke = new SolidColorBrush((Color)ColorConverter.ConvertFromString(vc.VehicleColor == "" ? "Black" : vc.VehicleColor));
        _rectangle.Fill = new SolidColorBrush((Color)ColorConverter.ConvertFromString(vc.VehicleColor == "" ? "Black" : vc.VehicleColor));
        i += 0;
    _rectangle.Width = tractorLengthScaled ;
    _rectangle.Height = tractorWidthScaled;
    rotation.CenterX = _rectangle.Width / 2;
    rotation.CenterY = _rectangle.Height / 2;
    _rectangle.RenderTransform = rotation;
    Canvas.SetTop(_rectangle, _locationY + i);
    Canvas.SetLeft(_rectangle, _locationX + i);
    _rectangle.SetValue(ZoomableCanvas.ZIndexProperty, 2);
    string _tooltipmsg = "Canvas: " + vc.ZoomableCanvas.Name;
    // Assign ToolTip Values for User
    _tooltipmsg += "\nX: " + vc.gCurrentX;
    _tooltipmsg += "\nY: " + vc.gCurrentY;
    _rectangle.ToolTip = _tooltipmsg;
    _rectangle.Name = _vehicleobjectname;
    //add to the canvas
    vc.ZoomableCanvas.Children.Add(_rectangle);
}
Note: VehicleClass holds all the Values for a certain Vehicle. DrawingQ holds the transformation scale from Reality to Zoomable Canvas.
So the issues I forsee:
- How to append the Size of a Jpeg file to get the size same as Rectangle?
- What kind of Shape object shall I use? Please suggest.
 
     
    