public void updater() { ProgressBar1.Visible = true; Label13.Visible = true; ProgressBar1.Maximum = 7; ProgressBar1.Step = 1; ProgressBar1.Value = 0; //Button1.Text = "Searching" string input = TargetNameBox.Text; Label13.Text = "Connecting to simbad.u-strasbg.fr"; Label13.Refresh(); WebClient client = new WebClient(); string url = "http://simbad.u-strasbg.fr/simbad/sim-script?script=output console=off script=off%0Aformat%20object%20%22%25FLUXLIST%28R,V,B;%20N=F,%29%20|%20%25OTYPE%28V%29%20|%20%25COO%28d;%20A%20D;FK5;J2000;%29%20|%20%25DIM%28X%20Y%29%20|%20%25IDLIST[%25*,]%20%22%0A" + HttpUtility.UrlEncode(input); ProgressBar1.Value = 1; client.Headers.Add("User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12"); client.Headers.Add("Accept", "*/*"); client.Headers.Add("Accept-Language", "en-gb,en;q=0.5"); client.Headers.Add("Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.7"); ProgressBar1.Value = 2; //Try string reply = client.DownloadString(url); //'RichTextBox1.Text = reply ProgressBar1.Value = 3; Label13.Text = ""; Label13.Refresh(); if (reply.Substring(0, 7) == "::error" | reply.Substring(0, 7) == "!! A pr" | string.IsNullOrEmpty(input)) { FluxLbl.Text = ""; TypeLbl.Text = ""; RALbl.Text = ""; SizeLbl.Text = ""; DecLbl.Text = ""; AltLbl.Text = ""; AzLbl.Text = ""; InfoBox.Text = ""; Label13.Text = "Object not found, or other error"; ProgressBar1.Value = 7; ProgressBar1.Visible = false; } else { string[] parts = reply.Split('|'); TargetsetBtn.Enabled = true; FluxLbl.Text = parts[0].Trim(); //flux FluxLbl.Refresh(); TypeLbl.Text = parts[1].Trim(); //type TypeLbl.Refresh(); //'Label11.Text = parts(2) 'coords string[] coords = parts[2].Split(' '); double rightasc = Convert.ToDouble(coords[1]); double declin = Convert.ToDouble(coords[2]); ra = Convert.ToDouble(rightasc); dec = Convert.ToDouble(declin); RALbl.Text = hh(rightasc / 15) + "h " + dm(rightasc / 15) + "m " + ds(rightasc / 15) + "s"; DecLbl.Text = dd(declin) + (Char)176 + " " + dm(declin) + (Char)39 + " " + ds(declin) + (Char)34; TimeSpan _TimeSpan = (DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0)); double juliandec = ((_TimeSpan.TotalSeconds) / 86400) + 2440587.5; double T = (juliandec - 2451545.0) / 36525; double theta = 280.46061837 + (360.98564736629 * (juliandec - 2451545)) + (0.000387933 * T * T) - ((T * T * T) / 38710000); double latrad = deg2rad(51.7763); declin = deg2rad(declin); double H = deg2rad(theta - 0.0963 - rightasc); double alt = Math.Round(rad2deg(Math.Asin(((Math.Sin(latrad)) * (Math.Sin(declin))) + ((Math.Cos(latrad)) * (Math.Cos(declin)) * (Math.Cos(H))))), 2); double az = Math.Round(rad2deg(Math.Atan2(Math.Sin(H), (Math.Cos(H) * Math.Sin(latrad)) - (Math.Tan(declin) * Math.Cos(latrad)))) + 180, 2); declin = rad2deg(declin); AltLbl.Text = Convert.ToString(alt); AltLbl.Refresh(); AzLbl.Text = Convert.ToString(az); AzLbl.Refresh(); RALbl.Refresh(); if (parts[3] == " ~ ~ ") { SizeLbl.Text = "star"; //size } else { SizeLbl.Text = parts[3]; //size } //TextBox2.Text = parts(3) 'size() SizeLbl.Refresh(); //RichTextBox3.Text = parts(4) 'names string[] names = parts[4].TrimStart().Split(','); int namenum = names.Count(); string namestring = ""; //RichTextBox3.Text = "test" + System.Environment.NewLine + CStr(namenum) ProgressBar1.Value = 4; for (int i = 0; i < namenum; i++) { if (i == namenum) { namestring = namestring + names[i]; } else { namestring = namestring + names[i] + System.Environment.NewLine; } } InfoBox.Text = namestring.TrimEnd(); //Label6.Text = CStr(rightasc) + " " + CStr(declin) if (ShowImageChk.Checked) { PictureBox1.Visible = true; System.IO.MemoryStream stream = new System.IO.MemoryStream(); byte[] data = null; ProgressBar1.Value = 5; Label13.Text = "Downloading image "; Label13.Refresh(); string url2 = "http://147.197.130.115/dss.php?w=300&ra=" + Convert.ToString(rightasc) + "&dec=" + Convert.ToString(declin) + "&x=10&y=10"; data = client.DownloadData(url2); //RichTextBox2.Text = url2 client.Dispose(); stream.Write(data, 0, data.Length); ProgressBar1.Value = 6; PictureBox1.Image = Image.FromStream(stream); PictureBox1.Visible = true; CreditLbl.Visible = false; } else { ProgressBar1.Value = 6; PictureBox1.Image = null; PictureBox1.Visible = false; CreditLbl.Visible = false; } Label13.Text = "Done"; //Button1.Text = "Submit" ProgressBar1.Value = 7; ProgressBar1.Visible = false; //Label13.Visible = False } //Catch ex As Exception // Label1.Text = "" // Label2.Text = "" // Label3.Text = "" // Label4.Text = "" // Label11.Text = "" // Label16.Text = "" // Label14.Text = "" // RichTextBox3.Text = "" // ProgressBar1.Value = 7 // ProgressBar1.Visible = False // Label13.Text = "Failed to connect to Simbad or other error" //End Try }
void ReleaseDesignerOutlets() { if (Acc != null) { Acc.Dispose(); Acc = null; } if (AccLbl != null) { AccLbl.Dispose(); AccLbl = null; } if (Alt != null) { Alt.Dispose(); Alt = null; } if (AltAcc != null) { AltAcc.Dispose(); AltAcc = null; } if (AltAccLbl != null) { AltAccLbl.Dispose(); AltAccLbl = null; } if (AltLbl != null) { AltLbl.Dispose(); AltLbl = null; } if (Error != null) { Error.Dispose(); Error = null; } if (ErrorLbl != null) { ErrorLbl.Dispose(); ErrorLbl = null; } if (Hdg != null) { Hdg.Dispose(); Hdg = null; } if (HdgAcc != null) { HdgAcc.Dispose(); HdgAcc = null; } if (HdgAccLbl != null) { HdgAccLbl.Dispose(); HdgAccLbl = null; } if (HdgLbl != null) { HdgLbl.Dispose(); HdgLbl = null; } if (Lat != null) { Lat.Dispose(); Lat = null; } if (LatLbl != null) { LatLbl.Dispose(); LatLbl = null; } if (Lon != null) { Lon.Dispose(); Lon = null; } if (LonLbl != null) { LonLbl.Dispose(); LonLbl = null; } if (Spd != null) { Spd.Dispose(); Spd = null; } if (SpdLbl != null) { SpdLbl.Dispose(); SpdLbl = null; } if (Updated != null) { Updated.Dispose(); Updated = null; } if (UpdatedLbl != null) { UpdatedLbl.Dispose(); UpdatedLbl = null; } }