示例#1
0
        private void HeaderContextRemoveKeys_Click(System.Object sender, System.EventArgs e)
        {
            for (int i = 0; i < HeaderKeysListBox.SelectedIndices.Count; i++)
            {
                if (!FITSHeader.ValidKeyEdit(HEADER[(int)HeaderKeysListBox.SelectedIndices[i]].Name, false))
                {
                    MessageBox.Show("At least one of the keys ('" + HEADER[(int)HeaderKeysListBox.SelectedIndices[i]].Name + "') is restricted. Try again.", "Warning...:");
                    return;
                }
            }

            int ind;

            string[] origkeylines = null;
            string[] origkeynames = null;
            bool[]   iscomment    = null;
            if (HeaderContextApplyAll.Checked)
            {
                origkeylines = new string[HeaderKeysListBox.SelectedIndices.Count];
                origkeynames = new string[HeaderKeysListBox.SelectedIndices.Count];
                iscomment    = new bool[HeaderKeysListBox.SelectedIndices.Count];
                for (int i = 0; i < HeaderKeysListBox.SelectedIndices.Count; i++)
                {
                    origkeylines[i] = HEADER[(int)HeaderKeysListBox.SelectedIndices[i]].GetFullyFomattedFITSLine();
                    origkeynames[i] = HEADER[(int)HeaderKeysListBox.SelectedIndices[i]].Name;
                    iscomment[i]    = HEADER[(int)HeaderKeysListBox.SelectedIndices[i]].IsCommentKey;
                }
            }

            for (int i = HeaderKeysListBox.SelectedIndices.Count - 1; i >= 0; i--)
            {
                if (!HeaderContextApplyAll.Checked)
                {
                    IMAGESET[IMAGESETHEADERINDEX].Header.RemoveKey((int)HeaderKeysListBox.SelectedIndices[i]);
                }
                else
                {
                    for (int j = 0; j < IMAGESET.Count; j++)
                    {
                        if (iscomment[i])
                        {
                            ind = IMAGESET[j].Header.GetKeyIndex(origkeylines[i], true);
                        }
                        else
                        {
                            ind = IMAGESET[j].Header.GetKeyIndex(origkeynames[i], false);
                        }

                        if (ind != -1)
                        {
                            IMAGESET[j].Header.RemoveKey(ind);
                        }
                    }
                }
            }

            this.Header = IMAGESET[IMAGESETHEADERINDEX].Header;
        }
示例#2
0
        private void HeaderContextEditKey_Click(System.Object sender, System.EventArgs e)
        {
            if (!FITSHeader.ValidKeyEdit(HEADER[HeaderKeysListBox.SelectedIndex].Name, true))
            {
                return;
            }

            JPFITS.FITSHeaderKeyDialog hkd = new JPFITS.FITSHeaderKeyDialog(HEADER[HeaderKeysListBox.SelectedIndex]);
            if (hkd.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }

            String origkeyline = HEADER[HeaderKeysListBox.SelectedIndex].GetFullyFomattedFITSLine();
            String origkeyname = HEADER[HeaderKeysListBox.SelectedIndex].Name;
            bool   iscomment   = HEADER[HeaderKeysListBox.SelectedIndex].IsCommentKey;
            int    ind;

            if (HeaderContextApplyAll.Checked)
            {
                for (int i = 0; i < IMAGESET.Count; i++)
                {
                    if (iscomment)
                    {
                        ind = IMAGESET[i].Header.GetKeyIndex(origkeyline, true);
                    }
                    else
                    {
                        ind = IMAGESET[i].Header.GetKeyIndex(origkeyname, false);
                    }

                    if (ind != -1)
                    {
                        IMAGESET[i].Header[ind] = hkd.HeaderLine;
                    }
                }
            }
            else
            {
                IMAGESET[IMAGESETHEADERINDEX].Header[HeaderKeysListBox.SelectedIndex] = hkd.HeaderLine;
            }

            this.Header = IMAGESET[IMAGESETHEADERINDEX].Header;
        }
示例#3
0
        private void EditCopyfromFileBtn_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter = "FITS|*.fts; *.fit; *.fits|All|*.*";
            if (ofd.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }

            FITSHeader hed = new FITSHeader(ofd.FileName);

            this.HEADER.CopyHeaderFrom(hed);

            HeaderKeysListBox.SuspendLayout();
            HeaderKeysListBox.Items.Clear();
            HeaderKeysListBox.Items.AddRange(HEADER.GetFormattedHeaderBlock(false, true));
            HeaderKeysListBox.ResumeLayout();
        }