private void MediaImageFullCardRoot_BindingContextChanged(object sender, EventArgs e)
        {
            MediaImageFullCard mifModel = (sender as MediaImageFullCard);

            // Xamarin sets to null as the parent page is destroyed
            if (this.BindingContext is null)
            {
                return;
            }

            Contract.Assert(BindingContext is HLinkHomeImageModel);

            hLMediaModel = this.BindingContext as HLinkHomeImageModel;

            Contract.Assert(hLMediaModel != null);

            if (hLMediaModel.Valid)
            {
                mifModel.image.BindingContext = hLMediaModel;
            }

            // Check if anything to display
            if (mifModel.image.IsVisible)
            {
                mifModel.IsVisible = true;
            }
            else
            {
                mifModel.IsVisible = false;
            }
        }
Example #2
0
        ///// <summary>
        ///// Organises the citation repository.
        ///// </summary>
        //private static async Task<HLinkHomeImageModel> OrganiseCitationImage(CitationModel argCitationModel)
        //{
        //    // -- Organsie Default FirstLinks ------------------------------

        // //// Sort media collection and get first link images //DataStore.DS.CitationData[argCitationModel.HLinkKey].GMediaRefCollection.SortAndSetFirst();

        // //// Sort note collection and get first link images //DataStore.DS.CitationData[argCitationModel.HLinkKey].GNoteRefCollection.SortAndSetFirst();

        // // -- Organise Home Images -----------------------

        // // Try media reference collection first HLinkHomeImageModel hlink = argCitationModel.GMediaRefCollection.FirstHLinkHomeImage;

        // // Check Source for Image if (!hlink.Valid) { if
        // (argCitationModel.GSourceRef.DeRef.HomeImageHLink.HomeUseImage) { hlink =
        // argCitationModel.GSourceRef.DeRef.HomeImageHLink; } }

        // // Handle the link if we can if (!hlink.Valid) {
        // argCitationModel.HomeImageHLink.HomeImageType = CommonConstants.HomeImageTypeSymbol;
        // argCitationModel.HomeImageHLink.HomeSymbol = CommonConstants.IconCitation; } else {
        // argCitationModel.HomeImageHLink = hlink; }

        //    return argCitationModel.HomeImageHLink;
        //}

        /// <summary>
        /// Organises the event repository.
        /// </summary>
        private static async Task <HLinkHomeImageModel> OrganiseEventImage(EventModel argEventModel)
        {
            // Setup home images

            // Try media reference collection first
            HLinkHomeImageModel hlink = argEventModel.GMediaRefCollection.FirstHLinkHomeImage;

            // Check Media for Images
            if (!hlink.Valid)
            {
                hlink = argEventModel.GMediaRefCollection.FirstHLinkHomeImage;
            }

            // Check Citation for Images
            if (!hlink.Valid)
            {
                hlink = argEventModel.GCitationRefCollection.FirstHLinkHomeImage;

                //hlink = DV.CitationDV.GetFirstImageFromCollection(argModel.GCitationRefCollection);
            }

            // Handle the link if we can
            if (!hlink.Valid)
            {
                argEventModel.HomeImageHLink.HomeImageType = CommonConstants.HomeImageTypeSymbol;
            }
            else
            {
                argEventModel.HomeImageHLink = hlink;
            }

            return(argEventModel.HomeImageHLink);
        }
        public static SourceModel SetHomeImage(SourceModel argModel)
        {
            if (argModel is null)
            {
                throw new ArgumentNullException(nameof(argModel));
            }

            // Get default image if available
            HLinkHomeImageModel hlink = argModel.GMediaRefCollection.FirstHLinkHomeImage;

            // Set default
            if (!hlink.Valid)
            {
                argModel.HomeImageHLink.HomeImageType = CommonConstants.HomeImageTypeSymbol;
                argModel.HomeImageHLink.HomeSymbol    = CommonConstants.IconSource;
            }
            else
            {
                argModel.HomeImageHLink.HomeImageType = CommonConstants.HomeImageTypeThumbNail;
                argModel.HomeImageHLink.HLinkKey      = hlink.HLinkKey;
            }

            // Get colour Get colour
            Application.Current.Resources.TryGetValue("CardBackGroundSource", out var varCardColour);
            argModel.HomeImageHLink.HomeSymbolColour = (Color)varCardColour;

            return(argModel);
        }
        public static FamilyModel SetHomeImage(FamilyModel argModel)
        {
            // Try media reference collection first
            HLinkHomeImageModel hlink = argModel.GMediaRefCollection.FirstHLinkHomeImage;

            if (!hlink.Valid)
            {
                hlink = argModel.GCitationRefCollection.FirstHLinkHomeImage;
            }

            if (!hlink.Valid)
            {
                hlink = argModel.GEventRefCollection.FirstHLinkHomeImage;
            }

            if (!hlink.Valid)
            {
                hlink = argModel.GNoteRefCollection.FirstHLinkHomeImage;
            }

            // Set the image if available
            if (hlink.Valid)
            {
                argModel.HomeImageHLink.HomeImageType = CommonEnums.HomeImageType.ThumbNail;
                argModel.HomeImageHLink.HLinkKey      = hlink.HLinkKey;
            }

            return(argModel);
        }
