示例#1
0
        internal Element_AdaptiveText ConvertToElement()
        {
            var answer = new Element_AdaptiveText()
            {
                Lang     = Language,
                Style    = HintStyle,
                Wrap     = HintWrap,
                MaxLines = HintMaxLines,
                MinLines = HintMinLines,
                Align    = HintAlign
            };

#if WINRT
            answer.Text = XmlWriterHelper.GetBindingOrAbsoluteXmlValue(Bindings, AdaptiveTextBindableProperty.Text, Text);
#else
            answer.Text = Text?.ToXmlString();
#endif

            return(answer);
        }
示例#2
0
        /// <summary>
        /// Attempts to find and re-use an existing text element inside the binding. Returns true if it could. Otherwise returns false, and the caller will have to specify the detailed status using the lock hint attribute.
        /// </summary>
        /// <param name="lineNumber">The lock screen line number.</param>
        /// <param name="lockText">The lock screen line text.</param>
        /// <param name="binding">The binding to look in for matches.</param>
        /// <returns>True if could re-use existing text element, otherwise false.</returns>
        private static bool TryReuseTextElementForLockDetailedText(int lineNumber, string lockText, Element_TileBinding binding)
        {
            if (lockText == null)
            {
                throw new ArgumentNullException("lockText cannot be null");
            }

            if (binding == null)
            {
                throw new ArgumentNullException("binding cannot be null");
            }

            // If a text element already has an id with the line number (only look at immediate children, since the lockscreen will ignore things under groups/subgroups)
            Element_AdaptiveText matchingIdTextElement = binding.Children.OfType <Element_AdaptiveText>().FirstOrDefault(i => i.Id != null && i.Id.Equals(lineNumber.ToString()));

            if (matchingIdTextElement != null)
            {
                // If the text in the element matches the lock text, then we're good, don't need to assign anything else!
                if (matchingIdTextElement.Text != null && matchingIdTextElement.Text.Equals(lockText))
                {
                    return(true);
                }

                // Otherwise, we need to specify the lock text in the hint attribute, so we return false
                return(false);
            }

            // Otherwise no text elements use that ID, so we could assign one if we find a text element that doesn't have an ID assigned and matches the lock text
            Element_AdaptiveText matchingTextTextElement = binding.Children.OfType <Element_AdaptiveText>().FirstOrDefault(i => i.Id == null && i.Text != null && i.Text.Equals(lockText));

            // If we found text that matched, we'll assign the id so it gets re-used for lock!
            if (matchingTextTextElement != null)
            {
                matchingTextTextElement.Id = lineNumber;
                return(true);
            }

            // Otherwise we'll need to specify lock text in hint attribute, so return false
            return(false);
        }