public void DateInput() { AdaptiveDateInput dateInput = new AdaptiveDateInput { ErrorMessage = "Date Input Error Message", Max = "2019-01-14", Min = "2017-01-14", Placeholder = "Placeholder", Height = HeightType.Stretch, Id = "DateInputId", IsRequired = true, IsVisible = false, Separator = true, Spacing = Spacing.Medium, Value = "2018-01-14", }; ValidateBaseElementProperties(dateInput, "DateInputId", false, true, Spacing.Medium, HeightType.Stretch); Assert.IsTrue(dateInput.IsRequired); Assert.AreEqual("Date Input Error Message", dateInput.ErrorMessage); Assert.AreEqual("2019-01-14", dateInput.Max); Assert.AreEqual("2017-01-14", dateInput.Min); Assert.AreEqual("Placeholder", dateInput.Placeholder); Assert.AreEqual("2018-01-14", dateInput.Value); var jsonString = dateInput.ToJson().ToString(); Assert.AreEqual("{\"errorMessage\":\"Date Input Error Message\",\"height\":\"Stretch\",\"id\":\"DateInputId\",\"isRequired\":true,\"isVisible\":false,\"max\":\"2019-01-14\",\"min\":\"2017-01-14\",\"placeholder\":\"Placeholder\",\"separator\":true,\"spacing\":\"medium\",\"type\":\"Input.Date\",\"value\":\"2018-01-14\"}", jsonString); }
public static FrameworkElement Render(AdaptiveDateInput input, AdaptiveRenderContext context) { if (context.Config.SupportsInteractivity) { var textBox = new TextBox() { Text = input.Value }; textBox.SetPlaceholder(input.Placeholder); textBox.Style = context.GetStyle($"Adaptive.Input.Text.Date"); textBox.SetContext(input); context.InputBindings.Add(input.Id, () => textBox.Text); return(textBox); } else { var container = AdaptiveTypedElementConverter.CreateElement <AdaptiveContainer>(); container.Spacing = input.Spacing; container.Separator = input.Separator; var textBlock = AdaptiveTypedElementConverter.CreateElement <AdaptiveTextBlock>(); textBlock.Text = XamlUtilities.GetFallbackText(input) ?? input.Placeholder; container.Items.Add(textBlock); if (input.Value != null) { textBlock = AdaptiveTypedElementConverter.CreateElement <AdaptiveTextBlock>(); textBlock.Text = input.Value; textBlock.Color = AdaptiveTextColor.Accent; textBlock.Wrap = true; container.Items.Add(textBlock); } return(context.Render(container)); } }
protected static HtmlTag DateInputRender(AdaptiveDateInput input, AdaptiveRendererContext context) { var uiDateInput = new HtmlTag("input") .Attr("name", input.Id) .Attr("type", "date") .AddClass("ac-input") .AddClass("ac-dateInput") .Style("width", "100%"); if (!string.IsNullOrEmpty(input.Value)) { uiDateInput.Attr("value", input.Value); } if (!string.IsNullOrEmpty(input.Min)) { uiDateInput.Attr("min", input.Min); } if (!string.IsNullOrEmpty(input.Max)) { uiDateInput.Attr("max", input.Max); } return(uiDateInput); }
public static FrameworkElement Render(AdaptiveDateInput input, AdaptiveRenderContext context) { if (context.Config.SupportsInteractivity) { var datePicker = new DatePicker(); datePicker.ToolTip = input.Placeholder; DateTime value; if (DateTime.TryParse(input.Value, out value)) { datePicker.SelectedDate = value; } DateTime minValue; if (DateTime.TryParse(input.Min, out minValue)) { datePicker.DisplayDateStart = minValue; } DateTime maxValue; if (DateTime.TryParse(input.Max, out maxValue)) { datePicker.DisplayDateEnd = maxValue; } datePicker.Style = context.GetStyle("Adaptive.Input.Date"); datePicker.DataContext = input; context.InputBindings.Add(input.Id, () => ToIso8601Date(datePicker.Text)); return(datePicker); } else { var textBlock = AdaptiveTypedElementConverter.CreateElement <AdaptiveTextBlock>(); textBlock.Text = XamlUtilities.GetFallbackText(input) ?? input.Placeholder; return(context.Render(textBlock)); } }
private async Task <AdaptiveCard> CreateDateTimeSelectorCard() { var card = new AdaptiveCard("1.0"); card.Body.Add(new AdaptiveTextBlock { Text = "Please select a date you would like to know about", Size = AdaptiveTextSize.Large, Weight = AdaptiveTextWeight.Lighter, }); var input = new AdaptiveDateInput { Id = "Text", Placeholder = "Select Date" }; card.Body.Add(input); card.Actions.Add(new AdaptiveSubmitAction { Title = "Submit", Data = new { input.Value } }); return(await Task.FromResult(card)); }
static AdaptiveCard GetDateAdaptiveCard(DateTime dateTime) { string json = System.IO.File.ReadAllText(@"Resources\\carBookingDate.json"); var card = AdaptiveCards.AdaptiveCard.FromJson(json).Card; AdaptiveContainer adaptiveContainer = (AdaptiveContainer)card.Body[1]; AdaptiveDateInput adaptiveDateInput = (AdaptiveDateInput)adaptiveContainer.Items[0]; adaptiveDateInput.Value = dateTime.ToString("yyyy-MM-dd"); return(card); }
public static FrameworkElement Render(AdaptiveDateInput input, AdaptiveRenderContext context) { var textBox = new TextBox() { Text = input.Value }; textBox.SetPlaceholder(input.Placeholder); textBox.Style = context.GetStyle($"Adaptive.Input.Text.Date"); textBox.SetContext(input); context.InputBindings.Add(input.Id, () => textBox.Text); return(textBox); }
private void SetValue(AdaptiveDateInput dataInput, object value) { if (value is DateTime) { dataInput.Value = ((DateTime)value).ToString("yyyy-MM-dd"); } if (value is string) { DateTime date; if (DateTime.TryParse(value as string, out date)) { dataInput.Value = date.ToString("yyyy-MM-dd"); } } }
public MainPage() { this.InitializeComponent(); AdaptiveCard card = new AdaptiveCard(); card.Body.Add(new AdaptiveTextBlock() { Text = "Hello", Size = AdaptiveTextSize.ExtraLarge }); card.Body.Add(new AdaptiveImage() { Url = new Uri("http://adaptivecards.io/content/cats/1.png") }); var datePicker = new AdaptiveDateInput() { Id = "123", Placeholder = "123", Value = "2017-09-20" }; card.Body.Add(datePicker); // serialize the card to JSON string json = card.ToJson(); var renderer = new AdaptiveCards.Rendering.Uwp.AdaptiveCardRenderer(); var cardNew = AdaptiveCards.Rendering.Uwp.AdaptiveCard.FromJsonString(json); var renderedAdaptiveCard = renderer.RenderAdaptiveCard(cardNew.AdaptiveCard); if (renderedAdaptiveCard.FrameworkElement != null) { myGrid.Children.Add(renderedAdaptiveCard.FrameworkElement); } }
public static FrameworkElement Render(AdaptiveDateInput input, AdaptiveRenderContext context) { if (!context.Config.SupportsInteractivity) { AdaptiveTextBlock textBlock = AdaptiveTypedElementConverter.CreateElement <AdaptiveTextBlock>(); textBlock.Text = XamlUtilities.GetFallbackText(input) ?? input.Placeholder; return(context.Render(textBlock)); } DatePicker datePicker = new DatePicker { DataContext = input, ToolTip = input.Placeholder, Style = context.GetStyle("Adaptive.Input.Date") }; if (DateTime.TryParse(input.Value, out DateTime value)) { datePicker.SelectedDate = value; } if (DateTime.TryParse(input.Min, out DateTime minValue)) { datePicker.DisplayDateStart = minValue; } if (DateTime.TryParse(input.Max, out DateTime maxValue)) { datePicker.DisplayDateEnd = maxValue; } context.InputBindings.Add(input.Id, () => datePicker.SelectedDate?.ToString("yyyy-MM-dd") ?? ""); return(datePicker); }
public virtual void Visit(AdaptiveDateInput inputDate) { }
private AdaptiveCard SetCard() { AdaptiveCard _card = new AdaptiveCard("1.0"); var _container = new AdaptiveContainer(); var colum = new AdaptiveColumnSet(); var _columnImage = new AdaptiveColumn() { Width = AdaptiveColumnWidth.Auto }; _columnImage.Items.Add(new AdaptiveImage() { Url = new Uri(this.UrlImage), Size = AdaptiveImageSize.Small, Style = AdaptiveImageStyle.Person, AltText = "Bootty" }); var _columnContent = new AdaptiveColumn() { Width = AdaptiveColumnWidth.Stretch }; _columnContent.Items.Add(new AdaptiveTextBlock() { Text = "Booty", Size = AdaptiveTextSize.Medium, Weight = AdaptiveTextWeight.Default, Color = AdaptiveTextColor.Default, Wrap = true, Spacing = AdaptiveSpacing.Default }); _columnContent.Items.Add(new AdaptiveTextBlock() { Text = DateTime.Now.ToString(), Size = AdaptiveTextSize.Small, Color = AdaptiveTextColor.Default, Wrap = true, IsSubtle = true, Spacing = AdaptiveSpacing.None }); var _textMessage = new AdaptiveTextBlock() { Text = this.Title, Size = AdaptiveTextSize.Medium, Color = AdaptiveTextColor.Default, Weight = AdaptiveTextWeight.Bolder, Wrap = true, IsSubtle = false }; var _textMessage2 = new AdaptiveTextBlock() { Text = this.Description, Size = AdaptiveTextSize.Small, Color = AdaptiveTextColor.Default, Weight = AdaptiveTextWeight.Default, Wrap = true, IsSubtle = false }; colum.Columns.Add(_columnImage); colum.Columns.Add(_columnContent); _container.Items.Add(colum); _card.Body.Add(_container); _card.Body.Add(_textMessage); _card.Body.Add(_textMessage2); //Form var _texDataSubtitle = new AdaptiveTextBlock() { Text = "Tus Datos", Size = AdaptiveTextSize.Medium, Color = AdaptiveTextColor.Default, Weight = AdaptiveTextWeight.Bolder, HorizontalAlignment = AdaptiveHorizontalAlignment.Left }; var _textTitleName = new AdaptiveTextBlock() { Text = "Tú Nombre", Size = AdaptiveTextSize.Small, Color = AdaptiveTextColor.Default, Weight = AdaptiveTextWeight.Default }; var _textName = new AdaptiveTextInput() { Id = "UserName", Placeholder = "Apellido, Nombre" }; var _textTitleEmail = new AdaptiveTextBlock() { Text = "Dirección de correo", Size = AdaptiveTextSize.Small, Color = AdaptiveTextColor.Default, Weight = AdaptiveTextWeight.Default }; var _textEmail = new AdaptiveTextInput() { Id = "Email", Placeholder = "correo electronico" }; var _texDatesSubtitle = new AdaptiveTextBlock() { Text = "Fechas", Size = AdaptiveTextSize.Medium, Color = AdaptiveTextColor.Default, Weight = AdaptiveTextWeight.Bolder, HorizontalAlignment = AdaptiveHorizontalAlignment.Left }; var _textTitleDeparture = new AdaptiveTextBlock() { Text = "Fecha de salida", Size = AdaptiveTextSize.Small, Color = AdaptiveTextColor.Default, Weight = AdaptiveTextWeight.Default }; var _textDeparture = new AdaptiveDateInput() { Id = "Departure" }; var _textTitleArrival = new AdaptiveTextBlock() { Text = "Fecha de regreso", Size = AdaptiveTextSize.Small, Color = AdaptiveTextColor.Default, Weight = AdaptiveTextWeight.Default }; var _textArrival = new AdaptiveDateInput() { Id = "Arrival" }; var _texOptionsSubtitle = new AdaptiveTextBlock() { Text = "Tipo de viaje", Size = AdaptiveTextSize.Normal, Color = AdaptiveTextColor.Default, Weight = AdaptiveTextWeight.Bolder, HorizontalAlignment = AdaptiveHorizontalAlignment.Left }; var _textTrasportOpciones = new AdaptiveTextBlock() { Text = "Tipo de transporte", Size = AdaptiveTextSize.Medium, Color = AdaptiveTextColor.Default, Weight = AdaptiveTextWeight.Default }; //traport var _transportChoice = new AdaptiveChoiceSetInput(); _transportChoice.Id = "TransporChoice"; _transportChoice.Value = "bus"; _transportChoice.Style = AdaptiveChoiceInputStyle.Expanded; _transportChoice.Choices.Add(new AdaptiveChoice() { Title = "Omnibus", Value = "Omnibus" }); _transportChoice.Choices.Add(new AdaptiveChoice() { Title = "Avion", Value = "Avion" }); var _textClassOpciones = new AdaptiveTextBlock() { Text = "Clase", Size = AdaptiveTextSize.Medium, Color = AdaptiveTextColor.Default, Weight = AdaptiveTextWeight.Default }; //traport var _classChoice = new AdaptiveChoiceSetInput(); _classChoice.Id = "ClassChoice"; _classChoice.Value = "Economica"; _classChoice.Style = AdaptiveChoiceInputStyle.Expanded; _classChoice.Choices.Add(new AdaptiveChoice() { Title = "Economica", Value = "Economica" }); _classChoice.Choices.Add(new AdaptiveChoice() { Title = "Primera", Value = "Primera" }); var _textCashOpciones = new AdaptiveTextBlock() { Text = "¿Forma de Pago?", Size = AdaptiveTextSize.Medium, Color = AdaptiveTextColor.Default, Weight = AdaptiveTextWeight.Default }; //traport var _cashChoice = new AdaptiveChoiceSetInput(); _cashChoice.Id = "CashChoice"; _cashChoice.Value = "Efectivo"; _cashChoice.Choices.Add(new AdaptiveChoice() { Title = "Efectivo", Value = "Efectivo" }); _cashChoice.Choices.Add(new AdaptiveChoice() { Title = "Tarjeta de Credito", Value = "Tarjeta de Credito" }); var _checkConditions = new AdaptiveToggleInput() { Id = "checkConditions", Value = "accept", Title = "Acepto los terminos y condiciones." }; var _submitButton = new AdaptiveSubmitAction() { Title = "Contratar", DataJson = JsonConvert.SerializeObject(new JsonDataAux() { From = TypeCards.FORM.ToString(), Action = "MDZFORM" }) }; _card.Body.Add(_texDataSubtitle); _card.Body.Add(_textTitleName); _card.Body.Add(_textName); _card.Body.Add(_textTitleEmail); _card.Body.Add(_textEmail); _card.Body.Add(_texDatesSubtitle); _card.Body.Add(_textTitleDeparture); _card.Body.Add(_textDeparture); _card.Body.Add(_textTitleArrival); _card.Body.Add(_textArrival); _card.Body.Add(_texOptionsSubtitle); _card.Body.Add(_textTrasportOpciones); _card.Body.Add(_transportChoice); _card.Body.Add(_textClassOpciones); _card.Body.Add(_classChoice); _card.Body.Add(_textCashOpciones); _card.Body.Add(_cashChoice); _card.Body.Add(_checkConditions); _card.Actions.Add(_submitButton); return(_card); }