Exemple #1
0
        private void FitsFinderWrkr_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            int numparams = Convert.ToInt32(REG.GetReg("CCDLAB", "FindFilesNumKeyValPairs"));

            string[]  fullfilesinit = (string[])e.Argument;
            ArrayList filelist      = new ArrayList();

            string[] KeyParams    = new string[(numparams)];
            string[] KeyValParams = new string[(numparams)];
            int      match        = 0;

            for (int i = 0; i < numparams; i++)            //get the key/keyvalue pairs
            {
                KeyParams[i]    = (string)REG.GetReg("CCDLAB", String.Concat("FindFilesKey", i));
                KeyValParams[i] = (string)REG.GetReg("CCDLAB", String.Concat("FindFilesKeyVal", i));
            }
            //done filling the param pairs...now need to do the work

            for (int ii = 0; ii < fullfilesinit.Length; ii++)
            {
                if (this.WAITBAR.DialogResult == DialogResult.Cancel)
                {
                    this.DialogResult = DialogResult.Cancel;
                    this.Tag          = DialogResult.Cancel;
                    return;
                }
                FitsFinderWrkr.ReportProgress(ii + 1, filelist.Count);

                FITSImage f1 = new FITSImage(fullfilesinit[ii], null, true, false, false, false);

                match = 0;
                for (int j = 0; j < f1.Header.Length; j++)
                {
                    string key = f1.Header[j].Name;
                    for (int k = 0; k < numparams; k++)
                    {
                        if (KeyParams[k] == key && KeyValParams[k] == f1.Header[j].Value)
                        {
                            match++;
                        }
                    }
                }
                if (match == numparams)
                {
                    filelist.Add(fullfilesinit[ii]);
                }
            }

            string[] matchedfiles = new string[(filelist.Count)];
            for (int h = 0; h < filelist.Count; h++)
            {
                matchedfiles[h] = (string)filelist[h];
            }

            e.Result = matchedfiles;

            this.DialogResult = DialogResult.OK;
        }
        public FITSImageExtensionsLister(string fileName)
        {
            InitializeComponent();

            string[] extlist = FITSImage.GetAllExtensionNames(fileName);

            if (extlist.Length == 0)
            {
                MessageBox.Show("No IMAGE extensions exist in the file...", "Error");
                this.CancelBtn.PerformClick();
                this.Close();
                return;
            }

            FITSImage fi = new FITSImage(fileName, null, true, false, false, false);

            if (fi.Header.GetKeyValue("NAXIS") == "0")
            {
                IncludePrimaryChck.Enabled = false;
            }

            int n = 1;

            for (int i = 0; i < extlist.Length; i++)
            {
                if (extlist[i] == "")
                {
                    ExtensionChckdListBox.Items.Add("Unnamed extension: " + n, true);
                    n++;
                }
                else
                {
                    ExtensionChckdListBox.Items.Add(extlist[i], true);
                }
            }
        }