コード例 #1
0
 public GCLocation(TLocation loc)
 {
     Title     = loc.CityName + " (" + loc.Country.Name + ")";
     Longitude = loc.Longitude;
     Latitude  = loc.Latitude;
     TimeZone  = loc.TimeZone;
 }
コード例 #2
0
        /// <summary>
        /// Loading file in the format, where values are separated with TAB character
        /// </summary>
        /// <param name="fileName">File name</param>
        /// <param name="flagStandardFile">TRUE if loaded file is standard one, FALSE if loaded file is imported external file</param>
        /// <returns>TRUE if file was successfuly loaded, FALSE if the file was not loaded</returns>
        public static bool LoadFile(string fileName, bool flagStandardFile)
        {
            locationList = new List <TLocation>();

            if (!File.Exists(fileName))
            {
                if (flagStandardFile)
                {
                    File.WriteAllText(fileName, Properties.Resources.cities2016);
                }
                else
                {
                    return(false);
                }
            }

            using (StreamReader sr = new StreamReader(fileName))
            {
                string line;
                while ((line = sr.ReadLine()) != null)
                {
                    if (line.StartsWith("#"))
                    {
                        continue;
                    }
                    TLocation loc = new TLocation(line);
                    if (loc.Valid)
                    {
                        locationList.Add(loc);
                    }
                }
            }

            return(true);
        }