From b7bc270a4edd271fe9cbb96f00dadfd1b4b6ed80 Mon Sep 17 00:00:00 2001 From: Michael Becker Date: Fri, 30 Aug 2019 00:38:18 -0400 Subject: [PATCH] Rename FamilyTreeMaker plugin to the more-generic Genealogy plugin --- .../UniversalEditor.TestProject/Program.cs | 61 ++++++++++--- .../UniversalEditor.TestProject.csproj | 4 + .../Editors/FamilyTree/FamilyTreeEditor.cs | 20 ++--- .../Properties/AssemblyInfo.cs | 0 ...or.Plugins.Genealogy.UserInterface.csproj} | 8 +- .../FamilyTreeMaker/Windows/FTWDataFormat.cs | 27 ------ .../FamilyTreeMaker/Windows/FTWDataFormat.cs | 55 ++++++++++++ .../Windows/INDDBDataFormat.cs | 87 +++++++++++++++++++ .../Windows/INDGROUPSDataFormat.cs | 53 +++++++++++ .../GEDCOM/GEDCOMChunkedDataFormat.cs | 64 ++++++++++++++ .../DataFormats/GEDCOM/GEDCOMDataFormat.cs | 42 +++++++++ .../FamilyTree/FamilyTreeObjectModel.cs | 4 +- .../ObjectModels/GEDCOM/GEDCOMChunk.cs | 17 ++++ .../GEDCOM/GEDCOMChunkedObjectModel.cs | 16 ++++ .../Properties/AssemblyInfo.cs | 0 .../UniversalEditor.Plugins.Genealogy.csproj} | 8 ++ CSharp/UniversalEditor.sln | 4 +- 17 files changed, 414 insertions(+), 56 deletions(-) rename CSharp/Plugins.UserInterface/{UniversalEditor.Plugins.FamilyTreeMaker.UserInterface => UniversalEditor.Plugins.Genealogy.UserInterface}/Editors/FamilyTree/FamilyTreeEditor.cs (92%) rename CSharp/Plugins.UserInterface/{UniversalEditor.Plugins.FamilyTreeMaker.UserInterface => UniversalEditor.Plugins.Genealogy.UserInterface}/Properties/AssemblyInfo.cs (100%) rename CSharp/Plugins.UserInterface/{UniversalEditor.Plugins.FamilyTreeMaker.UserInterface/UniversalEditor.Plugins.FamilyTreeMaker.UserInterface.csproj => UniversalEditor.Plugins.Genealogy.UserInterface/UniversalEditor.Plugins.Genealogy.UserInterface.csproj} (93%) delete mode 100644 CSharp/Plugins/UniversalEditor.Plugins.FamilyTreeMaker/DataFormats/FamilyTreeMaker/Windows/FTWDataFormat.cs create mode 100644 CSharp/Plugins/UniversalEditor.Plugins.Genealogy/DataFormats/FamilyTreeMaker/Windows/FTWDataFormat.cs create mode 100644 CSharp/Plugins/UniversalEditor.Plugins.Genealogy/DataFormats/FamilyTreeMaker/Windows/INDDBDataFormat.cs create mode 100644 CSharp/Plugins/UniversalEditor.Plugins.Genealogy/DataFormats/FamilyTreeMaker/Windows/INDGROUPSDataFormat.cs create mode 100644 CSharp/Plugins/UniversalEditor.Plugins.Genealogy/DataFormats/GEDCOM/GEDCOMChunkedDataFormat.cs create mode 100644 CSharp/Plugins/UniversalEditor.Plugins.Genealogy/DataFormats/GEDCOM/GEDCOMDataFormat.cs rename CSharp/Plugins/{UniversalEditor.Plugins.FamilyTreeMaker => UniversalEditor.Plugins.Genealogy}/ObjectModels/FamilyTree/FamilyTreeObjectModel.cs (73%) create mode 100644 CSharp/Plugins/UniversalEditor.Plugins.Genealogy/ObjectModels/GEDCOM/GEDCOMChunk.cs create mode 100644 CSharp/Plugins/UniversalEditor.Plugins.Genealogy/ObjectModels/GEDCOM/GEDCOMChunkedObjectModel.cs rename CSharp/Plugins/{UniversalEditor.Plugins.FamilyTreeMaker => UniversalEditor.Plugins.Genealogy}/Properties/AssemblyInfo.cs (100%) rename CSharp/Plugins/{UniversalEditor.Plugins.FamilyTreeMaker/UniversalEditor.Plugins.FamilyTreeMaker.csproj => UniversalEditor.Plugins.Genealogy/UniversalEditor.Plugins.Genealogy.csproj} (84%) diff --git a/CSharp/Applications/UniversalEditor.TestProject/Program.cs b/CSharp/Applications/UniversalEditor.TestProject/Program.cs index ceb383c3..02952dfd 100644 --- a/CSharp/Applications/UniversalEditor.TestProject/Program.cs +++ b/CSharp/Applications/UniversalEditor.TestProject/Program.cs @@ -4,10 +4,14 @@ using System.Text; using UniversalEditor.Accessors; using UniversalEditor.DataFormats.Markup.XML; using UniversalEditor.DataFormats.Package.OpenPackagingConvention; +using UniversalEditor.DataFormats.Text.Formatted.DOC; +using UniversalEditor.Plugins.Genealogy.ObjectModels.FamilyTree; using UniversalEditor.ObjectModels.FileSystem; using UniversalEditor.ObjectModels.Markup; using UniversalEditor.ObjectModels.Multimedia3D.Model; using UniversalEditor.ObjectModels.Package; +using UniversalEditor.ObjectModels.Text.Formatted; +using UniversalEditor.Plugins.Genealogy.DataFormats.GEDCOM; namespace UniversalEditor.TestProject { @@ -251,6 +255,51 @@ namespace UniversalEditor.TestProject } return String.Empty; } + + } + + private static void TestCDFDOC() + { + DOCDataFormat doc = new DOCDataFormat(); + FormattedTextObjectModel ftom = new FormattedTextObjectModel(); + + Document.Load(ftom, doc, new FileAccessor("/home/beckermj/Documents/UE Tests/OLE Compound Document/test.doc")); + } + + private static void TestCDFFTW() + { + GEDCOMDataFormat ged = new GEDCOMDataFormat(); + + FamilyTreeObjectModel ftom = new FamilyTreeObjectModel(); + + /* + FTWDataFormat cdf = new FTWDataFormat(); + cdf.LogPath = "/tmp/test.ue/AAFT/AAFT0000"; + Document.Load(ftom, cdf, new FileAccessor("/tmp/test.ue/AAFT/AAFT0000.FTW")); + + cdf.LogPath = "/tmp/test.ue/AAFT/AAFT0001"; + Document.Load(ftom, cdf, new FileAccessor("/tmp/test.ue/AAFT/AAFT0001.FTW")); + + cdf.LogPath = "/tmp/test.ue/AAFT/AAFT0002"; + Document.Load(ftom, cdf, new FileAccessor("/tmp/test.ue/AAFT/AAFT0002.FTW")); + // Document.Save(ftom, cdf, new FileAccessor("/home/beckermj/Documents/UE Tests/OLE Compound Document/Anthony Azcona Family Tree UE-TEST.ftw", true, true)); + */ + + Document.Load(ftom, ged, new FileAccessor("/tmp/test.ue/AAFT/AAFT.GED")); + } + + private static void TestOPCModel() + { + DateTime start = DateTime.Now; + + ModelObjectModel model = new ModelObjectModel(); + UniversalEditor.DataFormats.Multimedia3D.Model.PolygonMovieMaker.PMDModelDataFormat pmd = new DataFormats.Multimedia3D.Model.PolygonMovieMaker.PMDModelDataFormat(); + + Document.Load(model, pmd, new FileAccessor("/home/beckermj/Documents/UE Tests/Open Packaging Convention/Concertroid Model Data OPC (.pmdx)/test.pmdx_source/model/kio_miku_20111121.pmd")); + Document.Save(model, new OPCModelDataFormat(), new FileAccessor("/home/beckermj/Documents/UE Tests/Open Packaging Convention/Concertroid Model Data OPC (.pmdx)/kio_miku.pmdx", true, true)); + + DateTime end = DateTime.Now; + Console.WriteLine("Took " + (end - start).ToString() + " with buffer size " + MemoryAccessor.DefaultBufferAllocationSize); } public static void Main (string [] args) @@ -264,16 +313,8 @@ namespace UniversalEditor.TestProject Document.Save (om, df, new FileAccessor (fileName, true, true)); */ - DateTime start = DateTime.Now; - - ModelObjectModel model = new ModelObjectModel(); - UniversalEditor.DataFormats.Multimedia3D.Model.PolygonMovieMaker.PMDModelDataFormat pmd = new DataFormats.Multimedia3D.Model.PolygonMovieMaker.PMDModelDataFormat(); - - Document.Load(model, pmd, new FileAccessor("/home/beckermj/Documents/UE Tests/Open Packaging Convention/Concertroid Model Data OPC (.pmdx)/test.pmdx_source/model/kio_miku_20111121.pmd")); - Document.Save(model, new OPCModelDataFormat(), new FileAccessor("/home/beckermj/Documents/UE Tests/Open Packaging Convention/Concertroid Model Data OPC (.pmdx)/kio_miku.pmdx", true, true)); - - DateTime end = DateTime.Now; - Console.WriteLine("Took " + (end - start).ToString() + " with buffer size " + MemoryAccessor.DefaultBufferAllocationSize); + // TestCDFDOC(); + TestCDFFTW(); } } } diff --git a/CSharp/Applications/UniversalEditor.TestProject/UniversalEditor.TestProject.csproj b/CSharp/Applications/UniversalEditor.TestProject/UniversalEditor.TestProject.csproj index 8f304f06..f434c251 100644 --- a/CSharp/Applications/UniversalEditor.TestProject/UniversalEditor.TestProject.csproj +++ b/CSharp/Applications/UniversalEditor.TestProject/UniversalEditor.TestProject.csproj @@ -59,6 +59,10 @@ {4FD9DB1D-76AA-48D1-8446-95376C4A2BC2} UniversalEditor.Plugins.Multimedia3D + + {74A835FD-93B8-4268-B120-1ACAA128AC7B} + UniversalEditor.Plugins.Genealogy + \ No newline at end of file diff --git a/CSharp/Plugins.UserInterface/UniversalEditor.Plugins.FamilyTreeMaker.UserInterface/Editors/FamilyTree/FamilyTreeEditor.cs b/CSharp/Plugins.UserInterface/UniversalEditor.Plugins.Genealogy.UserInterface/Editors/FamilyTree/FamilyTreeEditor.cs similarity index 92% rename from CSharp/Plugins.UserInterface/UniversalEditor.Plugins.FamilyTreeMaker.UserInterface/Editors/FamilyTree/FamilyTreeEditor.cs rename to CSharp/Plugins.UserInterface/UniversalEditor.Plugins.Genealogy.UserInterface/Editors/FamilyTree/FamilyTreeEditor.cs index bfb88937..f98b99de 100644 --- a/CSharp/Plugins.UserInterface/UniversalEditor.Plugins.FamilyTreeMaker.UserInterface/Editors/FamilyTree/FamilyTreeEditor.cs +++ b/CSharp/Plugins.UserInterface/UniversalEditor.Plugins.Genealogy.UserInterface/Editors/FamilyTree/FamilyTreeEditor.cs @@ -1,5 +1,5 @@ -using System; -using UniversalEditor.ObjectModels.FamilyTree; +using System; +using UniversalEditor.Plugins.Genealogy.ObjectModels.FamilyTree; using UniversalEditor.UserInterface; namespace UniversalEditor.Editors.FamilyTree @@ -19,22 +19,22 @@ namespace UniversalEditor.Editors.FamilyTree public override void Paste () { throw new System.NotImplementedException (); - } - - private static EditorReference _er = null; + } + + private static EditorReference _er = null; public override EditorReference MakeReference () - { + { if (_er == null) { - _er = base.MakeReference (); + _er = base.MakeReference (); _er.SupportedObjectModels.Add (typeof (FamilyTreeObjectModel)); - } + } return _er; } protected override void OnObjectModelChanged (EventArgs e) { - base.OnObjectModelChanged (e); - + base.OnObjectModelChanged (e); + FamilyTreeObjectModel ftom = (ObjectModel as FamilyTreeObjectModel); } } diff --git a/CSharp/Plugins.UserInterface/UniversalEditor.Plugins.FamilyTreeMaker.UserInterface/Properties/AssemblyInfo.cs b/CSharp/Plugins.UserInterface/UniversalEditor.Plugins.Genealogy.UserInterface/Properties/AssemblyInfo.cs similarity index 100% rename from CSharp/Plugins.UserInterface/UniversalEditor.Plugins.FamilyTreeMaker.UserInterface/Properties/AssemblyInfo.cs rename to CSharp/Plugins.UserInterface/UniversalEditor.Plugins.Genealogy.UserInterface/Properties/AssemblyInfo.cs diff --git a/CSharp/Plugins.UserInterface/UniversalEditor.Plugins.FamilyTreeMaker.UserInterface/UniversalEditor.Plugins.FamilyTreeMaker.UserInterface.csproj b/CSharp/Plugins.UserInterface/UniversalEditor.Plugins.Genealogy.UserInterface/UniversalEditor.Plugins.Genealogy.UserInterface.csproj similarity index 93% rename from CSharp/Plugins.UserInterface/UniversalEditor.Plugins.FamilyTreeMaker.UserInterface/UniversalEditor.Plugins.FamilyTreeMaker.UserInterface.csproj rename to CSharp/Plugins.UserInterface/UniversalEditor.Plugins.Genealogy.UserInterface/UniversalEditor.Plugins.Genealogy.UserInterface.csproj index 78c4b127..7f908848 100644 --- a/CSharp/Plugins.UserInterface/UniversalEditor.Plugins.FamilyTreeMaker.UserInterface/UniversalEditor.Plugins.FamilyTreeMaker.UserInterface.csproj +++ b/CSharp/Plugins.UserInterface/UniversalEditor.Plugins.Genealogy.UserInterface/UniversalEditor.Plugins.Genealogy.UserInterface.csproj @@ -46,10 +46,6 @@ {30467E5C-05BC-4856-AADC-13906EF4CADD} UniversalEditor.Essential - - {74A835FD-93B8-4268-B120-1ACAA128AC7B} - UniversalEditor.Plugins.FamilyTreeMaker - {76FD1306-9CA4-428F-993B-B7E4EEEACBF3} UniversalEditor.Plugins.FileSystem @@ -62,6 +58,10 @@ {29E1C1BB-3EA5-4062-B62F-85EEC703FE07} UniversalWidgetToolkit + + {74A835FD-93B8-4268-B120-1ACAA128AC7B} + UniversalEditor.Plugins.Genealogy + \ No newline at end of file diff --git a/CSharp/Plugins/UniversalEditor.Plugins.FamilyTreeMaker/DataFormats/FamilyTreeMaker/Windows/FTWDataFormat.cs b/CSharp/Plugins/UniversalEditor.Plugins.FamilyTreeMaker/DataFormats/FamilyTreeMaker/Windows/FTWDataFormat.cs deleted file mode 100644 index 9de0310b..00000000 --- a/CSharp/Plugins/UniversalEditor.Plugins.FamilyTreeMaker/DataFormats/FamilyTreeMaker/Windows/FTWDataFormat.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System.Collections.Generic; -using UniversalEditor.DataFormats.FileSystem.Microsoft.CompoundDocument; -using UniversalEditor.ObjectModels.FamilyTree; -using UniversalEditor.ObjectModels.FileSystem; - -namespace UniversalEditor.DataFormats.FamilyTreeMaker.Windows -{ - public class FTWDataFormat : CompoundDocumentDataFormat - { - protected override void BeforeLoadInternal (Stack objectModels) - { - base.BeforeLoadInternal (objectModels); - objectModels.Push (new FileSystemObjectModel ()); - } - protected override void AfterLoadInternal (Stack objectModels) - { - base.AfterLoadInternal (objectModels); - - FileSystemObjectModel fsom = (objectModels.Pop () as FileSystemObjectModel); - FamilyTreeObjectModel ft = (objectModels.Pop () as FamilyTreeObjectModel); - } - protected override void BeforeSaveInternal (Stack objectModels) - { - base.BeforeSaveInternal (objectModels); - } - } -} diff --git a/CSharp/Plugins/UniversalEditor.Plugins.Genealogy/DataFormats/FamilyTreeMaker/Windows/FTWDataFormat.cs b/CSharp/Plugins/UniversalEditor.Plugins.Genealogy/DataFormats/FamilyTreeMaker/Windows/FTWDataFormat.cs new file mode 100644 index 00000000..282d659e --- /dev/null +++ b/CSharp/Plugins/UniversalEditor.Plugins.Genealogy/DataFormats/FamilyTreeMaker/Windows/FTWDataFormat.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using UniversalEditor.DataFormats.FileSystem.Microsoft.CompoundDocument; +using UniversalEditor.Plugins.Genealogy.ObjectModels.FamilyTree; +using UniversalEditor.ObjectModels.FileSystem; + +namespace UniversalEditor.Plugins.Genealogy.DataFormats.FamilyTreeMaker.Windows +{ + public class FTWDataFormat : CompoundDocumentDataFormat + { + protected override void BeforeLoadInternal (Stack objectModels) + { + base.BeforeLoadInternal (objectModels); + objectModels.Push (new FileSystemObjectModel ()); + } + protected override void AfterLoadInternal (Stack objectModels) + { + base.AfterLoadInternal (objectModels); + + FileSystemObjectModel fsom = (objectModels.Pop () as FileSystemObjectModel); + + File IND_DB = fsom.Files["IND.DB"]; + File INDGROUPS = fsom.Files["QEDIT0.DB"]; + + INDDBObjectModel objm = IND_DB.GetObjectModel(new INDDBDataFormat()); + + int maxNameLength = 0; + foreach (INDDBRecord item in objm.Items) + { + Console.WriteLine("{0} {1}", item.name.PadRight(40, ' '), item.testdt.ToString()); + if (item.name.Length > maxNameLength) maxNameLength = item.name.Length; + } + + Console.WriteLine(); + + INDGROUPSObjectModel objm1 = INDGROUPS.GetObjectModel(new INDGROUPSDataFormat()); + + foreach (INDGROUPSRecord rec in objm1.Items) + { + Console.WriteLine("{0}", rec.name); + } + + FamilyTreeObjectModel ft = (objectModels.Pop () as FamilyTreeObjectModel); + } + protected override void BeforeSaveInternal (Stack objectModels) + { + FamilyTreeObjectModel ft = (objectModels.Pop() as FamilyTreeObjectModel); + FileSystemObjectModel fsom = new FileSystemObjectModel(); + + objectModels.Push(fsom); + + base.BeforeSaveInternal (objectModels); + } + } +} diff --git a/CSharp/Plugins/UniversalEditor.Plugins.Genealogy/DataFormats/FamilyTreeMaker/Windows/INDDBDataFormat.cs b/CSharp/Plugins/UniversalEditor.Plugins.Genealogy/DataFormats/FamilyTreeMaker/Windows/INDDBDataFormat.cs new file mode 100644 index 00000000..be553291 --- /dev/null +++ b/CSharp/Plugins/UniversalEditor.Plugins.Genealogy/DataFormats/FamilyTreeMaker/Windows/INDDBDataFormat.cs @@ -0,0 +1,87 @@ +using System; +using UniversalEditor.IO; + +namespace UniversalEditor.Plugins.Genealogy.DataFormats.FamilyTreeMaker.Windows +{ + internal struct INDDBRecord + { + public string name; + public DateTime testdt; + + public INDDBRecord(string name, DateTime testdt) + { + this.name = name; + this.testdt = testdt; + } + } + internal class INDDBObjectModel : ObjectModel + { + public System.Collections.Generic.List Items { get; } = new System.Collections.Generic.List(); + + public override void Clear() + { + } + + public override void CopyTo(ObjectModel where) + { + } + } + internal class INDDBDataFormat : DataFormat + { + private static DataFormatReference _dfr = null; + protected override DataFormatReference MakeReferenceInternal() + { + if (_dfr == null) + { + _dfr = base.MakeReferenceInternal(); + _dfr.Capabilities.Add(typeof(INDDBObjectModel), DataFormatCapabilities.All); + } + return _dfr; + } + + protected override void LoadInternal(ref ObjectModel objectModel) + { + INDDBObjectModel objm = (objectModel as INDDBObjectModel); + Reader r = base.Accessor.Reader; + + byte[] junk = r.ReadBytes(128); // is this short sector garbage? + long unk1 = r.ReadInt64(); // bluh + + int test = r.ReadInt32(); + byte[] xx = r.ReadBytes(64); + + for (int i = 0; i < 133; i++) + { + // each record is 128 bytes long + long recordStart = r.Accessor.Position; + + ushort u0 = r.ReadUInt16(); + ushort u1 = r.ReadUInt16(); + ushort u2 = r.ReadUInt16(); + ushort u3 = r.ReadUInt16(); + ushort u4 = r.ReadUInt16(); + + string name = r.ReadFixedLengthString(40, Encoding.UTF16LittleEndian); // r.ReadFixedLengthString(40, Encoding.UTF16LittleEndian); + name = name.TrimNull(); + + ushort unknown = r.ReadUInt16(); + long dt = r.ReadInt64(); + + DateTime testdt = new DateTime(dt); + + long recordEnd = r.Accessor.Position; + + long posNext = recordEnd - recordStart; + r.Accessor.Seek(128 - posNext, SeekOrigin.Current); + + // 132 names in file + objm.Items.Add(new INDDBRecord(name, testdt)); + } + } + + protected override void SaveInternal(ObjectModel objectModel) + { + throw new NotImplementedException(); + } + } +} diff --git a/CSharp/Plugins/UniversalEditor.Plugins.Genealogy/DataFormats/FamilyTreeMaker/Windows/INDGROUPSDataFormat.cs b/CSharp/Plugins/UniversalEditor.Plugins.Genealogy/DataFormats/FamilyTreeMaker/Windows/INDGROUPSDataFormat.cs new file mode 100644 index 00000000..d56f5d1c --- /dev/null +++ b/CSharp/Plugins/UniversalEditor.Plugins.Genealogy/DataFormats/FamilyTreeMaker/Windows/INDGROUPSDataFormat.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using UniversalEditor.IO; + +namespace UniversalEditor.Plugins.Genealogy.DataFormats.FamilyTreeMaker.Windows +{ + internal struct INDGROUPSRecord + { + public string name; + + public INDGROUPSRecord(string name) + { + this.name = name; + } + } + internal class INDGROUPSObjectModel : ObjectModel + { + public List Items { get; } = new List(); + + public override void Clear() + { + Items.Clear(); + } + public override void CopyTo(ObjectModel where) + { + } + } + internal class INDGROUPSDataFormat : DataFormat + { + protected override void LoadInternal(ref ObjectModel objectModel) + { + INDGROUPSObjectModel om = (objectModel as INDGROUPSObjectModel); + Reader r = base.Accessor.Reader; + r.Seek(114, SeekOrigin.Begin); + + int count = r.ReadInt32(); + for (int i = 0; i < count; i++) + { + string v = r.ReadNullTerminatedString(Encoding.UTF16LittleEndian); + byte nul = r.ReadByte(); + + v = v.TrimNull(); + if (String.IsNullOrEmpty(v)) + break; + om.Items.Add(new INDGROUPSRecord(v)); + } + } + protected override void SaveInternal(ObjectModel objectModel) + { + throw new NotImplementedException(); + } + } +} diff --git a/CSharp/Plugins/UniversalEditor.Plugins.Genealogy/DataFormats/GEDCOM/GEDCOMChunkedDataFormat.cs b/CSharp/Plugins/UniversalEditor.Plugins.Genealogy/DataFormats/GEDCOM/GEDCOMChunkedDataFormat.cs new file mode 100644 index 00000000..f5406ebe --- /dev/null +++ b/CSharp/Plugins/UniversalEditor.Plugins.Genealogy/DataFormats/GEDCOM/GEDCOMChunkedDataFormat.cs @@ -0,0 +1,64 @@ +using System; +using UniversalEditor.IO; +using UniversalEditor.ObjectModels.Chunked; + +using UniversalEditor.Plugins.Genealogy.ObjectModels.GEDCOM; + +namespace UniversalEditor.Plugins.Genealogy.DataFormats.GEDCOM +{ + public class GEDCOMChunkedDataFormat : DataFormat + { + protected override void LoadInternal(ref ObjectModel objectModel) + { + GEDCOMChunkedObjectModel chunked = (objectModel as GEDCOMChunkedObjectModel); + + Reader r = base.Accessor.Reader; + int lineIndex = 0; // for debugging porpoises + + int lastLineID = 0; + string lastLineName = null; + string lastLineParm = null; + + GEDCOMChunk lastChunk = null; + + while (!r.EndOfStream) + { + lineIndex++; + + string line = r.ReadLine(); + line = line.Trim(); + + string[] lineParts = line.Split(new char[] { ' ' }, 3); + + int lineID = 0; + if (!Int32.TryParse(lineParts[0], out lineID)) + { + throw new InvalidDataFormatException("line " + lineIndex + ", part '" + lineParts[0] + "' invalid ; must be integer"); + } + + if (lineParts.Length < 2) + throw new InvalidDataFormatException("line " + lineIndex + ", content '" + line + "' must have at least 2 parts"); + + if (lastLineID < lineID) + { + // create a group for the existing node + GEDCOMChunk chunk = new GEDCOMChunk(); + chunk.Name = lastLineName; + // chunk + chunked.Chunks.Add(chunk); + + lastChunk = chunk; + } + + lastLineID = lineID; + lastLineName = lineParts[1]; + if (lineParts.Length > 2) + lastLineParm = lineParts[2]; + } + } + protected override void SaveInternal(ObjectModel objectModel) + { + throw new NotImplementedException(); + } + } +} diff --git a/CSharp/Plugins/UniversalEditor.Plugins.Genealogy/DataFormats/GEDCOM/GEDCOMDataFormat.cs b/CSharp/Plugins/UniversalEditor.Plugins.Genealogy/DataFormats/GEDCOM/GEDCOMDataFormat.cs new file mode 100644 index 00000000..a5707ff0 --- /dev/null +++ b/CSharp/Plugins/UniversalEditor.Plugins.Genealogy/DataFormats/GEDCOM/GEDCOMDataFormat.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using UniversalEditor.IO; +using UniversalEditor.ObjectModels.Chunked; +using UniversalEditor.Plugins.Genealogy.ObjectModels.FamilyTree; + +namespace UniversalEditor.Plugins.Genealogy.DataFormats.GEDCOM +{ + public class GEDCOMDataFormat : GEDCOMChunkedDataFormat + { + private static DataFormatReference _dfr = null; + protected override DataFormatReference MakeReferenceInternal() + { + if (_dfr == null) + { + _dfr = base.MakeReferenceInternal(); + _dfr.Capabilities.Add(typeof(FamilyTreeObjectModel), DataFormatCapabilities.All); + } + return _dfr; + } + + protected override void BeforeLoadInternal(Stack objectModels) + { + base.BeforeLoadInternal(objectModels); + objectModels.Push(new ChunkedObjectModel()); + } + + protected override void AfterLoadInternal(Stack objectModels) + { + base.AfterLoadInternal(objectModels); + + ChunkedObjectModel chunked = (objectModels.Pop() as ChunkedObjectModel); + FamilyTreeObjectModel ftom = (objectModels.Pop() as FamilyTreeObjectModel); + + } + + protected override void SaveInternal(ObjectModel objectModel) + { + FamilyTreeObjectModel ftom = (objectModel as FamilyTreeObjectModel); + } + } +} diff --git a/CSharp/Plugins/UniversalEditor.Plugins.FamilyTreeMaker/ObjectModels/FamilyTree/FamilyTreeObjectModel.cs b/CSharp/Plugins/UniversalEditor.Plugins.Genealogy/ObjectModels/FamilyTree/FamilyTreeObjectModel.cs similarity index 73% rename from CSharp/Plugins/UniversalEditor.Plugins.FamilyTreeMaker/ObjectModels/FamilyTree/FamilyTreeObjectModel.cs rename to CSharp/Plugins/UniversalEditor.Plugins.Genealogy/ObjectModels/FamilyTree/FamilyTreeObjectModel.cs index 8a829190..4f3e5404 100644 --- a/CSharp/Plugins/UniversalEditor.Plugins.FamilyTreeMaker/ObjectModels/FamilyTree/FamilyTreeObjectModel.cs +++ b/CSharp/Plugins/UniversalEditor.Plugins.Genealogy/ObjectModels/FamilyTree/FamilyTreeObjectModel.cs @@ -1,15 +1,13 @@ -namespace UniversalEditor.ObjectModels.FamilyTree +namespace UniversalEditor.Plugins.Genealogy.ObjectModels.FamilyTree { public class FamilyTreeObjectModel : ObjectModel { public override void Clear () { - throw new System.NotImplementedException (); } public override void CopyTo (ObjectModel where) { - throw new System.NotImplementedException (); } private static ObjectModelReference _omr = null; diff --git a/CSharp/Plugins/UniversalEditor.Plugins.Genealogy/ObjectModels/GEDCOM/GEDCOMChunk.cs b/CSharp/Plugins/UniversalEditor.Plugins.Genealogy/ObjectModels/GEDCOM/GEDCOMChunk.cs new file mode 100644 index 00000000..2af873c0 --- /dev/null +++ b/CSharp/Plugins/UniversalEditor.Plugins.Genealogy/ObjectModels/GEDCOM/GEDCOMChunk.cs @@ -0,0 +1,17 @@ +using System; +namespace UniversalEditor.Plugins.Genealogy.ObjectModels.GEDCOM +{ + public class GEDCOMChunk + { + public class GEDCOMChunkCollection + : System.Collections.ObjectModel.Collection + { + } + + public int Index { get; set; } = 0; + public string Name { get; set; } = null; + public string Value { get; set; } = null; + + public GEDCOMChunk.GEDCOMChunkCollection Chunks { get; } = new GEDCOMChunk.GEDCOMChunkCollection(); + } +} diff --git a/CSharp/Plugins/UniversalEditor.Plugins.Genealogy/ObjectModels/GEDCOM/GEDCOMChunkedObjectModel.cs b/CSharp/Plugins/UniversalEditor.Plugins.Genealogy/ObjectModels/GEDCOM/GEDCOMChunkedObjectModel.cs new file mode 100644 index 00000000..8c32d699 --- /dev/null +++ b/CSharp/Plugins/UniversalEditor.Plugins.Genealogy/ObjectModels/GEDCOM/GEDCOMChunkedObjectModel.cs @@ -0,0 +1,16 @@ +using System; +namespace UniversalEditor.Plugins.Genealogy.ObjectModels.GEDCOM +{ + public class GEDCOMChunkedObjectModel : ObjectModel + { + public GEDCOMChunk.GEDCOMChunkCollection Chunks { get; } = new GEDCOMChunk.GEDCOMChunkCollection(); + + public override void Clear() + { + } + + public override void CopyTo(ObjectModel where) + { + } + } +} diff --git a/CSharp/Plugins/UniversalEditor.Plugins.FamilyTreeMaker/Properties/AssemblyInfo.cs b/CSharp/Plugins/UniversalEditor.Plugins.Genealogy/Properties/AssemblyInfo.cs similarity index 100% rename from CSharp/Plugins/UniversalEditor.Plugins.FamilyTreeMaker/Properties/AssemblyInfo.cs rename to CSharp/Plugins/UniversalEditor.Plugins.Genealogy/Properties/AssemblyInfo.cs diff --git a/CSharp/Plugins/UniversalEditor.Plugins.FamilyTreeMaker/UniversalEditor.Plugins.FamilyTreeMaker.csproj b/CSharp/Plugins/UniversalEditor.Plugins.Genealogy/UniversalEditor.Plugins.Genealogy.csproj similarity index 84% rename from CSharp/Plugins/UniversalEditor.Plugins.FamilyTreeMaker/UniversalEditor.Plugins.FamilyTreeMaker.csproj rename to CSharp/Plugins/UniversalEditor.Plugins.Genealogy/UniversalEditor.Plugins.Genealogy.csproj index 4aed4d84..b8b08e4a 100644 --- a/CSharp/Plugins/UniversalEditor.Plugins.FamilyTreeMaker/UniversalEditor.Plugins.FamilyTreeMaker.csproj +++ b/CSharp/Plugins/UniversalEditor.Plugins.Genealogy/UniversalEditor.Plugins.Genealogy.csproj @@ -33,6 +33,12 @@ + + + + + + @@ -40,6 +46,8 @@ + + diff --git a/CSharp/UniversalEditor.sln b/CSharp/UniversalEditor.sln index be2375a7..057a55d7 100644 --- a/CSharp/UniversalEditor.sln +++ b/CSharp/UniversalEditor.sln @@ -129,9 +129,9 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniversalEditor.Plugins.Add EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniversalWidgetToolkit.Engines.WindowsForms", "..\..\UniversalWidgetToolkit\Engines\WindowsForms\UniversalWidgetToolkit.Engines.WindowsForms\UniversalWidgetToolkit.Engines.WindowsForms.csproj", "{B8573BB1-A0CD-41F4-A775-E0CB79555C59}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniversalEditor.Plugins.FamilyTreeMaker", "Plugins\UniversalEditor.Plugins.FamilyTreeMaker\UniversalEditor.Plugins.FamilyTreeMaker.csproj", "{74A835FD-93B8-4268-B120-1ACAA128AC7B}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniversalEditor.Plugins.Genealogy", "Plugins\UniversalEditor.Plugins.Genealogy\UniversalEditor.Plugins.Genealogy.csproj", "{74A835FD-93B8-4268-B120-1ACAA128AC7B}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniversalEditor.Plugins.FamilyTreeMaker.UserInterface", "Plugins.UserInterface\UniversalEditor.Plugins.FamilyTreeMaker.UserInterface\UniversalEditor.Plugins.FamilyTreeMaker.UserInterface.csproj", "{E6C8A539-F219-4BD0-A2F4-E7064ABF6777}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniversalEditor.Plugins.Genealogy.UserInterface", "Plugins.UserInterface\UniversalEditor.Plugins.Genealogy.UserInterface\UniversalEditor.Plugins.Genealogy.UserInterface.csproj", "{E6C8A539-F219-4BD0-A2F4-E7064ABF6777}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniversalEditor.TestProject", "Applications\UniversalEditor.TestProject\UniversalEditor.TestProject.csproj", "{242A32D8-9A3A-4FE3-902B-AB9C3154723A}" EndProject