Beispiel #1
0
        private void listView1_Click(object sender, EventArgs e)
        {
            if (listView1.SelectedIndices.Count > 0)
            {
                try
                {
                    VoRow  row = table.Rows[listView1.SelectedIndices[0]];
                    double ra  = Coordinates.ParseRA(row[raSource.SelectedIndex - 1].ToString(), true);
                    double dec = Coordinates.ParseDec(row[decSource.SelectedIndex - 1].ToString().ToString());
                    string id;

                    VoColumn col = table.GetColumnByUcd("meta.id");
                    if (col != null)
                    {
                        id = row[col.Name].ToString();
                    }
                    else
                    {
                        id = row[0].ToString();
                    }

                    TourPlace pl = new TourPlace(id, dec, ra, Classification.Star, Constellations.Containment.FindConstellationForPoint(ra, dec), ImageSetType.Sky, -1);
                    Earth3d.MainWindow.GotoTarget(pl, false, false, false);
                }
                catch
                {
                }
            }
        }
        private void AddSiapStcRow(string stcsColName, VoRow row, bool selected)
        {
            string stcs = row[stcsColName].ToString().Replace("  ", " ");
            Color  col  = Color.FromArgb(120, 255, 255, 255);

            if (selected)
            {
                col = Color.Yellow;
            }

            if (stcs.StartsWith("Polygon J2000"))
            {
                string[] parts = stcs.Split(new char[] { ' ' });

                int len   = parts.Length;
                int index = 0;
                while (index < len)
                {
                    if (parts[index] == "Polygon")
                    {
                        index += 2;
                        Vector3d lastPoint  = new Vector3d();
                        Vector3d firstPoint = new Vector3d();
                        bool     start      = true;
                        for (int i = index; i < len; i += 2)
                        {
                            if (parts[i] == "Polygon")
                            {
                                start = true;
                                break;
                            }
                            else
                            {
                                double Xcoord = Coordinates.ParseRA(parts[i], true) * 15 + 180;
                                double Ycoord = Coordinates.ParseDec(parts[i + 1]);


                                Vector3d pnt = Coordinates.GeoTo3dDouble(Ycoord, Xcoord);

                                if (!start)
                                {
                                    lineList2d.AddLine(lastPoint, pnt, col, new Dates());
                                }
                                else
                                {
                                    firstPoint = pnt;
                                    start      = false;
                                }
                                lastPoint = pnt;
                            }
                            index += 2;
                        }
                        if (len > 4)
                        {
                            lineList2d.AddLine(firstPoint, lastPoint, col, new Dates());
                        }
                    }
                }
            }
        }
Beispiel #3
0
        private void listView1_ItemMouseHover(object sender, ListViewItemMouseHoverEventArgs e)
        {
            if (listView1.SelectedIndices.Count > 0)
            {
                listView1.FullRowSelect = true;
                try
                {
                    VoRow row = table.Rows[e.Item.Index];

                    // double ra = Convert.ToDouble(row[GetRAColumn().Name]) / 15;
                    // double dec = Convert.ToDouble(row[GetDecColumn().Name]);
                    double ra  = Coordinates.ParseRA(row[raSource.SelectedIndex - 1].ToString(), true);
                    double dec = Coordinates.ParseDec(row[decSource.SelectedIndex - 1].ToString());
                    string id;

                    VoColumn col = table.GetColumnByUcd("meta.id");
                    if (col != null)
                    {
                        id = row[col.Name].ToString();
                    }
                    else
                    {
                        id = row[0].ToString();
                    }

                    TourPlace pl = new TourPlace(id, dec, ra, Classification.Star, Constellations.Containment.FindConstellationForPoint(ra, dec), ImageSetType.Sky, -1);
                    Earth3d.MainWindow.SetLabelText(pl, true);
                }
                catch
                {
                }
            }
        }
Beispiel #4
0
        public void LoadFromXML(XmlDocument xml)
        {
            XmlNode voTable = xml["VOTABLE"];

            if (voTable == null)
            {
                return;
            }
            int index = 0;

            try
            {
                XmlNode table = voTable["RESOURCE"]["TABLE"];
                if (table != null)
                {
                    foreach (XmlNode node in table.ChildNodes)
                    {
                        if (node.Name == "FIELD")
                        {
                            VoColumn col = new VoColumn(node, index++);
                            Columns.Add(col.Name, col);
                            Column.Add(col);
                        }
                    }
                }
            }
            catch
            {
                error     = true;
                errorText = voTable["DESCRIPTION"].InnerText.ToString();
            }
            try
            {
                XmlNode tableData = voTable["RESOURCE"]["TABLE"]["DATA"]["TABLEDATA"];
                if (tableData != null)
                {
                    foreach (XmlNode node in tableData.ChildNodes)
                    {
                        if (node.Name == "TR")
                        {
                            VoRow row = new VoRow(this);
                            row.ColumnData = new object[Columns.Count];
                            index          = 0;
                            foreach (XmlNode child in node.ChildNodes)
                            {
                                row.ColumnData[index++] = child.InnerText.Trim();
                            }
                            Rows.Add(row);
                        }
                    }
                }
            }
            catch
            {
            }
        }
 private void fromRegistry_CheckedChanged(object sender, EventArgs e)
 {
     if (fromRegistry.Checked && ResourceList.SelectedIndices.Count > 0)
     {
         VoRow selected = (VoRow)ResourceList.SelectedItems[0].Tag;
         baseUrl.Text = selected["accessURL"].ToString().Replace("&amp;", "&");
     }
     baseUrl.ReadOnly = fromRegistry.Checked;
     baseUrl.Enabled  = !fromRegistry.Checked;
 }
 private void ResourceList_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (fromRegistry.Checked)
     {
         if (ResourceList.SelectedIndices.Count > 0)
         {
             VoRow selected = (VoRow)ResourceList.SelectedItems[0].Tag;
             baseUrl.Text = selected["accessURL"].ToString().Replace("&amp;", "&");
         }
     }
 }