Example #5
0
        /// <summary>
        /// Gets the first image from collection or null if none found.
        /// </summary>
        /// <param name="argCollection">
        /// The collection. If null then the whole Media Repository is used.
        /// </param>
        /// <param name="DefaultHLink">
        /// The default h link.
        /// </param>
        /// <returns>
        /// </returns>
        public new HLinkHomeImageModel GetFirstImageFromCollection(HLinkMediaModelCollection argCollection)
        {
            // Handle null argument
            if (argCollection == null)
            {
                argCollection = GetAllAsHLink();
            }

            HLinkHomeImageModel returnMediaModel = new HLinkHomeImageModel();

            MediaModel tempMediaModel;

            if (argCollection.Count > 0)
            {
                // step through each mediamodel hlink in the collection
                for (int i = 0; i < argCollection.Count; i++)
                {
                    tempMediaModel = MediaData.GetModelFromHLink(argCollection[i]);

                    if (tempMediaModel.IsMediaFile)
                    {
                        returnMediaModel.ConvertFromMediaModel(argCollection[i].DeRef);
                        break;
                    }
                }
            }

            // return the image
            return(returnMediaModel);
        }
        /// <summary>
        /// Handles navigation in wards and sets up the event model parameter.
        /// </summary>
        /// <param name="e">
        /// The <see cref="NavigatedToEventArgs"/> instance containing the event data.
        /// </param>
        /// <param name="viewModelState">
        /// The parameter is not used.
        /// </param>
        public override void PopulateViewModel()
        {
            // Handle HLinkKeys
            CitationObject = DV.CitationDV.GetModelFromHLinkString(BaseNavParamsHLink.HLinkKey);

            if (CitationObject != null)
            {
                BaseTitle     = CitationObject.GetDefaultText;
                BaseTitleIcon = CommonConstants.IconCitation;

                // Get media image
                HLinkHomeImageModel mediaImage = CitationObject.HomeImageHLink;
                mediaImage.CardType = DisplayFormat.MediaCardLarge;
                BaseDetail.Add(mediaImage);

                //// Get Note
                //CardGroup noteCardGroup = new CardGroup();
                //NoteCardFull noteCard = new NoteCardFull();
                //noteCard.BindingContext = CitationObject.GetFirstModel;
                //noteCardGroup.Add(noteCard);
                //BaseDetail.Add(noteCardGroup);

                // Get basic details
                CardGroup t = new CardGroup {
                    Title = "Header Details"
                };

                t.Add(new CardListLineCollection
                {
                    new CardListLine("Card Type:", "Citation Detail"),
                    new CardListLine("Date:", CitationObject.GDateContent.GetLongDateAsString),
                    new CardListLine("Page:", CitationObject.GPage),
                    new CardListLine("Confidence:", CitationObject.GConfidence.ToString(CultureInfo.CurrentCulture)),
                });

                t.Add(DV.CitationDV.GetModelInfoFormatted(CitationObject));

                BaseDetail.Add(t);

                // Add Source details
                HLinkSourceModel sourceCard = CitationObject.GSourceRef;
                sourceCard.CardType = DisplayFormat.SourceCardSmall;
                BaseDetail.Add(sourceCard);

                // If only one note (the most common case) just display it in a large format,
                // otherwise setup a list of them.
                if (CitationObject.GNoteRefCollection.Count > 0)
                {
                    // TODO Fix this NoteObject = CitationObject.GNoteRefCollection[0].DeRef;
                }

                // Add remaining details
                BaseDetail.Add(CitationObject.GMediaRefCollection.GetCardGroup());
                BaseDetail.Add(CitationObject.GNoteRefCollection.GetCardGroup());
                BaseDetail.Add(CitationObject.GTagRef.GetCardGroup());
                BaseDetail.Add(CitationObject.GSourceAttributeCollection);

                BaseDetail.Add(CitationObject.BackHLinkReferenceCollection.GetCardGroup());
            }
        }
        /// <summary>
        /// Sets the Citation home image.
        /// </summary>
        /// <param name="argModel">
        /// The argument model.
        /// </param>
        /// <returns>
        /// </returns>
        /// <exception cref="ArgumentNullException">
        /// argModel
        /// </exception>
        public static CitationModel SetHomeImage(CitationModel argModel)
        {
            if (argModel is null)
            {
                throw new ArgumentNullException(nameof(argModel));
            }

            // Try media reference collection first
            HLinkHomeImageModel hlink = argModel.GMediaRefCollection.FirstHLinkHomeImage;

            // Check Source for Image
            if ((!hlink.Valid) && (argModel.GSourceRef.DeRef.HomeImageHLink.LinkToImage))
            {
                hlink = argModel.GSourceRef.DeRef.HomeImageHLink;
            }

            // Handle the link if we can
            if (hlink.Valid)
            {
                argModel.HomeImageHLink.HomeImageType = CommonEnums.HomeImageType.ThumbNail;
                argModel.HomeImageHLink.HLinkKey      = hlink.HLinkKey;
            }

            return(argModel);
        }
        public static PersonModel SetHomeImage(PersonModel argModel)
        {
            if (argModel is null)
            {
                throw new ArgumentNullException(nameof(argModel));
            }

            //// Get default image if available
            //HLinkHomeImageModel hlink = DV.PersonDV.GetDefaultImageFromCollection(argModel);

            HLinkHomeImageModel hlink = argModel.GMediaRefCollection.FirstHLinkHomeImage;

            // Check Citation for Images
            if (!hlink.Valid)
            {
                hlink = argModel.GCitationRefCollection.FirstHLinkHomeImage;
            }

            // Action any Link
            if (hlink.Valid)
            {
                argModel.HomeImageHLink.HomeImageType = CommonConstants.HomeImageTypeThumbNail;
                argModel.HomeImageHLink.HLinkKey      = hlink.HLinkKey;
            }
            else
            {
                argModel.HomeImageHLink.HomeImageType = CommonConstants.HomeImageTypeSymbol;
            }

            // Get colour
            Application.Current.Resources.TryGetValue("CardBackGroundPerson", out var varCardColour);
            argModel.HomeImageHLink.HomeSymbolColour = (Color)varCardColour;

            return(argModel);
        }
        public static EventModel SetHomeImage(EventModel argModel)
        {
            if (argModel is null)
            {
                throw new ArgumentNullException(nameof(argModel));
            }

            // Setup home images

            // Try media reference collection first
            HLinkHomeImageModel hlink = argModel.GMediaRefCollection.FirstHLinkHomeImage;

            // Check Media for Images
            if (!hlink.Valid)
            {
                hlink = argModel.GMediaRefCollection.FirstHLinkHomeImage;
            }

            // Check Citation for Images
            if (!hlink.Valid)
            {
                hlink = argModel.GCitationRefCollection.FirstHLinkHomeImage;

                //hlink = DV.CitationDV.GetFirstImageFromCollection(argModel.GCitationRefCollection);
            }

            // Handle the link if we can
            if (hlink.Valid)
            {
                argModel.HomeImageHLink.HomeImageType = CommonEnums.HomeImageType.ThumbNail;
                argModel.HomeImageHLink.HLinkKey      = hlink.HLinkKey;
            }

            return(argModel);
        }
