private static void AssertAdaptiveText(string expectedAdaptiveTextXml, AdaptiveText text) { AssertBindingGenericPayload("<binding template='ToastGeneric'>" + expectedAdaptiveTextXml + "</binding>", new ToastBindingGeneric() { Children = { text } }); }
private TileBinding CreateTileBinding(TileSize size, string title, int readingTime, string imageSource) { var binding = new TileBinding() { Branding = TileBranding.Logo, Content = new TileBindingContentAdaptive() }; // Create the XML in code var group = new AdaptiveGroup(); var subgroup = new AdaptiveSubgroup(); // Add the title to the tile var tileTitle = new AdaptiveText() { Text = title, HintMaxLines = size == TileSize.Large ? 3 : 2, HintWrap = true, HintStyle = size == TileSize.Medium ? AdaptiveTextStyle.Caption : AdaptiveTextStyle.Body }; subgroup.Children.Add(tileTitle); // Add the reading time string resourceName = size == TileSize.Medium ? "LiveTileReadingTimeShort" : "LiveTileReadingTime"; subgroup.Children.Add(new AdaptiveText() { Text = string.Format(_device.GetLocalizedResource(resourceName), readingTime), HintStyle = AdaptiveTextStyle.CaptionSubtle }); // Finally add the subgroup to the tile group.Children.Add(subgroup); // Add the background image if neccessary if (!string.IsNullOrEmpty(imageSource)) { (binding.Content as TileBindingContentAdaptive).BackgroundImage = new TileBackgroundImage() { Source = imageSource, HintOverlay = 60 }; } // Add the group to the tile (binding.Content as TileBindingContentAdaptive).Children.Add(group); return(binding); }
private static IList <AdaptiveText> GetNotificationText(SignalMessage message) { List <AdaptiveText> text = new List <AdaptiveText>(); AdaptiveText title = new AdaptiveText() { Text = message.Author.ThreadDisplayName, HintMaxLines = 1 }; AdaptiveText messageText = new AdaptiveText() { Text = message.Content.Content, HintWrap = true }; text.Add(title); text.Add(messageText); return(text); }
private IList <AdaptiveText> GetNotificationText(string authorName, string content) { List <AdaptiveText> text = new List <AdaptiveText>(); AdaptiveText title = new AdaptiveText() { Text = authorName, HintMaxLines = 1 }; AdaptiveText messageText = new AdaptiveText() { Text = content, HintWrap = true }; text.Add(title); text.Add(messageText); return(text); }
private void CreateOrUpdateTextEntities(AdaptiveText myTarget, TutorialManagerModelMiddleware model) { SerializedProperty arraySizeProperty = bindingIdsProperty.FindPropertyRelative("Array.size"); int listCount = arraySizeProperty.intValue; for (int a = 0; a < listCount; a++) { string qualifiedBindingId = string.Format("{0}-text", bindingIdsProperty.GetArrayElementAtIndex(a).stringValue); if (model.TMData.contentTable.ContainsKey(qualifiedBindingId)) { model.UpdateContentEntity(qualifiedBindingId, myTarget.GetCurrentText()); } else if (string.IsNullOrEmpty(myTarget.bindingIds[a]) == false) { model.CreateContentEntity(myTarget.bindingIds[a], ContentType.text, myTarget.GetCurrentText()); } } }
private static AdaptiveSubgroup CreateAdaptiveGroupColumn(string title, string value, string dateValue) { AdaptiveSubgroup adaptiveColumnGroup = new AdaptiveSubgroup(); var contentTitle = new AdaptiveText(); contentTitle.Text = title; var contenteValue = new AdaptiveText(); contenteValue.Text = value; var contentDate = new AdaptiveText(); contentDate.Text = dateValue; adaptiveColumnGroup.Children.Add(contentTitle); adaptiveColumnGroup.Children.Add(contenteValue); adaptiveColumnGroup.Children.Add(contentDate); return(adaptiveColumnGroup); }
public override void OnInspectorGUI() { serializedObject.Update(); RenderContentElements(); AdaptiveText myTarget = (AdaptiveText)target; TutorialManagerModelMiddleware model = TutorialManagerModelMiddleware.GetInstance(); RenderOverrideOnlyWhenNotEmptyCheckbox(); if (lastKnownTextValue != myTarget.GetCurrentText() || bindingsHaveChanged) { CreateOrUpdateTextEntities(myTarget, model); } bool hasText = false; if (myTarget.GetComponent <Text>() != null || myTarget.GetComponent <TextMesh>() != null) { hasText = true; } #if TEXTMESHPRO_PRESENT if (!hasText && myTarget.GetComponent <TMP_Text>() != null) { hasText = true; } #endif if (hasText == false) { // Display warning EditorGUILayout.HelpBox(k_TextRequiredMessage, MessageType.Warning, true); } serializedObject.ApplyModifiedProperties(); lastKnownTextValue = myTarget.GetCurrentText(); bindingsHaveChanged = false; }
private static void AssertAdaptiveTextPropertyValue(string expectedPropertyName, string expectedPropertyValue, AdaptiveText text) { AssertAdaptiveChild($"<text {expectedPropertyName}='{expectedPropertyValue}'/>", text); }
/// <summary> /// Makes sure the main app tile is an icon tile type /// </summary> public void UpdateMainTile(int unreadCount) { // Setup the main tile as iconic for small and medium TileContent content = new TileContent() { Visual = new TileVisual() { TileSmall = new TileBinding() { Content = new TileBindingContentIconic() { Icon = new TileImageSource("ms-appx:///Assets/AppAssets/IconicTiles/Iconic144.png"), } }, TileMedium = new TileBinding() { Content = new TileBindingContentIconic() { Icon = new TileImageSource("ms-appx:///Assets/AppAssets/IconicTiles/Iconic200.png"), } }, } }; // If the user is signed in we will do more for large and wide. if (m_baconMan.UserMan.IsUserSignedIn && m_baconMan.UserMan.CurrentUser != null && !String.IsNullOrWhiteSpace(m_baconMan.UserMan.CurrentUser.Name)) { content.Visual.TileWide = new TileBinding() { Content = new TileBindingContentAdaptive() { Children = { new AdaptiveText { Text = m_baconMan.UserMan.CurrentUser.Name, HintStyle = AdaptiveTextStyle.Caption }, new AdaptiveText { Text = String.Format("{0:N0}", m_baconMan.UserMan.CurrentUser.CommentKarma) + " comment karma", HintStyle = AdaptiveTextStyle.Caption }, new AdaptiveText { Text = String.Format("{0:N0}", m_baconMan.UserMan.CurrentUser.LinkKarma) + " link karma", HintStyle = AdaptiveTextStyle.Caption }, } }, }; // If we have messages replace the user name with the message string. if (unreadCount != 0) { var unreadCountText = new AdaptiveText { Text = unreadCount + " Unread Inbox Message" + (unreadCount == 1 ? "" : "s"), HintStyle = AdaptiveTextStyle.Body }; ((TileBindingContentAdaptive)content.Visual.TileWide.Content).Children[0] = unreadCountText; } // Also set the cake day if it is today DateTime origin = new DateTime(1970, 1, 1, 0, 0, 0, 0); DateTime userCreationTime = origin.AddSeconds(m_baconMan.UserMan.CurrentUser.CreatedUtc).ToLocalTime(); TimeSpan elapsed = DateTime.Now - userCreationTime; double fullYears = Math.Floor((elapsed.TotalDays / 365)); int daysUntil = (int)(elapsed.TotalDays - (fullYears * 365)); if (daysUntil == 0) { // Make the text var cakeDayText = new AdaptiveText { Text = "Today is your cake day!", HintStyle = AdaptiveTextStyle.Body }; ((TileBindingContentAdaptive)content.Visual.TileWide.Content).Children[0] = cakeDayText; } } // Set large to the be same as wide. content.Visual.TileLarge = content.Visual.TileWide; // Update the tile TileUpdateManager.CreateTileUpdaterForApplication().Update(new TileNotification(content.GetXml())); // Update the badge BadgeNumericNotificationContent badgeContent = new BadgeNumericNotificationContent(); badgeContent.Number = (uint)unreadCount; BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(new BadgeNotification(badgeContent.GetXml())); }
public static ToastNotification CreateMentionToast(string server, string username, string channel, string text) { try { AdaptiveText message; if (text.StartsWith("ACTION")) { message = new AdaptiveText { Text = text.Replace("ACTION", " * " + username) }; } else { message = new AdaptiveText { Text = text }; } // Construct the visuals of the toast ToastVisual visual = new ToastVisual() { BindingGeneric = new ToastBindingGeneric() { Children = { new AdaptiveText { Text = "Message from " + username }, message }, Attribution = new ToastGenericAttributionText { Text = "Mention in " + channel }, } }; ToastActionsCustom actions = new ToastActionsCustom() { Inputs = { new ToastTextBox("tbReply") { PlaceholderContent = "Reply to this mention..." } }, Buttons = { new ToastButton("Reply", new QueryString() { { "action", "reply" }, { "server", server }, { "channel", channel }, { "username", username } }.ToString()) { ActivationType = ToastActivationType.Foreground, ImageUri = "Assets/Send.png", TextBoxId = "tbReply" }, }, }; // Now we can construct the final toast content ToastContent toastContent = new ToastContent() { Visual = visual, Actions = actions, // Arguments when the user taps body of toast Launch = new QueryString() { { "action", "viewConversation" }, { "server", server }, { "channel", channel } }.ToString() }; // And create the toast notification return(new ToastNotification(toastContent.GetXml())); } catch (Exception e) { Debug.WriteLine(e.Message); Debug.WriteLine(e.StackTrace); } return(null); }
private static TileBindingContentAdaptive GenerateCondition(Weather weather, ForecastTileType forecastTileType) { var userlang = GlobalizationPreferences.Languages[0]; var culture = new CultureInfo(userlang); var content = new TileBindingContentAdaptive { // Background URI BackgroundImage = new TileBackgroundImage() { Source = wm.GetBackgroundURI(weather) } }; if (forecastTileType == ForecastTileType.Small) { content.Children.Add(new AdaptiveGroup() { Children = { new AdaptiveSubgroup() { Children = { new AdaptiveText() { Text = weather.update_time.ToString("ddd", culture), HintStyle = AdaptiveTextStyle.Base, HintAlign = AdaptiveTextAlign.Center }, new AdaptiveText() { Text = (Settings.IsFahrenheit ? Math.Round(weather.condition.temp_f) : Math.Round(weather.condition.temp_c)) + "º", HintStyle = AdaptiveTextStyle.Body, HintAlign = AdaptiveTextAlign.Center } } } } }); } else if (forecastTileType == ForecastTileType.Medium) { content.Children.Add(new AdaptiveGroup() { Children = { new AdaptiveSubgroup() { HintWeight = 1, Children = { new AdaptiveText() { Text = null } } }, new AdaptiveSubgroup() { HintWeight = 3, HintTextStacking = AdaptiveSubgroupTextStacking.Center, Children = { new AdaptiveImage() { HintRemoveMargin = true, Source = wm.GetWeatherIconURI(weather.condition.icon) }, new AdaptiveText() { Text = (Settings.IsFahrenheit ? Math.Round(weather.condition.temp_f) : Math.Round(weather.condition.temp_c)) + "º", HintStyle = AdaptiveTextStyle.Body, HintAlign = AdaptiveTextAlign.Center, } } }, new AdaptiveSubgroup() { HintWeight = 1, Children = { new AdaptiveText() { Text = null } } } } }); } else if (forecastTileType == ForecastTileType.Wide) { // Current Condition (Extended) var forecastGroup = new AdaptiveGroup(); var condition = new AdaptiveSubgroup() { HintWeight = 25, Children = { new AdaptiveImage() { HintRemoveMargin = true, Source = wm.GetWeatherIconURI(weather.condition.icon) } }, HintTextStacking = AdaptiveSubgroupTextStacking.Center }; var details = new AdaptiveSubgroup() { HintWeight = 75, Children = { new AdaptiveText() { Text = (String.IsNullOrWhiteSpace(weather.condition.weather)) ? "---" : weather.condition.weather, HintStyle = AdaptiveTextStyle.Caption }, new AdaptiveText() { Text = string.Format("{0}: {1}", App.ResLoader.GetString("Temp_Label"), (Settings.IsFahrenheit ? Math.Round(weather.condition.temp_f) : Math.Round(weather.condition.temp_c)) + "º"), HintStyle = AdaptiveTextStyle.Caption }, new AdaptiveText() { Text = string.Format("{0}: {1}", App.ResLoader.GetString("FeelsLike_Label"), (Settings.IsFahrenheit ? Math.Round(weather.condition.feelslike_f) : Math.Round(weather.condition.feelslike_c)) + "º"), HintStyle = AdaptiveTextStyle.CaptionSubtle }, new AdaptiveText() { Text = string.Format("{0}: {1}", App.ResLoader.GetString("Wind_Label"), Settings.IsFahrenheit ? Math.Round(weather.condition.wind_mph) + " mph" : Math.Round(weather.condition.wind_kph) + " kph"), HintStyle = AdaptiveTextStyle.CaptionSubtle } } }; forecastGroup.Children.Add(condition); forecastGroup.Children.Add(details); content.Children.Add(forecastGroup); } else if (forecastTileType == ForecastTileType.Large) { // Condition + 5-day forecast var forecastGroup = new AdaptiveGroup(); var condition = weather.condition; int forecastLength = LARGE_FORECAST_LENGTH; if (weather.forecast.Length < forecastLength) { forecastLength = weather.forecast.Length; } var conditionGroup = new AdaptiveGroup() { Children = { new AdaptiveSubgroup() { HintWeight = 25, HintTextStacking = AdaptiveSubgroupTextStacking.Center, Children = { new AdaptiveImage() { Source = wm.GetWeatherIconURI(weather.condition.icon) } } }, new AdaptiveSubgroup() { HintWeight = 75, Children = { new AdaptiveText() { Text = (String.IsNullOrWhiteSpace(weather.condition.weather)) ? "---" : weather.condition.weather, HintStyle = AdaptiveTextStyle.Caption }, new AdaptiveText() { Text = string.Format("{0}: {1}", App.ResLoader.GetString("Temp_Label"), (Settings.IsFahrenheit ? Math.Round(weather.condition.temp_f) : Math.Round(weather.condition.temp_c)) + "º"), HintStyle = AdaptiveTextStyle.Caption }, new AdaptiveText() { Text = string.Format("{0}: {1}", App.ResLoader.GetString("FeelsLike_Label"), (Settings.IsFahrenheit ? Math.Round(weather.condition.feelslike_f) : Math.Round(weather.condition.feelslike_c)) + "º"), HintStyle = AdaptiveTextStyle.CaptionSubtle }, new AdaptiveText() { Text = string.Format("{0}: {1}", App.ResLoader.GetString("Wind_Label"), Settings.IsFahrenheit ? Math.Round(weather.condition.wind_mph) + " mph" : Math.Round(weather.condition.wind_kph) + " kph"), HintStyle = AdaptiveTextStyle.CaptionSubtle } } } } }; var text = new AdaptiveText() { Text = "" }; for (int i = 0; i < forecastLength; i++) { var forecast = weather.forecast[i]; var subgroup = new AdaptiveSubgroup() { HintWeight = 1, Children = { new AdaptiveText() { Text = forecast.date.ToString("ddd", culture), HintAlign = AdaptiveTextAlign.Center }, new AdaptiveImage() { HintRemoveMargin = true, Source = wm.GetWeatherIconURI(forecast.icon) }, new AdaptiveText() { Text = (Settings.IsFahrenheit ? Math.Round(double.Parse(forecast.high_f)).ToString() : Math.Round(double.Parse(forecast.high_c)).ToString()) + "º", HintAlign = AdaptiveTextAlign.Center }, new AdaptiveText() { Text = (Settings.IsFahrenheit ? Math.Round(double.Parse(forecast.low_f)).ToString() : Math.Round(double.Parse(forecast.low_c)).ToString()) + "º", HintStyle = AdaptiveTextStyle.CaptionSubtle, HintAlign = AdaptiveTextAlign.Center } } }; forecastGroup.Children.Add(subgroup); } content.Children.Add(conditionGroup); content.Children.Add(text); content.Children.Add(forecastGroup); } return(content); }
private static TileBindingContentAdaptive GenerateHrForecast(Weather weather, ForecastTileType forecastTileType) { var userlang = GlobalizationPreferences.Languages[0]; var culture = new CultureInfo(userlang); var content = new TileBindingContentAdaptive { // Background URI BackgroundImage = new TileBackgroundImage() { Source = wm.GetBackgroundURI(weather) } }; if (forecastTileType == ForecastTileType.Small) { content.Children.Add(new AdaptiveGroup() { Children = { new AdaptiveSubgroup() { Children = { new AdaptiveText() { Text = weather.update_time.ToString("ddd", culture), HintStyle = AdaptiveTextStyle.Base, HintAlign = AdaptiveTextAlign.Center }, new AdaptiveText() { Text = (Settings.IsFahrenheit ? Math.Round(weather.condition.temp_f) : Math.Round(weather.condition.temp_c)) + "º", HintStyle = AdaptiveTextStyle.Body, HintAlign = AdaptiveTextAlign.Center } } } } }); } else if (forecastTileType == ForecastTileType.Medium) { var dateGroup = new AdaptiveGroup(); var forecastGroup = new AdaptiveGroup(); var tempGroup = new AdaptiveGroup(); string timeformat = culture.DateTimeFormat.ShortTimePattern.Contains("H") ? "HH" : "ht"; int forecastLength = MEDIUM_FORECAST_LENGTH; if (weather.hr_forecast.Length < forecastLength) { forecastLength = weather.hr_forecast.Length; } // 3hr forecast for (int i = 0; i < forecastLength; i++) { var hrforecast = weather.hr_forecast[i]; var dateSubgroup = new AdaptiveSubgroup() { HintWeight = 1, Children = { new AdaptiveText() { Text = hrforecast.date.ToString(timeformat, culture).ToLower(), HintAlign = AdaptiveTextAlign.Center }, } }; var iconSubgroup = new AdaptiveSubgroup() { HintWeight = 1, Children = { new AdaptiveImage() { HintRemoveMargin = true, Source = wm.GetWeatherIconURI(hrforecast.icon) }, } }; var tempSubgroup = new AdaptiveSubgroup() { HintWeight = 1, HintTextStacking = AdaptiveSubgroupTextStacking.Bottom, Children = { new AdaptiveText() { Text = (Settings.IsFahrenheit ? Math.Round(double.Parse(hrforecast.high_f)).ToString() : Math.Round(double.Parse(hrforecast.high_c)).ToString()) + "º", HintStyle = AdaptiveTextStyle.Caption, HintAlign = AdaptiveTextAlign.Center } } }; dateGroup.Children.Add(dateSubgroup); forecastGroup.Children.Add(iconSubgroup); tempGroup.Children.Add(tempSubgroup); } content.Children.Add(dateGroup); content.Children.Add(forecastGroup); content.Children.Add(tempGroup); } else if (forecastTileType == ForecastTileType.Wide) { // 5-hr forecast var forecastGroup = new AdaptiveGroup(); string timeformat = culture.DateTimeFormat.ShortTimePattern.Contains("H") ? "HH" : "ht"; int forecastLength = LARGE_FORECAST_LENGTH; if (weather.hr_forecast.Length < forecastLength) { forecastLength = weather.hr_forecast.Length; } for (int i = 0; i < forecastLength; i++) { var hrforecast = weather.hr_forecast[i]; var subgroup = new AdaptiveSubgroup() { HintWeight = 1, Children = { new AdaptiveText() { Text = hrforecast.date.ToString(timeformat, culture).ToLower(), HintAlign = AdaptiveTextAlign.Center }, new AdaptiveImage() { HintRemoveMargin = true, Source = wm.GetWeatherIconURI(hrforecast.icon) }, new AdaptiveText() { Text = (Settings.IsFahrenheit ? Math.Round(double.Parse(hrforecast.high_f)).ToString() : Math.Round(double.Parse(hrforecast.high_c)).ToString()) + "º", HintAlign = AdaptiveTextAlign.Center }, } }; forecastGroup.Children.Add(subgroup); } content.Children.Add(forecastGroup); } else if (forecastTileType == ForecastTileType.Large) { // Condition + 5-hr forecast var forecastGroup = new AdaptiveGroup(); string timeformat = culture.DateTimeFormat.ShortTimePattern.Contains("H") ? "HH" : "ht"; string poplabel = (weather.source.Equals(WeatherAPI.OpenWeatherMap) || weather.source.Equals(WeatherAPI.MetNo)) ? App.ResLoader.GetString("Cloudiness_Label") : App.ResLoader.GetString("Precipitation_Label"); // Cloudiness or Precipitation int forecastLength = LARGE_FORECAST_LENGTH; if (weather.hr_forecast.Length < forecastLength) { forecastLength = weather.hr_forecast.Length; } var conditionGroup = new AdaptiveGroup() { Children = { new AdaptiveSubgroup() { HintWeight = 25, HintTextStacking = AdaptiveSubgroupTextStacking.Center, Children = { new AdaptiveImage() { Source = wm.GetWeatherIconURI(weather.condition.icon) } } }, new AdaptiveSubgroup() { HintWeight = 75, Children = { new AdaptiveText() { Text = (String.IsNullOrWhiteSpace(weather.condition.weather)) ? "---" : weather.condition.weather, HintStyle = AdaptiveTextStyle.Caption }, new AdaptiveText() { Text = string.Format("{0}: {1}", App.ResLoader.GetString("Temp_Label"), (Settings.IsFahrenheit ? Math.Round(weather.condition.temp_f) : Math.Round(weather.condition.temp_c)) + "º"), HintStyle = AdaptiveTextStyle.Caption }, new AdaptiveText() { Text = string.Format("{0}: {1}", App.ResLoader.GetString("FeelsLike_Label"), (Settings.IsFahrenheit ? Math.Round(weather.condition.feelslike_f) : Math.Round(weather.condition.feelslike_c)) + "º"), HintStyle = AdaptiveTextStyle.CaptionSubtle }, new AdaptiveText() { Text = string.Format("{0}: {1}", App.ResLoader.GetString("Wind_Label"), Settings.IsFahrenheit ? Math.Round(weather.condition.wind_mph) + " mph" : Math.Round(weather.condition.wind_kph) + " kph"), HintStyle = AdaptiveTextStyle.CaptionSubtle }, new AdaptiveText() { Text = weather.precipitation != null ? string.Format("{0}: {1}", poplabel, weather.precipitation.pop + "%") : "", HintStyle = AdaptiveTextStyle.CaptionSubtle } } } } }; var text = new AdaptiveText() { Text = "" }; for (int i = 0; i < forecastLength; i++) { var hrforecast = weather.hr_forecast[i]; var subgroup = new AdaptiveSubgroup() { HintWeight = 1, Children = { new AdaptiveText() { Text = hrforecast.date.ToString(timeformat, culture).ToLower(), HintAlign = AdaptiveTextAlign.Center }, new AdaptiveImage() { HintRemoveMargin = true, Source = wm.GetWeatherIconURI(hrforecast.icon) }, new AdaptiveText() { Text = (Settings.IsFahrenheit ? Math.Round(double.Parse(hrforecast.high_f)).ToString() : Math.Round(double.Parse(hrforecast.high_c)).ToString()) + "º", HintAlign = AdaptiveTextAlign.Center }, } }; forecastGroup.Children.Add(subgroup); } content.Children.Add(conditionGroup); content.Children.Add(text); content.Children.Add(forecastGroup); } return(content); }
private static void AssertAdaptiveText(string expectedAdaptiveTextXml, AdaptiveText text) { AssertBindingGenericPayload("<binding template='ToastGeneric'>" + expectedAdaptiveTextXml + "</binding>", new ToastBindingGeneric() { Children = { text } }); }
private static void AssertAdaptiveTextPropertyValue(string expectedPropertyName, string expectedPropertyValue, AdaptiveText text) { AssertAdaptiveChild($"<text {expectedPropertyName}='{expectedPropertyValue}'/>", text); }