public void NumberInput()
        {
            AdaptiveNumberInput numberInput = new AdaptiveNumberInput
            {
                Max         = 50,
                Min         = 40,
                Placeholder = "Placeholder",
                Value       = 42,
                Height      = HeightType.Stretch,
                Id          = "NumberInputId",
                IsVisible   = false,
                Separator   = true,
                Spacing     = Spacing.Medium,
            };

            ValidateBaseElementProperties(numberInput, "NumberInputId", false, true, Spacing.Medium, HeightType.Stretch);

            Assert.AreEqual(50, numberInput.Max);
            Assert.AreEqual(40, numberInput.Min);
            Assert.AreEqual("Placeholder", numberInput.Placeholder);
            Assert.AreEqual(42, numberInput.Value);

            var jsonString = numberInput.ToJson().ToString();

            Assert.AreEqual("{\"height\":\"Stretch\",\"id\":\"NumberInputId\",\"isRequired\":false,\"isVisible\":false,\"max\":50,\"min\":40,\"placeholder\":\"Placeholder\",\"separator\":true,\"spacing\":\"medium\",\"type\":\"Input.Number\",\"value\":42}", jsonString);
        }
        protected static Element NumberInputRender(AdaptiveNumberInput input, ElementAdaptiveRenderContext context)
        {
            var uiNumberInput = new Input(InputType.Number)
                                .SetAttr("name", input.Id)
                                .AddClass("ac-input")
                                .AddClass("ac-numberInput")
                                .SetAttr("type", "number")
                                .Style("width", "100%");

            if (!double.IsNaN(input.Min))
            {
                uiNumberInput.SetAttr("min", input.Min.ToString());
            }

            if (!double.IsNaN(input.Max))
            {
                uiNumberInput.SetAttr("max", input.Max.ToString());
            }

            if (!double.IsNaN(input.Value))
            {
                uiNumberInput.SetAttr("value", input.Value.ToString());
            }

            return(uiNumberInput);
        }
 public static FrameworkElement Render(AdaptiveNumberInput input, AdaptiveRenderContext context)
 {
     if (context.Config.SupportsInteractivity)
     {
         var textBox = new TextBox()
         {
             Text = input.Value.ToString()
         };
         textBox.SetPlaceholder(input.Placeholder);
         textBox.Style = context.GetStyle($"Adaptive.Input.Text.Number");
         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 != double.NaN)
         {
             textBlock       = AdaptiveTypedElementConverter.CreateElement <AdaptiveTextBlock>();
             textBlock.Text  = input.Value.ToString();
             textBlock.Color = AdaptiveTextColor.Accent;
             textBlock.Wrap  = true;
             container.Items.Add(textBlock);
         }
         return(context.Render(container));
     }
 }
Ejemplo n.º 4
0
        public static FrameworkElement Render(AdaptiveNumberInput input, AdaptiveRenderContext context)
        {
            if (context.Config.SupportsInteractivity)
            {
                IntegerUpDown numberPicker = new IntegerUpDown();
                // numberPicker.ShowButtonSpinner = true;

                if (!Double.IsNaN(input.Value))
                {
                    numberPicker.Value = Convert.ToInt32(input.Value);
                }

                if (!Double.IsNaN(input.Min))
                {
                    numberPicker.Minimum = Convert.ToInt32(input.Min);
                }

                if (!Double.IsNaN(input.Max))
                {
                    numberPicker.Minimum = Convert.ToInt32(input.Max);
                }

                numberPicker.Watermark   = input.Placeholder;
                numberPicker.Style       = context.GetStyle("Adaptive.Input.Number");
                numberPicker.DataContext = input;
                context.InputBindings.Add(input.Id, () => numberPicker.Value?.ToString());
                return(numberPicker);
            }
            else
            {
                var textBlock = AdaptiveTypedElementConverter.CreateElement <AdaptiveTextBlock>();
                textBlock.Text = XamlUtilities.GetFallbackText(input) ?? input.Placeholder;
                return(context.Render(textBlock));
            }
        }
Ejemplo n.º 5
0
        static async public Task <Attachment> CreatePriceAssignationCard(Models.Cart cart, IPrestashopApi prestashopApi)
        {
            var card = CreateCardFromJson("prizeAssignationCard");

            var container = card.Body[3] as AdaptiveContainer;

            int index = 0;

            foreach (OrderLine line in cart.OrderLine)
            {
                var product = (await prestashopApi.GetProductById(line.ProductId)).First();

                var productTitle = new AdaptiveTextBlock
                {
                    Text   = "**" + product.GetNameByLanguage(Languages.English) + "**",
                    Weight = AdaptiveTextWeight.Bolder,
                    Wrap   = true
                };

                var columnSet = new AdaptiveColumnSet();

                var column = new AdaptiveColumn
                {
                    Width = AdaptiveColumnWidth.Stretch
                };

                var reference = new AdaptiveTextBlock
                {
                    Text = product.Reference,
                    Wrap = true
                };

                column.Items.Add(reference);

                var columnInput = new AdaptiveColumn
                {
                    Width = AdaptiveColumnWidth.Auto
                };

                var input = new AdaptiveNumberInput
                {
                    Id          = "InputCount" + index,
                    Placeholder = "Price"
                };
                column.Items.Add(input);
                columnSet.Columns.Add(column);
                columnSet.Columns.Add(columnInput);
                container.Items.Add(columnSet);

                index++;
            }

            return(new Attachment()
            {
                Content = JsonConvert.DeserializeObject(JsonConvert.SerializeObject(card)),
                ContentType = "application/vnd.microsoft.card.adaptive"
            });
        }
Ejemplo n.º 6
0
        public AdaptiveNumberInput GetadaptiveNumber(string IdInput, string PlaceholderInput)
        {
            var NumberInput = new AdaptiveNumberInput()
            {
                Id          = IdInput,
                Placeholder = PlaceholderInput,
                Min         = 0,
                Value       = 0
            };

            return(NumberInput);
        }
Ejemplo n.º 7
0
        public static FrameworkElement Render(AdaptiveNumberInput input, AdaptiveRenderContext context)
        {
            var textBox = new TextBox()
            {
                Text = input.Value.ToString()
            };

            textBox.SetPlaceholder(input.Placeholder);
            textBox.Style = context.GetStyle($"Adaptive.Input.Text.Number");
            textBox.SetContext(input);
            context.InputBindings.Add(input.Id, () => textBox.Text);
            return(textBox);
        }
Ejemplo n.º 8
0
 public virtual void Visit(AdaptiveNumberInput inputNumber)
 {
 }
Ejemplo n.º 9
0
 private void SetValue(AdaptiveNumberInput numberInput, object value)
 {
     numberInput.Value = Convert.ToDouble(value);
 }