Example #10
0
        /// <summary>
        /// Sets the Citation home image.
        /// </summary>
        /// <param name="argModel">
        /// The argument model.
        /// </param>
        /// <returns>
        /// </returns>
        /// <exception cref="ArgumentNullException">
        /// argModel
        /// </exception>
        public static CitationModel SetHomeImage(CitationModel argModel)
        {
            if (argModel is null)
            {
                throw new ArgumentNullException(nameof(argModel));
            }

            // Try media reference collection first
            HLinkHomeImageModel hlink = argModel.GMediaRefCollection.FirstHLinkHomeImage;

            // Check Source for Image
            if ((!hlink.Valid) && (argModel.GSourceRef.DeRef.HomeImageHLink.LinkToImage))
            {
                hlink = argModel.GSourceRef.DeRef.HomeImageHLink;
            }

            // Handle the link if we can
            if (!hlink.Valid)
            {
                argModel.HomeImageHLink.HomeImageType = CommonConstants.HomeImageTypeSymbol;
            }
            else
            {
                argModel.HomeImageHLink.HomeImageType = CommonConstants.HomeImageTypeThumbNail;
                argModel.HomeImageHLink.HLinkKey      = hlink.HLinkKey;
            }

            // Get colour
            Application.Current.Resources.TryGetValue("CardBackGroundCitation", out var varCardColour);
            argModel.HomeImageHLink.HomeSymbolColour = (Color)varCardColour;

            return(argModel);
        }
Example #11
0
        public static EventModel SetHomeImage(EventModel argModel)
        {
            if (argModel is null)
            {
                throw new ArgumentNullException(nameof(argModel));
            }

            // Get colour
            Application.Current.Resources.TryGetValue("CardBackGroundEvent", out var varCardColour);
            Color cardColour = (Color)varCardColour;

            // Setup home images

            // Try media reference collection first
            HLinkHomeImageModel hlink = argModel.GMediaRefCollection.FirstHLinkHomeImage;

            // Check Media for Images
            if (!hlink.Valid)
            {
                hlink = argModel.GMediaRefCollection.FirstHLinkHomeImage;
            }

            // Check Citation for Images
            if (!hlink.Valid)
            {
                hlink = argModel.GCitationRefCollection.FirstHLinkHomeImage;

                //hlink = DV.CitationDV.GetFirstImageFromCollection(argModel.GCitationRefCollection);
            }

            // Handle the link if we can
            if (!hlink.Valid)
            {
                argModel.HomeImageHLink.HomeImageType = CommonConstants.HomeImageTypeSymbol;
            }
            else
            {
                argModel.HomeImageHLink.HomeImageType = CommonConstants.HomeImageTypeThumbNail;
                argModel.HomeImageHLink.HLinkKey      = hlink.HLinkKey;
            }

            //// Set links
            //HLinkHomeImageModel hlink = argModel.GMediaRefCollection.FirstHLinkHomeImage;
            //if (!hlink.Valid)
            //{
            //    argModel.HomeImageHLink.HomeImageType = CommonConstants.HomeImageTypeSymbol;
            //    argModel.HomeImageHLink.HomeSymbol = CommonConstants.IconEvents;
            //}
            //else
            //{
            //    argModel.HomeImageHLink = SetHomeHLink(argModel.HomeImageHLink, hlink);
            //}

            argModel.HomeImageHLink.HomeSymbolColour = cardColour;
            return(argModel);
        }
        /// <summary>
        /// Populates the view ViewModel.
        /// </summary>
        /// <returns>
        /// </returns>
        public override void PopulateViewModel()
        {
            BaseCL.LogRoutineEntry("AddressDetailViewModel");

            AddressObject = DV.AddressDV.GetModelFromHLink(BaseNavParamsHLink);

            if (AddressObject.Valid)
            {
                BaseTitle = AddressObject.GetDefaultText;

                // Get media image
                HLinkHomeImageModel AddressImage = AddressObject.HomeImageHLink;
                AddressImage.CardType = DisplayFormat.MediaCardLarge;
                BaseDetail.Add(AddressImage);

                // Get Header Details
                CardGroup headerCardGroup = new CardGroup {
                    Title = "Address Details"
                };

                // Get the Name Details
                CardListLineCollection nameDetails = new CardListLineCollection
                {
                    new CardListLine("Card Type:", "Address Detail"),

                    new CardListLine("Street:", AddressObject.GStreet),
                    new CardListLine("City:", AddressObject.GCity),
                    new CardListLine("Locality:", AddressObject.GLocality),
                    new CardListLine("County:", AddressObject.GCounty),
                    new CardListLine("State:", AddressObject.GState),
                    new CardListLine("Country:", AddressObject.GCountry),

                    new CardListLine("Date:", AddressObject.GDate.ShortDate),
                    new CardListLine("Postal:", AddressObject.GPostal),
                    new CardListLine("Phone:", AddressObject.GPhone),
                };

                headerCardGroup.Add(nameDetails);

                // Add Standard details
                headerCardGroup.Add(DV.PersonDV.GetModelInfoFormatted(AddressObject));

                // Add map card
                headerCardGroup.Add(TurnAddressToURLModel());

                // Add header
                BaseDetail.Add(headerCardGroup);

                BaseDetail.Add(AddressObject.GCitationRefCollection.GetCardGroup());
                BaseDetail.Add(AddressObject.GNoteRefCollection.GetCardGroup());

                BaseDetail.Add(AddressObject.BackHLinkReferenceCollection.GetCardGroup());
            }

            return;
        }
        /// <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 OCURLModelCollection GetURLCollection(XElement xmlData)
        {
            OCURLModelCollection t = new OCURLModelCollection();

            // Get colour
            Application.Current.Resources.TryGetValue("CardBackGroundUtility", out var varCardColour);
            Color cardColour = (Color)varCardColour;

            // Run query
            var theERElement =
                from orElementEl
                in xmlData.Elements(ns + "url")
                select orElementEl;

            if (theERElement.Any())
            {
                HLinkHomeImageModel newHomeLink = new HLinkHomeImageModel
                {
                    HomeImageType = CommonConstants.HomeImageTypeSymbol,
                    HomeSymbol    = CommonConstants.IconBookMark // TODO  Windows.UI.Xaml.Controls.Symbol.World,
                };

                // load event object references
                foreach (XElement theLoadORElement in theERElement)
                {
                    URLModel tt = new URLModel
                    {
                        Handle = "URL Collection",

                        HomeImageHLink = newHomeLink,

                        Priv = SetPrivateObject(GetAttribute(theLoadORElement.Attribute("priv"))),

                        GType = GetAttribute(theLoadORElement.Attribute("type")),

                        GHRef = GetUri(GetAttribute(theLoadORElement.Attribute("href"))),

                        GDescription = GetAttribute(theLoadORElement.Attribute("description")),
                    };

                    // set the Home image or symbol
                    tt.HomeImageHLink.HomeImageType    = CommonConstants.HomeImageTypeSymbol;
                    tt.HomeImageHLink.HomeSymbol       = IconFont.Link;
                    tt.HomeImageHLink.HomeSymbolColour = cardColour;

                    t.Add(tt);
                }
            }

            // Return sorted by the default text
            t.Sort(T => T.DeRef.GetDefaultText);

            return(t);
        }
