コード例 #1
0
        private void loadFromStrings(List <string> lines)
        {
            for (int line = 0; line < lines.Count; line++)
            {
                if (!lines[line].StartsWith("#"))
                {
                    string[]      parts  = lines[line].Split('|');
                    List <string> tokens = new List <string>();
                    tokens.AddRange(parts);
                    if (tokens.Count < 4)
                    {
                        continue;
                    }
                    if (tokens[0].Length > 0 && (tokens[0].StartsWith("L") || tokens[0].StartsWith("M") || tokens[0].StartsWith("-")))
                    {
                        tokens[0] = tokens[0].Substring(1);
                    }
                    PrefixKind entryKind = (PrefixKind)Convert.ToInt32(tokens[0].Substring(0, 2));
                    if (!entryKind.Equals(PrefixKind.DXCC))
                    {
                        continue;
                    }
                    // populate new entry
                    PrefixEntry entry = new PrefixEntry();

                    entry.Id   = Entries.Count;
                    entry.Kind = entryKind;
                    // level
                    string level = tokens[0].Substring(2);
                    entry.Level = String.IsNullOrEmpty(level) ? 0 : Convert.ToInt32(level);
                    // location
                    entry.Data.Location.X = String.IsNullOrEmpty(tokens[1]) ? 0 : Convert.ToInt32(tokens[1]);
                    entry.Data.Location.Y = String.IsNullOrEmpty(tokens[2]) ? 0 : Convert.ToInt32(tokens[2]);
                    // rest
                    entry.Data.Territory    = tokens[3];
                    entry.Data.Prefix       = tokens[4];
                    entry.Data.CQ           = tokens[5];
                    entry.Data.ITU          = tokens[6];
                    entry.Data.Continent    = tokens[7];
                    entry.Data.TZ           = tokens[8];
                    entry.Data.ADIF         = tokens[9];
                    entry.Data.ProvinceCode = tokens[10];
                    entry.Mask = tokens[13];
                    Entries.Add(entry);
                }
            }
        }
コード例 #2
0
        private void AddToIndex(char char1, char char2, PrefixEntry entry)
        {
            int p1 = AfreetConstants.Chars.IndexOf(char1);
            int p2 = AfreetConstants.Chars.IndexOf(char2);

            p1 = p1 >= 0 ? p1 : 0;
            p2 = p2 >= 0 ? p2 : 0;

            int Len = Index[p1, p2].Count;

            // no dupes
            for (int i = 0; i < Len; i++)
            {
                if (Index[p1, p2][i] == entry)
                {
                    return;
                }
            }
            // add
            Index[p1, p2].Add(entry);
        }