Пример #1
0
        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);
        }
Пример #2
0
        public static FrameworkElement Render(MyCustomRating rating, AdaptiveRenderContext context)
        {
            var textBlock = new AdaptiveTextBlock
            {
                Size  = rating.Size,
                Color = rating.Color
            };

            for (int i = 0; i < rating.Rating; i++)
            {
                textBlock.Text += "\u2605";
            }
            textBlock.Text += $" ({rating.Rating})";
            return(context.Render(textBlock));
        }
Пример #3
0
        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);
        }