private void InitializeComponent()
 {
     this.LoadFromXaml(typeof(MainPage));
     itemQualquer = this.FindByName<Entry>("itemQualquer");
     lblContador = this.FindByName<Label>("lblContador");
     stpContador = this.FindByName<Stepper>("stpContador");
     sldContador = this.FindByName<Slider>("sldContador");
 }
Ejemplo n.º 2
0
        public IndividualListCell()
        {
            var itemName = new Label {
                YAlign = TextAlignment.Center,
                FontSize = 20,
                TextColor = Color.Black
            };
            itemName.SetBinding(Label.TextProperty, "ListDataItemName");

            itemQuantity = new Label {
               HorizontalOptions = LayoutOptions.CenterAndExpand,
                YAlign = TextAlignment.Center,
                TextColor = Color.Black,
                FontSize = 16
            };

            itemQuantity.SetBinding(Label.TextProperty, "itemQuantity");

            Stepper stepper = new Stepper {
                Minimum = 1.0,
                Maximum = 10.0,
                Increment = 1.0,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                VerticalOptions = LayoutOptions.CenterAndExpand
            };
            stepper.SetBinding(Stepper.ValueProperty, "itemQuantity");
            stepper.ValueChanged += OnStepperValueChanged;

            var addToBasketButton = new Button {
                Text = "Add to Basket",
                HorizontalOptions = LayoutOptions.CenterAndExpand
               // VerticalOptions = LayoutOptions.FillAndExpand,

            };
            addToBasketButton.Clicked += (sender, e) => {

                var item = (TapandGo.Data.ItemsListData)BindingContext;
                TapandGo.Database.Database.GetDatabase().TransferFromListToBasket(item.ItemId, item.ListDataItemName, item.itemQuantity, item.ListDataItemPrice, item.ListDataItemPicture, item.ListDataItemPriceString);

            };

            var itemImage = new Image {

            };
            itemImage.SetBinding(Image.SourceProperty, "ListDataItemPicture");

            var layout = new StackLayout {
                Padding = new Thickness(20, 0, 0, 0),
                Orientation = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.StartAndExpand,
                Children = {itemImage, itemName, itemQuantity, stepper}
            };

            View = layout;
        }
 private void InitializeComponent()
 {
     this.LoadFromXaml(typeof(ExamModeRandomConfigPage));
     Main = this.FindByName <StackLayout>("Main");
     TimeSwitch = this.FindByName <Switch>("TimeSwitch");
     TimeLabel = this.FindByName <Label>("TimeLabel");
     StackLayoutTime = this.FindByName <StackLayout>("StackLayoutTime");
     LabelTotalTime = this.FindByName <Label>("LabelTotalTime");
     LabelTimeLabel = this.FindByName <Label>("LabelTimeLabel");
     Stepper = this.FindByName <Stepper>("Stepper");
     LabelQuestionSelection = this.FindByName <Label>("LabelQuestionSelection");
     QuestionLabel = this.FindByName <Label>("QuestionLabel");
 }
 public StepperHandler(NativeComponentRenderer renderer, XF.Stepper stepperControl) : base(renderer, stepperControl)
 {
     StepperControl = stepperControl ?? throw new ArgumentNullException(nameof(stepperControl));
     StepperControl.ValueChanged += (s, e) =>
     {
         if (ValueChangedEventHandlerId != default)
         {
             renderer.Dispatcher.InvokeAsync(() => renderer.DispatchEventAsync(ValueChangedEventHandlerId, null, new ChangeEventArgs {
                 Value = StepperControl.Value
             }));
         }
     };
 }
Ejemplo n.º 5
0
        public static StackLayout GetSelectedOffsetStepper(FlexPie flexPie)
        {
            Label label = new Label();

            label.Text = "Selected Item Offset";

            label.VerticalOptions = LayoutOptions.FillAndExpand;
            label.HorizontalOptions = LayoutOptions.FillAndExpand;

            Label value = new Label();

            value.Text = "0.2";

            value.VerticalOptions = LayoutOptions.FillAndExpand;
            value.HorizontalOptions = LayoutOptions.FillAndExpand;

            StackLayout labelStack = new StackLayout();

            labelStack.Orientation = StackOrientation.Vertical;

            labelStack.Children.Add(label);
            labelStack.Children.Add(value);

            Stepper stepper = new Stepper();

            stepper.VerticalOptions = LayoutOptions.FillAndExpand;
            stepper.HorizontalOptions = LayoutOptions.FillAndExpand;

            stepper.Value = 0.2;
            stepper.Increment = .10;
            stepper.Minimum = 0;
            stepper.Maximum = .50;

            stepper.ValueChanged += (e, sender) =>
            {
                Stepper sentStepper = (Stepper)e;

                value.Text = String.Format("{0:F1}", sentStepper.Value);

                flexPie.SelectedItemOffset = sentStepper.Value;
            };

            StackLayout stack = new StackLayout();

            stack.Orientation = StackOrientation.Horizontal;

            stack.Children.Add(labelStack);
            stack.Children.Add(stepper);

            return stack;
        }
        public StepperDemoPage()
        {
            Label header = new Label
            {
                Text = "Stepper",
                Font = Font.BoldSystemFontOfSize(50),
                HorizontalOptions = LayoutOptions.Center
            };

            Stepper stepper = new Stepper
            {
                Minimum = 0,
                Maximum = 10,
                Increment = 0.1,
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions = LayoutOptions.CenterAndExpand
            };
            stepper.ValueChanged += OnStepperValueChanged;

            label = new Label
            {
                Text = "Stepper value is 0",
                Font = Font.SystemFontOfSize(NamedSize.Large),
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions = LayoutOptions.CenterAndExpand
            };

            // Accomodate iPhone status bar.
            this.Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5);

            // Build the page.
            this.Content = new StackLayout
            {
                Children = 
                {
                    header,
                    stepper,
                    label
                }
            };
        }
Ejemplo n.º 7
0
        public StepperDemoPage()
        {
            Label header = new Label
            {
                Text = "Stepper",
				FontSize = 50,
				FontAttributes = FontAttributes.Bold,
                HorizontalOptions = LayoutOptions.Center
            };

            Stepper stepper = new Stepper
            {
                Minimum = 0,
                Maximum = 10,
                Increment = 0.1,
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions = LayoutOptions.CenterAndExpand
            };
            stepper.ValueChanged += OnStepperValueChanged;

            label = new Label
            {
                Text = "Stepper value is 0",
				FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)),
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions = LayoutOptions.CenterAndExpand
            };

            // Build the page.
            this.Content = new StackLayout
            {
                Children = 
                {
                    header,
                    stepper,
                    label
                }
            };
        }
Ejemplo n.º 8
0
        public StepperHandler(NativeComponentRenderer renderer, XF.Stepper stepperControl) : base(renderer, stepperControl)
        {
            StepperControl = stepperControl ?? throw new ArgumentNullException(nameof(stepperControl));

            Initialize(renderer);
        }
