/// <summary> /// Raises the <see cref="E:Activated"/> event. /// </summary> /// <param name="e"> /// The <see cref="IActivatedEventArgs"/> instance containing the event data. /// </param> protected override void OnActivated(IActivatedEventArgs e) { // Handle Protocol Activation // // Handles URIs of the format used by Gramps internally gramps://person/handle/12345 if (e.Kind == ActivationKind.Protocol) { if (e is ProtocolActivatedEventArgs uriArgs) { string[] uriSegments = uriArgs.Uri.Segments; if (uriSegments[1] != "handle/") { ErrorInfo badUriAdditionalInfo = new ErrorInfo("Bad Protocol Activation Argument") { { "URI", uriArgs.Uri.ToString() }, { "Data", uriArgs.Data.ToString() } }; ((GrampsView.App)Xamarin.Forms.Application.Current).Services.GetService <IErrorNotifications>().NotifyError(badUriAdditionalInfo); } // TODO Handle if GrampsView not running switch (uriArgs.Uri.Host) { case Constants.ModelNameFamily: { HLinkFamilyModel targetFamily = new HLinkFamilyModel { HLinkKey = new HLinkKey(uriSegments[2]) }; targetFamily.UCNavigate(); break; } case Constants.ModelNamePerson: { HLinkPersonModel targetPerson = new HLinkPersonModel { HLinkKey = new HLinkKey(uriSegments[2]) }; targetPerson.UCNavigate(); break; } default: { // TODO Handle bad arg better break; } } } } }
public override void SetGlyph() { foreach (HLinkChildRefModel argHLink in this) { // This is required ot get Glyph valid so we can load the Person HLink argHLink.HLinkGlyphItem.ImageType = Common.CommonEnums.HLinkGlyphType.Symbol; HLinkPersonModel t = argHLink.DeRef.HLink; argHLink.HLinkGlyphItem.ImageType = t.DeRef.ModelItemGlyph.ImageType; argHLink.HLinkGlyphItem.ImageHLink = t.DeRef.ModelItemGlyph.ImageHLink; argHLink.HLinkGlyphItem.ImageSymbol = t.DeRef.ModelItemGlyph.ImageSymbol; argHLink.HLinkGlyphItem.ImageSymbolColour = t.DeRef.ModelItemGlyph.ImageSymbolColour; argHLink.HLinkGlyphItem.MediaHLink = t.DeRef.ModelItemGlyph.MediaHLink; } }
public HLinkBackLink SetBookMarkTarget(string argGTarget, string argGHlink) { switch (argGTarget) { case "person": { HLinkPersonModel p1 = new HLinkPersonModel { HLinkKey = argGHlink }; return(new HLinkBackLink(p1)); } case "family": { HLinkFamilyModel p1 = new HLinkFamilyModel { HLinkKey = argGHlink }; return(new HLinkBackLink(p1)); } case "event": { HLinkEventModel p1 = new HLinkEventModel { HLinkKey = argGHlink }; return(new HLinkBackLink(p1)); } case "source": { HLinkSourceModel p1 = new HLinkSourceModel { HLinkKey = argGHlink }; return(new HLinkBackLink(p1)); } case "citation": { HLinkCitationModel p1 = new HLinkCitationModel { HLinkKey = argGHlink }; return(new HLinkBackLink(p1)); } case "place": { HLinkPlaceModel p1 = new HLinkPlaceModel { HLinkKey = argGHlink }; return(new HLinkBackLink(p1)); } case "media": { HLinkMediaModel p1 = new HLinkMediaModel { HLinkKey = argGHlink }; return(new HLinkBackLink(p1)); } case "repository": { HLinkRepositoryModel p1 = new HLinkRepositoryModel { HLinkKey = argGHlink }; return(new HLinkBackLink(p1)); } case "note": { HLinkNoteModel p1 = new HLinkNoteModel { HLinkKey = argGHlink }; return(new HLinkBackLink(p1)); } } return(new HLinkBackLink()); }
/// <summary> /// Organises the person repository. /// </summary> private static async Task <bool> OrganisePersonRepository() { await DataStore.CN.MajorStatusAdd("Organising Person data").ConfigureAwait(false); foreach (PersonModel thePersonModel in DV.PersonDV.DataViewData) { HLinkPersonModel t = thePersonModel.HLink; // -- Organse Back Links --------------------- // Citation Collection foreach (HLinkCitationModel citationRef in thePersonModel.GCitationRefCollection) { DataStore.DS.CitationData[citationRef.HLinkKey].BackHLinkReferenceCollection.Add(new HLinkBackLink(t)); } // Event Collection foreach (HLinkEventModel eventRef in thePersonModel.GEventRefCollection) { DataStore.DS.EventData[eventRef.HLinkKey].BackHLinkReferenceCollection.Add(new HLinkBackLink(t)); } foreach (HLinkMediaModel mediaRef in thePersonModel.GMediaRefCollection) { DataStore.DS.MediaData[mediaRef.HLinkKey].BackHLinkReferenceCollection.Add(new HLinkBackLink(t)); } // Note Collection foreach (HLinkNoteModel noteRef in thePersonModel.GNoteRefCollection) { DataStore.DS.NoteData[noteRef.HLinkKey].BackHLinkReferenceCollection.Add(new HLinkBackLink(t)); } // Parent RelationShip foreach (HLinkFamilyModel familyRef in thePersonModel.GParentInRefCollection) { DataStore.DS.FamilyData[familyRef.HLinkKey].BackHLinkReferenceCollection.Add(new HLinkBackLink(t)); } // Sibling Collection foreach (HLinkPersonModel personRef in thePersonModel.SiblingRefCollection) { DataStore.DS.PersonData[personRef.HLinkKey].BackHLinkReferenceCollection.Add(new HLinkBackLink(t)); } // Back Reference Tag HLinks foreach (HLinkTagModel tagRef in thePersonModel.GTagRefCollection) { // Set the backlinks DataStore.DS.TagData[tagRef.HLinkKey].BackHLinkReferenceCollection.Add(new HLinkBackLink(t)); } // -- Setup some extra values ------------------------------ // set Birthdate EventModel birthDate = DV.EventDV.GetEventType(thePersonModel.GEventRefCollection, CommonConstants.EventTypeBirth); if (birthDate.Valid) { thePersonModel.BirthDate = birthDate.GDate; } // set Is Living if (DV.EventDV.GetEventType(thePersonModel.GEventRefCollection, CommonConstants.EventTypeDeath).Valid) { thePersonModel.IsLiving = false; } else { thePersonModel.IsLiving = true; } // set Sibling Collection if (thePersonModel.GChildOf.Valid) { thePersonModel.SiblingRefCollection = DV.FamilyDV.FamilyData[thePersonModel.GChildOf.HLinkKey].GChildRefCollection; } DataStore.DS.PersonData[thePersonModel.HLinkKey] = thePersonModel; } return(true); }
/// <summary> /// load families from external storage. /// </summary> /// <param name="familyRepository"> /// The family repository. /// </param> /// <returns> /// Flag indicating if the family data was loaded. /// </returns> public async Task <bool> LoadFamiliesAsync() { // RepositoryModelType<FamilyModel, HLinkFamilyModel> await DataStore.CN.MajorStatusAdd("Loading Family data").ConfigureAwait(false); { // Load notes try { // Run query var de = from el in localGrampsXMLdoc.Descendants(ns + "family") select el; // get family fields TODO // Loop through results to get the Families foreach (XElement familyElement in de) { FamilyModel loadFamily = DV.FamilyDV.NewModel(); // Family attributes loadFamily.LoadBasics(GetBasics(familyElement)); //loadFamily.Id = (string)familyElement.Attribute("id"); ////if (loadFamily.Id == "F0152") ////{ ////} //loadFamily.Handle = (string)familyElement.Attribute("handle"); //loadFamily.Change = GetDateTime((string)familyElement.Attribute("change")); //loadFamily.Priv = SetPrivateObject((string)familyElement.Attribute("priv")); // Family fields // relationship type XElement tempRelationship = familyElement.Element(ns + "rel"); if (tempRelationship != null) { loadFamily.GFamilyRelationship = (string)tempRelationship.Attribute("type"); } // father element XElement tempFather = familyElement.Element(ns + "father"); if (tempFather != null) { loadFamily.GFather.HLinkKey = (string)tempFather.Attribute("hlink"); } // mother element XElement tempMother = familyElement.Element(ns + "mother"); if (tempMother != null) { loadFamily.GMother.HLinkKey = (string)tempMother.Attribute("hlink"); } // ChildRef loading var thisORElement = from thisORElementEl in familyElement.Descendants(ns + "childref") select thisORElementEl; if (thisORElement.Any()) { // load child object references foreach (XElement thisLoadORElement in thisORElement) { HLinkPersonModel t = new HLinkPersonModel { // load the hlink HLinkKey = (string)thisLoadORElement.Attribute("hlink"), }; loadFamily.GChildRefCollection.Add(t); } } // Citation References loadFamily.GCitationRefCollection = GetCitationCollection(familyElement); // Event References loadFamily.GEventRefCollection = GetEventCollection(familyElement); // ObjectRef loading loadFamily.GMediaRefCollection = await GetObjectCollection(familyElement).ConfigureAwait(false); loadFamily.GNoteRefCollection = GetNoteCollection(familyElement); loadFamily.GTagRefCollection = GetTagCollection(familyElement); // set the Home image or symbol now that everything is laoded loadFamily = SetHomeImage(loadFamily); // save the family DV.FamilyDV.FamilyData.Add(loadFamily); localGrampsCommonLogging.LogVariable("Family Name", loadFamily.Handle); } } catch (Exception e) { // TODO handle this await DataStore.CN.MajorStatusAdd(e.Message).ConfigureAwait(false); throw; } } // now let everyone know that we have finished await DataStore.CN.MajorStatusDelete().ConfigureAwait(false); return(true); }
public SearcHandlerItem(HLinkPersonModel argHLinkPersonModel) { baseBackLink = new HLinkBackLink(argHLinkPersonModel); }
public static HLinkBackLink SetBookMarkTarget(string argGTarget, HLinkKey argHLinkKey) { switch (argGTarget) { case "person": { HLinkPersonModel p1 = DV.PersonDV.GetModelFromHLinkKey(argHLinkKey).HLink; return(new HLinkBackLink(p1)); } case "family": { HLinkFamilyModel p1 = DV.FamilyDV.GetModelFromHLinkKey(argHLinkKey).HLink; return(new HLinkBackLink(p1)); } case "event": { HLinkEventModel p1 = DV.EventDV.GetModelFromHLinkKey(argHLinkKey).HLink; return(new HLinkBackLink(p1)); } case "source": { HLinkSourceModel p1 = DV.SourceDV.GetModelFromHLinkKey(argHLinkKey).HLink; return(new HLinkBackLink(p1)); } case "citation": { HLinkCitationModel p1 = DV.CitationDV.GetModelFromHLinkKey(argHLinkKey).HLink; return(new HLinkBackLink(p1)); } case "place": { HLinkPlaceModel p1 = DV.PlaceDV.GetModelFromHLinkKey(argHLinkKey).HLink; return(new HLinkBackLink(p1)); } case "media": { HLinkMediaModel p1 = DV.MediaDV.GetModelFromHLinkKey(argHLinkKey).HLink; return(new HLinkBackLink(p1)); } case "repository": { HLinkRepositoryModel p1 = DV.RepositoryDV.GetModelFromHLinkKey(argHLinkKey).HLink; return(new HLinkBackLink(p1)); } case "note": { HLinkNoteModel p1 = DV.NoteDV.GetModelFromHLinkKey(argHLinkKey).HLink; return(new HLinkBackLink(p1)); } } return(new HLinkBackLink()); }
/// <summary> /// Populates the view ViewModel. /// </summary> /// <returns> /// </returns> public override void HandleViewDataLoadEvent() { BaseCL.RoutineEntry("PersonDetailViewModel"); // TODO try again to set this up when the toolkit is a little more mature or I have an // idea where the bug is coming from BaseCurrentLayoutState = LayoutState.Loading; HLinkPersonModel HLinkPerson = CommonRoutines.GetHLinkParameter <HLinkPersonModel>(BaseParamsHLink); PersonObject = HLinkPerson.DeRef; if (!(PersonObject is null)) { BaseModelBase = PersonObject; // Get media image MediaCard = PersonObject.ModelItemGlyph; // Get the Name Details BaseDetail.Add(PersonObject.GPersonNamesCollection.GetPrimaryName); // Get the Person Details CardListLineCollection nameDetails = GetExtraPersonDetails(); nameDetails.Title = "Person Detail"; BaseDetail.Add(nameDetails); // Get date card BaseDetail.Add(PersonObject.BirthDate.AsHLink("Birth Date")); // Get parent details BaseDetail.Add( new HLinkParentLinkModel { DeRef = PersonObject.GChildOf.DeRef, }); // Add Standard details BaseDetail.Add(DV.PersonDV.GetModelInfoFormatted(PersonObject)); // If Bio note, display it while showing the full list further below. BioNote = PersonObject.GNoteRefCollection.GetBio; NotesWithoutHighlight = PersonObject.GNoteRefCollection.GetCollectionWithoutOne(BioNote); // Add PersonRefDetails - TODO //if (BaseNavParamsHLink is HLinkPersonRefModel) //{ // HLinkPersonRefModel personRef = (BaseNavParamsHLink as HLinkPersonRefModel); // Contract.Assert(personRef != null); // BaseDetail.Add(personRef.GCitationCollection.GetCardGroup("PersonRef Citations")); // BaseDetail.Add(personRef.GNoteCollection.GetCardGroup("PersonRef Notes")); //} } // TODO fix this BaseCurrentLayoutState = LayoutState.None; return; }