Beispiel #7
0
        private void listView1_RetrieveVirtualItem(object sender, RetrieveVirtualItemEventArgs e)
        {
            VoRow row = table.Rows[e.ItemIndex];

            string[] data  = new string[row.ColumnData.GetLength(0)];
            int      index = 0;

            foreach (object o in row.ColumnData)
            {
                data[index++] = o.ToString();
            }
            e.Item         = new ListViewItem(data);
            e.Item.Checked = row.Selected;
            e.Item.Tag     = row;
        }
Beispiel #8
0
        private void listView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listView1.SelectedIndices.Count > 0)
            {
                listView1.FullRowSelect = true;
                try
                {
                    VoRow row = table.Rows[listView1.SelectedIndices[0]];

                    table.SelectedRow = row;
                    layer.CleanUp();
                    double ra  = Coordinates.ParseRA(row[raSource.SelectedIndex - 1].ToString(), true);
                    double dec = Coordinates.ParseDec(row[decSource.SelectedIndex - 1].ToString());
                    string id;

                    VoColumn col = table.GetColumnByUcd("meta.id");
                    if (col != null)
                    {
                        id = row[col.Name].ToString();
                    }
                    else
                    {
                        id = row[0].ToString();
                    }

                    TourPlace pl = new TourPlace(id, dec, ra, Classification.Star, Constellations.Containment.FindConstellationForPoint(ra, dec), ImageSetType.Sky, -1);
                    Earth3d.MainWindow.SetLabelText(pl, true);

                    if (table.SampId != null)
                    {
                        Earth3d.MainWindow.sampConnection.TableHighlightRow("", table.SampId, listView1.SelectedIndices[0]);
                    }
                }
                catch
                {
                }
            }
        }
Beispiel #9
0
        private void listView1_ItemChecked(object sender, ItemCheckedEventArgs e)
        {
            VoRow row = e.Item.Tag as VoRow;

            row.Selected = e.Item.Checked;
        }
        private void AddSiapStcRow(string stcsColName, VoRow row, bool selected)
        {
            var stcs = row[stcsColName].ToString().Replace("  ", " ");
            var col = Color.FromArgb(120, 255, 255, 255);

            if (selected)
            {
                col = Color.Yellow;
            }

            if (stcs.StartsWith("Polygon J2000"))
            {
                var parts = stcs.Split(new[] { ' ' });

                var len = parts.Length;
                var index = 0;
                while (index < len)
                {
                    if (parts[index] == "Polygon")
                    {
                        index += 2;
                        var lastPoint = new Vector3d();
                        var firstPoint = new Vector3d();
                        var start = true;
                        for (var i = index; i < len; i += 2)
                        {
                            if (parts[i] == "Polygon")
                            {
                                start = true;
                                break;
                            }
                            var Xcoord = Coordinates.ParseRA(parts[i], true) * 15 + 180;
                            var Ycoord = Coordinates.ParseDec(parts[i + 1]);

                            var pnt = Coordinates.GeoTo3dDouble(Ycoord, Xcoord);

                            if (!start)
                            {
                                lineList2d.AddLine(lastPoint, pnt, col, new Dates());
                            }
                            else
                            {
                                firstPoint = pnt;
                                start = false;
                            }
                            lastPoint = pnt;
                            index += 2;
                        }
                        if (len > 4)
                        {
                            lineList2d.AddLine(firstPoint, lastPoint, col, new Dates());
                        }

                    }
                }
            }
        }
        public void LoadFromXML(XmlDocument xml)
        {
            XmlNode voTable = xml["VOTABLE"];

            if (voTable == null)
            {
                return;
            }
            var index = 0;
            try
            {
                XmlNode table = voTable["RESOURCE"]["TABLE"];
                if (table != null)
                {
                    foreach (XmlNode node in table.ChildNodes)
                    {
                        if (node.Name == "FIELD")
                        {
                            var col = new VoColumn(node, index++);
                            Columns.Add(col.Name, col);
                            Column.Add(col);
                        }
                    }
                }
            }
            catch
            {
                error = true;
                errorText = voTable["DESCRIPTION"].InnerText;
            }
            try
            {
                XmlNode tableData = voTable["RESOURCE"]["TABLE"]["DATA"]["TABLEDATA"];
                if (tableData != null)
                {
                    foreach (XmlNode node in tableData.ChildNodes)
                    {
                        if (node.Name == "TR")
                        {
                            var row = new VoRow(this);
                            row.ColumnData = new object[Columns.Count];
                            index = 0;
                            foreach (XmlNode child in node.ChildNodes)
                            {
                                row.ColumnData[index++] = child.InnerText.Trim();
                            }
                            Rows.Add(row);
                        }
                    }
                }
            }
            catch
            {
            }
        }