Ejemplo n.º 9
0
		public ScaleRotate()
		{
			Label label = new Label
			{
				Text = "SCALE AND\nROTATE",
				HorizontalTextAlignment = TextAlignment.Center,
				HorizontalOptions = LayoutOptions.Center,
				VerticalOptions = LayoutOptions.CenterAndExpand
			};

			// Label and Slider for Scale property.
			Label scaleSliderValue = new Label
			{
				VerticalTextAlignment = TextAlignment.Center
			};
			Grid.SetRow(scaleSliderValue, 0);
			Grid.SetColumn(scaleSliderValue, 0);

			Slider scaleSlider = new Slider
			{
				Maximum = 10
			};
			Grid.SetRow(scaleSlider, 0);
			Grid.SetColumn(scaleSlider, 1);

			// Set Bindings.
			scaleSliderValue.BindingContext = scaleSlider;
			scaleSliderValue.SetBinding(Label.TextProperty, 
				new Binding("Value", BindingMode.OneWay, null, null, "Scale = {0:F1}"));

			scaleSlider.BindingContext = label;
			scaleSlider.SetBinding(Slider.ValueProperty,
				new Binding("Scale", BindingMode.TwoWay));

			// Label and Slider for Rotation property.
			Label rotationSliderValue = new Label
			{
				VerticalTextAlignment = TextAlignment.Center
			};
			Grid.SetRow(rotationSliderValue, 1);
			Grid.SetColumn(rotationSliderValue, 0);

			Slider rotationSlider = new Slider
			{
				Maximum = 360
			};
			Grid.SetRow(rotationSlider, 1);
			Grid.SetColumn(rotationSlider, 1);

			// Set Bindings.
			rotationSliderValue.BindingContext = rotationSlider;
			rotationSliderValue.SetBinding(Label.TextProperty,
				new Binding("Value", BindingMode.OneWay, null, null, "Rotation = {0:F0}"));

			rotationSlider.BindingContext = label;
			rotationSlider.SetBinding(Slider.ValueProperty,
				new Binding("Rotation", BindingMode.TwoWay));

			// Label and Slider for AnchorX property.
			Label anchorxStepperValue = new Label
			{
				VerticalTextAlignment = TextAlignment.Center
			};
			Grid.SetRow(anchorxStepperValue, 2);
			Grid.SetColumn(anchorxStepperValue, 0);

			Stepper anchorxStepper = new Stepper
			{
				Maximum = 2,
				Minimum = -1,
				Increment = 0.5
			};
			Grid.SetRow(anchorxStepper, 2);
			Grid.SetColumn(anchorxStepper, 1);

			// Set bindings.
			anchorxStepperValue.BindingContext = anchorxStepper;
			anchorxStepperValue.SetBinding(Label.TextProperty,
				new Binding("Value", BindingMode.OneWay, null, null, "AnchorX = {0:F1}"));

			anchorxStepper.BindingContext = label;
			anchorxStepper.SetBinding(Stepper.ValueProperty, 
				new Binding("AnchorX", BindingMode.TwoWay));

			// Label and Slider for AnchorY property.
			Label anchoryStepperValue = new Label
			{
				VerticalTextAlignment = TextAlignment.Center
			};
			Grid.SetRow(anchoryStepperValue, 3);
			Grid.SetColumn(anchoryStepperValue, 0);

			Stepper anchoryStepper = new Stepper
			{
				Maximum = 2,
				Minimum = -1,
				Increment = 0.5
			};
			Grid.SetRow(anchoryStepper, 3);
			Grid.SetColumn(anchoryStepper, 1);

			// Set bindings.
			anchoryStepperValue.BindingContext = anchoryStepper;
			anchoryStepperValue.SetBinding(Label.TextProperty,
				new Binding("Value", BindingMode.OneWay, null, null, "AnchorY = {0:F1}"));

			anchoryStepper.BindingContext = label;
			anchoryStepper.SetBinding(Stepper.ValueProperty, 
				new Binding("AnchorY", BindingMode.TwoWay));

			// Assemble the page.
			Content = new StackLayout
			{
				Children =
				{
					label,
					new Grid
					{
						Padding = 10,
						RowDefinitions = 
						{
							new RowDefinition { Height = GridLength.Auto },
							new RowDefinition { Height = GridLength.Auto },
							new RowDefinition { Height = GridLength.Auto },
							new RowDefinition { Height = GridLength.Auto },
						},
						ColumnDefinitions = 
						{
							new ColumnDefinition { Width = GridLength.Auto },
							new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star)}
						},
						Children = 
						{
							scaleSliderValue,
							scaleSlider,
							rotationSliderValue,
							rotationSlider,
							anchorxStepperValue, 
							anchorxStepper,
							anchoryStepperValue,
							anchoryStepper
						}
					}
				}
			};
		}
        public SliderStepperSwitchPage()
        {
            // Create a Slider and set event handler.
            Slider slider = new Slider
            {
                VerticalOptions = LayoutOptions.EndAndExpand
            };
            slider.ValueChanged += OnSliderValueChanged;

            // Create a Label to display the Slider value.
            sliderValueLabel = new Label
            {
                Font = Font.SystemFontOfSize(NamedSize.Large),
                VerticalOptions = LayoutOptions.StartAndExpand,
                HorizontalOptions = LayoutOptions.Center
            };

            // Create a Stepper and set event handler.
            Stepper stepper = new Stepper
            {
                VerticalOptions = LayoutOptions.EndAndExpand,
                HorizontalOptions = LayoutOptions.Center
            };
            stepper.ValueChanged += 
                (object sender, ValueChangedEventArgs args) =>
                {
                    stepperValueLabel.Text = args.NewValue.ToString();
                };
                
            // Create a Label to display the Stepper value.
            stepperValueLabel = new Label
            {
                Font = Font.SystemFontOfSize(NamedSize.Large),
                VerticalOptions = LayoutOptions.StartAndExpand,
                HorizontalOptions = LayoutOptions.Center
            };

            // Create a Switch and set event handler.
            Switch switcher = new Switch
            {
                VerticalOptions = LayoutOptions.EndAndExpand,
                HorizontalOptions = LayoutOptions.Center
            };
            switcher.Toggled += OnSwitcherToggled;

            // Create a Label to display the Switch value.
            switchToggledLabel = new Label
            {
                Font = Font.SystemFontOfSize(NamedSize.Large),
                VerticalOptions = LayoutOptions.StartAndExpand,
                HorizontalOptions = LayoutOptions.Center
            };

            // Put them all in a StackLayout.
            this.Content = new StackLayout
            {
                Children = 
                {
                    slider,
                    sliderValueLabel,
                    stepper,
                    stepperValueLabel,
                    switcher,
                    switchToggledLabel,  
                }
            };
        }
