/// <summary> /// Adds the visited. /// </summary> /// <param name="argHLink"> /// The argument h link. /// </param> /// <param name="argBool"> /// if set to <c> true </c> [argument bool]. /// </param> private void AddVisited(HLinkKey argHLink, bool argBool) { if (!nodeVisited.ContainsKey(argHLink)) { nodeVisited.Add(argHLink, argBool); } }
/// <summary> /// Compares to. Bases it on the HLInkKey for want of anything else that makes sense. /// </summary> /// <param name="obj"> /// The object. /// </param> /// <returns> /// </returns> public int CompareTo(object obj) { if (obj == null) { return(1); } return(HLinkKey.CompareTo((obj as HLinkBase).HLinkKey)); }
/// <summary> /// Loads the BookMark data asynchronous. /// </summary> /// <returns> /// True if loaded ok. /// </returns> public async Task LoadBookMarksAsync() { _iocCommonNotifications.DataLogEntryAdd("Loading BookMark data"); { try { // Run query var de = from el in localGrampsXMLdoc.Descendants(ns + "bookmark") select el; // set BookMark count field int bookMarkCount = 0; // Loop through results foreach (XElement argBookMark in de) { // BookMark Handle bookMarkCount++; // BookMark fields string GTarget = GetAttribute(argBookMark.Attribute("target")); HLinkKey GHLink = new HLinkKey(GetAttribute(argBookMark.Attribute("hlink"))); HLinkBackLink newHlinkBackLink = SetBookMarkTarget(GTarget, GHLink); if (newHlinkBackLink.Valid) { DataStore.Instance.DS.BookMarkCollection.Add(newHlinkBackLink); } else { _iocCommonNotifications.NotifyError(new ErrorInfo("Bad BookMark") { { "HLink", argBookMark.ToString() } }); } _iocCommonNotifications.DataLogEntryReplace($"Loading bookmark type: {newHlinkBackLink.HLinkType}"); } DataStore.Instance.DS.BookMarkCollection.Title = string.Empty; } catch (Exception e) { // TODO handle this _iocCommonNotifications.DataLogEntryAdd(e.Message); throw; } } _iocCommonNotifications.DataLogEntryReplace("Bookmark load complete"); return; }
private static HLinkPlaceNameModelCollection GetPlaceNameModelCollection(XElement xmlData) { HLinkPlaceNameModelCollection t = new HLinkPlaceNameModelCollection { Title = "Place Name Collection" }; // Run query IEnumerable <XElement> theERElement = from orElementEl in xmlData.Elements(ns + "pname") select orElementEl; if (theERElement.Any()) { // Load attribute object references foreach (XElement theLoadORElement in theERElement) { PlaceNameModel newPlaceNameModel = new PlaceNameModel { GValue = GetAttribute(theLoadORElement, "value"), GLang = GetAttribute(theLoadORElement, "lang"), GDate = GetDate(theLoadORElement), }; newPlaceNameModel.ModelItemGlyph.Symbol = Constants.IconPlace; newPlaceNameModel.HLinkKey = HLinkKey.NewAsGUID(); HLinkPlaceNameModel tt = new HLinkPlaceNameModel { DeRef = newPlaceNameModel }; if (string.IsNullOrEmpty(newPlaceNameModel.GValue)) { } t.Add(tt); } } return(t); }
/// <summary> /// Load zero or more url content xml elements into alist of url models. /// </summary> /// <param name="xmlData"> /// the xElement containing the url references. /// </param> private HLinkURLModelCollection GetURLCollection(XElement xmlData) { HLinkURLModelCollection t = new HLinkURLModelCollection(); // Run query IEnumerable <XElement> theERElement = from orElementEl in xmlData.Elements(ns + "url") select orElementEl; if (theERElement.Any()) { foreach (XElement theLoadORElement in theERElement) { URLModel tt = new URLModel { Priv = GetPrivateObject(theLoadORElement), GType = GetAttribute(theLoadORElement.Attribute("type")), GHRef = GetUri(GetAttribute(theLoadORElement.Attribute("href"))), GDescription = GetAttribute(theLoadORElement.Attribute("description")), }; tt.ModelItemGlyph.ImageType = CommonEnums.HLinkGlyphType.Symbol; tt.ModelItemGlyph.Symbol = Constants.IconURL; tt.HLinkKey = HLinkKey.NewAsGUID(); HLinkURLModel ttt = new HLinkURLModel { DeRef = tt }; t.Add(ttt); } } return(t); }
/// <summary> /// Override for the OnNavigatedTo Prism method. /// </summary> public override void HandleViewDataLoadEvent() { BaseCL.RoutineEntry("PeopleGraphViewModel"); HLinkKey startPoint = new HLinkKey("_c47a6bd11500b4b0cc8"); // Assume person PersonModel t = DV.PersonDV.GetModelFromHLinkKey(startPoint); // TODO add back in //if (t.HLink.Valid == true) //{ // StartHLink = t.HLink; //} //else //{ // FamilyModel tf = DV.FamilyDV.GetModelFromHLinkKey(startPoint); // StartHLink = tf.HLink; //} if (!StartHLink.Valid) { App.Current.Services.GetService <IErrorNotifications>().NotifyError(new ErrorInfo("HLink passed to PersonGraph not found")); return; } GraphReset(); GetGraph(); LayoutPreStart(); LayoutNodes(); LayoutEdges(); }
public HLinkBackLink() { HLinkKey = HLinkKey.NewAsGUID(); }
public virtual ItemGlyph GetGlyph(HLinkKey argHLinkKey) { return(GetModelFromHLinkKey(argHLinkKey).ModelItemGlyph); }
private async Task <HLinkMediaModel> CreateClippedMediaModel(HLinkMediaModel argHLinkLoadImageModel) { if (argHLinkLoadImageModel is null) { throw new ArgumentNullException(nameof(argHLinkLoadImageModel)); } if (!argHLinkLoadImageModel.DeRef.Valid) { throw new ArgumentException("CreateClippedMediaModel argument is invalid", nameof(argHLinkLoadImageModel)); } IMediaModel returnMediaModel = await MainThread.InvokeOnMainThreadAsync(() => { // TODO cleanup code. Multiple copies of things in use IMediaModel theMediaModel = argHLinkLoadImageModel.DeRef; SKBitmap resourceBitmap = new SKBitmap(); IMediaModel newMediaModel = new MediaModel(); HLinkKey newHLinkKey = new HLinkKey($"{argHLinkLoadImageModel.HLinkKey.Value}-{argHLinkLoadImageModel.GCorner1X}{argHLinkLoadImageModel.GCorner1Y}{argHLinkLoadImageModel.GCorner2X}{argHLinkLoadImageModel.GCorner2Y}"); string outFileName = $"{newHLinkKey.Value}{"~crop"}.png"; if (newHLinkKey.Value == "_c5132553a185c9c51d8-35415065") { } Debug.WriteLine(newHLinkKey.Value); string outFilePath = Path.Combine(DataStore.Instance.AD.CurrentImageAssetsFolder.Path, outFileName); Debug.WriteLine(argHLinkLoadImageModel.DeRef.MediaStorageFilePath); // Check if already exists IMediaModel fileExists = DV.MediaDV.GetModelFromHLinkKey(newHLinkKey); if ((!fileExists.Valid) && theMediaModel.IsMediaStorageFileValid) { // Needs clipping using (StreamReader stream = new StreamReader(theMediaModel.MediaStorageFilePath)) { //resourceBitmap = SKBitmap.Decode(stream.BaseStream); // TODO See https://github.com/mono/SkiaSharp/issues/1621 SKImage img = SKImage.FromEncodedData(stream.BaseStream); resourceBitmap = SKBitmap.FromImage(img); } // Check for too large a bitmap //Debug.WriteLine("Image ResourceBitmap size: " + resourceBitmap.ByteCount); if (resourceBitmap.ByteCount > int.MaxValue - 1000) { // TODO Handle this better. Perhaps resize? Delete for now resourceBitmap = new SKBitmap(); } float crleft = (float)(argHLinkLoadImageModel.GCorner1X / 100d * theMediaModel.MetaDataWidth); float crright = (float)(argHLinkLoadImageModel.GCorner2X / 100d * theMediaModel.MetaDataWidth); float crtop = (float)(argHLinkLoadImageModel.GCorner1Y / 100d * theMediaModel.MetaDataHeight); float crbottom = (float)(argHLinkLoadImageModel.GCorner2Y / 100d * theMediaModel.MetaDataHeight); SKRect cropRect = new SKRect(crleft, crtop, crright, crbottom); SKBitmap croppedBitmap = new SKBitmap( (int)cropRect.Width, (int)cropRect.Height ); SKRect dest = new SKRect( 0, 0, cropRect.Width, cropRect.Height ); SKRect source = new SKRect( cropRect.Left, cropRect.Top, cropRect.Right, cropRect.Bottom); using (SKCanvas canvas = new SKCanvas(croppedBitmap)) { canvas.DrawBitmap(resourceBitmap, source, dest); } // create an image COPY SKImage image = SKImage.FromBitmap(croppedBitmap); // encode the image (defaults to PNG) SKData encoded = image.Encode(); // get a stream over the encoded data using (Stream stream = File.Open(outFilePath, FileMode.OpenOrCreate, FileAccess.Write, FileShare.ReadWrite)) { encoded.SaveTo(stream); } croppedBitmap.Dispose(); // ------------ Save new MediaObject newMediaModel = theMediaModel.Clone(); newMediaModel.HLinkKey = newHLinkKey; newMediaModel.OriginalFilePath = outFilePath; newMediaModel.MediaStorageFile = new FileInfoEx(argFileName: outFilePath); newMediaModel.IsInternalMediaFile = true; newMediaModel.InternalMediaFileOriginalHLink = theMediaModel.HLinkKey; newMediaModel.MetaDataHeight = cropRect.Height; newMediaModel.MetaDataWidth = cropRect.Width; // newMediaModel = SetHomeImage(newMediaModel); DataStore.Instance.DS.MediaData.Add((MediaModel)newMediaModel); } else { ErrorInfo t = new ErrorInfo("File not found when Region specified in ClipMedia") { { "Original ID", theMediaModel.Id }, { "Original File", theMediaModel.MediaStorageFilePath }, { "Clipped Id", argHLinkLoadImageModel.DeRef.Id } }; _iocCommonNotifications.NotifyError(t); } resourceBitmap.Dispose(); return(newMediaModel); }).ConfigureAwait(false); return(returnMediaModel.HLink); }
public override EventModel GetModelFromHLinkKey(HLinkKey argHLinkKey) { return(EventData[argHLinkKey.Value]); }
public override CitationModel GetModelFromHLinkKey(HLinkKey argHLinkKey) { return(DataStore.Instance.DS.CitationData[argHLinkKey.Value]); }
public override NoteModel GetModelFromHLinkKey(HLinkKey argHLinkKey) { return(NoteData[argHLinkKey.Value]); }
///// <summary> ///// Gets any children of the family. ///// </summary> ///// <returns> ///// </returns> //public HLinkPersonModelCollection GetChildren(HLinkFamilyModel hlinkFamily) //{ // HLinkPersonModelCollection t = new HLinkPersonModelCollection(); // // Handle the case where there is no data. if (FamilyData.Count == 0) { return new // HLinkPersonModelCollection(); } // // TODO fix this // if (FamilyData.GetModelFromHLink(hlinkFamily).GChildRefCollection.Count > 0) // { // t.Add(FamilyData.GetModelFromHLink(hlinkFamily).GChildRefCollection[0].DeRef.HLink); // return t; // } // else // { // return null; // } //} ///// <summary> ///// Get the currents partner. ///// </summary> ///// <returns> ///// </returns> //public HLinkPersonModel GetCurrentPartner(HLinkFamilyModel hlinkFamily) //{ // // Handle the case where there is no data. // if (FamilyData.Count == 0) // { // return null; // } // return FamilyData.GetModelFromHLink(hlinkFamily).GMother; //} ///// <summary> ///// Currents the spouses. ///// </summary> ///// <param name="hlinkFamily"> ///// The hlink family. ///// </param> ///// <returns> ///// </returns> //public HLinkPersonModelCollection GetCurrentSpouses(HLinkFamilyModel hlinkFamily) //{ // HLinkPersonModelCollection t = new HLinkPersonModelCollection(); // // Handle the case where there is no data. if (FamilyData.Count == 0) { return t; } // t.Add(FamilyData.GetModelFromHLink(hlinkFamily).GMother); // return t; //} ///// <summary> ///// Gets the father. ///// </summary> ///// <param name="arg"> ///// The argument. ///// </param> ///// <returns> ///// </returns> //public IPersonModel GetFather(HLinkKey argHLinkKey) //{ // // Handle the case where there is no data. // if (FamilyData.Count == 0) // { // return null; // } // return GetModelFromHLinkKey(argHLinkKey).GFather.DeRef; //} public override FamilyModel GetModelFromHLinkKey(HLinkKey argHLinkKey) { return(FamilyData[argHLinkKey.Value]); }
private HLinkPersonNameModelCollection GetPersonNameCollection(XElement xmlData) { HLinkPersonNameModelCollection t = new HLinkPersonNameModelCollection { Title = "Person Name Collection" }; var theERElement = from orElementEl in xmlData.Elements(ns + "name") select orElementEl; if (theERElement.Any()) { // Load attribute object references foreach (XElement theLoadORElement in theERElement) { // TODO is date handling correct PersonNameModel newPersonNameModel = new PersonNameModel { GCitationRefCollection = GetCitationCollection(theLoadORElement), GDate = SetDate(theLoadORElement), GDisplay = GetElement(theLoadORElement, "display"), GFamilyNick = GetElement(theLoadORElement, "familynick"), GFirstName = GetElement(theLoadORElement, "first"), GGroup = GetElement(theLoadORElement, "group"), GNick = GetElement(theLoadORElement, "nick"), Priv = GetPrivateObject(theLoadORElement), GSort = GetElement(theLoadORElement, "sort"), GSuffix = GetElement(theLoadORElement, "suffix"), GSurName = GetSurnameCollection(theLoadORElement), GTitle = GetElement(theLoadORElement, "title"), GType = GetAttribute(theLoadORElement.Attribute("type")), GNoteReferenceCollection = GetNoteCollection(theLoadORElement), }; newPersonNameModel.GAlt = new AltModel(GetAttribute(theLoadORElement, "alt")); newPersonNameModel.HLinkKey = HLinkKey.NewAsGUID(); DataStore.Instance.DS.PersonNameData.Add(newPersonNameModel); //var tt = (DataStore.Instance.DS.PersonNameData.Where(x => x.Value.GSurName.GetPrimarySurname == "Ainger")); //if (tt.Count() > 0) //{ //} // Create a HLink to the model HLinkPersonNameModel newHlink = new HLinkPersonNameModel { HLinkKey = newPersonNameModel.HLinkKey }; t.Add(newHlink); } } // Do not sort as the source file order is the one the creator wanted return(t); }
private HLinkAddressModelCollection GetAddressCollection(XElement xmlData) { HLinkAddressModelCollection t = new HLinkAddressModelCollection { Title = "Address Collection" }; // Run query var theERElement = from orElementEl in xmlData.Elements(ns + "address") select orElementEl; if (theERElement.Any()) { // Load address object references foreach (XElement theLoadORElement in theERElement) { AddressModel newAddressModel = new AddressModel { GCitationRefCollection = GetCitationCollection(theLoadORElement), GCity = GetElement(theLoadORElement, "city"), GCountry = GetElement(theLoadORElement, "country"), GCounty = GetElement(theLoadORElement, "county"), GDate = GetDate(theLoadORElement), GLocality = GetElement(theLoadORElement, "locality"), GPhone = GetElement(theLoadORElement, "phone"), GPostal = GetElement(theLoadORElement, "postal"), GState = GetElement(theLoadORElement, "state"), GStreet = GetElement(theLoadORElement, "street"), Priv = GetPrivateObject(theLoadORElement), GNoteRefCollection = GetNoteCollection(theLoadORElement), }; // Set model hlinkkey etc newAddressModel.HLinkKey = HLinkKey.NewAsGUID(); newAddressModel.Id = newAddressModel.HLinkKey.Value; DataStore.Instance.DS.AddressData.Add(newAddressModel); // Create a HLink to the model HLinkAdressModel newHlink = new HLinkAdressModel { HLinkKey = newAddressModel.HLinkKey, }; t.Add(newHlink); } } return(t); }
public override AddressModel GetModelFromHLinkKey(HLinkKey argHLinkKey) { return(AddressData[argHLinkKey.Value]); }
public override TagModel GetModelFromHLinkKey(HLinkKey argHLinkKey) { return(TagData[argHLinkKey.Value]); }
public override NameMapModel GetModelFromHLinkKey(HLinkKey argHLinkKey) { return(NameMapData[argHLinkKey.Value]); }
/// <summary> /// Gets the specified h link string. /// </summary> /// <param name="HLinkString"> /// The h link string. /// </param> /// <returns> /// </returns> public override PersonModel GetModelFromHLinkKey(HLinkKey argHLinkKey) { return(PersonData[argHLinkKey.Value]); }
public override HeaderModel GetModelFromHLinkKey(HLinkKey argHLinkKey) { return(HeaderData.Values.First()); }
public override MediaModel GetModelFromHLinkKey(HLinkKey argHLinkKey) { return(DataStore.Instance.DS.MediaData[argHLinkKey.Value]); }
public override PlaceModel GetModelFromHLinkKey(HLinkKey argHLinkKey) { return(PlaceData[argHLinkKey.Value]); }
/// <summary> /// Gets the specified h link string. /// </summary> /// <param name="HLinkString"> /// The h link string. /// </param> /// <returns> /// ModelBase. /// </returns> public abstract TB GetModelFromHLinkKey(HLinkKey argHLinkKey);
public override RepositoryModel GetModelFromHLinkKey(HLinkKey argHLinkKey) { return(RepositoryData[argHLinkKey.Value]); }
public override int GetHashCode() { return(HLinkKey.GetHashCode()); }
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()); }