private void PasteFromTle_Click(object sender, EventArgs e)
        {
            if (Clipboard.ContainsText() && Clipboard.GetText().Length > 0)
            {
                string   data  = Clipboard.GetText(TextDataFormat.UnicodeText);
                string[] lines = data.Split(new char[] { '\n', '\r' });
                string   line1 = "";
                string   line2 = "";
                for (int i = 0; i < lines.Length; i++)
                {
                    lines[i] = lines[i].Trim();
                    if (lines[i].Length == 69 && ReferenceFrame.IsTLECheckSumGood(lines[i]))
                    {
                        if (line1.Length == 0 && lines[i].Substring(0, 1) == "1")
                        {
                            line1 = lines[i];
                        }
                        if (line2.Length == 0 && lines[i].Substring(0, 1) == "2")
                        {
                            line2 = lines[i];
                        }
                    }
                }

                if (line1.Length == 69 && line2.Length == 69)
                {
                    frame.FromTLE(line1, line2, 398600441800000);
                    SyncToFrame();
                    return;
                }
            }

            UiTools.ShowMessageBox(Language.GetLocalizedText(756, "The clipbboard does not appear to contain a valid TLE set. Copy the contents of a Two Line Elements (TLE) set from your source to the clipboard in plain text and click paste again"), Language.GetLocalizedText(755, "Paste Orbital Elements from TLE"));
        }
Esempio n. 2
0
        public override void LoadData(string path)
        {
            filename = path;
            if (File.Exists(filename))
            {
                string[] data = File.ReadAllLines(path);
                frames.Clear();
                for (int i = 0; i < data.Length; i += 2)
                {
                    int line1 = i;
                    int line2 = i + 1;
                    if (data[i].Length > 0)
                    {
                        ReferenceFrame frame = new ReferenceFrame();
                        if (data[i].Substring(0, 1) != "1")
                        {
                            line1++;
                            line2++;
                            frame.Name = data[i].Trim();
                            i++;
                        }
                        else if (data[i].Substring(0, 1) == "1")
                        {
                            frame.Name = data[i].Substring(2, 5);
                        }
                        else
                        {
                            i -= 2;
                            continue;
                        }

                        frame.Reference          = ReferenceFrames.Custom;
                        frame.Oblateness         = 0;
                        frame.ShowOrbitPath      = true;
                        frame.ShowAsPoint        = true;
                        frame.ReferenceFrameType = ReferenceFrameTypes.Orbital;
                        frame.Scale = 1;
                        frame.SemiMajorAxisUnits = AltUnits.Meters;
                        frame.MeanRadius         = 10;
                        frame.Oblateness         = 0;
                        frame.FromTLE(data[line1], data[line2], 398600441800000);
                        frames.Add(frame);
                    }
                    else
                    {
                        i -= 1;
                    }
                }
            }
        }
        public override void LoadData(string path)
        {
            filename = path;
            if (File.Exists(filename))
            {
                var data = File.ReadAllLines(path);
                frames.Clear();
                for (var i = 0; i < data.Length; i += 2)
                {
                    var line1 = i;
                    var line2 = i + 1;
                    var frame = new ReferenceFrame();
                    if (data[i].Substring(0, 1) != "1")
                    {
                        line1++;
                        line2++;
                        frame.Name = data[i].Trim();
                        i++;
                    }
                    else if (data[i].Substring(0, 1) == "1")
                    {
                        frame.Name = data[i].Substring(2, 5);
                    }
                    else
                    {
                        i -= 2;
                        continue;
                    }

                    frame.Reference = ReferenceFrames.Custom;
                    frame.Oblateness = 0;
                    frame.ShowOrbitPath = true;
                    frame.ShowAsPoint = true;
                    frame.ReferenceFrameType = ReferenceFrameTypes.Orbital;
                    frame.Scale = 1;
                    frame.SemiMajorAxisUnits = AltUnits.Meters;
                    frame.MeanRadius = 10;
                    frame.Oblateness = 0;
                    frame.FromTLE(data[line1], data[line2], 398600441800000);
                    frames.Add(frame);
                }
            }
        }