Ejemplo n.º 11
0
        private void InitializeElements()
        {
            billLabel = CreateLabel("Your bill");
            billLabel.SetBinding(Label.TextProperty, "Bill");
            billEntry = CreateEntry();

            tipPersentageLabel = CreateLabel("Your tip rate, %:");
            tipPersentageLabel.SetBinding(Label.TextProperty, "TipPersentage");
            tipPersentageStepper = CreateStepper(true);

            numberOfPeopleLabel = CreateLabel("Number of people:");
            numberOfPeopleLabel.SetBinding(Label.TextProperty, "NumberOfPeople");
            numberOfPeopleStepper = CreateStepper(false);

            tipAmountTextLabel = CreateLabel("Tip amount: ");
            tipAmountValueLabel = CreateLabel(string.Empty);

            totalAmountTextLabel = CreateLabel("Total amount: ");
            totalAmountValueLabel = CreateLabel(string.Empty);

            amountPerPersonTextLabel = CreateLabel("Tip per person:");
            amountPerPersonValueLabel = CreateLabel(string.Empty);

            calculateTipButton = CreateButton();
            calculateTipButton.Clicked += CalculateTipButton_Clicked;
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Gets a list of StackLayout objects associated with properties in an object that have been 
        /// decorated with a UiProperty attribute.
        /// </summary>
        /// <returns>The property stacks.</returns>
        /// <param name="o">Object to get StackLayouts for.</param>
        public static List<StackLayout> GetPropertyStacks(object o)
        {
            List<StackLayout> propertyStacks = new List<StackLayout>();

            List<Tuple<PropertyInfo, UiProperty>> propertyUiElements = o.GetType()
                                                                        .GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
                                                                        .Select(p => new Tuple<PropertyInfo, UiProperty>(p, Attribute.GetCustomAttribute(p, typeof(UiProperty), true) as UiProperty))
                                                                        .Where(pp => pp.Item2 != null)
                                                                        .OrderBy(pp => pp.Item2._order).ToList();

            foreach (Tuple<PropertyInfo, UiProperty> propertyUiElement in propertyUiElements)
            {
                UiProperty uiElement = propertyUiElement.Item2;

                Label parameterNameLabel = new Label
                {
                    Text = uiElement.LabelText ?? propertyUiElement.Item1.Name + ":",
                    HorizontalOptions = LayoutOptions.Start,
                    FontSize = 20
                };

                bool addParameterValueLabel = false;

                View view = null;
                BindableProperty bindingProperty = null;
                IValueConverter converter = null;
                if (uiElement is OnOffUiProperty)
                {
                    view = new Switch();
                    bindingProperty = Switch.IsToggledProperty;
                }
                else if (uiElement is DisplayYesNoUiProperty)
                {
                    view = new Label
                    {
                        FontSize = 20
                    };

                    bindingProperty = Label.TextProperty;
                    converter = new DisplayYesNoUiProperty.ValueConverter();
                    uiElement.Editable = true;  // just makes the label text non-dimmed. a label's text is never editable.
                }
                else if (uiElement is DisplayStringUiProperty)
                {
                    view = new Label
                    {
                        FontSize = 20
                    };

                    bindingProperty = Label.TextProperty;
                    converter = new DisplayStringUiProperty.ValueConverter();
                    uiElement.Editable = true;  // just makes the label text non-dimmed. a label's text is never editable.
                }
                else if (uiElement is EntryIntegerUiProperty)
                {
                    view = new Entry
                    {
                        Keyboard = Keyboard.Numeric,
                        HorizontalOptions = LayoutOptions.FillAndExpand
                    };

                    bindingProperty = Entry.TextProperty;
                    converter = new EntryIntegerUiProperty.ValueConverter();
                }
                else if (uiElement is EntryFloatUiProperty)
                {
                    view = new Entry
                    {
                        Keyboard = Keyboard.Numeric,
                        HorizontalOptions = LayoutOptions.FillAndExpand
                    };

                    bindingProperty = Entry.TextProperty;
                    converter = new EntryFloatUiProperty.ValueConverter();
                }
                else if (uiElement is EditorUiProperty)
                {
                    view = new Editor
                    {
                        Keyboard = Keyboard.Default,
                        HorizontalOptions = LayoutOptions.FillAndExpand
                    };

                    bindingProperty = Editor.TextProperty;
                }
                else if (uiElement is IncrementalIntegerUiProperty)
                {
                    IncrementalIntegerUiProperty p = uiElement as IncrementalIntegerUiProperty;
                    view = new Stepper
                    {
                        Minimum = p.Minimum,
                        Maximum = p.Maximum,
                        Increment = p.Increment
                    };

                    bindingProperty = Stepper.ValueProperty;
                    addParameterValueLabel = true;
                }
                else if (uiElement is EntryStringUiProperty)
                {
                    view = new Entry
                    {
                        Keyboard = Keyboard.Default,
                        HorizontalOptions = LayoutOptions.FillAndExpand
                    };

                    bindingProperty = Entry.TextProperty;
                }
                else if (uiElement is ListUiProperty)
                {
                    Picker picker = new Picker
                    {
                        HorizontalOptions = LayoutOptions.FillAndExpand
                    };

                    List<object> items = (uiElement as ListUiProperty).Items.ToList();
                    foreach (object item in items)
                        picker.Items.Add(item.ToString());

                    picker.SelectedIndex = items.IndexOf(propertyUiElement.Item1.GetValue(o));

                    picker.SelectedIndexChanged += (oo, ee) =>
                        {
                            if (picker.SelectedIndex >= 0)
                                propertyUiElement.Item1.SetValue(o, items[picker.SelectedIndex]);
                        };

                    view = picker;
                }

                if (view != null)
                {
                    StackLayout stack = new StackLayout
                    {
                        Orientation = StackOrientation.Horizontal,
                        HorizontalOptions = LayoutOptions.FillAndExpand
                    };

                    stack.Children.Add(parameterNameLabel);

                    if (addParameterValueLabel)
                    {
                        Label parameterValueLabel = new Label
                        {
                            HorizontalOptions = LayoutOptions.FillAndExpand,
                            FontSize = 20
                        };
                        parameterValueLabel.BindingContext = o;
                        parameterValueLabel.SetBinding(Label.TextProperty, propertyUiElement.Item1.Name);

                        stack.Children.Add(parameterValueLabel);
                    }

                    view.IsEnabled = uiElement.Editable;

                    if (bindingProperty != null)
                    {
                        view.BindingContext = o;
                        view.SetBinding(bindingProperty, new Binding(propertyUiElement.Item1.Name, converter: converter));
                    }

                    stack.Children.Add(view);

                    propertyStacks.Add(stack);
                }
            }

            return propertyStacks;
        }
        public IEnumerable<ViewSample> BuildSamples()
        {
            var activityIndicator = new ActivityIndicator {
                IsEnabled = true,
                IsRunning = true
            };

            var boxView = new BoxView {
                Color = Color.Red
            };

            var button = new Button {
                Text = "Click Me"
            };
            var buttonLabel = new Label {
                Text = ""
            };
            button.Clicked += (sender, e) => {
                buttonLabel.Text = "I've been clicked!";
            };
            var buttonStack = new StackLayout {
                Children = { button, buttonLabel }
            };

            var datePicker = new DatePicker ();

            var editor = new Editor {
                Text = "You can edit multiple lines of text here!"
            };
            var entry = new Entry {
                Placeholder = "Enter a single line of text"
            };

            var image = new Image {
                Source = ImageSource.FromUri(new Uri("http://placehold.it/350x150"))
            };

            var label = new Label {
                Text = "Hello, I'm a label!"
            };

            var picker = new Picker ();
            picker.Items.Add ("Red");
            picker.Items.Add ("Green");
            picker.Items.Add ("Purple");
            picker.Items.Add ("Grey");
            picker.Items.Add ("Black");

            var progressBar = new ProgressBar {
                Progress = 0
            };
            var progressButton = new Button {
                Text = "Start Progressing"
            };
            progressButton.Clicked += async (sender, e) => {
                await progressBar.ProgressTo(1.0, 500, Easing.Linear);
            };

            var progressStack = new StackLayout {
                Children = { progressBar, progressButton }
            };

            var searchBar = new SearchBar ();

            var slider = new Slider ();

            var stepper = new Stepper ();

            var @switch = new Switch ();

            var timePicker = new TimePicker ();

            var webView = new WebView {
                Source = new UrlWebViewSource {
                    Url = "https://tutsplus.com/"
                },
                VerticalOptions = LayoutOptions.FillAndExpand
            };

            return new List<ViewSample> {
                new ViewSample {
                    Name = "ActivityIndicator",
                    View = activityIndicator
                },
                new ViewSample {
                    Name = "BoxView",
                    View = boxView
                },
                new ViewSample {
                    Name = "Button",
                    View = buttonStack
                },
                new ViewSample {
                    Name = "DatePicker",
                    View = datePicker
                },
                new ViewSample {
                    Name = "Editor",
                    View = editor
                },
                new ViewSample {
                    Name = "Entry",
                    View = entry
                },
                new ViewSample {
                    Name = "Image",
                    View = image
                },
                new ViewSample {
                    Name = "Label",
                    View = label
                },
                new ViewSample {
                    Name = "Picker",
                    View = picker
                },
                new ViewSample {
                    Name = "ProgressBar",
                    View = progressStack
                },
                new ViewSample {
                    Name = "SearchBar",
                    View = searchBar
                },
                new ViewSample {
                    Name = "Slider",
                    View = slider
                },
                new ViewSample {
                    Name = "Stepper",
                    View = stepper
                },
                new ViewSample {
                    Name = "Switch",
                    View = @switch
                },
                new ViewSample {
                    Name = "TimePicker",
                    View = timePicker
                },
                new ViewSample {
                    Name = "WebView",
                    View = webView
                }
            };
        }
Ejemplo n.º 14
0
        public ShoppingList()
        {
            /* Top part layout*/
            var button_back = new Button {
                Text = "Back",
                VerticalOptions = LayoutOptions.Top,
                HorizontalOptions = LayoutOptions.Left
            };
            button_back.Clicked= new BackButtonPressedEventArgs();
            var label_main_title = new Label {
                Text = "North Lakes",
                Font = Font.BoldSystemFontOfSize(NamedSized.Large),
                VerticalOptions = LayoutOptions.Top,
                HorizontalOptions = LayoutOptions.Center,
            };
            var label_sum_money = new Label {
                Text = "$",
                Font = Font.BoldSystemFontOfSize(NamedSized.Small),
                VerticalOptions = LayoutOptions.Top,
                HorizontalOptions = LayoutOptions.Right
            };
            var layout_top = new Frame {
                Layout.Padding = 0,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions = LayoutOptions.Top,
                Children = {button_back, label_main_title, label_sum_money}
            };
            /* Finish Top part payout*/

            /* Search Bar */
            var entry1 = new Entry {
                Placeholder = "Searching somethin here",
                HorizontalOptions = LayoutOptions.FillAndExpand
            };
            /* Finish Search Bar*/

            /* Middle Part Layout*/
            var layout_middle = new Grid{
                HorizontalOptions = LayoutOptions.FillAndExpand,
            };
            layout_middle.Children.Add (new Button { Text = "Lists", HorizontalOptions = LayoutOptions.Center},0,0);
            layout_middle.Children.Add (new Button { Text = "Specials", HorizontalOptions = LayoutOptions.Center},0,1);
            layout_middle.Children.Add (new Button { Text = "Basket", HorizontalOptions = LayoutOptions.Center},0,2);
            layout_middle.Children.Add (new Button { Text = "More", HorizontalOptions = LayoutOptions.Center},0,3);
            /* Finish Middle Part Layout*/

            /* Bottom Part Layout*/
            var layout_bottom = new Grid {
                HorizontalOptions = LayoutOptions.FillAndExpand,
            };
            layout_bottom.Children.Add (new Label { Text = "YOUR LISTS", HorizontalOptions = LayoutOptions.Center},0,0);
            layout_bottom.Children.Add (new Button { Text = "EDIT", HorizontalOptions = LayoutOptions.Center},0,4);

            layout_bottom.Children.Add (new Button { Text = "Add a New List...", HorizontalOptions = LayoutOptions.Center},1,0);

            layout_bottom.Children.Add (new Button { Text = "Breakfast(2)", HorizontalOptions = LayoutOptions.Center},2,0);

            layout_bottom.Children.Add (new Label { Text = "Pauls Full Cream Milk", HorizontalOptions = LayoutOptions.Center},3,0,3,1);
            var stepper1 = new Stepper { Minimum = 0, Increment = 1, HorizontalOptions = LayoutOptions.Center };
            layout_bottom.Children.Add (stepper1,3,2,3,3);
            var label_amaount1 = new Label { Text = "1", HorizontalOptions = LayoutOptions.Center };
            layout_bottom.Children.Add (label_amaount1,3,4);
            layout_bottom.Children.Add (new Button { }, 3,5);
            stepper1.ValueChanged += OnStepperValueChanged;

            layout_bottom.Children.Add (new Label { Text = "Pauls Full Cream Milk", HorizontalOptions = LayoutOptions.Center},4,0,4,1);
            var stepper2 = new Stepper { Minimum = 0, Increment = 1, HorizontalOptions = LayoutOptions.Center };
            layout_bottom.Children.Add (stepper2,4,2,4,3);
            var label_amaount2 = new Label { Text = "1", HorizontalOptions = LayoutOptions.Center };
            layout_bottom.Children.Add (label_amaount2,4,4);
            layout_bottom.Children.Add (new Button { }, 4,5);
            stepper2.ValueChanged += OnStepperValueChanged;

            layout_bottom.Children.Add (new Label { Text = "List(0)", HorizontalOptions = LayoutOptions.Center},5,0);
            layout_bottom.Children.Add (new Label { Text = "DEFAULT", HorizontalOptions = LayoutOptions.Center},5,5);

            layout_bottom.Children.Add (new Label { Text = "Suggested Lists", HorizontalOptions = LayoutOptions.Center},6,0,6,1);
            layout_bottom.Children.Add (new Label { Text = "Edit", HorizontalOptions = LayoutOptions.Center},5,5);

            layout_bottom.Children.Add (new Label { Text = "This is a picture", HorizontalOptions = LayoutOptions.Center},7,0,8,2);
            layout_bottom.Children.Add (new Label { Text = "This is a picture", HorizontalOptions = LayoutOptions.Center},7,3,8,5);

            /* Finish Bottom Part Layout*/

            Content = new StackLayout
            {
                Children = {
                    layout_top,
                    entry1,
                    layout_middle,
                    layout_bottom
                }
            };
        }
Ejemplo n.º 15
0
       //  Note that there are a couple of options for retrieving the selection value for 
       //  many of these views and those options will be placed in each of the two Label 
       //  views’ Text properties.

        public Controls()
		{
			eventValue = new Label();
			eventValue.Text = "Value in Event";
            pageValue = new Label();
            pageValue.Text = "Value in Page";


            Picker picker = new Picker
            {
                Title = "Option",
                VerticalOptions = LayoutOptions.CenterAndExpand
            };

            var options = new List<string> { "First", "Second", "Third", "Fourth" };

            foreach (string optionName in options)
            {
                picker.Items.Add(optionName);
            }

            picker.SelectedIndexChanged += (sender, args) =>
            {
                pageValue.Text = picker.Items[picker.SelectedIndex];
            }; 


			DatePicker datePicker = new DatePicker
			{
				Format = "D",
				VerticalOptions = LayoutOptions.CenterAndExpand
			};

			datePicker.DateSelected += (object sender, DateChangedEventArgs e) => 
            {
                eventValue.Text = e.NewDate.ToString();
                pageValue.Text = datePicker.Date.ToString();
            };


			TimePicker timePicker = new TimePicker
			{
				Format = "T",
				VerticalOptions = LayoutOptions.CenterAndExpand
			};

            // no built-in TimeSelected event so use data-binding PropertyChanged event
            timePicker.PropertyChanged += (sender, e) =>
            {
                if (e.PropertyName == TimePicker.TimeProperty.PropertyName)
                {
                    pageValue.Text = timePicker.Time.ToString();
                }
            };

            // Stepper stepper = new Stepper(0 ,10 ,0 , 1);  // alternative declaration
			Stepper stepper = new Stepper
			{
				Minimum = 0,
				Maximum = 10,
				Increment = 1,
				HorizontalOptions = LayoutOptions.Center,
				VerticalOptions = LayoutOptions.CenterAndExpand
			};
            stepper.ValueChanged += (sender, e) =>
            {
                eventValue.Text = String.Format("Stepper value is {0:F1}", e.NewValue);
                pageValue.Text = stepper.Value.ToString();
            };

            // Slider  slider = new Slider  (0 ,100 ,50); // alternative declaration
			Slider slider = new Slider
			{
                Minimum = 0,
                Maximum = 100,
                Value = 50,
                VerticalOptions = LayoutOptions.CenterAndExpand,
                WidthRequest = 300

			};

            slider.ValueChanged += (sender, e) =>
            {
                eventValue.Text = String.Format("Slider value is {0:F1}", e.NewValue);
                pageValue.Text = slider.Value.ToString();
            };


			Switch switcher = new Switch
			{
				HorizontalOptions = LayoutOptions.Center,
				VerticalOptions = LayoutOptions.CenterAndExpand
			};

            switcher.Toggled += (sender, e) =>
            {
       			eventValue.Text = String.Format("Switch is now {0}", e.Value);
                pageValue.Text = switcher.IsToggled.ToString();
            };

            this.Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5);

			this.Content = new StackLayout {
				HorizontalOptions = LayoutOptions.Center,
				Children = {
					eventValue,
   					pageValue,
                    picker,
					datePicker,
					timePicker,
					stepper,
					slider,
					switcher
				}
			};
		}
