private void FormMeridianDiagram_Load(object eventSender, EventArgs eventArgs) { Form_Initialize_Renamed(); DisplayMerDiag(); MeridianPicBx.Refresh(); FormMeridianDiagramLoaded = true; }
public void DisplayMerDiag() { double Y2Dec; double X2Dec; double Y1Dec; double X1Dec; // Dim Ho As Double float i; // , XAlt As Single, YAlt As Single ZNoriginal = (float)ZN; LHAoriginal = (float)LHA; int drawdelta = 35; DrawWidth = (int)(MeridianPicBx.Width / 2d - drawdelta); bm = new Bitmap(MeridianPicBx.Width, MeridianPicBx.Height); meridgraphic = Graphics.FromImage(bm); meridgraphic.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; meridgraphic.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit; meridgraphic.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality; string LatStr = ""; string Decstr = ""; string LHAstr = ""; double tmpLDeg = 0d; double tmpLMin = 0d; double tmpDec = 0d; double tmpLHADeg = 0d; double tmpLHAMin = 0d; if (DrawBasicEqTDiagram == false) { double tempLat = 0d; if (L < 0d) { tempLat = -L; } // tmpLDeg = -Int(L) // tmpLMin = (-L - tmpLDeg) * 60 else { tempLat = L; // tmpLDeg = Int(L) // tmpLMin = (L - tmpLDeg) * 60 } tmpLDeg = Convert.ToInt32(tempLat); tmpLMin = (tempLat - tmpLDeg) * 60d; tmpLHADeg = Convert.ToDouble(Convert.ToInt32(LHAoriginal)); tmpLHAMin = (LHAoriginal - tmpLHADeg) * 60d; LHAstr = tmpLHADeg.ToString("##0") + '°' + " " + tmpLHAMin.ToString("#0.0") + "'"; LatStr = tmpLDeg.ToString("##0") + '°'; if (L < 0d) { LatStr += tmpLMin.ToString("#0.0") + "'" + CommonGlobals.g_LatS; } else { LatStr += tmpLMin.ToString("#0.0") + "'" + CommonGlobals.g_LatN; } if (Dec < 0d) { tmpDec = -Dec; } else { tmpDec = Dec; } double DecDeg = Convert.ToInt32(tmpDec); double DecMin = (tmpDec - DecDeg) * 60d; Decstr = DecDeg.ToString("#0") + '°' + " " + DecMin.ToString("#0.0") + "'"; // tmpDec.ToString("#0.0") & Chr(176) if (Dec < 0d) { Decstr += CommonGlobals.g_LatS; } else { Decstr += CommonGlobals.g_LatN; } int HoDeg = (int)Convert.ToInt32(Ho); double HoMin = (Ho - HoDeg) * 60d; string HoStr = HoDeg.ToString("#0") + '°' + " " + HoMin.ToString("#0.0") + "'"; if (string.IsNullOrEmpty(BodyName)) { meridgraphic.DrawString("Lat: " + LatStr + Environment.NewLine + "LHA: " + LHAstr + Environment.NewLine + "Zn : " + Math.Round(ZNoriginal, 0, MidpointRounding.AwayFromZero).ToString("##0") + '°' + Environment.NewLine + "Ho : " + HoStr + Environment.NewLine + "Dec: " + Decstr, new Font("Arial", 8f, FontStyle.Bold), Brushes.DarkBlue, 15f, 15f); } else { meridgraphic.DrawString("Body: " + BodyName + Environment.NewLine + "Lat: " + LatStr + Environment.NewLine + "LHA: " + LHAstr + Environment.NewLine + "Zn : " + Math.Round(ZN, 0, MidpointRounding.AwayFromZero).ToString("##0") + '°' + Environment.NewLine + "Ho : " + HoStr + Environment.NewLine + "Dec: " + Decstr, new Font("Arial", 8f, FontStyle.Bold), Brushes.DarkBlue, 15f, 15f); } } CommonTranslate(); var DPen = new Pen(Color.Black, 2f); DPen.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid; var ptA = new Point(); var ptB = new Point(); ptA.X = 0; ptA.Y = 0; ptB.X = 0; ptB.Y = 0; // Me.Circle(0, 0), 3000 meridgraphic.DrawEllipse(DPen, -DrawWidth, -DrawWidth, 2 * DrawWidth, 2 * DrawWidth); meridgraphic.FillEllipse(Brushes.LightGoldenrodYellow, -DrawWidth, -DrawWidth, 2 * DrawWidth, 2 * DrawWidth); // draw the N / S horizon line ptA.X = -1 * DrawWidth; ptA.Y = 0; ptB.X = DrawWidth; ptB.Y = 0; meridgraphic.DrawLine(DPen, ptA, ptB); meridgraphic.DrawString(CommonGlobals.g_LatN, new Font("Arial", 10f, FontStyle.Bold), Brushes.DarkBlue, -1 * DrawWidth - 20, -6); meridgraphic.DrawString(CommonGlobals.g_LatS, new Font("Arial", 10f, FontStyle.Bold), Brushes.DarkBlue, DrawWidth + 20, 6f); meridgraphic.DrawString("Visible Horizon", new Font("Arial", 8f, FontStyle.Bold), Brushes.DarkBlue, 20f, -12); // draw the Zenith / Nadir line ptA.X = 0; ptA.Y = -1 * DrawWidth; ptB.X = 0; ptB.Y = DrawWidth; meridgraphic.DrawLine(DPen, ptA, ptB); meridgraphic.DrawString("Z at Lat=" + LatStr, new Font("Arial", 10f, FontStyle.Bold), Brushes.DarkBlue, -10, -DrawWidth - 20); meridgraphic.DrawString("Na at Lat=" + LatStr, new Font("Arial", 10f, FontStyle.Bold), Brushes.DarkBlue, -3, DrawWidth + 15); // draw the 5 degree and 10 degree tick marks on the surrounding circle var DPenC = new Pen(Color.Black, 1f); for (i = 0f; i <= 359f; i++) { if (i % 10f == 0f) { ptA.X = DrawWidth + 3; // * System.Math.Cos(i * Pi / 180) // ptA.Y = DrawWidth * System.Math.Sin(i * Pi / 180) ptB.X = DrawWidth - 10; // * System.Math.Cos(i * Pi / 180) } // ptB.Y = (DrawWidth - 10) * System.Math.Sin(i * Pi / 180) else if (i % 5f == 0f) { ptA.X = DrawWidth; // * System.Math.Cos(i * Pi / 180) // ptA.Y = DrawWidth * System.Math.Sin(i * Pi / 180) ptB.X = DrawWidth - 5; // * System.Math.Cos(i * Pi / 180) } // ptB.Y = (DrawWidth - 5) * System.Math.Sin(i * Pi / 180) else { ptA.X = DrawWidth; // * System.Math.Cos(i * Pi / 180) // ptA.Y = DrawWidth * System.Math.Sin(i * Pi / 180) ptB.X = DrawWidth - 3; // ptB.Y = (DrawWidth - 3) * System.Math.Sin(i * Pi / 180) } // * System.Math.Cos(i * Pi / 180) meridgraphic.DrawLine(DPenC, ptA.X, 0, ptB.X, 0); meridgraphic.RotateTransform(1f); } if (DrawBasicEqTDiagram == true) { DrawBasicEqTDiagram = false; goto ExitDrawTime; } CommonTranslate(); meridgraphic.RotateTransform((float)L); // Draw the celestial equator line Q / Q' based on the Latitude L. Write the strings Q & Q' at each end DPen.Color = Color.Blue; meridgraphic.DrawLine(DPen, DrawWidth, 0, -DrawWidth, 0); meridgraphic.DrawString("Q ", new Font("Arial", 8f, FontStyle.Bold), Brushes.DarkBlue, 0f, -DrawWidth - 12); meridgraphic.DrawString("Q'", new Font("Arial", 8f, FontStyle.Bold), Brushes.DarkBlue, 0f, DrawWidth + 12); meridgraphic.RotateTransform(-90); meridgraphic.DrawString("Celestial Equator", new Font("Arial", 8f, FontStyle.Bold), Brushes.DarkBlue, 20f, -12); CommonTranslate(); meridgraphic.RotateTransform((float)L); DPen.Color = Color.Black; DPen.Color = Color.Blue; meridgraphic.DrawLine(DPen, 0, -DrawWidth, 0, DrawWidth); // Draw the Pole North (Pn) and Pole South (Ps) line and ending strings - based on Latitude L if (Math.Sign(L) == 1 | Math.Sign(L) == 0) { meridgraphic.DrawString("Pn", new Font("Arial", 8f, FontStyle.Bold), Brushes.DarkBlue, -DrawWidth - 15, 0f); meridgraphic.DrawString("Ps", new Font("Arial", 8f, FontStyle.Bold), Brushes.DarkBlue, DrawWidth + 15, 0f); DPen.Color = Color.Black; } // South Pole if (Math.Sign(L) == -1) { meridgraphic.DrawString("Pn", new Font("Arial", 8f, FontStyle.Bold), Brushes.DarkBlue, DrawWidth + 15, 0f); meridgraphic.DrawString("Ps", new Font("Arial", 8f, FontStyle.Bold), Brushes.DarkBlue, -DrawWidth - 15, 0f); DPen.Color = Color.Black; } // meridgraphic.ResetTransform() CommonTranslate(); DPen.Color = Color.DarkRed; meridgraphic.RotateTransform(90f); XAlt = (float)(DrawWidth * Math.Cos(-Ho * Pi / 180d)); YAlt = (float)(DrawWidth * Math.Sin(-Ho * Pi / 180d)); CommonTranslate(); ptA.X = (int)XAlt; ptA.Y = (int)YAlt; PtAInt = ptA; ptB.X = (int)-XAlt; ptB.Y = (int)YAlt; PtBInt = ptB; meridgraphic.DrawLine(DPen, ptA, ptB); meridgraphic.DrawString("Ho=" + Ho.ToString("#0.0") + '°' + " above horizon", new Font("Arial", 8f, FontStyle.Bold), Brushes.DarkRed, ptB.X + 25, ptB.Y - 12); DPen.Color = Color.Green; // Draw the declination line based on Latitude L, Declination dec. X1Dec = DrawWidth * Math.Cos(-(90d - L + Dec) * Pi / 180d); Y1Dec = DrawWidth * Math.Sin(-(90d - L + Dec) * Pi / 180d); ptA.X = (int)X1Dec; ptA.Y = (int)Y1Dec; PtCInt = ptA; X2Dec = -DrawWidth *Math.Cos(-(90d - L - Dec) *Pi / 180d); Y2Dec = -DrawWidth *Math.Sin(-(90d - L - Dec) *Pi / 180d); ptB.X = (int)X2Dec; ptB.Y = (int)Y2Dec; PtDInt = ptB; meridgraphic.RotateTransform((float)-(90d - L)); X1Dec = DrawWidth * Math.Cos(-Dec * Pi / 180d); Y1Dec = DrawWidth * Math.Sin(-Dec * Pi / 180d); ptA.X = (int)X1Dec; ptA.Y = (int)Y1Dec; ptB.X = (int)-X1Dec; ptB.Y = (int)Y1Dec; meridgraphic.DrawLine(DPen, ptA, ptB); meridgraphic.DrawString("Dec " + Decstr + " of celestial equator", new Font("Arial", 8f, FontStyle.Bold), Brushes.Green, ptB.X + 25, ptB.Y - 12); meridgraphic.RotateTransform((float)(90d - L)); CommonTranslate(); PtIntercept = GetIntersection(PtAInt, PtBInt, PtCInt, PtDInt); // If PtIntercept.X = 0 And PtIntercept.Y = 0 Then ' this is when the Dec and Ho are parallel lines or have no intersection // ErrorMsgBox("Dec and Ho lines are parallel lines. They have no intersection for plotting Point M or LHA and Zn ") // GoTo ExitDrawTime // End If meridgraphic.DrawEllipse(DPen, PtIntercept.X - 5, PtIntercept.Y - 5, 10, 10); meridgraphic.FillEllipse(DPen.Brush, PtIntercept.X - 5, PtIntercept.Y - 5, 10, 10); meridgraphic.DrawString("M", new Font("Arial", 10f, FontStyle.Bold), DPen.Brush, PtIntercept.X - 20, PtIntercept.Y - 20); if (chkDispZnLHA.CheckState == CheckState.Checked) { Ellipses(); } if (chkTwiLites.CheckState == CheckState.Checked) { DisPlayTwiLights(); } ExitDrawTime: ; if (System.IO.File.Exists(BMFname)) { System.IO.File.Delete(BMFname); } bm.Save(BMFname); MeridianPicBx.ImageLocation = BMFname; bm.Dispose(); MeridianPicBx.Refresh(); return; }