Ejemplo n.º 1
0
        public LocksFromFile()
        {
            string        FileName = "locks.txt";
            string        LineFromFile;
            List <string> Challenges;

            try
            {
                using (StreamReader MyStream = new StreamReader(FileName))
                {
                    LineFromFile = MyStream.ReadLine();
                    while (LineFromFile != null)
                    {
                        Challenges = LineFromFile.Split(';').ToList();
                        Lock LockFromFile = new Lock();
                        foreach (var C in Challenges)
                        {
                            List <string> Conditions = new List <string>();
                            Conditions = C.Split(',').ToList();
                            LockFromFile.AddChallenge(Conditions);
                        }
                        Locks.Add(LockFromFile);
                        LineFromFile = MyStream.ReadLine();
                    }
                }
            }
            catch
            {
                Console.WriteLine("File not loaded");
            }
        }
Ejemplo n.º 2
0
 public static void GetCountriesFromFile(DictionaryCountries dictionaryCountries)
 {
     try
     {
         Console.WriteLine("Reading Countries:\n");
         int i = 0;
         using (StreamReader sr = new StreamReader(Const.Path, System.Text.Encoding.Default))
         {
             string LineFromFile;
             while ((LineFromFile = sr.ReadLine()) != null)
             {
                 if (i == 0)
                 {
                     i++;
                     continue;
                 }
                 List<string> tmp = LineFromFile.Split('\t').ToList();
                 Console.WriteLine($"{i, 3}. {tmp.First(), -20}     {tmp.Last(), -20}");
                 dictionaryCountries.countries.Add(i, new Country(tmp.First(), bool.Parse(tmp.Last())));
                 i++;
             }
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
     }
 }
Ejemplo n.º 3
0
    /// ********************************************************************************

    private void TargetLoop()
    {
        string szPathToMapFile = "C:\\Users\\Rick\\Documents\\Software Bisque\\TheSkyX Professional Edition\\Exported Data\\map.txt";

        ///Set the exposure time for the image
        double dExposure = 1.0;

        string LineFromFile;
        double dAz;
        double dAlt;

        //Connect to TSX TheSky and Uility methods
        sky6Utils        tsx_util = new sky6Utils();
        sky6RASCOMTheSky tsx_sky  = new sky6RASCOMTheSky();
        sky6RASCOMTele   tsx_tele = new sky6RASCOMTele();
        ccdsoftCamera    tsx_cam  = new ccdsoftCamera();

        ///Open the observing list export file for targets
        StreamReader MyFile = File.OpenText(szPathToMapFile); ///Stream object for Export Data text file

        ///Get the first line -- headers
        ///Exit if the file is empty
        if (MyFile.EndOfStream == true)
        {
            return;
        }
        ;
        LineFromFile = MyFile.ReadLine();

        int iRAindex  = LineFromFile.IndexOf("RA");
        int iDecindex = LineFromFile.IndexOf("Dec");

        while (MyFile.EndOfStream == false)
        {
            LineFromFile = MyFile.ReadLine();
            MessageBox.Show("RA: " + LineFromFile.Substring(iRAindex, 13) + "  Dec: " + LineFromFile.Substring(iDecindex, 13));

            string sname = LineFromFile.Substring((LineFromFile.Length - 12), 12);
            tsx_util.ConvertStringToRA(LineFromFile.Substring(iRAindex, 13));
            dAz = tsx_util.dOut0;
            tsx_util.ConvertStringToDec(LineFromFile.Substring(iDecindex, 13));
            dAlt = tsx_util.dOut0;

            ///Slew to object
            tsx_tele.SlewToAzAlt(dAz, dAlt, sname);

            ///Set exposure time and try { for image, exit if error
            tsx_cam.ExposureTime = dExposure;
            tsx_cam.TakeImage();
            ///Add to T-point Model
            tsx_sky.AutoMap();
        }
        ;   //Loop
    }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            //Task1
            string LineFromFile;
            string Number     = "";
            string Person     = "";
            string AllNumbers = "";

            string[] SplitLine = new string[2];
            Dictionary <String, String> PhoneBook = new Dictionary <String, String>();
            StreamReader FileReader = new StreamReader("D:\\phones.txt");

            while ((LineFromFile = FileReader.ReadLine()) != null)
            {
                SplitLine = LineFromFile.Split('-');
                Person    = SplitLine[0];
                Number    = SplitLine[1];
                Person    = Person.Trim();
                Number    = Number.Trim();
                PhoneBook.Add(Person, Number);
            }
            foreach (KeyValuePair <string, string> pair in PhoneBook)
            {
                AllNumbers = AllNumbers + pair.Value + Environment.NewLine;
            }
            File.WriteAllText("D:\\phones2.txt", AllNumbers);

            //Task2
            bool   Result    = false;
            string ResultStr = "";

            Console.Write("Please enter the name for search in the database: ");
            string Input = Console.ReadLine();

            foreach (KeyValuePair <string, string> pair in PhoneBook)
            {
                if (Input == pair.Key)
                {
                    Result    = true;
                    ResultStr = pair.Value;
                }
            }
            if (Result == true)
            {
                Console.WriteLine("The phone number of the person is {0}.", ResultStr);
            }
            else
            {
                Console.WriteLine("You typed the wrong ID.");
            }

            //Task3
            string Median    = "";
            string NewOutput = "";

            foreach (KeyValuePair <string, string> pair in PhoneBook)
            {
                if (pair.Value.StartsWith("8"))
                {
                    Median = "+3" + pair.Value;
                }
                else
                {
                    Median = pair.Value;
                }
                NewOutput += pair.Key + " - " + Median + Environment.NewLine;
                File.WriteAllText("D:\\new.txt", NewOutput);
            }
            Console.ReadLine();
        }