Beispiel #1
0
        /// <summary>
        /// Basic method to draw a line starting at a point between two points.
        /// Parameters are in world coordinates and sizes.
        /// </summary>
        /// <param name="width"> Width of the line to draw in meters </param>
        /// <param name="color"> Color of the line</param>
        /// <param name="point"> WorldLocation of the first point of the line (for zero offset)</param>
        /// <param name="length"> length of the line to draw in meters (also when shifted by offset)</param>
        /// <param name="angle"> Angle (in rad east of North)</param>
        /// <param name="lengthOffset">Instead of starting to draw at the given point, only start to draw a distance offset further along the line</param>
        public void DrawLine(float width, Color color, WorldLocation point, float length, float angle, float lengthOffset)
        {
            WorldLocation beginPoint;
            float         sinAngle = (float)Math.Sin(angle);
            float         cosAngle = (float)Math.Cos(angle);

            if (lengthOffset == 0)
            {
                beginPoint = point;
            }
            else
            {
                beginPoint             = new WorldLocation(point);
                beginPoint.Location.X += lengthOffset * sinAngle;
                beginPoint.Location.Z += lengthOffset * cosAngle;
            }
            WorldLocation endPoint = new WorldLocation(beginPoint); //location of end-point

            endPoint.Location.X += length * sinAngle;
            endPoint.Location.Z += length * cosAngle;
            if (OutOfArea(beginPoint) && OutOfArea(endPoint))
            {
                return;
            }
            // definition of rotation in ORTS is angle right of North
            // rotation in the window/draw area is angle right/south of right-horizontal
            // hence a 90 degree correction
            // To prevent double calculations, offset is already taken into account here
            BasicShapes.DrawLine(GetWindowSize(width), color, GetWindowVector(beginPoint),
                                 GetWindowSize(length), angle - MathHelper.Pi / 2);
        }
 /// <summary>
 /// Draw a border around the area
 /// </summary>
 /// <param name="color">The color of the border line</param>
 public void DrawBorder(Color color)
 {
     // We do not use DrawBorder below to prevent a line not being drawn because of OutOfArea
     BasicShapes.DrawLine(1, color, GetWindowVector(0, 0), GetWindowVector(0, AreaH));
     BasicShapes.DrawLine(1, color, GetWindowVector(AreaW, 0), GetWindowVector(AreaW, AreaH));
     BasicShapes.DrawLine(1, color, GetWindowVector(0, 0), GetWindowVector(AreaW, 0));
     BasicShapes.DrawLine(1, color, GetWindowVector(0, AreaH), GetWindowVector(AreaW, AreaH));
 }
 /// <summary>
 /// Basic method to draw a dashed line between two points. Coordinates are in area coordinates.
 /// </summary>
 /// <param name="width"> Width of the line to draw in meters </param>
 /// <param name="color"> Color of the line</param>
 /// <param name="point1"> WorldLocation of the first point of the line</param>
 /// <param name="point2"> WorldLocation of to the last point of the line</param>
 public void DrawDashedLine(float width, Color color, WorldLocation point1, WorldLocation point2)
 {
     if (OutOfArea(point1) && OutOfArea(point2))
     {
         return;
     }
     BasicShapes.DrawDashedLine(GetWindowSize(width), color, GetWindowVector(point1), GetWindowVector(point2));
 }
        /// <summary>
        /// Draw a texture, determined by its name.
        /// </summary>
        /// <param name="location">Location where to draw the texture</param>
        /// <param name="textureName">Name identifying the texture</param>
        /// <param name="angle">Rotation angle for the texture</param>
        /// <param name="size">Size of the texture in world-meters</param>
        /// <param name="minPixelSize">Minimum size in pixels, to make sure you always see something</param>
        /// <param name="maxPixelSize">Maximum size in pixels, to make sure icons are not becoming too big</param>
        /// <param name="color">Color you want the simple texture to have</param>
        public void DrawTexture(WorldLocation location, string textureName, float size, int minPixelSize, int maxPixelSize, Color color, float angle)
        {
            if (OutOfArea(location))
            {
                return;
            }
            float pixelSize = (float)Math.Min(Math.Max(GetWindowSize(size), minPixelSize), maxPixelSize);

            BasicShapes.DrawTexture(GetWindowVector(location), textureName, angle, pixelSize, color, false);
        }
        /// <summary>
        /// Draw a texture, determined by its name, with possible flipping
        /// </summary>
        /// <param name="location">Location where to draw the texture</param>
        /// <param name="textureName">Name identifying the texture</param>
        /// <param name="angle">Rotation angle for the texture</param>
        /// <param name="size">Size of the texture in world-meters</param>
        ///<param name="flip">Whether the texture needs to be flipped (vertically)</param>
        public void DrawTexture(WorldLocation location, string textureName, float size, float angle, bool flip)
        {
            if (OutOfArea(location))
            {
                return;
            }
            float pixelSize = GetWindowSize(size);

            BasicShapes.DrawTexture(GetWindowVector(location), textureName, angle, pixelSize, Color.White, flip);
        }
        /// <summary>
        /// Draw/print a string message on the draw area
        /// </summary>
        /// <param name="location">The world location acting as the starting point of the drawing</param>
        /// <param name="message">The message to print</param>
        /// <param name="offsetX">The offset in X-direction of the top-left location in pixels</param>
        /// <param name="offsetY">The offset in Y-direction of the top-left location in pixels</param>
        public void DrawExpandingString(WorldLocation location, string message, int offsetX, int offsetY)
        {
            if (OutOfArea(location))
            {
                return;
            }
            Vector2 textOffset = new Vector2(offsetX, offsetY);

            BasicShapes.DrawExpandingString(GetWindowVector(location) + textOffset, DrawColors.colorsNormal.Text, message);
        }
        /// <summary>
        /// Draw a horizontal line trough the given world line, all the way from bottom to top. 1 pixel wide.
        /// </summary>
        /// <param name="color">Color of the line</param>
        /// <param name="point">Worldlocation through which to draw the line</param>
        private void DrawLineHorizontal(Color color, WorldLocation point)
        {
            Vector2 middle = GetWindowVector(point);
            Vector2 left   = GetWindowVector(0, 0);
            Vector2 right  = GetWindowVector(AreaW, 0);

            right.Y = middle.Y;
            left.Y  = middle.Y;
            BasicShapes.DrawLine(1, color, left, right);
        }
        /// <summary>
        /// Draw a vertical line trough the given world line, all the way from bottom to top. 1 pixel wide.
        /// </summary>
        /// <param name="color">Color of the line</param>
        /// <param name="point">Worldlocation through which to draw the line</param>
        private void DrawLineVertical(Color color, WorldLocation point)
        {
            Vector2 middle = GetWindowVector(point);
            Vector2 top    = GetWindowVector(0, 0);
            Vector2 bot    = GetWindowVector(0, AreaH);

            bot.X = middle.X;
            top.X = middle.X;
            BasicShapes.DrawLine(1, color, bot, top);
        }