Example #14
0
        public HLinkHomeImageModel GetHLinkHomeImageModel()
        {
            HLinkHomeImageModel returnHLinkHomeImageModel = new HLinkHomeImageModel
            {
                // Copy fields
                GPriv    = GPriv,
                HLinkKey = HLinkKey,
                //HomeImageClippedBitmap = argHLinkMediaModel.LoadingClipInfo.HomeImageClippedBitmap;
                HomeImageType    = HomeImageType,
                HomeSymbol       = HomeSymbol,
                HomeSymbolColour = HomeSymbolColour
            };

            return(returnHLinkHomeImageModel);
        }
Example #15
0
        /// <summary>
        /// Organises the person repository.
        /// </summary>
        private static async Task <HLinkHomeImageModel> OrganisePersonImage(PersonModel arrgPersonModel)
        {
            //// -- Organise First Image and Sorts ------------------------------
            //DataStore.DS.PersonData[arrgPersonModel.HLinkKey].GCitationRefCollection.SortAndSetFirst();

            //DataStore.DS.PersonData[arrgPersonModel.HLinkKey].GEventRefCollection.SortAndSetFirst();

            //DataStore.DS.PersonData[arrgPersonModel.HLinkKey].GMediaRefCollection.SortAndSetFirst();

            //DataStore.DS.PersonData[arrgPersonModel.HLinkKey].GNoteRefCollection.SortAndSetFirst();

            //DataStore.DS.PersonData[arrgPersonModel.HLinkKey].GParentInRefCollection.SortAndSetFirst();

            //DataStore.DS.PersonData[arrgPersonModel.HLinkKey].SiblingRefCollection.SortAndSetFirst();

            // -- Organise Home Image ------------------------------

            //if (argModel.Id == "I0568")
            //{
            //}

            // Get default image if available
            HLinkHomeImageModel hlink = DV.PersonDV.GetDefaultImageFromCollection(arrgPersonModel);

            // Check Media for Images
            if (!hlink.Valid)
            {
                hlink = arrgPersonModel.GMediaRefCollection.FirstHLinkHomeImage;
            }

            // Check Citation for Images
            if (!hlink.Valid)
            {
                hlink = arrgPersonModel.GCitationRefCollection.FirstHLinkHomeImage;
            }

            // Action any Link
            if (!hlink.Valid)
            {
                arrgPersonModel.HomeImageHLink.HomeImageType = CommonConstants.HomeImageTypeSymbol;
            }
            else
            {
                arrgPersonModel.HomeImageHLink = hlink;
            }

            return(arrgPersonModel.HomeImageHLink);
        }
        /// <summary>
        /// Populates the view ViewModel.
        /// </summary>
        /// <returns>
        /// </returns>
        public override void PopulateViewModel()
        {
            // Cache the Source model
            SourceObject = DV.SourceDV.GetModelFromHLink(BaseNavParamsHLink);

            if (!(SourceObject is null))
            {
                // Get basic details
                BaseTitle     = SourceObject.GetDefaultText;
                BaseTitleIcon = CommonConstants.IconSource;

                // Get media image
                HLinkHomeImageModel personImage = SourceObject.HomeImageHLink;
                personImage.CardType = DisplayFormat.MediaCardLarge;
                Contract.Assert(SourceObject.HomeImageHLink != null, SourceObject.Id);
                BaseDetail.Add(personImage);

                // Header Card
                CardGroup t = new CardGroup {
                    Title = "Header Details"
                };

                t.Add(new CardListLineCollection
                {
                    new CardListLine("Card Type:", "Source Detail"),
                    new CardListLine("Title:", SourceObject.GSTitle),
                    new CardListLine("Author:", SourceObject.GSAuthor),
                    new CardListLine("Pub Info:", SourceObject.GSPubInfo),
                    new CardListLine("Abbrev:", SourceObject.GSAbbrev),
                });

                // Add Model details
                t.Add(DV.SourceDV.GetModelInfoFormatted(SourceObject));

                BaseDetail.Add(t);

                // Add bulk items
                BaseDetail.Add(SourceObject.GMediaRefCollection.GetCardGroup());
                BaseDetail.Add(SourceObject.GNoteRefCollection.GetCardGroup());
                BaseDetail.Add(SourceObject.GTagRefCollection.GetCardGroup());
                BaseDetail.Add(SourceObject.GRepositoryRefCollection.GetCardGroup());
                BaseDetail.Add(SourceObject.GSourceAttributeCollection);

                BaseDetail.Add(SourceObject.BackHLinkReferenceCollection.GetCardGroup());
            }
        }
