public void TimeInput() { AdaptiveTimeInput timeInput = new AdaptiveTimeInput { Max = "05:00", Min = "01:00", Placeholder = "Placeholder", Value = "02:00", Height = HeightType.Stretch, Id = "TimeInputId", IsVisible = false, Separator = true, Spacing = Spacing.Medium, }; ValidateBaseElementProperties(timeInput, "TimeInputId", false, true, Spacing.Medium, HeightType.Stretch); Assert.IsFalse(timeInput.IsRequired); Assert.IsTrue(timeInput.ErrorMessage.Length == 0); Assert.AreEqual("05:00", timeInput.Max); Assert.AreEqual("01:00", timeInput.Min); Assert.AreEqual("Placeholder", timeInput.Placeholder); Assert.AreEqual("02:00", timeInput.Value); var jsonString = timeInput.ToJson().ToString(); }
public static FrameworkElement Render(AdaptiveTimeInput input, AdaptiveRenderContext context) { if (!context.Config.SupportsInteractivity) { AdaptiveTextBlock textBlock = AdaptiveTypedElementConverter.CreateElement <AdaptiveTextBlock>(); textBlock.Text = XamlUtilities.GetFallbackText(input) ?? input.Placeholder; return(context.Render(textBlock)); } TimePicker timePicker = new TimePicker { DataContext = input, ToolTip = input.Placeholder, Style = context.GetStyle("Adaptive.Input.Time"), Is24Hours = true }; if (DateTime.TryParse(input.Value, out DateTime value)) { timePicker.SelectedTime = value; } context.InputBindings.Add(input.Id, () => timePicker.SelectedTime?.ToString("HH:mm") ?? ""); return(timePicker); }
protected static HtmlTag TimeInputRender(AdaptiveTimeInput input, AdaptiveRendererContext context) { var uiTimeInput = new HtmlTag("input") .Attr("type", "time") .Attr("name", input.Id) .AddClass("ac-input") .AddClass("ac-timeInput") .Style("width", "100%"); if (!string.IsNullOrEmpty(input.Value)) { uiTimeInput.Attr("value", input.Value); } if (!string.IsNullOrEmpty(input.Min)) { uiTimeInput.Attr("min", input.Min); } if (!string.IsNullOrEmpty(input.Max)) { uiTimeInput.Attr("max", input.Max); } return(uiTimeInput); }
public static FrameworkElement Render(AdaptiveTimeInput 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.Time"); textBox.SetContext(input); context.InputBindings.Add(input.Id, () => textBox.Text); return(textBox); } else { AdaptiveContainer container = AdaptiveTypedElementConverter.CreateElement <AdaptiveContainer>(); container.Spacing = input.Spacing; container.Separator = input.Separator; AdaptiveTextBlock 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)); } }
public static FrameworkElement Render(AdaptiveTimeInput input, AdaptiveRenderContext context) { if (context.Config.SupportsInteractivity) { var timePicker = new TimePicker(); DateTime value; if (IsSupportedTimeFormat(input.Value) && DateTime.TryParse(input.Value, out value)) { timePicker.Value = value; } TimeSpan minValue; if (IsSupportedTimeFormat(input.Min) && TimeSpan.TryParse(input.Min, out minValue)) { timePicker.EndTime = minValue; } TimeSpan maxValue; if (IsSupportedTimeFormat(input.Max) && TimeSpan.TryParse(input.Max, out maxValue)) { timePicker.EndTime = maxValue; } timePicker.Watermark = input.Placeholder; timePicker.Style = context.GetStyle("Adaptive.Input.Time"); timePicker.DataContext = input; context.InputBindings.Add(input.Id, () => ToIso8601Time(timePicker.Text)); return(timePicker); } else { var textBlock = AdaptiveTypedElementConverter.CreateElement <AdaptiveTextBlock>(); textBlock.Text = XamlUtilities.GetFallbackText(input) ?? input.Placeholder; return(context.Render(textBlock)); } }
static AdaptiveCard GetTimeAdaptiveCard(DateTime dateTime) { string json = System.IO.File.ReadAllText(@"Resources\\carBookingTime.json"); var card = AdaptiveCards.AdaptiveCard.FromJson(json).Card; AdaptiveContainer adaptiveContainer = (AdaptiveContainer)card.Body[1]; AdaptiveTimeInput adaptiveTimeInput = (AdaptiveTimeInput)adaptiveContainer.Items[0]; adaptiveTimeInput.Value = dateTime.ToString("hh:mm"); return(card); }
public static FrameworkElement Render(AdaptiveTimeInput input, AdaptiveRenderContext context) { var textBox = new TextBox() { Text = input.Value }; textBox.SetPlaceholder(input.Placeholder); textBox.Style = context.GetStyle("Adaptive.Input.Text.Time"); textBox.SetContext(input); context.InputBindings.Add(input.Id, () => textBox.Text); return(textBox); }
private void SetValue(AdaptiveTimeInput timeInput, object value) { if (value is DateTime) { timeInput.Value = ((DateTime)value).ToString("HH:mm:ss"); } if (value is string) { DateTime time; if (DateTime.TryParse(value as string, out time)) { timeInput.Value = time.ToString("HH:mm:ss"); } } }
public virtual void Visit(AdaptiveTimeInput inputTime) { }