private void InitializeFamiliarizeListView() { int familiarizeDictionaryCount = familiarizeDictionary.Count; // Setting the height of the list view to match the amount of buttons i will add to it. RectTransform listViewVerticalLayoutGroup = UIManager.s_instance.listViewContentParent; Vector2 newWidthHeight = listViewVerticalLayoutGroup.sizeDelta; newWidthHeight.y = defaultListViewButton.GetComponent <RectTransform>().sizeDelta.y *familiarizeDictionaryCount; listViewVerticalLayoutGroup.sizeDelta = newWidthHeight; // Creating new buttons out the dictionary and stuffing them in the vertical layout group foreach (KeyValuePair <string, FamiliarizeDictionaryEntry> entry in familiarizeDictionary) { KeyValuePair <string, FamiliarizeDictionaryEntry> appendedEntry = entry; ListViewButton newListViewButton = Instantiate(defaultListViewButton).GetComponent <ListViewButton>(); newListViewButton.childText.text = entry.Value.uiText.listViewText; newListViewButton.key = appendedEntry.Key; FamiliarizeDictionaryEntry appendedValue = appendedEntry.Value; appendedValue.button = newListViewButton; newListViewButton.transform.SetParent(listViewVerticalLayoutGroup, false); // Setting the individual keys is called on the Start function of the list items. } }
public void GoToStep(int newStepIndex) { if (hasFinishedModule) { return; } ResetSceneObjects(); currentStepIndex = newStepIndex; // Update UI Text UIManager.s_instance.UpdateDescriptionViewText(acquireStepList[currentStepIndex].uiText.descriptionViewText); // Update scene StartCoroutine(InitializeNextStep()); // Get our new selected list view button, change its text white, set it interactable, and check its checkbox. ListViewButton newListViewButtonSelection = UIManager.s_instance.listViewContentParent.GetChild(currentStepIndex).GetComponent <ListViewButton>(); newListViewButtonSelection.GetComponent <Button>().interactable = true; newListViewButtonSelection.childText.color = Color.white; newListViewButtonSelection.checkBox.isOn = true; // Highlight button and check if the "Next" button should appear or disappear. ToggleListViewButtonHighLight(currentStepIndex, true); UpdateNextButton(); }
private ListViewButton CreateButton(string content, string arguments, string imageUri, ActivationType activationType, Scenario scenarioType) { // Auto-generate content if (activationType == ActivationType.System && content.Length == 0) { // Case-sensitive switch (arguments) { case "snooze": content = "Snooze"; break; case "dismiss": content = "Dismiss"; break; } } ListViewButton b = new ListViewButton() { Content = content }; b.Action = delegate { TriggerActivation(arguments, activationType); }; return(b); }
private void AddButton(ListViewButton el) { if (_buttons.Count == 0) { _buttons.Add(el); } else { _buttons.Insert(_buttons.Count - 1, el); } }
public void GoToStep(int stepIndex) { ResetInputsAndObjects(); currentStepIndex = stepIndex; // Update scene StartCoroutine(InitializeNextStep()); // Get our new selected list view button, change its text white, set it interactable, and check its checkbox. ListViewButton newListViewButtonSelection = UIManager.s_instance.listViewContentParent.GetChild(currentStepIndex).GetComponent <ListViewButton>(); newListViewButtonSelection.childText.color = Color.white; newListViewButtonSelection.checkBox.isOn = true; UIManager.s_instance.UpdateDescriptionViewText(/*"Hint: " +*/ practiceStepList[stepIndex].uiText.descriptionViewText); ToggleListViewItemHighLight(stepIndex, true); }
private void InitializeAcquireListView() { int acquireListCount = acquireStepList.Count; // Setting the height of the list view to match the amount of buttons I will add to it. RectTransform listViewVerticalLayoutGroup = UIManager.s_instance.listViewContentParent; Vector2 newWidthHeight = listViewVerticalLayoutGroup.sizeDelta; //newWidthHeight.x = defaultListViewButton.GetComponent<RectTransform>().sizeDelta.x; newWidthHeight.y = UIManager.s_instance.defaultListViewButton.GetComponent <RectTransform>().sizeDelta.y *acquireListCount; listViewVerticalLayoutGroup.sizeDelta = newWidthHeight; // Creating new buttons out the dictionary and stuffing them in the vertical layout group for (int i = 0; i < acquireListCount; i++) { // Index 0 is special because it is the title for our list view if (i == 0) { ListViewButton newListViewSectionTitle = Instantiate(UIManager.s_instance.defaultListViewModuleTitle).GetComponent <ListViewButton>(); newListViewSectionTitle.listIndex = 0; newListViewSectionTitle.transform.SetParent(listViewVerticalLayoutGroup, false); newListViewSectionTitle.childText.text = acquireStepList[0].uiText.listViewText; continue; } StepsListEntry temp = acquireStepList[i]; if (temp.isSectionParent) { ListViewButton newListViewSectionTitle = Instantiate(defaultListViewSectionTitle).GetComponent <ListViewButton>(); newListViewSectionTitle.listIndex = i; newListViewSectionTitle.transform.SetParent(listViewVerticalLayoutGroup, false); newListViewSectionTitle.childText.text = /*contextIndentation + contextIndentation +*/ temp.uiText.listViewText; } else { ListViewButton newListViewButton = Instantiate(UIManager.s_instance.defaultListViewButton).GetComponent <ListViewButton>(); newListViewButton.listIndex = i; newListViewButton.transform.SetParent(listViewVerticalLayoutGroup, false); newListViewButton.childText.text = temp.uiText.listViewText; newListViewButton.childText.color = Color.grey; newListViewButton.GetComponent <Button>().interactable = false; } } }
// Page Object // ListViewButton public void ClickListViewButton() { ListViewButton.Click(); }
private void InitializeContent(IToast toastContent) { _currContent = toastContent; HasContent = false; TextBlockTitle.Text = ""; TextBlockTitle.MaxLines = 3; TextBlockTitle.TextWrapping = TextWrapping.WrapWholeWords; TextBlockBody.Text = ""; TextBlockBody.MaxLines = 3; TextBlockBody.TextWrapping = TextWrapping.WrapWholeWords; TextBlockBody2.Visibility = Visibility.Collapsed; TextBlockBody2.MaxLines = 3; TextBlockBody2.TextWrapping = TextWrapping.WrapWholeWords; StackPanelInlineImages.Children.Clear(); DefaultImageAppLogo.Visibility = Visibility.Visible; ImageAppLogo.Visibility = Visibility.Collapsed; CircleImageAppLogo.Visibility = Visibility.Collapsed; _elementsWithIds = new Dictionary <string, FrameworkElement>(); _currLaunch = ""; _currActivationType = ActivationType.Foreground; _buttons.Clear(); _buttons.Add(CreateButton("Launch", toastContent?.Launch, null, toastContent != null ? toastContent.ActivationType.GetValueOrDefault(ActivationType.Foreground) : ActivationType.Foreground, Scenario.Default)); if (toastContent != null) { _currLaunch = toastContent.Launch; _currActivationType = toastContent.ActivationType.GetValueOrDefault(ActivationType.Foreground); if (toastContent.Visual != null) { var visual = toastContent.Visual; AdaptiveBinding binding; if (toastContent.Context == NotificationType.Toast) { binding = visual.Bindings.FirstOrDefault(); } else { binding = visual.Bindings.FirstOrDefault(i => i.Template == Model.Enums.Template.ToastGeneric); } if (binding != null) { HasContent = true; var container = binding.Container; var texts = container.Children.OfType <AdaptiveTextField>().ToList(); List <AdaptiveImage> appLogoOverrides = null; List <AdaptiveImage> heroImages = new List <AdaptiveImage>(); var attributionTexts = container.Children.OfType <AdaptiveTextField>().Where(i => i.Placement == Model.Enums.TextPlacement.Attribution).ToList(); appLogoOverrides = new List <AdaptiveImage>(); // First pull out images with placements and attribution text for (int i = 0; i < container.Children.Count; i++) { var child = container.Children[i]; if (child is AdaptiveImage) { AdaptiveImage img = child as AdaptiveImage; switch (img.Placement) { case Model.Enums.Placement.AppLogoOverride: appLogoOverrides.Add(img); container.RemoveChildAt(i); i--; break; case Model.Enums.Placement.Hero: heroImages.Add(img); container.RemoveChildAt(i); i--; break; } } else if (child is AdaptiveTextField) { AdaptiveTextField txt = child as AdaptiveTextField; if (txt.Placement != Model.Enums.TextPlacement.Inline) { container.RemoveChildAt(i); i--; } } } // Assign hero if (heroImages.Any()) { ImageHero.Visibility = Visibility.Visible; ImageHeroBrush.ImageSource = ImageHelper.GetBitmap(heroImages.First().Src); } else { ImageHero.Visibility = Visibility.Collapsed; ImageHeroBrush.ImageSource = null; } texts = new List <AdaptiveTextField>(); // Pull out all texts for (int i = 0; i < container.Children.Count; i++) { var child = container.Children[i]; if (child is AdaptiveTextField && (child as AdaptiveTextField).Placement == Model.Enums.TextPlacement.Inline) { texts.Add(child as AdaptiveTextField); container.RemoveChildAt(i); i--; } } var titleText = texts.ElementAtOrDefault(0); if (titleText != null) { TextBlockTitle.Text = titleText.Text; var bodyTextLine1 = texts.ElementAtOrDefault(1); if (bodyTextLine1 != null) { TextBlockBody.Text = bodyTextLine1.Text; var bodyTextLine2 = texts.ElementAtOrDefault(2); if (bodyTextLine2 != null) { TextBlockBody2.Text = bodyTextLine2.Text; TextBlockBody2.Visibility = Visibility.Visible; } TextBlockBody.Visibility = Visibility.Visible; } else { TextBlockBody.Visibility = Visibility.Collapsed; } } else { TextBlockTitle.Text = Properties.DisplayName; TextBlockBody.Text = "New notification"; TextBlockBody.Visibility = Visibility.Visible; } var images = container.Children.OfType <AdaptiveImage>().ToList(); if (appLogoOverrides == null) { appLogoOverrides = images.Where(i => i.Placement == Model.Enums.Placement.AppLogoOverride).ToList(); } var appLogoOverride = appLogoOverrides.FirstOrDefault(); if (appLogoOverride != null) { DefaultImageAppLogo.Visibility = Visibility.Collapsed; var source = ImageHelper.GetBitmap(appLogoOverride.Src); if (appLogoOverride.HintCrop == Model.Enums.HintCrop.Circle) { CircleImageAppLogo.Source = source; CircleImageAppLogo.Visibility = Visibility.Visible; } else { ImageAppLogo.Source = source; ImageAppLogo.Visibility = Visibility.Visible; } } foreach (var image in images.Where(i => i.Placement == Model.Enums.Placement.Inline)) { var uiImage = new Image() { Source = ImageHelper.GetBitmap(image.Src), MaxHeight = 100, Stretch = Stretch.Uniform, HorizontalAlignment = HorizontalAlignment.Stretch, Margin = new Thickness(0, 0, 0, 6) }; StackPanelInlineImages.Children.Add(uiImage); } // Attribution if (toastContent.SupportedFeatures.RS1_Style_Toasts) { if (attributionTexts.Any()) { TextBlockAttributionSeparationDot.Visibility = Visibility.Visible; TextBlockAttributionSecondPart.Visibility = Visibility.Visible; TextBlockAttributionSecondPart.Text = attributionTexts.First().Text; } else { TextBlockAttributionSeparationDot.Visibility = Visibility.Collapsed; TextBlockAttributionSecondPart.Visibility = Visibility.Collapsed; } } } } if (toastContent.Actions != null) { var actions = toastContent.Actions; if (actions.HintSystemCommands == Model.Enums.HintSystemCommands.SnoozeAndDismiss) { //AddInput(CreateComboBox("systemSnoozeSelection", null, new Selection[] //{ // new Selection(NotificationType.Toast, CurrFeatureSet) // { // Content = "5 minutes", // Id = "5" // }, // new Selection(NotificationType.Toast, CurrFeatureSet) // { // Content = "9 minutes", // Id = "9" // }, // new Selection(NotificationType.Toast, CurrFeatureSet) // { // Content = "10 minutes", // Id = "10" // }, // new Selection(NotificationType.Toast, CurrFeatureSet) // { // Content = "1 hour", // Id = "60" // }, // new Selection(NotificationType.Toast, CurrFeatureSet) // { // Content = "4 hours", // Id = "240" // }, // new Selection(NotificationType.Toast, CurrFeatureSet) // { // Content = "1 day", // Id = "1440" // } //}, "9", true)); AddButton(CreateButton("Snooze", "snooze", null, ActivationType.System, toastContent.Scenario)); AddButton(CreateButton("Dismiss", "dismiss", null, ActivationType.System, toastContent.Scenario)); } else { List <Model.BaseElements.Action> actionElements = actions.ActionElements.ToList(); if (toastContent.SupportedFeatures.RS1_Style_Toasts) { actionElements.RemoveAll(i => i.Placement != Model.Enums.ActionPlacement.Inline); } // Initialize inputs foreach (var i in actions.Inputs) { ListViewButton button; switch (i.Type) { case Model.BaseElements.InputType.Text: button = new TextBoxButton(i); break; case Model.BaseElements.InputType.Selection: button = new SelectionButton(i); break; default: throw new NotImplementedException(); } AddButton(button); } // Initialize buttons foreach (var a in actionElements) { ListViewButton uiButton = CreateButton(a.Content, a.Arguments, a.ImageUri, a.ActivationType, toastContent.Scenario); //AssignId(uiButton, a.Id); //if (!a.HintVisible) // uiButton.Visibility = Visibility.Collapsed; AddButton(uiButton); } } } } ListViewButtons.SelectedIndex = 0; }