Beispiel #1
0
        static void Main(string[] args)
        {
            string       filePath;
            StreamReader sr = new StreamReader(@".\..\..\testfiles.txt");
            List <KeyValuePair <int, string> > times = new List <KeyValuePair <int, string> >(100);

            while (!sr.EndOfStream)
            {
                IFITSFile ff = Factory.CreateFITSFile();
                filePath = sr.ReadLine();
                if (filePath.StartsWith("#"))
                {
                    continue;
                }
                if (filePath.StartsWith("@end"))
                {
                    break;
                }
                Console.Write(string.Format("Processing: [{0}]", filePath));
                try
                {
                    int before = Environment.TickCount;
                    ff.Load(filePath);
                    int time = Environment.TickCount - before;
                    // clear line
                    Console.CursorLeft = 0;
                    Console.Write(new StringBuilder(Console.WindowWidth).Append(' ', Console.WindowWidth - 1).ToString());
                    Console.CursorLeft = 0;
                    // write time
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.Write(time.ToString() + "\t");
                    Console.ResetColor();
                    // write file name
                    Console.Write(string.Format("@ [{0}]", filePath));
                    times.Add(new KeyValuePair <int, string>(time, filePath));
                }
                //*
                catch
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.Write("FAILED");
                    Console.ResetColor();
                }
                //*/
                // next line
                Console.WriteLine();
            }
            Console.WriteLine("Done!");
            Console.ReadKey();

            StreamWriter w = new StreamWriter(@"c:\temp\ztimes.txt");

            foreach (KeyValuePair <int, string> p in times)
            {
                w.WriteLine(string.Format("{0}\t{1}", p.Key, p.Value));
            }
            w.Close();
        }
Beispiel #2
0
        private void CloseFileFromNode(TreeNode n)
        {
            IFITSFile ff = (IFITSFile)n.Tag;

            foreach (TreeNode hduNode in n.Nodes)
            {
                foreach (TreeNode handlerNode in hduNode.Nodes)
                {
                    if (handlerNode.Tag is KeyValuePair <Guid, int> )
                    {
                        CloseHandler(handlerNode.Tag);
                    }
                }
            }
            structureTreeView.Nodes.Remove(n);
            ff.Close();
        }
Beispiel #3
0
        private void LoadFile(string filePath)
        {
            // load the file
            IFITSFile ff = Factory.CreateFITSFile();

            StartWaitCursor();
            try
            {
                // load file
                _curTreeNode = null;
                ff.Load(filePath);
                // populate tree
                _curTreeNode             = structureTreeView.Nodes.Add(new FileInfo(filePath).Name);
                _curTreeNode.Tag         = ff;
                _curTreeNode.ToolTipText = filePath;
                for (int i = 0; i < ff.HDUs.Length; i++)
                {
                    TreeNode n = _curTreeNode.Nodes.Add("HDU - " + ff.HDUs[i].Name);
                    n.Tag = new KeyValuePair <IHDU, int>(ff.HDUs[i], -1);
                }
                _curTreeNode.Expand();
            }
#if !DEBUG
            catch (Najm.FITSIO.Exception ex)
            {
                RemoveCurrentFileNode();
                MessageBox.Show(ex.Message);
            }
            catch (System.Exception ex)
            {
                RemoveCurrentFileNode();
                MessageBox.Show(string.Format("An error occurred while opening this file: {0}", ex.Message));
            }
#endif
            finally
            {
                EndWaitCursor();
            }
        }