Ejemplo n.º 16
0
        public BasketPageCell()
        {
            var itemName = new Label {
                YAlign = TextAlignment.Center,
                FontSize = 20,
                TextColor = Color.Black

            };
            itemName.SetBinding(Label.TextProperty, "BasketItemName");

            Button deleteButton = new Button {
                Text = "Delete"
            };

            deleteButton.Clicked += (sender, e) => {

                var item = (TapandGo.Data.ShoppingBasketData)BindingContext;
                TapandGo.Database.Database.GetDatabase().DeleteItemFromBasket(item.ShoppingBasketId);
                ShoppingCart.Refresh();

            };

            Stepper stepper = new Stepper {
                Minimum = 0.0,
                Maximum = 10.0,
                Increment = 1.0,
                HorizontalOptions = LayoutOptions.CenterAndExpand
            };
            stepper.SetBinding(Stepper.ValueProperty, "BasketItemQuantity");
               // stepper.ValueChanged += OnStepperValueChanged;

            var itemPrice = new Label {
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                YAlign = TextAlignment.Center,
                TextColor = Color.Black
            };
            itemPrice.SetBinding(Label.TextProperty, "BasketItemPriceString");

            var itemQuantity = new Entry {
                HorizontalOptions = LayoutOptions.CenterAndExpand,
              //  YAlign = TextAlignment.Center,
                TextColor = Color.Black,

            };

            itemQuantity.SetBinding(Entry.TextProperty, "BasketItemQuantity");
            itemQuantity.Keyboard = Keyboard.Numeric;
            int lastQuantity = Convert.ToInt32 ( itemQuantity.Text );
            itemQuantity.Completed += (sender, e) => {
                var i = itemQuantity.Text;
                int quantity = Convert.ToInt32(i);
                var item = (TapandGo.Data.ShoppingBasketData)BindingContext;
                int id = item.BasketItemID;
                int basketID = item.ShoppingBasketId;
                string newItemName = item.BasketItemName;
                double newItemPrice = item.BasketItemPrice;
                string itemPriceString = item.BasketItemPriceString;
                string itemPicture = item.BasketItemPicture;

                Database.Database.GetDatabase().UpdateBasketItemQuantity(quantity, id, newItemName, newItemPrice, itemPriceString, itemPicture, basketID);

                ShoppingCart.totalPrice.Text = "Total: $" + Database.Database.GetDatabase().GetTotalPrice().ToString() + ".00";
            };

            var itemImage = new Image {

            };
            itemImage.SetBinding(Image.SourceProperty, "BasketItemPicture");

            var layout = new StackLayout {
               Padding = new Thickness(20, 0, 0, 0),
                Orientation = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.StartAndExpand,
                Children = {itemImage, itemName, itemQuantity, itemPrice, deleteButton}
            };
            View = layout;
        }
