using Casic.Birmm.RbFreqStandMeasure.Properties; using Casic.Birmm.RbFreqStandMeasure.tools; using Casic.Birmm.RbFreqStandMeasure.Tools; using System; using System.Collections.Generic; using System.Drawing; using System.Drawing.Drawing2D; using System.Reflection; using System.Threading; using System.Windows.Forms; namespace Casic.Birmm.RbFreqStandMeasure { public partial class StatusCtrlForm : UserControl { public static StatusCtrlForm statusCtrlForm; public static Coordinate coo ; private readonly object obj = new object(); public static Graphics gp; private static bool created = false; public StatusCtrlForm() { InitializeComponent(); statusCtrlForm = this; //label_date.Text = DateTime.Now.ToString("yyyy-MM-dd"); //label_time.Text = DateTime.Now.ToString("HH:mm:ss"); ////if (!created) //{ // gp = coo.CreateGraphics(); // created = true; //} coo = new Coordinate(); panelSite.Controls.Add(coo); coo.Show(); //new Thread(() => //{ lock (obj) { if (!FreshStatus.isStarted) { FreshStatus.startClockFresh(); FreshStatus.startSatelliteFresh(); } Thread.Sleep(500); label_clockStatus.Text = FreshStatus.clockStatus; label_receiverStatus.Text = FreshStatus.receiverStatus; label_date.Text = FreshStatus.date; label_time.Text = FreshStatus.time; label_mjd.Text = FreshStatus.mjd; label_lat.Text = FreshStatus.lat; label_lng.Text = FreshStatus.lng; label_x.Text = FreshStatus.x; label_y.Text = FreshStatus.y; label_z.Text = FreshStatus.z; label_usaTotal.Text = FreshStatus.totalGP+""; label_chnTotal.Text = FreshStatus.totalBD+""; LogHelper.WriteInfoLog(MethodBase.GetCurrentMethod().DeclaringType, "界面初始化。。。。。。"); draw(FreshStatus.bdList, FreshStatus.gpList); } //}).Start(); } public void draw(List<string> bdList, List<string> gpList) { try { if (bdList.Count > 0 || gpList.Count>0) { Invoke(new MethodInvoker(delegate () { panelSite.Controls.Clear(); coo = new Coordinate(); panelSite.Controls.Add(coo); coo.Show(); drawFunc(bdList); drawFunc(gpList); } )); } } catch (Exception ex) { LogHelper.WriteInfoLog(MethodBase.GetCurrentMethod().DeclaringType, "draw error:" + ex.Message); } } private void drawFunc(List<string> gvsList) { try { Invoke(new MethodInvoker(delegate () { if (gvsList.Count > 0) { Graphics gp = coo.CreateGraphics(); gp.SmoothingMode = SmoothingMode.HighQuality; int gpCount = 0; int bdCount = 0; foreach (string gsv in gvsList) { string[] arr = gsv.Split(','); int length = arr.Length; for (int i = 4; i < arr.Length; i = i + 3) { if ((i + 3) < arr.Length) { int Elevation = Convert.ToInt32(arr[i + 1]); int azimuth = Convert.ToInt32(arr[i + 2]); double cosLen = Math.Cos(Elevation * Math.PI / 180) * (575 / 2); double xCor = Math.Cos(azimuth * Math.PI / 180) * cosLen; double yCor = Math.Sin(azimuth * Math.PI / 180) * cosLen; int x = (int)Math.Floor(600 / 2 + xCor); int y = (int)Math.Floor(610 / 2 - yCor); string type = "CHN"; if (gsv.Contains("GPGSV")) { type = "USA"; gpCount++; } else { bdCount++; } gp.DrawImage((Bitmap)Resources.ResourceManager.GetObject(type), x, y); LogHelper.WriteInfoLog(MethodBase.GetCurrentMethod().DeclaringType, "gvsList.count="+ gvsList.Count+",画了一个" +type + "x="+x+"y="+y); } } if(gpCount>0)label_usaTotal.Text = gpCount + ""; if (bdCount > 0) label_chnTotal.Text = bdCount + ""; } gp.Dispose(); } } )); } catch (Exception e) { LogHelper.WriteInfoLog(MethodBase.GetCurrentMethod().DeclaringType, "drawFunc错误:" + e.Message); } } } }