-
Notifications
You must be signed in to change notification settings - Fork 2
/
ImportTLE.cs
50 lines (45 loc) · 1.54 KB
/
ImportTLE.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Copyright (c) 2016 SolarLiner - Part of the TLE Orbiter Sceneraio Generator (TLEOSG)
using System;
using System.Net;
using System.Windows.Forms;
namespace TLEOrbiter
{
public partial class ImportTLE : Form
{
public ImportTLE()
{
InitializeComponent();
}
public string TLEData { get; private set; }
private void BT_OK_Click(object sender, EventArgs e)
{
WebClient WC = new WebClient();
try
{
Log.Write("Getting URL: " + TB_TleUrl.Text);
TLEData = WC.DownloadString(TB_TleUrl.Text);
}
catch(Exception ex)
{
Log.WriteError(ex);
EP_Validator.SetError(TB_TleUrl, ex.Message);
return;
}
DialogResult = DialogResult.OK;
//this.Close();
}
private void TB_TleUrl_TextChanged(object sender, EventArgs e)
{
if (!Uri.IsWellFormedUriString(TB_TleUrl.Text, UriKind.Absolute))
EP_Validator.SetError(TB_TleUrl, "Must enter a validate URL");
}
private void BT_BrowseLocalFile_Click(object sender, EventArgs e)
{
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*";
if (openFileDialog.ShowDialog() == DialogResult.OK) {
TB_TleUrl.Text = new Uri(openFileDialog.FileName).AbsoluteUri;
}
}
}
}