Ejemplo n.º 17
0
        public App()
        {
            //Lijst van tests
            string[] testenarray = new string[] { "test 1", "test 2", "test 25", "Doet zot zijn zeer?" };
            //Lijst van patienten
            string[] patientenarray = new string[] { "Jef", "Jantje", "Piet", "Joris", "En Korneel", "Baarden", "Varen" };



            //Aanmaken van controls
            Label tekst = new Label
            {
                XAlign = TextAlignment.Center,
                Text = "Welcome to Xamarin Forms!"

            };
            Picker tests = new Picker
            {
                Title = "Test",
                Rotation = 45.0
                //HorizontalOptions = LayoutOptions.Center,         
            };
            Picker patienten = new Picker
            {
                Title = "Patient",
                HorizontalOptions = LayoutOptions.Center
            };
            Button startbtn = new Button
            {
                Text = "Start"
            };
            startbtn.Clicked += StartButtonClicked;


            Stepper noname = new Stepper
            {
                HorizontalOptions = LayoutOptions.Center
            };

            //Alle logica
            //testen in combobox steken
            for (int i = 0; i < testenarray.Count(); i++)
            {
                tests.Items.Add(testenarray[i]);
            }
            //Patienten in combobox steken
            for (int i = 0; i < patientenarray.Count(); i++)
            {
                patienten.Items.Add(patientenarray[i]);
            }

            // The root page of your application
            MainPage = new ContentPage
            {
                Content = new StackLayout
                {
                    VerticalOptions = LayoutOptions.Center,
                    Children = {
                        tests,
                        patienten,
                        startbtn
                    }
                }
            };
        }
		public RotationYDemoPage ()
		{
			this.Title = "RotationY";

			// Label to be transformed.
			Label label = new Label {
				Text = "ROTATIONY",
				FontSize = 50,
				HorizontalOptions = LayoutOptions.Center,
				VerticalOptions = LayoutOptions.CenterAndExpand
			};

			// Label and Slider for RotationY property.
			Label rotationSliderValue = new Label {
				VerticalTextAlignment = TextAlignment.Center
			};
			Grid.SetRow (rotationSliderValue, 0);
			Grid.SetColumn (rotationSliderValue, 0);

			Slider rotationSlider = new Slider {
				Maximum = 360
			};
			Grid.SetRow (rotationSlider, 0);
			Grid.SetColumn (rotationSlider, 1);

			// Set Bindings.
			rotationSliderValue.BindingContext = rotationSlider;
			rotationSliderValue.SetBinding (Label.TextProperty,
				new Binding ("Value", BindingMode.OneWay,
					null, null, "RotationY = {0:F0}\u00B0"));

			rotationSlider.BindingContext = label;
			rotationSlider.SetBinding (Slider.ValueProperty,
				new Binding ("RotationY", BindingMode.TwoWay));

			// Label and Slider for AnchorX property.
			Label anchorxStepperValue = new Label {
				VerticalTextAlignment = TextAlignment.Center
			};
			Grid.SetRow (anchorxStepperValue, 1);
			Grid.SetColumn (anchorxStepperValue, 0);

			Stepper anchorxStepper = new Stepper {
				Maximum = 2,
				Minimum = -1,
				Increment = 0.5
			};
			Grid.SetRow (anchorxStepper, 1);
			Grid.SetColumn (anchorxStepper, 1);

			// Set bindings.
			anchorxStepperValue.BindingContext = anchorxStepper;
			anchorxStepperValue.SetBinding (Label.TextProperty,
				new Binding ("Value", BindingMode.OneWay,
					null, null, "AnchorX = {0:F1}"));

			anchorxStepper.BindingContext = label;
			anchorxStepper.SetBinding (Stepper.ValueProperty,
				new Binding ("AnchorX", BindingMode.TwoWay));

			// Label and Slider for AnchorY property.
			Label anchoryStepperValue = new Label {
				VerticalTextAlignment = TextAlignment.Center
			};
			Grid.SetRow (anchoryStepperValue, 2);
			Grid.SetColumn (anchoryStepperValue, 0);

			Stepper anchoryStepper = new Stepper {
				Maximum = 2,
				Minimum = -1,
				Increment = 0.5
			};
			Grid.SetRow (anchoryStepper, 2);
			Grid.SetColumn (anchoryStepper, 1);

			// Set bindings.
			anchoryStepperValue.BindingContext = anchoryStepper;
			anchoryStepperValue.SetBinding (Label.TextProperty,
				new Binding ("Value", BindingMode.OneWay,
					null, null, "AnchorY = {0:F1}"));

			anchoryStepper.BindingContext = label;
			anchoryStepper.SetBinding (Stepper.ValueProperty,
				new Binding ("AnchorY", BindingMode.TwoWay));

			// Assemble the page.
			this.Content = new StackLayout {
				Children = {
					label,
					new Grid {
						Padding = 10,
						RowDefinitions = {
							new RowDefinition { Height = GridLength.Auto },
							new RowDefinition { Height = GridLength.Auto },
							new RowDefinition { Height = GridLength.Auto }
						},
						ColumnDefinitions = {
							new ColumnDefinition { Width = GridLength.Auto },
							new ColumnDefinition { Width = new GridLength (1, GridUnitType.Star) }
						},
						Children = {
							rotationSliderValue,
							rotationSlider,
							anchorxStepperValue, 
							anchorxStepper,
							anchoryStepperValue,
							anchoryStepper
						}
					}
				}
			};

		}
