private void OpenFITSImage(String FileName) { try { FILENAME = FileName; String file = FILENAME.Substring(FILENAME.LastIndexOf("\\")); this.Text = file.Substring(1); string[] list = FITSBinTable.GetAllExtensionNames(FileName); REG.SetReg("JPFITS", "BinTableOpenFilesPath", FileName.Substring(0, FileName.LastIndexOf("\\"))); for (int i = 0; i < list.Length; i++) { if (list[i] == "") { MenuChooseTable.DropDownItems.Add("UNNAMED"); } else { MenuChooseTable.DropDownItems.Add(list[i]); } ((ToolStripMenuItem)MenuChooseTable.DropDownItems[MenuChooseTable.DropDownItems.Count - 1]).CheckOnClick = true; this.MenuChooseTable.DropDownItems[MenuChooseTable.DropDownItems.Count - 1].Click += new System.EventHandler(MenuChooseTable_Click); ((ToolStripMenuItem)this.MenuChooseTable.DropDownItems[MenuChooseTable.DropDownItems.Count - 1]).CheckedChanged += new System.EventHandler(MenuChooseTable_CheckedChanged); } this.Show(); if (list.Length == 1) { PopulateTable(list[0]); } else { MenuChooseTable.ShowDropDown(); } } catch (Exception e) { MessageBox.Show(e.Data + " "+ e.InnerException + " " + e.Message + " "+ e.Source + " " + e.StackTrace + " "+ e.TargetSite); } }
private void ViewHeaderMenu_Click(object sender, EventArgs e) { HeaderListBox.Items.Clear(); FITSBinTable bt = new FITSBinTable(FILENAME, EXTENSIONNAME); for (int i = 0; i < bt.Header.Length; i++) { HeaderListBox.Items.Add(bt.Header[i]); } if (!HEADERFRONT) { HeaderListBox.BringToFront(); } else { HeaderListBox.SendToBack(); } HEADERFRONT = !HEADERFRONT; }
private void PopulateTable(String ExtensionName) { //try { EXTENSIONNAME = ExtensionName; FITSBINTABLE = new FITSBinTable(FILENAME, EXTENSIONNAME); string[] labels = FITSBINTABLE.TableDataLabelsTTYPE; for (int i = 0; i < labels.Length; i++) { labels[i] = labels[i].Trim(); } for (int i = 0; i < labels.Length; i++) { MenuChooseTableEntries.DropDownItems.Add(labels[i]); ((ToolStripMenuItem)MenuChooseTableEntries.DropDownItems[MenuChooseTableEntries.DropDownItems.Count - 1]).CheckOnClick = true; ((ToolStripMenuItem)MenuChooseTableEntries.DropDownItems[MenuChooseTableEntries.DropDownItems.Count - 1]).Checked = true; this.MenuChooseTableEntries.DropDownItems[MenuChooseTableEntries.DropDownItems.Count - 1].Click += new System.EventHandler(MenuChooseTableEntries_Click); ((ToolStripMenuItem)this.MenuChooseTableEntries.DropDownItems[MenuChooseTableEntries.DropDownItems.Count - 1]).CheckedChanged += new System.EventHandler(ViewAllChck_CheckedChanged); } XDrop.Items.AddRange(labels); YDrop.Items.AddRange(labels); ExtensionTableGrid.Columns.Clear(); ExtensionTableGrid.Rows.Clear(); ExtensionTableGrid.ColumnCount = labels.Length; ExtensionTableGrid.RowCount = FITSBINTABLE.Naxis2; for (int i = 0; i < labels.Length; i++) { ExtensionTableGrid.Columns[i].HeaderText = labels[i]; } DATATABLE = new object[labels.Length]; for (int i = 0; i < labels.Length; i++) { int[] dimNElements; TypeCode type; Object entry; if (FITSBINTABLE.GetTableDataTypes(i) == TypeCode.Char || FITSBINTABLE.GetTTYPEIsHeapVariableRepeatEntry(i)) { entry = FITSBINTABLE.GetTTYPEEntry(labels[i], out type, out dimNElements); } else { entry = FITSBINTABLE.GetTTYPEEntry(labels[i], out dimNElements); type = TypeCode.Double; } if (type != TypeCode.Char && !FITSBINTABLE.GetTTYPEIsHeapVariableRepeatEntry(i)) { if (dimNElements.Length != 1) { DATATABLE[i] = new double[(FITSBINTABLE.Naxis2)]; Parallel.For(0, FITSBINTABLE.Naxis2, j => { ((double[])DATATABLE[i])[j] = Double.NaN; }); } else { DATATABLE[i] = (double[])entry; } } else if (type == TypeCode.Char) { DATATABLE[i] = (string[])entry; } else if (FITSBINTABLE.GetTTYPEIsHeapVariableRepeatEntry(i)) { DATATABLE[i] = new double[(FITSBINTABLE.Naxis2)]; Parallel.For(0, FITSBINTABLE.Naxis2, j => { ((double[])DATATABLE[i])[j] = Double.NaN; }); } } } /*catch (Exception e) * { * MessageBox.Show(e.Data + " " + e.InnerException + " " + e.Message + " " + e.Source + " " + e.StackTrace + " " + e.TargetSite); * }*/ this.BringToFront(); this.Activate(); }