private void ShowCenterTileInfo() { if (!tiles.ContainsKey(centerTilexy)) { tbTileInfo.Text = "center tile is blank!"; return; } TileMeta centerTile = tiles[centerTilexy]; string result = "X,Y,Z/" + centerTilexy + " TileCount/" + tiles.Count + " LevelRange/" + levelMin + "->" + levelMax; // show utm info int utmx, utmy; double res; centerTilexy.GetUtmXy(out utmx, out utmy, out res); result += "\r\nIf Utm: x,y,zone,res/" + utmx + "," + utmy + "," + centerTile.zone + "," + res + " x1,x2,y1,y2/" + utmx * 400 * res + "," + (utmx + 1) * 400 * res + "," + (utmy + 1) * 400 * res + "," + utmy * 400 * res; // show bing info result += "\r\nIf Bing: QKey/" + BingProjection.GetQuadKey(centerTilexy) + " LatLon/" + BingProjection.TileXYToLatLong(centerTilexy); // show NASA info double lat, lon; centerTilexy.GetNeighbor(0, 1).GetNASALatLon(out lat, out lon); result += "\r\nIf NASA: LeftBot/" + lat.ToString("F6") + "," + lon.ToString("F6"); centerTilexy.GetNeighbor(1, 0).GetNASALatLon(out lat, out lon); result += " RightTop/" + lat.ToString("F6") + "," + lon.ToString("F6"); tbTileInfo.Text = result + "\r\n\r\n"; }
public void Paint(bool originalOnly = false, bool centerOnly = false) { // clear image Graphics g = Graphics.FromImage(pbox.Image); if (!originalOnly) { g.Clear(bgColor); } else { g.Clear(Color.FromArgb(0, 0, 0, 0)); } // draw tiles for (int j = 0; j < rowCount; j++) { for (int i = 0; i < columnCount; i++) { int offsetx = i - centerX; int offsety = j - centerY; if (centerOnly && (offsetx != 0 || offsety != 0)) { continue; } TileXY xy = centerTilexy.GetNeighbor(offsetx, offsety); if (tiles.ContainsKey(xy)) { TileMeta tmeta = tiles[xy]; byte[] imgBuff = MDataFile.Read(tdataPaths[tmeta.tdataPathId], tmeta.imgOffset, tmeta.imgLength); Rectangle rect = new Rectangle(i * imageSize, j * imageSize, imageSize, imageSize); g.DrawImage(Image.FromStream(new MemoryStream(imgBuff)), rect); if (!originalOnly && !_isShowValidGraph && distinguishPng && tmeta.hasAlpha) { g.FillRectangle(brushCoverPNG, rect); } } } } if (!originalOnly) { // get current utm correction zone int zone = Int32.Parse(tbUtmCorrectionZone.Text); // get top left tile xy TileXY topLeftTileXY = centerTilexy.GetNeighbor(-centerX, -centerY); // draw masks if (!_isShowValidGraph) { foreach (Mask m in masks) { // draw utm corrected masks g.FillPolygon(m.type == 0 ? brushMaskSkip : (m.type == 1 ? brushMaskNewRange : brushMaskRemove), m.GetUtmCorrectedRelativePolygon(topLeftTileXY, zone)); } } // show valid graph if (_isShowValidGraph && pixelValidRange != null) { pixelValidRange.DrawValidGraph((Bitmap)pbox.Image); } // draw mouse line if (isMouseDown) { g.DrawRectangle(penMouseDragLine, Math.Min(mousePositionNow.X, mousePositionStart.X), Math.Min(mousePositionNow.Y, mousePositionStart.Y), Math.Abs(mousePositionNow.X - mousePositionStart.X), Math.Abs(mousePositionNow.Y - mousePositionStart.Y)); // draw utm corrected line Point start = new Point(Math.Min(mousePositionStart.X, mousePositionNow.X), Math.Min(mousePositionStart.Y, mousePositionNow.Y)); Point end = new Point(Math.Max(mousePositionStart.X, mousePositionNow.X), Math.Max(mousePositionStart.Y, mousePositionNow.Y)); Mask mTmp = new Mask(start, end, topLeftTileXY); g.DrawPolygon(penMouseDragLineUtmCorrected, mTmp.GetUtmCorrectedRelativePolygon(topLeftTileXY, zone)); } } pbox.Refresh(); ShowCenterTileInfo(); }