Ejemplo n.º 1
0
        protected override void DisplayCustomPoiInfo(Object modelObject)
        {
            ExampleApp.SearchResultModelCLI model = modelObject as ExampleApp.SearchResultModelCLI;

            EegeoResultModel eegeoResultModel = EegeoResultModel.FromResultModel(model);

            m_closing = false;

            m_webBrowser.LoadCompleted -= (OnWebPageLoaded);

            m_titlesGrid.RowDefinitions[1].Height = new GridLength(1, GridUnitType.Star);
            m_poiImageContainer.Height            = m_imageContainerHeight;
            m_poiImageContainer.Visibility        = Visibility.Visible;
            m_poiImage.Visibility        = Visibility.Collapsed;
            m_poiImageDivider.Visibility = Visibility.Visible;

            m_contentContainer.ScrollToTop();

            if (eegeoResultModel.WebViewUrl != null)
            {
                Uri  hyperlink;
                bool webViewUrlIsValid = Uri.TryCreate(eegeoResultModel.WebViewUrl, UriKind.Absolute, out hyperlink) &&
                                         (hyperlink.Scheme == Uri.UriSchemeHttp || hyperlink.Scheme == Uri.UriSchemeHttps);

                if (webViewUrlIsValid)
                {
                    Uri url = new Uri(eegeoResultModel.WebViewUrl);

                    m_poiHasWebContent          = true;
                    m_webBrowser.Visibility     = Visibility.Hidden;
                    m_webBrowser.LoadCompleted += (OnWebPageLoaded);
                    m_webBrowser.Source         = url;

                    if (eegeoResultModel.WebViewHeight != 0)
                    {
                        m_webBrowserOriginalHeight = eegeoResultModel.WebViewHeight;
                        m_poiImageContainer.Height = eegeoResultModel.WebViewHeight;

                        if (eegeoResultModel.WebViewHeight > m_maxWebViewHeight)
                        {
                            m_webBrowserOriginalHeight = m_maxWebViewHeight;
                            m_poiImageContainer.Height = m_maxWebViewHeight;
                        }
                    }
                    else
                    {
                        m_webBrowserOriginalHeight = m_defaultWebViewHeight;
                        m_poiImageContainer.Height = m_defaultWebViewHeight;
                    }
                }
                else
                {
                    HandleNoWebView(eegeoResultModel);
                }
            }
            else
            {
                HandleNoWebView(eegeoResultModel);
            }


            if (!m_poiHasWebContent)
            {
                Uri uri;
                if ((eegeoResultModel.ImageUrl != null) && TryCreateWebLink(eegeoResultModel.ImageUrl, out uri))
                {
                    m_poiImageDivider.Visibility = Visibility.Visible;
                }
                else
                {
                    m_poiImageContainer.Visibility = Visibility.Collapsed;
                    m_poiImageDivider.Visibility   = Visibility.Collapsed;
                }
            }

            if (eegeoResultModel.Phone != null)
            {
                PhoneText = eegeoResultModel.Phone;
                m_phoneDetailsContainer.Visibility = Visibility.Visible;
            }
            else
            {
                m_phoneDetailsContainer.Visibility = Visibility.Collapsed;
            }

            if (eegeoResultModel.Address != null)
            {
                AddressText = eegeoResultModel.Address.Replace(", ", Environment.NewLine);
                m_addressDetailsContainer.Visibility = Visibility.Visible;
            }
            else
            {
                AddressText = null;
                m_addressDetailsContainer.Visibility = Visibility.Collapsed;
            }

            if (eegeoResultModel.WebUrl != null)
            {
                WebAddressText = eegeoResultModel.WebUrl;
                m_webDetailsContainer.Visibility = Visibility.Visible;
                m_qrCodeContainer.Visibility     = Visibility.Visible;
            }
            else
            {
                m_webDetailsContainer.Visibility = Visibility.Collapsed;
                m_qrCodeContainer.Visibility     = Visibility.Collapsed;
            }

            if (eegeoResultModel.Facebook != null)
            {
                m_facebookIcon.Visibility = Visibility.Visible;
                m_facebookText            = eegeoResultModel.Facebook;
            }
            else
            {
                m_facebookIcon.Visibility = Visibility.Collapsed;
            }

            if (eegeoResultModel.Twitter != null)
            {
                m_twitterIcon.Visibility = Visibility.Visible;
                m_twitterText            = eegeoResultModel.Twitter;
            }
            else
            {
                m_twitterIcon.Visibility = Visibility.Collapsed;
            }

            if (eegeoResultModel.Email != null)
            {
                m_emailIcon.Visibility = Visibility.Visible;
                m_emailText            = eegeoResultModel.Email;
            }
            else
            {
                m_emailIcon.Visibility = Visibility.Collapsed;
            }

            bool shouldCollapseDivider = eegeoResultModel.Facebook == null &&
                                         eegeoResultModel.Twitter == null &&
                                         eegeoResultModel.Email == null &&
                                         eegeoResultModel.Address == null &&
                                         eegeoResultModel.Phone == null &&
                                         eegeoResultModel.WebUrl == null;

            if (shouldCollapseDivider || m_detailsDividerVisibility == Visibility.Collapsed)
            {
                m_detailsDivider.Visibility = Visibility.Collapsed;
            }
            else
            {
                m_detailsDivider.Visibility = Visibility.Visible;
            }

            if (eegeoResultModel.Facebook == null && eegeoResultModel.Twitter == null && eegeoResultModel.Email == null)
            {
                m_socialLinkIconsContainer.Visibility = Visibility.Collapsed;
            }
            else
            {
                m_socialLinkIconsContainer.Visibility = Visibility.Visible;
            }

            m_linkedInIcon.Visibility = Visibility.Collapsed;
            m_slackIcon.Visibility    = Visibility.Collapsed;
            TitleText = model.Title;
            if (model.Subtitle != "")
            {
                SubTitleText = model.Subtitle;
            }
            else
            {
                m_titlesGrid.RowDefinitions[1].Height = new GridLength(0);
            }

            if (model.HumanReadableTags != null)
            {
                HumanReadableTagsText    = string.Join(", ", model.HumanReadableTags);
                m_tagsDivider.Visibility = Visibility.Visible;
            }
            else
            {
                m_tagsDivider.Visibility = Visibility.Collapsed;
            }

            if (eegeoResultModel.Description != null)
            {
                DescriptionText = eegeoResultModel.Description;
                m_descriptionContainer.Visibility = Visibility.Visible;
            }
            else
            {
                m_descriptionContainer.Visibility = Visibility.Collapsed;
            }

            TagIcon = IconProvider.GetIconForTag(model.IconKey, m_isInKioskMode);

            ShowAll();

            base.DisplayCustomPoiInfo(modelObject);
        }