Ejemplo n.º 19
0
		public Controls ()
		{
			eventValue = new Label ();
			eventValue.Text = "Value in Handler";
			pageValue = new Label ();
			pageValue.Text = "Value in Page";




			// Picker
			Picker picker = new Picker 
			{
				Title = "Options",
				VerticalOptions = LayoutOptions.CenterAndExpand
			};

			var options = new List<string> { "First", "Second", "Third", "Fourth" };

			foreach (string optionName in options) 
			{
				picker.Items.Add (optionName);
			}

			picker.SelectedIndexChanged += (sender, args) => 
			{
				pageValue.Text = picker.Items[picker.SelectedIndex];
			};



			// Date Picker
			DatePicker datePicker = new DatePicker 
			{
				Format = "D",
				VerticalOptions = LayoutOptions.CenterAndExpand
			};

			datePicker.DateSelected += (object sender, DateChangedEventArgs e) =>
			{
				eventValue.Text = e.NewDate.ToString();
				pageValue.Text = datePicker.Date.ToString();
			};
			datePicker.MaximumDate = Convert.ToDateTime ("1/1/2019");
			datePicker.MinimumDate = Convert.ToDateTime ("1/1/2014");



			// Time Picker
			TimePicker timePicker = new TimePicker 
			{
				Format = "T",
				VerticalOptions = LayoutOptions.CenterAndExpand
			};

			timePicker.PropertyChanged += (sender, e) => 
			{
				if (e.PropertyName == TimePicker.TimeProperty.PropertyName)
				{
					pageValue.Text = timePicker.Time.ToString();
				}
			};



			// Stepper
			Stepper stepper = new Stepper 
			{
				Minimum = 0,
				Maximum = 10,
				Increment = 1,
				HorizontalOptions = LayoutOptions.Center,
				VerticalOptions = LayoutOptions.CenterAndExpand
			};

			stepper.ValueChanged += (sender, e) => 
			{
				eventValue.Text = String.Format("Stepper value is {0:F1}",e.NewValue);
				pageValue.Text = Stepper.ValueProperty.ToString();
			};



			// Slider
			Slider slider = new Slider 
			{
				Minimum = 0,
				Maximum = 100,
				Value = 50,
				VerticalOptions = LayoutOptions.CenterAndExpand,
				WidthRequest = 300
			};

			slider.ValueChanged += (sender, e) => 
			{
				eventValue.Text = String.Format("Slider value is {0:F1}",e.NewValue);
				pageValue.Text = slider.Value.ToString();
			};



			// Switch
			Switch switcher = new Switch 
			{
				HorizontalOptions = LayoutOptions.Center,
				VerticalOptions = LayoutOptions.CenterAndExpand
			};

			switcher.Toggled += (sender, e) => 
			{
				eventValue.Text = String.Format("Switch is now {0}", e.Value);
				pageValue.Text = switcher.IsToggled.ToString();

			};
		





		

			StackLayout stackLay = new StackLayout {
				//Spacing = 0,
				//Orientation = StackOrientation.Horizontal,
				HorizontalOptions = LayoutOptions.Center,
				Children = {
					//HorizontalOptions = LayoutOptions.Center,
					eventValue,
					pageValue,
					picker,
					datePicker,
					timePicker,
					stepper,
					slider,
					switcher
				}

			};

			this.Content = stackLay;

		}
