private static TileBinding GenerateImageTileBinding(Uri imageUrl, string text = default, bool isLarge = false, string desc = default) { var ctx = new TileBindingContentAdaptive() { PeekImage = new TilePeekImage() { Source = imageUrl != null ? imageUrl.OriginalString : "" }, TextStacking = (isLarge && desc.IsValid()) ? TileTextStacking.Top : TileTextStacking.Bottom }; AdaptiveTextStyle ats = isLarge ? AdaptiveTextStyle.Caption : AdaptiveTextStyle.CaptionSubtle; ctx.Children.Add(new AdaptiveText() { Text = text.Trim(), HintMaxLines = 2, HintStyle = ats }); if (isLarge && desc.IsValid()) { ctx.Children.Add(new AdaptiveText() { Text = desc.Trim().FromHtmlToText(), HintMaxLines = 5, HintWrap = true, HintStyle = AdaptiveTextStyle.CaptionSubtle }); } return(new TileBinding() { Content = ctx }); }
private static void AssertAdaptiveTextStyle(string expectedPropertyValue, AdaptiveTextStyle style) { AssertAdaptiveTextPropertyValue("hint-style", expectedPropertyValue, new AdaptiveText() { HintStyle = style }); }
public void AddTextTest_WithTextAndFullOptions_ReturnSelfWithTextAndAllOptionsAdded() { // Arrange string testText = "Test Text"; AdaptiveTextStyle testStyle = AdaptiveTextStyle.Header; bool testWrapHint = true; int testHintMaxLine = 2; int testHintMinLine = 1; AdaptiveTextAlign testAlign = AdaptiveTextAlign.Auto; string testLanguage = "en-US"; ToastContentBuilder builder = new ToastContentBuilder(); // Act ToastContentBuilder anotherReference = builder.AddText(testText, testStyle, testWrapHint, testHintMaxLine, testHintMinLine, testAlign, testLanguage); // Assert Assert.AreSame(builder, anotherReference); var text = builder.Content.Visual.BindingGeneric.Children.First() as AdaptiveText; Assert.AreEqual(testText, (string)text.Text); Assert.AreEqual(testHintMaxLine, text.HintMaxLines); Assert.AreEqual(testLanguage, text.Language); // These values should still be the default values, since they aren't used for top-level text Assert.AreEqual(AdaptiveTextStyle.Default, text.HintStyle); Assert.IsNull(text.HintWrap); Assert.IsNull(text.HintMinLines); Assert.AreEqual(AdaptiveTextAlign.Default, text.HintAlign); }
/// <summary> /// /// </summary> /// <param name="text"></param> /// <returns></returns> private static AdaptiveText GetCenteredAdaptiveText(string text, AdaptiveTextStyle style = AdaptiveTextStyle.CaptionSubtle) { return(new AdaptiveText() { Text = text, HintWrap = true, HintAlign = AdaptiveTextAlign.Center, HintStyle = style }); }