Server.Items.Sextant.Format C# (CSharp) Method

Format() public static method

public static Format ( Point3D p, Map map, int &xLong, int &yLat, int &xMins, int &yMins, bool &xEast, bool &ySouth ) : bool
p Point3D
map Map
xLong int
yLat int
xMins int
yMins int
xEast bool
ySouth bool
return bool
		public static bool Format( Point3D p, Map map, ref int xLong, ref int yLat, ref int xMins, ref int yMins, ref bool xEast, ref bool ySouth )
		{
			if ( map == null || map == Map.Internal )
				return false;

			int x = p.X, y = p.Y;
			int xCenter, yCenter;
			int xWidth, yHeight;

			if ( !ComputeMapDetails( map, x, y, out xCenter, out yCenter, out xWidth, out yHeight ) )
				return false;

			double absLong = (double)((x - xCenter) * 360) / xWidth;
			double absLat  = (double)((y - yCenter) * 360) / yHeight;

			if ( absLong > 180.0 )
				absLong = -180.0 + (absLong % 180.0);

			if ( absLat > 180.0 )
				absLat = -180.0 + (absLat % 180.0);

			bool east = ( absLong >= 0 ), south = ( absLat >= 0 );

			if ( absLong < 0.0 )
				absLong = -absLong;

			if ( absLat < 0.0 )
				absLat = -absLat;

			xLong = (int)absLong;
			yLat  = (int)absLat;

			xMins = (int)((absLong % 1.0) * 60);
			yMins = (int)((absLat  % 1.0) * 60);

			xEast = east;
			ySouth = south;

			return true;
		}
	}

Usage Example

コード例 #1
0
            public MessageGump(MessageEntry entry, Map map, Point3D loc) : base((640 - entry.Width) / 2, (480 - entry.Height) / 2)
            {
                int    xLong = 0, yLat = 0;
                int    xMins = 0, yMins = 0;
                bool   xEast = false, ySouth = false;
                string fmt;

                if (Sextant.Format(loc, map, ref xLong, ref yLat, ref xMins, ref yMins, ref xEast, ref ySouth))
                {
                    fmt = String.Format("{0}°{1}'{2},{3}°{4}'{5}", yLat, yMins, ySouth ? "S" : "N", xLong, xMins, xEast ? "E" : "W");
                }
                else
                {
                    fmt = "?????";
                }

                AddPage(0);
                AddBackground(0, 0, entry.Width, entry.Height, 2520);
                AddHtml(38, 38, entry.Width - 83, entry.Height - 86, String.Format(entry.Message, fmt), false, false);
            }
All Usage Examples Of Server.Items.Sextant::Format