Ejemplo n.º 20
0
        public App()
        {
            // The root page of your application

            var indicator = new ActivityIndicator() {
                HorizontalOptions = LayoutOptions.CenterAndExpand
            };
            indicator.IsVisible = false;
            var numeroDePersonasEntry =
                new Entry {
                Text = "5"
            };
            Stepper numeroDePersonasStepper = new Stepper
            {
                Minimum = 0,
                Maximum = 30,
                Increment = 1,
                Value = 5,
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions = LayoutOptions.CenterAndExpand
            };
            var set3Button = new Button{ Text = "3" };
            set3Button.Clicked += delegate(object sender, EventArgs e) {
                numeroDePersonasEntry.Text = "3";
                numeroDePersonasStepper.Value = 3;
            };
            var set4Button = new Button{ Text = "4" };
            set4Button.Clicked += delegate(object sender, EventArgs e) {
                numeroDePersonasEntry.Text = "4";
                numeroDePersonasStepper.Value = 4;
            };
            var set5Button = new Button{ Text = "5" };
            set5Button.Clicked += delegate(object sender, EventArgs e) {
                numeroDePersonasEntry.Text = "5";
                numeroDePersonasStepper.Value = 5;
            };
            var set6Button = new Button{ Text = "6" };
            set6Button.Clicked += delegate(object sender, EventArgs e) {
                numeroDePersonasEntry.Text = "6";
                numeroDePersonasStepper.Value = 6;
            };
            var set7Button = new Button{ Text = "7" };
            set7Button.Clicked += delegate(object sender, EventArgs e) {
                numeroDePersonasEntry.Text = "7";
                numeroDePersonasStepper.Value = 7;
            };
            var set8Button = new Button{ Text = "8" };
            set8Button.Clicked += delegate(object sender, EventArgs e){
                numeroDePersonasEntry.Text = "8";
                numeroDePersonasStepper.Value = 8;
            };
            numeroDePersonasStepper.ValueChanged += delegate(object sender, ValueChangedEventArgs e) {
                try
                {
                    int numeroDePersonas =  Int32.Parse( numeroDePersonasEntry.Text ) ;
                    numeroDePersonasEntry.Text = "" + e.NewValue ;
                }
                catch(Exception exception)
                {

                }
            };
            var totalDeLaComidaEntry =
                new Entry {
                Text = "500",

                HorizontalOptions = LayoutOptions.FillAndExpand
            };
            var plus500Button = new Button{ Text = "+500" };
            plus500Button.Clicked += delegate(object sender, EventArgs e){
                try
                {
                    float totalDeLaComida =  float.Parse( totalDeLaComidaEntry.Text ) ;
                    totalDeLaComidaEntry.Text = "" + ( totalDeLaComida + 500f);
                }
                catch( Exception exception )
                {
                }
            };
            var plus300Button = new Button{ Text = "+300" };
            plus300Button.Clicked += delegate(object sender, EventArgs e){
                try
                {
                    float totalDeLaComida =  float.Parse( totalDeLaComidaEntry.Text ) ;
                    totalDeLaComidaEntry.Text = "" + ( totalDeLaComida + 300f);
                }
                catch( Exception exception )
                {
                }
            };
            var plus100Button = new Button{ Text = "+100" };
            plus100Button.Clicked += delegate(object sender, EventArgs e){
                try
                {
                    float totalDeLaComida =  float.Parse( totalDeLaComidaEntry.Text ) ;
                    totalDeLaComidaEntry.Text = "" + ( totalDeLaComida + 100f );
                }
                catch( Exception exception )
                {
                }
            };
            var plus50Button = new Button{ Text = "+50" };
            plus50Button.Clicked += delegate(object sender, EventArgs e){
                try
                {
                    float totalDeLaComida =  float.Parse( totalDeLaComidaEntry.Text ) ;
                    totalDeLaComidaEntry.Text = "" + ( totalDeLaComida + 50f);
                }
                catch( Exception exception )
                {
                }
            };
            var plus30Button = new Button{ Text = "+30" };
            plus30Button.Clicked += delegate(object sender, EventArgs e){
                try
                {
                    float totalDeLaComida =  float.Parse( totalDeLaComidaEntry.Text ) ;
                    totalDeLaComidaEntry.Text = "" + ( totalDeLaComida + 30f);
                }
                catch( Exception exception )
                {
                }
            };
            var plus10Button = new Button{ Text = "+10" };
            plus10Button.Clicked += delegate(object sender, EventArgs e){
                try
                {
                    float totalDeLaComida =  float.Parse( totalDeLaComidaEntry.Text ) ;
                    totalDeLaComidaEntry.Text = "" + ( totalDeLaComida + 10f);
                }
                catch( Exception exception )
                {
                }
            };
            var plus5Button = new Button{ Text = "+5" };
            plus5Button.Clicked += delegate(object sender, EventArgs e){
                try
                {
                    float totalDeLaComida =  float.Parse( totalDeLaComidaEntry.Text ) ;
                    totalDeLaComidaEntry.Text = "" + ( totalDeLaComida + 5f);
                }
                catch( Exception exception )
                {
                }
            };
            var plus3Button = new Button{ Text = "+3" };
            plus3Button.Clicked += delegate(object sender, EventArgs e){
                try
                {
                    float totalDeLaComida =  float.Parse( totalDeLaComidaEntry.Text ) ;
                    totalDeLaComidaEntry.Text = "" + ( totalDeLaComida + 3f);
                }
                catch( Exception exception )
                {
                }
            };
            var plus1Button = new Button{ Text = "+1" };
            plus1Button.Clicked += delegate(object sender, EventArgs e){
                try
                {
                    float totalDeLaComida =  float.Parse( totalDeLaComidaEntry.Text ) ;
                    totalDeLaComidaEntry.Text = "" + ( totalDeLaComida + 1f);
                }
                catch( Exception exception )
                {
                }
            };

            var cambiarMonedaButton = new Button{ Text = "MXN" };

            cambiarMonedaButton.Clicked += async delegate(object sender, EventArgs e){
                try
                {
                    float totalDeLaComida =  float.Parse( totalDeLaComidaEntry.Text ) ;

                    indicator.IsVisible = true;
                    indicator.IsRunning = true;
                    var from = "USD";
                    var to = "MXN";
                    if( cambiarMonedaButton.Text.Equals("MXN"))
                    {
                        from = "USD";
                        to = "MXN";
                    }
                    else
                    {
                        from = "MXN";
                        to = "USD";
                    }
                    HttpResponse<string> response = await Unirest.get("https://currency-exchange.p.mashape.com/exchange?from="+from+"&q="+totalDeLaComida+"&"+to+"=MXN")
                        .header("X-Mashape-Key", "xUnaD3PLmhmshJQmfF35NhFUZUOSp1vJXQtjsnrTrGSsoxOBad")
                        .header("Accept", "text/plain")
                        .asStringAsync();
                    indicator.IsRunning = false;
                    indicator.IsVisible = false;
                    totalDeLaComidaEntry.Text = response.Body;
                    if( cambiarMonedaButton.Text.Equals("MXN"))
                    {
                        cambiarMonedaButton.Text = "USD";
                    }
                    else
                    {
                        cambiarMonedaButton.Text = "MXN";
                    }
                    //MainPage.DisplayAlert ("Calculado", "Cambio:" +response.Body , "OK");
                }
                catch( Exception exception )
                {
                }
            };
            var porcentajeDePropinaEntry =
                new Entry {
                Text = "10"
            };
            var porcentajeDePropinaSlider =
                new Slider(0,100,10) ;

            porcentajeDePropinaSlider.ValueChanged += delegate(object sender, ValueChangedEventArgs e) {
                porcentajeDePropinaEntry.Text = "" + e.NewValue;
            };
            var CalcularPropinaButton = new Button {
                Text = "Calcular propina",
                FontSize = Device.GetNamedSize (NamedSize.Large, typeof(Label)),
                FontAttributes = FontAttributes.Bold
            };

            MainPage = new ContentPage {
                Content =
                    new ContentView{
                    Padding = 40,
                        Content =
                        new StackLayout {
                        VerticalOptions = LayoutOptions.Center,
                        Children = {
                            new Label {
                                XAlign = TextAlignment.Center,
                                Text = "Numero de personas",
                                FontSize = Device.GetNamedSize (NamedSize.Large, typeof(Label)),
                                FontAttributes = FontAttributes.Bold
                            },
                            new StackLayout {
                                Orientation = StackOrientation.Horizontal,
                                Padding = 20,
                                Children ={
                                    set3Button,
                                    set4Button,
                                    set5Button,
                                    set6Button,
                                    set7Button,
                                    set8Button
                                }
                            },
                            new StackLayout {
                                Orientation = StackOrientation.Horizontal,
                                Padding = 20,
                                Children ={
                                    numeroDePersonasStepper,

                                }
                            },
                            numeroDePersonasEntry,
                            new Label {
                                XAlign = TextAlignment.Center,
                                Text = "Total de la comida ( $ )",
                                FontSize = Device.GetNamedSize (NamedSize.Large, typeof(Label)),
                                FontAttributes = FontAttributes.Bold
                            },
                            new StackLayout {
                                Orientation = StackOrientation.Horizontal,
                                Padding = 20,
                                Children ={
                                    new StackLayout {
                                        Orientation = StackOrientation.Vertical,
                                        Padding = 20,
                                        Children ={
                                            plus500Button,
                                            plus300Button,
                                            plus100Button,
                                        }
                                    },
                                    new StackLayout {
                                        Orientation = StackOrientation.Vertical,
                                        Padding = 20,
                                        Children ={
                                            plus50Button,
                                            plus30Button,
                                            plus10Button,
                                        }
                                    },
                                    new StackLayout {
                                        Orientation = StackOrientation.Vertical,
                                        Padding = 20,
                                        Children ={
                                            plus5Button,
                                            plus3Button,
                                            plus1Button,
                                        }
                                    },
                                }
                            },
                            new StackLayout {
                                Orientation = StackOrientation.Horizontal,
                                Padding = 20,
                                Children ={
                                    totalDeLaComidaEntry,
                                    indicator,
                                    cambiarMonedaButton}
                            },
                            new Label {
                                XAlign = TextAlignment.Center,
                                Text = "Porcentaje de propina ( % )",
                                FontSize = Device.GetNamedSize (NamedSize.Large, typeof(Label)),
                                FontAttributes = FontAttributes.Bold
                            },
                            porcentajeDePropinaSlider,
                            porcentajeDePropinaEntry,
                            CalcularPropinaButton
                        }
                    }
                }
            };

            CalcularPropinaButton.Clicked +=   delegate(object sender, EventArgs e) {
                try
                {
                    int numeroDePersonas =  Int32.Parse( numeroDePersonasEntry.Text ) ;
                    float totalDeLaComida = float.Parse( totalDeLaComidaEntry.Text );
                    float porcentajeDePropina = float.Parse( porcentajeDePropinaEntry.Text );
                    float propinaPorPersona = ( totalDeLaComida / (float)numeroDePersonas ) * (porcentajeDePropina / 100f);
                    MainPage.DisplayAlert ("Calculado", "Propina por persona:" + propinaPorPersona , "OK");
                }
                catch(Exception exception)
                {
                    MainPage.DisplayAlert ("Erro", "Favor de revisar los campos" , "OK");
                }
            };
        }
        public SliderStepperSwitchBindingsPage()
        {
            // Create a Slider.
            Slider slider = new Slider
            {
                VerticalOptions = LayoutOptions.EndAndExpand
            };

            // Create a Label to display the Slider value.
            Label sliderValueLabel = new Label
            {
                Font = Font.SystemFontOfSize(NamedSize.Large),
                VerticalOptions = LayoutOptions.StartAndExpand,
                HorizontalOptions = LayoutOptions.Center
            };

            // Create a Stepper.
            Stepper stepper = new Stepper
            {
                VerticalOptions = LayoutOptions.EndAndExpand,
                HorizontalOptions = LayoutOptions.Center
            };

            // Create a Label to display the Stepper value.
            Label stepperValueLabel = new Label
            {
                Font = Font.SystemFontOfSize(NamedSize.Large),
                VerticalOptions = LayoutOptions.StartAndExpand,
                HorizontalOptions = LayoutOptions.Center,
            };

            // Create a Switch.
            Switch switcher = new Switch
            {
                IsToggled = true,
                VerticalOptions = LayoutOptions.EndAndExpand,
                HorizontalOptions = LayoutOptions.Center
            };

            // Create a Label to display the Switch value.
            Label switchToggledLabel = new Label
            {
                Font = Font.SystemFontOfSize(NamedSize.Large),
                VerticalOptions = LayoutOptions.StartAndExpand,
                HorizontalOptions = LayoutOptions.Center
            };

            // Put them all in a StackLayout.
            this.Content = new StackLayout
            {
                Children = 
                {
                    slider,
                    sliderValueLabel,
                    stepper,
                    stepperValueLabel,
                    switcher,
                    switchToggledLabel,  
                }
            };

            sliderValueLabel.BindingContext = slider;
            sliderValueLabel.SetBinding (Label.OpacityProperty, "Value");

            slider.BindingContext = switcher;
            slider.SetBinding (Slider.IsEnabledProperty, "IsToggled");

            stepper.BindingContext = switcher;
            stepper.SetBinding (Stepper.IsEnabledProperty, "IsToggled");

            sliderValueLabel.SetBinding (Label.TextProperty, 
                new Binding ("Value", BindingMode.Default, null, null,
                                "The Slider value is {0:F2}"));

            stepperValueLabel.BindingContext = stepper;
            stepperValueLabel.SetBinding (Label.TextProperty,
                new Binding ("Value", BindingMode.Default, null, null,
                                "The Stepper value is {0}"));
                    
            switchToggledLabel.BindingContext = switcher;
            switchToggledLabel.SetBinding (Label.TextProperty,
                new Binding ("IsToggled", BindingMode.Default, null, null,
                                "The Switch is toggled {0}"));
        }
