private void FunctionCalcBoundariesSync(Quadrant map, GregorianDateTime date) { GCLog.Write("Ekadasi Boundaries Calculation START"); RootArray = null; CalculationFinished = false; GregorianDateTime dt = new GregorianDateTime(date); dt.PreviousDay(); dt.PreviousDay(); GCLocation loc = new GCLocation(); TTimeZone tz = new TTimeZone(); loc.Latitude = 0; loc.Longitude = 0; loc.TimeZone = tz; TResultCalendar cal = new TResultCalendar(); cal.EkadasiOnly = true; List <Quadrant> quandrantList = new List <Quadrant>(); quandrantList.Add(map); QuadrantArray qa; map = null; int count = 0, maxCount = 2000; while (quandrantList.Count > 0) { map = quandrantList[0]; quandrantList.RemoveAt(0); if (stopRequested) { break; } map.Details = CalculateQuadrantArray(map, dt, loc, cal, quandrantList); if (RootArray == null) { RootArray = map.Details; } // for testing count++; if (count >= maxCount) { break; } } CalculationFinished = true; GCLog.Write("Ekadasi Boundaries Calculation END"); StopMethodDelegate stopMethod = new StopMethodDelegate(PerformeStop); this.Invoke(stopMethod); }
private void DrawQuandrantOverlay(Graphics g, GCMap map, Rectangle mapArea, QuadrantArray qa) { for (int x = 0; x < qa.Quadrants.GetLength(0); x++) { for (int y = 0; y < qa.Quadrants.GetLength(1); y++) { double longitude = qa.Longitudes[x]; double latitude = qa.Latitudes[y]; double longitude2 = qa.Longitudes[x + 1]; double latitude2 = qa.Latitudes[y + 1]; int x0, y0, x1, y1; x0 = map.LongitudeToX(longitude, ref mapArea); y0 = map.LatitudeToY(latitude, ref mapArea); x1 = map.LongitudeToX(longitude2, ref mapArea); y1 = map.LatitudeToY(latitude2, ref mapArea); Quadrant q = qa.Quadrants[x, y]; //g.DrawString(q.ResultState.ToString(), SystemFonts.MenuFont, Brushes.Black, (x0 + x1) / 2, (y0 + y1) / 2); switch (q.ResultState) { case QuadrantResultState.Consistent: Color c = q.WS.Result.color; g.FillRectangle(getBrush(c), x0, y1, x1 - x0, y0 - y1); break; case QuadrantResultState.Inconsistent: if (q.Details != null) { DrawQuandrantOverlay(g, map, mapArea, q.Details); } break; case QuadrantResultState.Decomposable: if (q.Details != null) { DrawQuandrantOverlay(g, map, mapArea, q.Details); } break; case QuadrantResultState.NotAvailable: break; } } } }
private QuadrantArray CalculateQuadrantArray(Quadrant map, GregorianDateTime dt, GCLocation loc, TResultCalendar cal, List <Quadrant> qlist) { QuadrantArray qa = new QuadrantArray(map, calculateSplits(map.LongitudeRange, map.pixelsX), calculateSplits(map.LatitudeRange, map.pixelsY)); for (int lo = 0; lo < qa.Longitudes.Length; lo++) { for (int la = 0; la < qa.Latitudes.Length; la++) { if (qa.Points[lo, la].Result != null) { continue; } VAISNAVADAY vd = GetCalcDay(dt, loc, cal, qa.Longitudes[lo], qa.Latitudes[la]); /* loc.SetCoordinates(qa.Longitudes[lo], qa.Latitudes[la]); * cal.CalculateCalendar(loc, dt, 5); * for (int i = 0; i < 5; i++) * { * VAISNAVADAY vd = cal.GetDay(i); * if (vd.nFastID == FastType.FAST_EKADASI) * { * qa.Points[lo, la].Result = GetSafeResult(vd); * } * }*/ if (vd != null) { qa.Points[lo, la].Result = GetSafeResult(vd); } } } for (int lo = 0; lo < qa.Quadrants.GetLength(0); lo++) { for (int la = 0; la < qa.Quadrants.GetLength(1); la++) { if (qa.Quadrants[lo, la].ResultState == QuadrantResultState.Decomposable) { qlist.Add(qa.Quadrants[lo, la]); } } } return(qa); }
private void DrawmapWithOverlay(Size clientArea, Graphics g) { GCMap map = DataSource.EMOV_GetMap(); map.Preparefactors(); // insufficient dimensions if (clientArea.Width < 50 || clientArea.Height < 50 || map.ImageSize.Width < 50 || map.ImageSize.Height < 50) { return; } Size clientAreaWithoutLegend = new Size(clientArea.Width - 10, clientArea.Height - 50); double ratioImageToScreen = Math.Min((double)clientAreaWithoutLegend.Width / map.ImageSize.Width, (double)clientAreaWithoutLegend.Height / map.ImageSize.Height); clientAreaWithoutLegend = new Size(Convert.ToInt32(ratioImageToScreen * map.ImageSize.Width), Convert.ToInt32(ratioImageToScreen * map.ImageSize.Height)); Rectangle mapArea = new Rectangle(clientArea.Width / 2 - clientAreaWithoutLegend.Width / 2, 10, clientAreaWithoutLegend.Width, clientAreaWithoutLegend.Height); Rectangle mapAreaBitmap = new Rectangle(0, 0, clientAreaWithoutLegend.Width, clientAreaWithoutLegend.Height); globalMapArea = mapArea; g.DrawImage(map.Image, mapArea); QuadrantArray qa = DataSource.EMOV_GetOverlay(); if (qa != null) { if (CalculationFinished) { overlayBitmap = null; if (overlayBitmap == null) { overlayBitmap = new Bitmap(mapArea.Width + 1, mapArea.Height + 1, PixelFormat.Format32bppArgb); overlayGraphics = Graphics.FromImage(overlayBitmap); } // e.Graphics.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceOver; // e.Graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.GammaCorrected; //overlayGraphics.FillRectangle(getBrush(Color.Transparent), 0, 0, mapArea.Width, mapArea.Height); DrawQuandrantOverlay(overlayGraphics, map, mapAreaBitmap, qa); g.DrawImage(overlayBitmap, mapArea); } else { DrawQuandrantOverlay(g, map, mapArea, qa); } //g.DrawRectangle(Pens.Red, mapArea); } DrawLongitudeLine(g, 0, map, mapArea); DrawLatitudeLine(g, 0, map, mapArea); DrawLatitudeLine(g, -66, map, mapArea); DrawLatitudeLine(g, 66, map, mapArea); List <QuandrantResult> results = DataSource.EMOV_GetResults(); for (int i = 0; i < results.Count; i++) { int y = clientArea.Height - results.Count * 20 - 4 + i * 20; Color c = results[i].color; g.FillRectangle(getBrush(Color.FromArgb(255, c)), mapArea.Left, y, 20, 15); g.FillRectangle(getBrush(results[i].color), mapArea.Left, y, 20, 15); g.DrawRectangle(Pens.Black, mapArea.Left, y, 20, 15); g.DrawString(results[i].ToString(), legendFont, Brushes.Black, mapArea.Left + 40, y); } }