Beispiel #9
0
        /// <summary>
        /// Draw/print a string message on the draw area
        /// </summary>
        /// <param name="location">The world location acting as the starting point of the drawing</param>
        /// <param name="message">The message to print</param>
        public void DrawExpandingString(WorldLocation location, string message)
        {
            if (OutOfArea(location))
            {
                return;
            }
            // We offset the top-left corner to make sure the text is not on the marker.
            int     offsetXY   = 2 + (int)GetWindowSize(2f);
            Vector2 textOffset = new Vector2(offsetXY, offsetXY);

            BasicShapes.DrawExpandingString(GetWindowVector(location) + textOffset, DrawColors.colorsNormal.Text, message);
        }
Beispiel #10
0
        /// <summary>
        /// Draw (print) the values of longitude and latitude
        /// </summary>
        /// <param name="mstsLocation">MSTS Location which to translate to real world coordinates</param>
        public void Draw(WorldLocation mstsLocation)
        {
            if (!Properties.Settings.Default.showLonLat)
            {
                return;
            }

            double latitude  = 1f;
            double longitude = 1f;

            worldLoc.ConvertWTC(mstsLocation.TileX, mstsLocation.TileZ, mstsLocation.Location, ref latitude, ref longitude);
            string latitudeDegrees  = MathHelper.ToDegrees((float)latitude).ToString("F5", System.Globalization.CultureInfo.CurrentCulture);
            string longitudeDegrees = MathHelper.ToDegrees((float)longitude).ToString("F5", System.Globalization.CultureInfo.CurrentCulture);
            string locationText     = String.Format(System.Globalization.CultureInfo.CurrentCulture,
                                                    "Lon = {0}; Lat = {1}", longitudeDegrees, latitudeDegrees);

            BasicShapes.DrawString(lowerLeft, DrawColors.colorsNormal.Text, locationText);
        }
Beispiel #11
0
 /// <summary>
 /// Simply draw a blank background for this area
 /// </summary>
 /// <param name="color">The background color you want</param>
 public void DrawBackground(Color color)
 {
     BasicShapes.DrawLine(AreaW, color, GetWindowVector(AreaW / 2, 0), GetWindowVector(AreaW / 2, AreaH));
 }
Beispiel #12
0
 /// <summary>
 /// Basic method to draw a line between two points without checking whether it is out of bounds or not. Coordinates are in area coordinates.
 /// </summary>
 /// <param name="width"> Width of the line to draw in meters </param>
 /// <param name="color"> Color of the line</param>
 /// <param name="point1"> WorldLocation of the first point of the line</param>
 /// <param name="point2"> WorldLocation of to the last point of the line</param>
 public void DrawLineAlways(float width, Color color, WorldLocation point1, WorldLocation point2)
 {
     BasicShapes.DrawLine(GetWindowSize(width), color, GetWindowVector(point1), GetWindowVector(point2));
 }
Beispiel #13
0
 /// <summary>
 /// This simply draws the debug string.
 /// </summary>
 private void Draw()
 {
     BasicShapes.DrawString(startLocation, Color.Black, DrawString);
 }