Ejemplo n.º 22
0
 public StepperEvents(Stepper This)
     : base(This)
 {
     this.This = This;
 }
Ejemplo n.º 23
0
 public static StepperEvents Events(this Stepper This)
 {
     return(new StepperEvents(This));
 }
Ejemplo n.º 24
0
        public static StackLayout GetOffsetStepper(FlexPie flexPie)
        {
            Label label = new Label();

            label.Text = "Offset";

            label.VerticalOptions = LayoutOptions.FillAndExpand;
            label.HorizontalOptions = LayoutOptions.FillAndExpand;

            Label value = new Label();

            value.Text = "0.0";

            value.VerticalOptions = LayoutOptions.FillAndExpand;
            value.HorizontalOptions = LayoutOptions.FillAndExpand;

            StackLayout labelStack = new StackLayout();

            labelStack.Orientation = StackOrientation.Vertical;

            labelStack.Children.Add(label);
            labelStack.Children.Add(value);

            Stepper stepper = new Stepper();

            stepper.VerticalOptions = LayoutOptions.FillAndExpand;
            stepper.HorizontalOptions = LayoutOptions.FillAndExpand;

            stepper.Increment = .10;
            stepper.Minimum = 0;
            stepper.Maximum = 1.00;

            stepper.ValueChanged += (e, sender) =>
            {
                Stepper sentStepper = (Stepper)e;

                if (sentStepper.Value > 0)
                {
                    value.Text = sentStepper.Value.ToString();
                }
                else
                {
                    value.Text = "0.0";
                }

                flexPie.Offset = sentStepper.Value;
            };

            StackLayout stack = new StackLayout();

            stack.Orientation = StackOrientation.Horizontal;

            stack.Children.Add(labelStack);
            stack.Children.Add(stepper);

            return stack;
        }
		public Controls ()
		{
			System.Diagnostics.Debug.WriteLine ("Controls:: Hello");

			eventValue = new Label {
				Text = "Value in Handler"
			};
			pageValue = new Label {
				Text = "Value in Page"
			};

			Picker picker = new Picker {
				Title = "Option",
				VerticalOptions = LayoutOptions.CenterAndExpand
			};

			var options = new List<string> {
				"First",
				"Second",
				"Third",
				"Fourth"
			};

			foreach (string optionName in options) {
				picker.Items.Add (optionName);
			}
			picker.SelectedIndexChanged += (sender, e) => {
				System.Diagnostics.Debug.WriteLine("Picked " + picker.Items[picker.SelectedIndex]);
				pageValue.Text = picker.Items[picker.SelectedIndex];
			};

			DatePicker datePicker = new DatePicker {
				Format = "D",
				VerticalOptions = LayoutOptions.CenterAndExpand
			};
			datePicker.DateSelected += (object sender, DateChangedEventArgs e) => {
				eventValue.Text = e.NewDate.ToString();
				pageValue.Text = datePicker.Date.ToString();
			};

			TimePicker timePicker = new TimePicker {
				Format = "T",
				VerticalOptions = LayoutOptions.Center
			};
			timePicker.PropertyChanged += (sender, e) => {
				if (e.PropertyName == TimePicker.TimeProperty.PropertyName) {
					pageValue.Text = timePicker.Time.ToString();
				}
			};

			Stepper stepper = new Stepper {
				Minimum = 0,
				Maximum = 10,
				Increment = 1,
				HorizontalOptions = LayoutOptions.Center,
				VerticalOptions = LayoutOptions.CenterAndExpand
			};
			// Alternatively
			// public Stepper(min, max, start, increment)
			// Stepper stepper = new Stepper(0, 10, 0, 1);
			stepper.ValueChanged += (sender, e) => {
				eventValue.Text = String.Format("Stepper value is {0:F1}", e.NewValue);
				pageValue.Text = stepper.Value.ToString();
			};

			Slider slider = new Slider {
				Minimum = 0,
				Maximum = 100,
				WidthRequest = 100,
				HorizontalOptions = LayoutOptions.Center,
				VerticalOptions = LayoutOptions.CenterAndExpand
			};
			slider.ValueChanged += (sender, e) => {
				eventValue.Text = String.Format("Slider val is {0:F1}", e.NewValue);
				pageValue.Text = slider.Value.ToString();
			};

			// Layout
			StackLayout stackLayout = new StackLayout {
				Children = {
					eventValue,
					pageValue,
					picker,
					datePicker,
					timePicker,
					stepper,
					slider
				},
				HorizontalOptions = LayoutOptions.Center,
			};

			Content = stackLayout;
			Padding = new Thickness (0, Device.OnPlatform (20, 0, 0), 0, 0);

		}