Example #17
0
        /// <summary>
        /// Organises the family repository.
        /// </summary>
        private static async Task <HLinkHomeImageModel> OrganiseFamilyImage(FamilyModel argFamilyModel)
        {
            // -- Organse First and Sorts --------------------------

            //DataStore.DS.FamilyData[argFamilyModel.HLinkKey].GCitationRefCollection.SortAndSetFirst();

            //DataStore.DS.FamilyData[argFamilyModel.HLinkKey].GEventRefCollection.SortAndSetFirst();

            //DataStore.DS.FamilyData[argFamilyModel.HLinkKey].GMediaRefCollection.SortAndSetFirst();

            //DataStore.DS.FamilyData[argFamilyModel.HLinkKey].GNoteRefCollection.SortAndSetFirst();

            // -- Organse Home Image ---------------------

            // Try media reference collection first
            HLinkHomeImageModel hlink = argFamilyModel.GMediaRefCollection.FirstHLinkHomeImage;

            if (!hlink.Valid)
            {
                hlink = argFamilyModel.GCitationRefCollection.FirstHLinkHomeImage;
            }

            if (!hlink.Valid)
            {
                hlink = argFamilyModel.GEventRefCollection.FirstHLinkHomeImage;
            }

            if (!hlink.Valid)
            {
                hlink = argFamilyModel.GNoteRefCollection.FirstHLinkHomeImage;
            }

            // Set the image if available
            if (hlink.Valid)
            {
                argFamilyModel.HomeImageHLink = hlink;
            }
            else
            {
                // Set to default
                argFamilyModel.HomeImageHLink.HomeImageType = CommonConstants.HomeImageTypeSymbol;
                argFamilyModel.HomeImageHLink.HomeSymbol    = CommonConstants.IconFamilies;
            }

            return(argFamilyModel.HomeImageHLink);
        }
        private void MediaImageSkia_BindingContextChanged(object sender, EventArgs e)
        {
            try
            {
                HLinkHomeImageModel newHLinkMedia = this.BindingContext as HLinkHomeImageModel;

                if (newHLinkMedia is null)
                {
                    //DataStore.CN.NotifyError("Bad HlinkMediaModel (is null) passed to MediaImage");
                    return;
                }

                if (!newHLinkMedia.Valid)
                {
                    //DataStore.CN.NotifyError("Invalid HlinkMediaModel (" + HLinkMedia.HLinkKey + ") passed to MediaImage");
                    return;
                }

                if (newHLinkMedia == ExistingHLinkMedia)
                {
                    return;
                }

                // Input valid so start work
                this.daSymbol.IsVisible = false;
                this.daImage.IsVisible  = false;
                this.daImage.Source     = null;

                // Save the HLink so can check for duplicate chanegs later
                ExistingHLinkMedia = newHLinkMedia;

                if (!ExistingHLinkMedia.Valid || !ExistingHLinkMedia.LinkToImage)
                {
                    ShowSymbol();
                    return;
                }
                else
                {
                    ShowImage();
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        /// <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 OCURLModelCollection GetURLCollection(XElement xmlData)
        {
            OCURLModelCollection t = new OCURLModelCollection();

            // Run query
            var theERElement =
                from orElementEl
                in xmlData.Elements(ns + "url")
                select orElementEl;

            if (theERElement.Any())
            {
                HLinkHomeImageModel newHomeLink = new HLinkHomeImageModel
                {
                    HomeImageType = CommonEnums.HomeImageType.Symbol,
                    HomeSymbol    = CommonConstants.IconBookMark // TODO  Windows.UI.Xaml.Controls.Symbol.World,
                };

                // load event object references
                foreach (XElement theLoadORElement in theERElement)
                {
                    URLModel tt = new URLModel
                    {
                        Handle = "URL Collection",

                        HomeImageHLink = newHomeLink,

                        Priv = SetPrivateObject(GetAttribute(theLoadORElement.Attribute("priv"))),

                        GType = GetAttribute(theLoadORElement.Attribute("type")),

                        GHRef = GetUri(GetAttribute(theLoadORElement.Attribute("href"))),

                        GDescription = GetAttribute(theLoadORElement.Attribute("description")),
                    };

                    t.Add(tt);
                }
            }

            // Return sorted by the default text
            t.Sort(T => T.DeRef.GetDefaultText);

            return(t);
        }
Example #20
0
        public static SourceModel SetHomeImage(SourceModel argModel)
        {
            if (argModel is null)
            {
                throw new ArgumentNullException(nameof(argModel));
            }

            // Get default image if available
            HLinkHomeImageModel hlink = argModel.GMediaRefCollection.FirstHLinkHomeImage;

            // Set default
            if (hlink.Valid)
            {
                argModel.HomeImageHLink.HomeImageType = CommonEnums.HomeImageType.ThumbNail;
                argModel.HomeImageHLink.HLinkKey      = hlink.HLinkKey;
            }

            return(argModel);
        }
Example #21
0
        private static void HandleVMPropertyChanged(BindableObject bindable, object oldValue, object newValue)
        {
            MediaImageFull mifModel = (bindable as MediaImageFull);

            HLinkHomeImageModel argHLinkMediaModel = newValue as HLinkHomeImageModel;

            if (argHLinkMediaModel == mifModel.HLinkMediaModel)
            {
                return;
            }

            mifModel.HLinkMediaModel = argHLinkMediaModel;

            if (!(argHLinkMediaModel is null) && (argHLinkMediaModel.Valid))
            {
                MediaModel t = argHLinkMediaModel.DeRef;

                if ((t.IsMediaStorageFileValid) && (t.IsMediaFile))
                {
                    try
                    {
                        mifModel.daImage.Source = t.MediaStorageFilePath;
                        var tt = mifModel.daImage.Source;

                        mifModel.IsVisible = true;

                        // TODO cleanup code so does nto use bindignContext if possible
                        mifModel.BindingContext = argHLinkMediaModel;

                        return;
                    }
                    catch (Exception ex)
                    {
                        DataStore.CN.NotifyException("Exception in MediaImageFull control", ex);
                        throw;
                    }
                }
            }

            // Nothing to display so hide
            mifModel.IsVisible = false;
        }
        public static FamilyModel SetHomeImage(FamilyModel argModel)
        {
            // Try media reference collection first
            HLinkHomeImageModel hlink = argModel.GMediaRefCollection.FirstHLinkHomeImage;

            if (!hlink.Valid)
            {
                hlink = argModel.GCitationRefCollection.FirstHLinkHomeImage;
            }

            if (!hlink.Valid)
            {
                hlink = argModel.GEventRefCollection.FirstHLinkHomeImage;
            }

            if (!hlink.Valid)
            {
                hlink = argModel.GNoteRefCollection.FirstHLinkHomeImage;
            }

            // Set the image if available
            if (hlink.Valid)
            {
                argModel.HomeImageHLink.HomeImageType = CommonConstants.HomeImageTypeThumbNail;
                argModel.HomeImageHLink.HLinkKey      = hlink.HLinkKey;
            }
            else
            {
                // Set to default
                argModel.HomeImageHLink.HomeImageType = CommonConstants.HomeImageTypeSymbol;
                argModel.HomeImageHLink.HomeSymbol    = CommonConstants.IconFamilies;
            }

            // Get colour
            Application.Current.Resources.TryGetValue("CardBackGroundFamily", out var varCardColour);
            argModel.HomeImageHLink.HomeSymbolColour = (Color)varCardColour;

            return(argModel);
        }
Example #23
0
        /// <summary>
        /// Gets the first image from collection.
        /// </summary>
        /// <param name="theCollection">
        /// The collection.
        /// </param>
        /// <returns>
        /// </returns>
        public new HLinkHomeImageModel GetFirstImageFromCollection(HLinkPersonNameModelCollection theCollection)
        {
            if (theCollection == null)
            {
                return(null);
            }

            HLinkHomeImageModel returnMediaModel = new HLinkHomeImageModel();

            if (theCollection.Count > 0)
            {
                // step through each mediamodel hlink in the collection Accept either a direct
                // mediamodel reference or a hlink to a Source media reference.

                // do { } while (!mediaFoundFlag);
                for (int i = 0; i < theCollection.Count; i++)
                {
                    HLinkPersonNameModel currentHLink = theCollection[i];

                    returnMediaModel = currentHLink.DeRef.GCitationRefCollection.FirstHLinkHomeImage;

                    // TODO Still needed Handle Source Links
                    if (currentHLink.DeRef.HomeImageHLink.LinkToImage)
                    {
                        returnMediaModel = currentHLink.DeRef.HomeImageHLink;
                    }

                    if (returnMediaModel.Valid)
                    {
                        break;
                    }
                }
            }

            // return the image
            return(returnMediaModel);
        }
        private void ShowSymbol(HLinkHomeImageModel argHLMediaModel)
        {
            // Input valid so start work
            daSymbol.IsVisible = true;
            daImage.IsVisible  = false;

            // Set symbol
            FontImageSource tt = this.daSymbol.Source as FontImageSource;

            tt.Glyph = argHLMediaModel.HomeSymbol;
            tt.Color = argHLMediaModel.HomeSymbolColour;

            if (tt.Glyph == null)
            {
                DataStore.CN.NotifyError("MediaImageSkia (" + argHLMediaModel.HLinkKey + ") Null Glyph");
            }

            if (tt.Color == null)
            {
                DataStore.CN.NotifyError("MediaImageSkia (" + argHLMediaModel.HLinkKey + ") Null Colour");
            }

            this.daSymbol.Source = tt;
        }
        private void ShowSomething(HLinkHomeImageModel argHHomeMedia)
        {
            try
            {
                if (!argHHomeMedia.Valid)
                {
                    //DataStore.CN.NotifyError("Invalid HlinkMediaModel (" + HLinkMedia.HLinkKey + ") passed to MediaImage");
                    return;
                }

                if (argHHomeMedia == WorkHLMediaModel)
                {
                    return;
                }

                // Save the HLink so can check for duplicate changes later

                WorkHLMediaModel = argHHomeMedia;

                if (!argHHomeMedia.Valid || !argHHomeMedia.LinkToImage)
                {
                    ShowSymbol(argHHomeMedia);
                    return;
                }
                else
                {
                    ShowImage(argHHomeMedia.DeRef);
                }
            }
            catch (Exception ex)
            {
                DataStore.CN.NotifyException("MediaImageSkia", ex);

                throw;
            }
        }
        public static PersonModel SetHomeImage(PersonModel argModel)
        {
            if (argModel is null)
            {
                throw new ArgumentNullException(nameof(argModel));
            }

            HLinkHomeImageModel hlink = argModel.GMediaRefCollection.FirstHLinkHomeImage;

            // Check Citation for Images
            if (!hlink.Valid)
            {
                hlink = argModel.GCitationRefCollection.FirstHLinkHomeImage;
            }

            // Action any Link
            if (hlink.Valid)
            {
                argModel.HomeImageHLink.HomeImageType = CommonEnums.HomeImageType.ThumbNail;
                argModel.HomeImageHLink.HLinkKey      = hlink.HLinkKey;
            }

            return(argModel);
        }
        /// <summary>
        /// Populates the view ViewModel.
        /// </summary>
        /// <returns>
        /// </returns>
        public override async Task <bool> PopulateViewModelAsync()
        {
            BaseCL.LogRoutineEntry("PersonDetailViewModel");

            PersonObject = DV.PersonDV.GetModelFromHLink(BaseNavParamsHLink);

            if (!(PersonObject is null))
            {
                BaseTitle = PersonObject.GPersonNamesCollection.GetPrimaryName.GetDefaultText;

                // Get media image
                HLinkHomeImageModel personImage = PersonObject.HomeImageHLink;
                Contract.Assert(PersonObject.HomeImageHLink != null, PersonObject.Id);
                personImage.CardType = DisplayFormat.MediaCardLarge;
                BaseDetail.Add(personImage);

                // Get Header Details
                CardGroup headerCardGroup = new CardGroup {
                    Title = "Header Details"
                };

                // Get the Name Details
                CardListLineCollection nameDetails = new CardListLineCollection
                {
                    new CardListLine("Card Type:", "Person Detail"),
                };

                headerCardGroup.Add(nameDetails);

                // Handle the common case where there is only one name
                if (PersonObject.GPersonNamesCollection.Count == 1)
                {
                    headerCardGroup.Add(PersonObject.GPersonNamesCollection[0]);
                }

                // Get extra details
                CardListLineCollection extraDetailsCard = new CardListLineCollection
                {
                    new CardListLine("Gender:", PersonObject.GGenderAsString),
                };

                if (PersonObject.BirthDate != null)
                {
                    extraDetailsCard.Add(new CardListLine("Birth Date:", PersonObject.BirthDate.GetLongDateAsString));

                    if (PersonObject.IsLiving)
                    {
                        extraDetailsCard.Add(new CardListLine("Age:", PersonObject.BirthDate.GetAge));
                    }
                    else
                    {
                        extraDetailsCard.Add(new CardListLine("Years Since Birth:", PersonObject.BirthDate.GetAge));

                        EventModel ageAtDeath = DV.EventDV.GetEventType(PersonObject.GEventRefCollection, "Death");
                        if (ageAtDeath.Valid)
                        {
                            extraDetailsCard.Add(new CardListLine("Age at Death:", ageAtDeath.GDate.DateDifferenceDecoded(PersonObject.BirthDate)));
                        }
                    }
                }
                else
                {
                    extraDetailsCard.Add(new CardListLine("Birth Date:", "Unknown"));
                }

                extraDetailsCard.Add(new CardListLine("Is Living:", PersonObject.IsLivingAsString));

                headerCardGroup.Add(extraDetailsCard);

                // Get parent details
                headerCardGroup.Add(
                    new ParentLinkModel
                {
                    Parents = PersonObject.GChildOf.DeRef,
                });

                // Add Standard details
                headerCardGroup.Add(DV.PersonDV.GetModelInfoFormatted(PersonObject));

                BaseDetail.Add(headerCardGroup);

                // Handle the uncommon case where there is more than one name
                if (PersonObject.GPersonNamesCollection.Count > 1)
                {
                    // Add extra name details
                    BaseDetail.Add(PersonObject.GPersonNamesCollection.GetCardGroup1());
                }

                // Get Bio
                HLinkNoteModel bioCard = PersonObject.GNoteRefCollection.GetBio;
                bioCard.CardType = DisplayFormat.NoteCardFull;
                BaseDetail.Add(bioCard);

                // Add details
                BaseDetail.Add(PersonObject.GParentInRefCollection.GetCardGroup());
                BaseDetail.Add(PersonObject.GEventRefCollection.GetCardGroup());
                BaseDetail.Add(PersonObject.GCitationRefCollection.GetCardGroup());
                BaseDetail.Add(PersonObject.GNoteRefCollection.GetCardGroup());
                BaseDetail.Add(PersonObject.GMediaRefCollection.GetCardGroup());
                BaseDetail.Add(PersonObject.GAttributeCollection);
                BaseDetail.Add(PersonObject.GAddress);
                BaseDetail.Add(PersonObject.GTagRefCollection.GetCardGroup());
                BaseDetail.Add(PersonObject.GURLCollection);
                BaseDetail.Add(PersonObject.GLDSCollection);
                BaseDetail.Add(PersonObject.GPersonRefCollection);

                BaseDetail.Add(PersonObject.GPersonNamesCollection.GetPrimaryName.GCitationRefCollection.GetCardGroup("Name Citations"));
                BaseDetail.Add(PersonObject.GPersonNamesCollection.GetPrimaryName.GNoteReferenceCollection.GetCardGroup("Name Notes"));

                BaseDetail.Add(PersonObject.BackHLinkReferenceCollection.GetCardGroup());

                // TODO localActivitySession = await CommonTimeline.AddToTimeLine("Person",
                // PersonObject, PersonObject.HomeImageHLink.DeRef.MediaStorageFilePath, "Person: "
                // + PersonObject.BirthName.FullName, "Born: " + PersonObject.BirthDate.GetShortDateAsString).ConfigureAwait(false);
            }

            return(true);
        }
        /// <summary>
        /// Populates the view ViewModel.
        ///
        /// XML 1.71 all done
        /// </summary>
        /// <returns>
        /// </returns>
        public override void PopulateViewModel()
        {
            BaseCL.LogRoutineEntry("NameDetailViewModel");

            PersonNameObject = DV.PersonNameDV.GetModelFromHLink(BaseNavParamsHLink);

            if (PersonNameObject.Valid)
            {
                BaseTitle = PersonNameObject.GetDefaultText;

                // Get media image
                HLinkHomeImageModel AddressImage = PersonNameObject.HomeImageHLink;
                AddressImage.CardType = DisplayFormat.MediaCardLarge;
                BaseDetail.Add(AddressImage);

                // Get Header Details
                CardGroup headerCardGroup = new CardGroup {
                    Title = "Person Name Details"
                };
                BaseDetail.Add(headerCardGroup);

                // TODO Show All Surnames
                CardListLineCollection PersonNameCards = new CardListLineCollection
                {
                    new CardListLine("Type:", PersonNameObject.GType),
                    new CardListLine("Full Name:", PersonNameObject.FullName),
                    new CardListLine("Title:", PersonNameObject.GTitle),
                    new CardListLine("FirstName:", PersonNameObject.GFirstName),
                    new CardListLine("SurName:", PersonNameObject.GSurName.GetPrimarySurname),
                    new CardListLine("Suffix:", PersonNameObject.GSuffix),

                    new CardListLine("Alt:", PersonNameObject.GAlt.GetDefaultText),
                    new CardListLine("Call:", PersonNameObject.GCall),
                    new CardListLine("Date:", PersonNameObject.GDate.ShortDate),
                    new CardListLine("Display:", PersonNameObject.GDisplay),
                    new CardListLine("Family Nick:", PersonNameObject.GFamilyNick),

                    new CardListLine("Group:", PersonNameObject.GGroup),
                    new CardListLine("Nick:", PersonNameObject.GNick),
                    new CardListLine("Priv:", PersonNameObject.GPriv),
                    new CardListLine("Sort:", PersonNameObject.GSort)
                };

                BaseDetail.Add(PersonNameCards);

                foreach (SurnameModel item in PersonNameObject.GSurName)
                {
                    CardListLineCollection SurnameCard = new CardListLineCollection
                    {
                        new CardListLine("Prefix:", item.GPrefix),
                        new CardListLine("Primary:", item.GPrim),
                        new CardListLine("Derivation:", item.GDerivation),
                        new CardListLine("Connector:", item.GConnector),
                    };

                    BaseDetail.Add(SurnameCard);
                }

                BaseDetail.Add(PersonNameObject.GCitationRefCollection.GetCardGroup());
                BaseDetail.Add(PersonNameObject.GNoteReferenceCollection.GetCardGroup());

                BaseDetail.Add(PersonNameObject.BackHLinkReferenceCollection.GetCardGroup());
            }

            return;
        }
        /// <summary>
        /// Populates the view ViewModel.
        /// </summary>
        /// <returns>
        /// Task.
        /// </returns>
        public override void PopulateViewModel()
        {
            FamilyObject = DV.FamilyDV.GetModelFromHLink(BaseNavParamsHLink);

            if (!(FamilyObject is null))
            {
                BaseTitle     = FamilyObject.FamilyDisplayName;
                BaseTitleIcon = CommonConstants.IconFamilies;

                // Get media image
                HLinkHomeImageModel personImage = FamilyObject.HomeImageHLink;
                Contract.Assert(FamilyObject.HomeImageHLink != null, FamilyObject.Id);
                personImage.CardType = DisplayFormat.MediaCardLarge;
                BaseDetail.Add(personImage);

                // Get basic details
                CardGroup t = new CardGroup {
                    Title = "Header Details"
                };

                t.Add(new CardListLineCollection
                {
                    new CardListLine("Card Type:", "Family Detail"),
                    new CardListLine("Family Display Name:", FamilyObject.FamilyDisplayName),
                    new CardListLine("Family Relationship:", FamilyObject.GFamilyRelationship),
                    new CardListLine("Father Name:", FamilyObject.GFather.DeRef.GPersonNamesCollection.GetPrimaryName.DeRef.FullName),
                    new CardListLine("Mother Name:", FamilyObject.GMother.DeRef.GPersonNamesCollection.GetPrimaryName.DeRef.FullName),
                });

                // Add Model details
                t.Add(DV.FamilyDV.GetModelInfoFormatted(FamilyObject));

                // Add parent link
                t.Add(new ParentLinkModel
                {
                    Parents = localFamilyModel,
                });

                BaseDetail.Add(t);

                // Detail reference
                BaseDetail.Add(FamilyObject.GEventRefCollection.GetCardGroup());
                BaseDetail.Add(FamilyObject.GChildRefCollection.GetCardGroup()); // TODO , "Children");

                BaseDetail.Add(FamilyObject.GCitationRefCollection.GetCardGroup());
                BaseDetail.Add(FamilyObject.GMediaRefCollection.GetCardGroup());
                BaseDetail.Add(FamilyObject.GNoteRefCollection.GetCardGroup());
                BaseDetail.Add(FamilyObject.GAttributeCollection);
                BaseDetail.Add(FamilyObject.GTagRefCollection.GetCardGroup());

                BaseDetail.Add(FamilyObject.BackHLinkReferenceCollection.GetCardGroup());

                string outFamEvent;
                if (FamilyObject.GEventRefCollection.Count > 0)
                {
                    // TODO Handle this
                    outFamEvent = FamilyObject.GEventRefCollection.FirstOrDefault().DeRef.GType + ": " + FamilyObject.GEventRefCollection.FirstOrDefault().DeRef.GDate.ShortDate;
                }

                // TODO localActivitySession = await CommonTimeline.AddToTimeLine("Family",
                // localFamilyModel, localFamilyModel.HomeImageHLink.DeRef.MediaStorageFilePath,
                // "Family: " + localFamilyModel.FamilyDisplayName, outFamEvent).ConfigureAwait(false);

                // TODO //CommonTimeline.FinishActivitySessionAsync(localActivitySession); }
            }
        }
Example #30
0
        /// <summary>
        /// Handles navigation in wards and sets up the event model parameter.
        /// </summary>
        /// <returns>
        /// </returns>
        public override void PopulateViewModel()
        {
            BaseCL.LogRoutineEntry("MediaDetailViewModel OnNavigatedTo");

            CurrentHLinkMedia = BaseNavParamsHLink as HLinkMediaModel;

            if (!(CurrentHLinkMedia is null))
            {
                CurrentMediaObject = DV.MediaDV.GetModelFromHLink(CurrentHLinkMedia);

                if (!(CurrentMediaObject is null))
                {
                    BaseTitle     = CurrentMediaObject.GetDefaultText;
                    BaseTitleIcon = CommonConstants.IconMedia;

                    // Get basic details
                    CardGroup t = new CardGroup {
                        Title = "Header Details"
                    };

                    t.Add(new CardListLineCollection
                    {
                        new CardListLine("Card Type:", "Media Detail"),
                        new CardListLine("Date:", CurrentMediaObject.GDateValue.GetLongDateAsString),
                        new CardListLine("File Description:", CurrentMediaObject.GDescription),
                        new CardListLine("File Mime Type:", CurrentMediaObject.FileMimeType),
                        new CardListLine("File Content Type:", CurrentMediaObject.FileContentType),
                        new CardListLine("File Mime SubType:", CurrentMediaObject.FileMimeSubType),
                        new CardListLine("OriginalFilePath:", CurrentMediaObject.OriginalFilePath),
                    });

                    // Set up note re opening in photo app
                    CardListLineCollection t1 = new CardListLineCollection
                    {
                        new CardListLine(string.Empty, "Note: Double click the image to open it.")
                    };

                    t.Add(t1);

                    // Add standard details
                    t.Add(DV.MediaDV.GetModelInfoFormatted(CurrentMediaObject));

                    BaseDetail.Add(t);

                    // Get media image
                    HLinkHomeImageModel personImage = CurrentMediaObject.HomeImageHLink;
                    Contract.Assert(CurrentMediaObject.HomeImageHLink != null, CurrentMediaObject.Id);
                    personImage.CardType = DisplayFormat.MediaCardLarge;
                    BaseDetail.Add(personImage);

                    // Add HLink Details
                    BaseDetail.Add(CurrentHLinkMedia.GAttributeRefCollection);
                    BaseDetail.Add(CurrentHLinkMedia.GCitationRefCollection.GetCardGroup("HLink Citations"));
                    BaseDetail.Add(CurrentHLinkMedia.GNoteRefCollection.GetCardGroup("HLink Notes"));

                    // Add Model details
                    BaseDetail.Add(CurrentMediaObject.GCitationRefCollection.GetCardGroup());
                    BaseDetail.Add(CurrentMediaObject.GNoteRefCollection.GetCardGroup());
                    BaseDetail.Add(CurrentMediaObject.GTagRefCollection.GetCardGroup());

                    BaseDetail.Add(CurrentMediaObject.BackHLinkReferenceCollection.GetCardGroup());
                }

                BaseCL.LogRoutineExit("MediaDetailViewModel OnNavigatedTo");
            }
        }