Ejemplo n.º 1
0
        public string ToGEDCOM()
        {
            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < _family.Length; i++)
            {
                _family[i].MemRef = "I" + i;
            }

            int l = 0;

            #region header
            sb.AppendLine(l + " HEAD");
            l++;

            sb.AppendLine(l + " SOUR CESTGENEAL");
            l++;
            sb.AppendLine(l + " VERS " + Assembly.GetExecutingAssembly().GetName().Version);
            sb.AppendLine(l + " NAME C'est Geneal");
            l--;
            sb.AppendLine(l + " SUBM @S1@");
            sb.AppendLine(l + " GEDC");
            l++;
            sb.AppendLine(l + " VERS 5.5.1");
            sb.AppendLine(l + " FORM LINEAGE-LINKED");
            l--;
            sb.AppendLine(l + " CHAR UNICODE");
            sb.AppendLine(l + " LANG English");
            sb.AppendLine(l + " NOTE Tree of " + getMemberFromName(Preferences.RootUser).CleanName);

            l--;
            #endregion

            #region submission
            sb.AppendLine(l + " @S1@ SUBM");
            l++;

            sb.AppendLine(l + " NAME CESTGENEAL_EXPORT");

            l--;
            #endregion

            for (int i = 0; i < _family.Length; i++)
            {
                Member mem = _family[i];

                #region general
                sb.AppendLine(l + " @" + mem.MemRef + "@ INDI");
                l++;

                sb.AppendLine(l + " NAME " + mem.GEDCOMName);
                #endregion

                #region birth
                sb.AppendLine(l + " BIRT");
                l++;

                if (mem.BirthDate.Year > 1)
                {
                    sb.AppendLine(l + " DATE " + mem.BirthDate.ToString("dd MMM yyyy", CultureInfo.InvariantCulture));
                }
                if (mem.BirthLocation != "")
                {
                    sb.AppendLine(l + " PLAC " + mem.BirthLocation);
                }

                l--;
                #endregion

                #region death
                sb.AppendLine(l + " DEAT");
                l++;

                if (mem.BirthDate.Year > 1)
                {
                    sb.AppendLine(l + " DATE " + mem.BirthDate.ToString("dd MMM yyyy", CultureInfo.InvariantCulture));
                }
                if (mem.DeathLoction != "")
                {
                    sb.AppendLine(l + " PLAC " + mem.DeathLoction);
                }

                l--;
                #endregion

                #region family

                string famRef = getFamilyRefFromMember(mem);
                if (famRef.Length > 1)
                {
                    if (addChildToFamily(mem, famRef))
                    {
                        sb.AppendLine(l + " FAMC @" + famRef + "@");
                    }
                }

                #endregion

                l--;
            }

            #region families

            for (int i = 0; i < _families.Count; i++)
            {
                _families[i].flatten(l, sb);
            }

            #endregion

            sb.Append(l + " TRLR");

            return(sb.ToString());
        }
Ejemplo n.º 2
0
 private String getFamilyRefFromMember(Member mem)
 {
     return("F" + getMemberRefFromName(mem.Parent1) + getMemberRefFromName(mem.Parent2));
 }