Esempio n. 1
1
        private ScrollView GenerateOptionLayout()
        {
            var stack = new StackLayout { Orientation = StackOrientation.Vertical };

            var peak = new Entry { Keyboard = Keyboard.Numeric, Placeholder = "Peak" };
            peak.SetBinding(Entry.TextProperty, OptionViewModel.PeakCommandPropertyName);
            stack.Children.Add(peak);

            var distance = new Entry { Keyboard = Keyboard.Numeric, Placeholder = "Distance" };
            distance.SetBinding(Entry.TextProperty, OptionViewModel.DistanceCommandPropertyName);
            stack.Children.Add(distance);

            var dogAllowed = new Switch();
            dogAllowed.SetBinding(Switch.IsToggledProperty, OptionViewModel.DogAllowedCommandPropertyName);
            stack.Children.Add(dogAllowed);

            var goodForKids = new Switch();
            goodForKids.SetBinding(Switch.IsToggledProperty, OptionViewModel.GoodForKidsCommandPropertyName);
            stack.Children.Add(goodForKids);

            var seasonStart = new Picker { Title = "SeasonStart" };
            foreach (var season in options.Seasons)
            {
                seasonStart.Items.Add(season.Value);
            }
            seasonStart.SetBinding(Picker.SelectedIndexProperty, OptionViewModel.SeasonStartCommandPropertyName);
            stack.Children.Add(seasonStart);

            var seasonEnd = new Picker { Title = "SeasonEnd" };
            foreach (var season in options.Seasons)
            {
                seasonEnd.Items.Add(season.Value);
            }
            seasonEnd.SetBinding(Picker.SelectedIndexProperty, OptionViewModel.SeasonEndCommandPropertyName);
            stack.Children.Add(seasonEnd);

            var trailType = new Picker() { Title = "Trail Type" };
            stack.Children.Add(trailType);
            foreach (var type in options.TrailsTypes)
            {
                trailType.Items.Add(type.Value);
            }
            trailType.SetBinding(Picker.SelectedIndexProperty, OptionViewModel.TypeCommandPropertyName);

            var trailDurationType = new Picker() { Title = "Trail Duration Type" };
            foreach (var durType in options.TrailsDurationTypes)
            {
                trailDurationType.Items.Add(durType.Value);
            }
            trailDurationType.SetBinding(Picker.SelectedIndexProperty, OptionViewModel.DurationTypeCommandPropertyName);
            stack.Children.Add(trailDurationType);

            var button = GenericsContent.GenerateDefaultButton("Update");
            button.SetBinding(Button.CommandProperty, OptionViewModel.UpdateCommandPropertyName);
            stack.Children.Add(button);

            return new ScrollView { Content = stack };
        }
Esempio n. 2
0
        private static Picker GeneratePickerForCommentRate()
        {
            var picker = new Picker
            {
                TextColor = DefaultAppStyles.DefaultTextColor,
                Title = "Rate",
            };

            for (int i = 0; i < 6; i++)
            {
                picker.Items.Add(i.ToString());
            }

            picker.SetBinding(Picker.SelectedIndexProperty, CommentsViewModel.RatePropertyName);
            return picker;
        }
Esempio n. 3
0
        } //end ctor


        private Layout BuildView()
        {
            this.BackgroundColor = AppColors.CONTENTLIGHTBKG;

            Label lblItem = new Label() { Text = "Product:",  TextColor = AppColors.LABELBLUE };
            Picker pickerItem = new Picker() { HorizontalOptions = LayoutOptions.FillAndExpand, BackgroundColor = AppColors.LABELGRAY };

            foreach(var a in Order.ItemTypes)
            {
                pickerItem.Items.Add(a);
            }
            pickerItem.SetBinding(Picker.SelectedIndexProperty, "ItemIndex");

            Label lblPrice = new Label() { Text = "Price:", TextColor = AppColors.LABELBLUE };
            Entry entryPrice = new Entry() { HorizontalOptions = LayoutOptions.FillAndExpand, Keyboard = Keyboard.Numeric,
                BackgroundColor = AppColors.LABELGRAY };
            entryPrice.SetBinding(Entry.TextProperty, "Price");

            Label lblDateDue = new Label() { Text = "Date Due:", TextColor = AppColors.LABELBLUE };
            DatePicker dateDue = new DatePicker() { HorizontalOptions = LayoutOptions.FillAndExpand, BackgroundColor = AppColors.LABELGRAY };
            dateDue.SetBinding(DatePicker.DateProperty, "Order.DueDate");

            Button btnOrder = new Button() { Text = "Place Order", HorizontalOptions = LayoutOptions.Center, TextColor = AppColors.LABELWHITE };
            btnOrder.Clicked += btnOrder_Clicked;

            StackLayout stack = new StackLayout()
            {
                Padding = 10,

                Children =
                {
                    lblItem,
                    pickerItem,
                    lblPrice,
                    entryPrice,
                    lblDateDue,
                    dateDue,
                    btnOrder

                }

            };

            return stack;
        }
		public SvgImageSamplePage ()
		{
			_ViewModel = new SvgImageSamplePageViewModel();
			var insetLabel = new Label();
			insetLabel.SetBinding(Label.TextProperty, nameof(SvgImageSamplePageViewModel.SvgInsets), stringFormat: "Stretchable Insets: {0:C2}");
			var resourcePicker = new Picker() {
				HorizontalOptions = LayoutOptions.FillAndExpand,
			};
			foreach (var resourceName in SvgImageSamplePageViewModel.AvailableResourceNames) {
				resourcePicker.Items.Add(resourceName);
			}
			resourcePicker.SetBinding(Picker.SelectedIndexProperty, nameof(SvgImageSamplePageViewModel.SvgResourceIndex), BindingMode.TwoWay);
			var insetSlider = new Slider() {
				Minimum = 0,
				Maximum = 35,
				Value = _ViewModel.AllSidesInset,
			};
			insetSlider.SetBinding(Slider.ValueProperty, nameof(SvgImageSamplePageViewModel.AllSidesInset), BindingMode.TwoWay);
			var slicingSvg = new SvgImage() {
				SvgAssembly = typeof(App).GetTypeInfo().Assembly,
				WidthRequest = 300,
				HeightRequest = 300,
			};
			slicingSvg.SetBinding(SvgImage.SvgStretchableInsetsProperty, nameof(SvgImageSamplePageViewModel.SvgInsets));
			slicingSvg.SetBinding(SvgImage.SvgPathProperty, nameof(SvgImageSamplePageViewModel.SvgResourcePath));
			var svgButton = new Button() {
				WidthRequest = 300,
				HeightRequest = 300,
				BackgroundColor = Color.Transparent,
			};

			// The root page of your application
			Title = "9-Slice SVG Scaling";
			Content = new ScrollView {
				Content = new StackLayout {
					VerticalOptions = LayoutOptions.Start,
					HorizontalOptions = LayoutOptions.Center,
					Children = {
						insetLabel,
						resourcePicker,
						insetSlider,
						new AbsoluteLayout() {
							WidthRequest = 300,
							HeightRequest = 300,
							Children = {
								slicingSvg,
								svgButton,
							},
						},
						new Label () {
							Text = "Using TwinTechsForms.SvgImage",
						},
						new Label () {
							Text = "Proportional Scaling",
						},
						new SvgImage() {
							SvgAssembly = typeof(App).GetTypeInfo().Assembly,
							SvgPath = "TwinTechs.TwinTechs.Example.SvgImageSample.Assets.funky-border.svg",
							WidthRequest = 50,
							HeightRequest = 50,
						},
						new SvgImage() {
							SvgAssembly = typeof(App).GetTypeInfo().Assembly,
							SvgPath = "TwinTechs.TwinTechs.Example.SvgImageSample.Assets.funky-border.svg",
							WidthRequest = 100,
							HeightRequest = 100,
						},
						new Label () {
							Text = "9-Slice Scaling",
						},
						new SvgImage() {
							SvgAssembly = typeof(App).GetTypeInfo().Assembly,
							SvgPath = "TwinTechs.TwinTechs.Example.SvgImageSample.Assets.funky-border.svg",
							SvgStretchableInsets = new ResizableSvgInsets (18),
							WidthRequest = 50,
							HeightRequest = 50,
							HorizontalOptions = LayoutOptions.Start,
						},
						new SvgImage() {
							SvgAssembly = typeof(App).GetTypeInfo().Assembly,
							SvgPath = "TwinTechs.TwinTechs.Example.SvgImageSample.Assets.funky-border.svg",
							SvgStretchableInsets = new ResizableSvgInsets (18),
							WidthRequest = 100,
							HeightRequest = 100,
							HorizontalOptions = LayoutOptions.Start,
						},
						new SvgImage() {
							SvgAssembly = typeof(App).GetTypeInfo().Assembly,
							SvgPath = "TwinTechs.TwinTechs.Example.SvgImageSample.Assets.funky-border.svg",
							SvgStretchableInsets = new ResizableSvgInsets (18),
							WidthRequest = 300,
							HeightRequest = 300,
							HorizontalOptions = LayoutOptions.Start,
						},
						new Label () {
							Text = "Using TwinTechsForms.NControl.SvgImageView",
						},
						new Label () {
							Text = "Proportional Scaling",
						},
						new SvgImageView() {
							SvgAssembly = typeof(App).GetTypeInfo().Assembly,
							SvgPath = "TwinTechs.TwinTechs.Example.SvgImageSample.Assets.funky-border.svg",
							WidthRequest = 50,
							HeightRequest = 50,
						},
						new SvgImageView() {
							SvgAssembly = typeof(App).GetTypeInfo().Assembly,
							SvgPath = "TwinTechs.TwinTechs.Example.SvgImageSample.Assets.funky-border.svg",
							WidthRequest = 100,
							HeightRequest = 100,
						},
						new Label () {
							Text = "9-Slice Scaling",
						},
						new SvgImageView () {
							SvgAssembly = typeof(App).GetTypeInfo().Assembly,
							SvgPath = "TwinTechs.TwinTechs.Example.SvgImageSample.Assets.funky-border.svg",
							SvgStretchableInsets = new TwinTechsForms.NControl.ResizableSvgInsets (18),
							WidthRequest = 50,
							HeightRequest = 50,
							HorizontalOptions = LayoutOptions.Start,
						},
						new SvgImageView () {
							SvgAssembly = typeof(App).GetTypeInfo().Assembly,
							SvgPath = "TwinTechs.TwinTechs.Example.SvgImageSample.Assets.funky-border.svg",
							SvgStretchableInsets = new TwinTechsForms.NControl.ResizableSvgInsets (18),
							WidthRequest = 100,
							HeightRequest = 100,
							HorizontalOptions = LayoutOptions.Start,
						},
						new SvgImageView () {
							SvgAssembly = typeof(App).GetTypeInfo().Assembly,
							SvgPath = "TwinTechs.TwinTechs.Example.SvgImageSample.Assets.funky-border.svg",
							SvgStretchableInsets = new TwinTechsForms.NControl.ResizableSvgInsets (18),
							WidthRequest = 300,
							HeightRequest = 300,
							HorizontalOptions = LayoutOptions.Start,
						},
					},
					BindingContext = _ViewModel,
				},
			};
			svgButton.Clicked += (sender, e) => {
				DisplayAlert("Tapped!", "SVG button tapped!", "OK");
			};
		}
Esempio n. 5
0
        public TodoItemPage()
        {
            this.SetBinding(ContentPage.TitleProperty, "Todo");
            NavigationPage.SetHasNavigationBar(this, true);

            //task name
            var nameLabel = new Label { Text = "Name" };
            var nameEntry = new Entry();
            nameEntry.SetBinding(Entry.TextProperty, "Name");

            //Notes
            var notesLabel = new Label { Text = "Notes" };
            var notesEntry = new Entry();
            notesEntry.SetBinding(Entry.TextProperty, "Notes");

            //Category
            var categoryLabel = new Label { Text = "Category" };
            var categoryPicker = new Picker
            {
                Title = "Category",
                VerticalOptions = LayoutOptions.CenterAndExpand
            };
            foreach (var category in App.CategoryDatabase.GetCategories())
            {
                categoryPicker.Items.Add(category.Name);
            }
            categoryPicker.SetBinding(Picker.SelectedIndexProperty, "CategoryId");

            //var categoryPicker = new BindablePicker
            //{
            //    Title = "Category",
            //    VerticalOptions = LayoutOptions.CenterAndExpand,
            //    ItemsSource = App.CategoryDatabase.GetCategoryNames()
            //};
            //categoryPicker.SetBinding(BindablePicker.SelectedItemProperty, "Category");

            //Due date
            var dueDateLabel = new Label { Text = "Due Date" };
            var dueDatePicker = new DatePicker
            {
                Format = "D",
                VerticalOptions = LayoutOptions.CenterAndExpand
            };
            dueDatePicker.SetBinding(DatePicker.DateProperty, "DueDate");

            //Reminder Date
            var reminderDateLabel = new Label { Text = " Set Reminder" };
            var reminderDatePicker = new DatePicker
            {
                Format = "D",
                VerticalOptions = LayoutOptions.CenterAndExpand
            };
            reminderDatePicker.SetBinding(DatePicker.DateProperty, "ReminderDate");

            //Done
            var doneLabel = new Label { Text = "Done" };
            var doneEntry = new Switch();
            doneEntry.SetBinding(Switch.IsToggledProperty, "Done");

            //Save
            var saveButton = new Button { Text = "Save" };
            saveButton.Clicked += (sender, e) =>
            {
                var todoItem = (TodoItem)BindingContext;
                App.Database.SaveItem(todoItem);
                this.Navigation.PopAsync();
            };
            Content = new StackLayout
            {
                VerticalOptions = LayoutOptions.StartAndExpand,
                Padding = new Thickness(20),
                Children = {
                    nameLabel, nameEntry,
                    notesLabel, notesEntry,
                    categoryLabel, categoryPicker,
                    dueDateLabel, dueDatePicker,
                    reminderDateLabel, reminderDatePicker,
                    doneLabel, doneEntry,
                    saveButton
                }
            };
        }
        public App() {
            var resourcePicker = new Picker() {
                VerticalOptions = LayoutOptions.CenterAndExpand,
            };
            foreach (var resourceName in TestModel.AvailableResourceNames) {
                resourcePicker.Items.Add(resourceName);
            }
            resourcePicker.SetBinding(Picker.SelectedIndexProperty, nameof(TestModel.SvgResourceIndex), BindingMode.TwoWay);
            var insetSlider = new Slider() {
                Minimum = 0,
                Maximum = 35,
                Value = _ViewModel.AllSidesInset,
            };
            insetSlider.SetBinding(Slider.ValueProperty, nameof(TestModel.AllSidesInset), BindingMode.TwoWay);
            var slicingSvg = new SvgImageView() {
                SvgAssembly = typeof(App).GetTypeInfo().Assembly,
                SvgPath = _ViewModel.SvgResourcePath,
                WidthRequest = 300,
                HeightRequest = 300,
            };
            slicingSvg.SetBinding(SvgImageView.SvgStretchableInsetsProperty, nameof(TestModel.SvgInsets));
            slicingSvg.SetBinding(SvgImageView.SvgPathProperty, nameof(TestModel.SvgResourcePath));

            // The root page of your application
            MainPage = new ContentPage {
                Content = new StackLayout {
                    VerticalOptions = LayoutOptions.Center,
                    HorizontalOptions = LayoutOptions.Center,
                    Children = {
                        resourcePicker,
                        insetSlider,
                        slicingSvg,
                    },
                    BindingContext = _ViewModel,
                },
            };
        }
        public App() {
            _ViewModel = new TestModel();
            var insetLabel = new Label();
            insetLabel.SetBinding(Label.TextProperty, nameof(TestModel.SvgInsets), stringFormat: "Stretchable Insets: {0:C2}");
            var resourcePicker = new Picker() {
                HorizontalOptions = LayoutOptions.FillAndExpand,
            };
            foreach (var resourceName in TestModel.AvailableResourceNames) {
                resourcePicker.Items.Add(resourceName);
            }
            resourcePicker.SetBinding(Picker.SelectedIndexProperty, nameof(TestModel.SvgResourceIndex), BindingMode.TwoWay);
            var insetSlider = new Slider() {
                Minimum = 0,
                Maximum = 35,
                Value = _ViewModel.AllSidesInset,
            };
            insetSlider.SetBinding(Slider.ValueProperty, nameof(TestModel.AllSidesInset), BindingMode.TwoWay);
            var slicingSvg = new SvgImage() {
                SvgAssembly = typeof(App).GetTypeInfo().Assembly,
                WidthRequest = 300,
                HeightRequest = 300,
            };
            slicingSvg.SetBinding(SvgImage.SvgStretchableInsetsProperty, nameof(TestModel.SvgInsets));
            slicingSvg.SetBinding(SvgImage.SvgPathProperty, nameof(TestModel.SvgResourcePath));
            var svgButton = new Button() {
                WidthRequest = 300,
                HeightRequest = 300,
            };

            // The root page of your application
            MainPage = new NavigationPage (new ContentPage {
                Title = "9-Slice SVG Scaling",
                Content = new StackLayout {
                    VerticalOptions = LayoutOptions.Start,
                    HorizontalOptions = LayoutOptions.Center,
                    Children = {
                        insetLabel,
                        resourcePicker,
                        insetSlider,
                        new AbsoluteLayout() {
                            WidthRequest = 300,
                            HeightRequest = 300,
                            Children = {
                                slicingSvg,
                                svgButton,
                            },
                        },
                    },
                    BindingContext = _ViewModel,
                },
            });
            svgButton.Clicked += (sender, e) => {
                MainPage.DisplayAlert("Tapped!", "SVG button tapped!", "OK");
            };
        }
        private void AddLocationPicker()
        {
            var label = new Label
            {
                Text = c_cannotDetectGeolocationMessage,
            };
            layout.Children.Add(label);

            var picker = new Picker
            {
                Title = "Province",
                BindingContext = LoadingLocationViewModel.UserSelectedLocation,
            };
            layout.Children.Add(picker);

            foreach (var location in LoadingLocationViewModel.RaffleLocations)
            {
                picker.Items.Add(location.Name);
            }
            picker.SetBinding(Picker.SelectedIndexProperty, new Binding("Name", BindingMode.TwoWay, new PickerRaffleLocationNameToIndexConverter(), LoadingLocationViewModel.RaffleLocations));

            var button = new Button
            {
                Text = "Next",
            };
            layout.Children.Add(button);
            button.Clicked += (sender, e) =>
            {
                MessagingCenter.Send<LoadingLocationPage>(this, "Success");
            };
        }
Esempio n. 9
0
        /// <summary>
        /// Initializes the component.
        /// </summary>
        /// <param name="tshirt">Tshirt.</param>
        void InitializeComponent(TShirt tshirt)
        {
            var layout = new StackLayout
            {
                VerticalOptions = LayoutOptions.Center
            };

            var image = new Image
            {
                HorizontalOptions = LayoutOptions.Center,
                Source = tshirt.Image
            };

            var label = new Label { HorizontalOptions = LayoutOptions.Center, Text = tshirt.Name };

            var genderCell = new SwitchCell { Text = "Women / Men" };
            genderCell.SetBinding<OrderViewModel>(SwitchCell.OnProperty, vm => vm.IsMen);

            var sizeLabel = new Label { Text = "Size", HorizontalOptions = LayoutOptions.StartAndExpand, VerticalOptions = LayoutOptions.Center };
            var sizePicker = new Picker { Title = "Small", WidthRequest = 100.0, HorizontalOptions = LayoutOptions.EndAndExpand, VerticalOptions = LayoutOptions.Center };
            sizePicker.Items.Add("Small");
            sizePicker.Items.Add("Medium");
            sizePicker.Items.Add("Large");
            sizePicker.Items.Add("X-Large");
            sizePicker.SetBinding<OrderViewModel>(Picker.SelectedIndexProperty, vm => vm.SizeIndex);

            var sizeLayout = new StackLayout
            {
                Padding = new Thickness(15, 0),
                Spacing = 0,
                Orientation = StackOrientation.Horizontal,
                Children =
                {
                    sizeLabel,
                    sizePicker
                }
            };

            var sizeCell = new ViewCell
            {
                View = sizeLayout
            };

            var optionSection = new TableSection { Title = "Options" };
            optionSection.Add(genderCell);
            optionSection.Add(sizeCell);

            var tableView = new TableView
            {
                Intent = TableIntent.Form,
                HeightRequest = 300.0,
                Root = new TableRoot
                {
                    optionSection
                }
            };

            var buttonCancel = new Button { HorizontalOptions = LayoutOptions.EndAndExpand, Text = "Cancel" };
            buttonCancel.Clicked += async (sender, e) => await Navigation.PopModalAsync();

            var buttonOrder = new Button { HorizontalOptions = LayoutOptions.StartAndExpand, Text = "Purchase" };
            buttonOrder.SetBinding<OrderViewModel>(Button.CommandProperty, vm => vm.OrderCommand);

            var bottomLayout = new StackLayout
            {
                Spacing = 0,
                Orientation = StackOrientation.Horizontal,
                Children =
                {
                    buttonCancel,
                    new Label
                    {
                        HorizontalOptions = LayoutOptions.CenterAndExpand
                    },
                    buttonOrder
                }
            };

            layout.Children.Add(image);
            layout.Children.Add(label);
            layout.Children.Add(tableView);
            layout.Children.Add(bottomLayout);

            Content = layout;
        }
Esempio n. 10
0
 public static View CreatePickerFor(string propertyName, LayoutOptions layout)
 {
     Picker iiPicker = new Picker
     {
         HorizontalOptions = layout,
         Title = "Leave Type",
         HeightRequest = 150,
         WidthRequest = 150,
     };
     iiPicker.Items.Add("Leave Type");
     iiPicker.Items.Add("Casual Leave");
     iiPicker.Items.Add("Medical Leave");
     iiPicker.Items.Add("Paid Leave");
     iiPicker.SetBinding(Picker.TitleProperty, propertyName);
     iiPicker.SelectedIndex = 0;
     return iiPicker;
 }
        public RegistrationPage(bool isUpdate, Page parent, UserAccount userAccount = null)
        {
            InitializeComponent();
            if (!isUpdate)
            {
                Title = "Registration";
            }
            else
            {
                Title = "Update Information";
            }
            _tableView.Intent = TableIntent.Menu;

            if (userAccount == null)
            {
                _viewModel = new AccountInfoViewModel();
            }
            else
            {
                _viewModel = new AccountInfoViewModel(userAccount);
            }
            this.BindingContext = _viewModel;

            #region Birthday
            var birthdayCell = new ViewCell();
            _birthdaySection.Add(birthdayCell);

            var birthdayLayout = new StackLayout
            {
                Padding = new Thickness(10, 0, 10, 0),
            };
            birthdayCell.View = birthdayLayout;

            var datePicker = new DatePicker
            {
                Format = "MMM d yyyy",
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions = LayoutOptions.CenterAndExpand,
            };
            birthdayLayout.Children.Add(datePicker);
            datePicker.SetBinding(DatePicker.DateProperty, "UserAccount.Birthday", BindingMode.TwoWay);
            #endregion

            #region Province
            var provinceCellLayout = new StackLayout
            {
                Padding = new Thickness(10, 0, 10, 0),
            };
            _provinceCell.View = provinceCellLayout;

            var provincePicker = new Picker
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions = LayoutOptions.CenterAndExpand,
            };
            provinceCellLayout.Children.Add(provincePicker);

            var firstCountry = DatabaseManager.DbConnection.Table<Country>().First();
            var provinces = DatabaseManager.DbConnection.Table<Province>().Where(x => x.CountryCode == firstCountry.CountryCode).ToList();
            foreach (var province in provinces)
            {
                provincePicker.Items.Add(province.ProvinceName);
            }
            provincePicker.SetBinding(Picker.SelectedIndexProperty, new Binding("UserAccount.Province", BindingMode.TwoWay, new PickerProvinceToIndexConverter(), provinces));
            #endregion

            #region Country
            var countryCellLayout = new StackLayout
            {
                Padding = new Thickness(10, 0, 10, 0),
            };
            _countryCell.View = countryCellLayout;

            var countryPicker = new Picker
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions = LayoutOptions.CenterAndExpand,
            };
            countryCellLayout.Children.Add(countryPicker);

            var countries = DatabaseManager.DbConnection.Table<Country>().ToList();
            foreach (var country in countries)
            {
                countryPicker.Items.Add(country.CountryName);
            }
            countryPicker.SetBinding(Picker.SelectedIndexProperty, new Binding("UserAccount.Country", BindingMode.TwoWay, new PickerCountryToIndexConverter(), countries));

            countryPicker.SelectedIndexChanged += (sender, e) =>
            {
                provincePicker.Items.Clear();

                var countryCode = countries[countryPicker.SelectedIndex].CountryCode;
                var newProvinces = DatabaseManager.DbConnection.Table<Province>().Where(x => x.CountryCode == countryCode).ToList();

                // If there is no province, use N/A
                if ((newProvinces == null) || (newProvinces.Count == 0))
                {
                    newProvinces = new List<Province>
                    {
                        new Province
                        {
                            ProvinceName = "N/A",
                        }
                    };
                }

                foreach (var province in newProvinces)
                {
                    provincePicker.Items.Add(province.ProvinceName);
                }
                provincePicker.SetBinding(Picker.SelectedIndexProperty, new Binding("UserAccount.Province", BindingMode.TwoWay, new PickerProvinceToIndexConverter(), newProvinces));
            };
            #endregion

            #region Raffle Result
            var raffleResultsViewCell = new ViewCell();
            _raffleResultsSection.Add(raffleResultsViewCell);

            var raffleResultsLayout = new StackLayout
            {
                Padding = new Thickness(10, 0, 10, 0),
            };
            raffleResultsViewCell.View = raffleResultsLayout;

            var raffleResultsPicker = new Picker
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions = LayoutOptions.CenterAndExpand,
            };
            raffleResultsLayout.Children.Add(raffleResultsPicker);

            foreach (var item in c_contactMethods)
            {
                raffleResultsPicker.Items.Add(item);
            }
            raffleResultsPicker.SetBinding(Picker.SelectedIndexProperty, new Binding("UserAccount.PreferedContactMethod", BindingMode.TwoWay, new PickerContactMethodsConverter()));
            #endregion

            #region Charity Message
            var charityMessagesViewCell = new ViewCell();
            _charityMessagesSection.Add(charityMessagesViewCell);

            var charityMessagesLayout = new StackLayout
            {
                Padding = new Thickness(10, 0, 10, 0),
            };
            charityMessagesViewCell.View = charityMessagesLayout;

            var charityMessagesPicker = new Picker
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions = LayoutOptions.CenterAndExpand,
            };
            charityMessagesLayout.Children.Add(charityMessagesPicker);

            foreach (var item in c_contactMethods)
            {
                charityMessagesPicker.Items.Add(item);
            }
            charityMessagesPicker.SetBinding(Picker.SelectedIndexProperty, new Binding("UserAccount.PreferedContactMethodCharity", BindingMode.TwoWay, new PickerContactMethodsConverter()));
            #endregion

            if (!isUpdate)
            {
                var createAccountButtonViewCell = new ViewCell();
                _createAccountButtonSection.Add(createAccountButtonViewCell);

                var createAccountButtonLayout = new StackLayout
                {
                    Padding = new Thickness(5, 0, 5, 0),
                    BackgroundColor = Color.Accent,
                };
                createAccountButtonViewCell.View = createAccountButtonLayout;

                var createAccountButton = new Button
                {
                    Text = "Create Account",
                    HorizontalOptions = LayoutOptions.CenterAndExpand,
                    TextColor = Color.White,
                };
                createAccountButtonLayout.Children.Add(createAccountButton);

                createAccountButton.Clicked += async (sender, e) =>
                {
                    var result = await _viewModel.CreateAccount();
                    if (result.Item1)
                    {
                        this.Navigation.PopAsync();
                        var answer = await DisplayAlert("Register Phone Number", "Send registration code to your phone now?", "Later", "Yes");
                        if (!answer) // use !answer because the negative choice has a bigger font
                        {
                            parent.Navigation.PushAsync(new VerifyPhonePage(_viewModel.UserAccount.Email, _viewModel.UserAccount.Phone, _viewModel.UserAccount.CountryCode)); //Country code is updated after calling _viewModel.CreateAccount()
                        }
                    }
                    else
                    {
                        DisplayAlert("Server request failed", "", "OK");
                    }
                };
            }
            else
            {
                // Edit Account Page
                _toolbarItemIsEnabled = true;

                _onDoneButtonClicked = new Command(async () =>
                    {
                        if (_toolbarItemIsEnabled)
                        {
                            if (_viewModel.InfoHasNotChanged())
                            {
                                DisplayAlert("Warning", "Your information has not changed.", "Retry");
                            }
                            else
                            {
                                _toolbarItemIsEnabled = false; // Disable the button while await
                                var result = await _viewModel.UpdateAccountInfo();
                                _toolbarItemIsEnabled = true;
                                if (result.Item1)
                                {
                                    this.Navigation.InsertPageBefore(new AccountInfoPage(), parent);
                                    this.Navigation.PopAsync(false);
                                    this.Navigation.PopAsync(false);
                                }
                                else
                                {
                                    DisplayAlert("Error", result.Item2, "Retry");
                                }
                            }
                        }
                    });

                var toolbarItem = new ToolbarItem
                {
                    Text = "Done",
                    Command = _onDoneButtonClicked,
                };
                this.ToolbarItems.Add(toolbarItem);
            }
        }
Esempio n. 12
0
        public TermsPage(int pageNumber, int totalPageNumbers)
        {
            viewModel = new TermsPageViewModel();
            BindingContext = viewModel;

            #region Create Scenario Stack
            var scenarioLabel = new Label
            {
                Text = "Scenario",
                FontAttributes = FontAttributes.Bold
            };
            var scenarioPicker = new Picker();
            scenarioPicker.Items.Add("1");
            scenarioPicker.Items.Add("2");
            scenarioPicker.Items.Add("3");
            scenarioPicker.SetBinding(Picker.SelectedIndexProperty, "PickerValue");

            var scenarioStack = new StackLayout
            {
                Orientation = StackOrientation.Horizontal,
                Children = {
                    scenarioLabel,
                    scenarioPicker
                },
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions = LayoutOptions.Center
            };

            #endregion

            #region Create Scenario Label
            var term1Label = new Label
            {
                Text = "Down Payment to BFC"
            };
            var term2Label = new Label
            {
                Text = "Amount Financed"
            };
            var term3Label = new Label
            {
                Text = "Compounding Period"
            };
            var term4Label = new Label
            {
                Text = "Funding Program"
            };
            var term5Label = new Label
            {
                Text = "Funding Source"
            };
            var term6Label = new Label
            {
                Text = "Payment/Terms/Run Rate"
            };
            var term7Label = new Label
            {
                Text = "Security Deposit"
            };
            var term8Label = new Label
            {
                Text = "Advanced Payments"
            };
            var term9Label = new Label
            {
                Text = "Total Time"
            };
            var term10Label = new Label
            {
                Text = "Doc Fee"
            };
            var term11Label = new Label
            {
                Text = "Purchase Options"
            };
            var term12Label = new Label
            {
                Text = "Purchase Options Type"
            };
            var term13Label = new Label
            {
                Text = "Additional Collatoral"
            };
            var term14Label = new Label
            {
                Text = "Total Initial Cash"
            };
            var term15Label = new Label
            {
                Text = "Total Referral Cash"
            };
            var term16Label = new Label
            {
                Text = "Other Income/Expense"
            };
            var term17Label = new Label
            {
                Text = "IRR"
            };
            var term18Label = new Label
            {
                Text = "One-Off Profit / PTS / Source"
            };
            var term19Label = new Label
            {
                Text = "Commission"
            };
            var term20Label = new Label
            {
                Text = "T-Value Calculation"
            };
            #endregion

            #region Create Labels for Scenario Data
            var term1Data = new Label();
            term1Data.SetBinding(Label.TextProperty, "Term1Data");

            var term2Data = new Label();
            term2Data.SetBinding(Label.TextProperty, "Term2Data");

            var term3Data = new Label();
            term3Data.SetBinding(Label.TextProperty, "Term3Data");

            var term4Data = new Label();
            term4Data.SetBinding(Label.TextProperty, "Term4Data");

            var term5Data = new Label();
            term5Data.SetBinding(Label.TextProperty, "Term5Data");

            var term6Data = new Label();
            term6Data.SetBinding(Label.TextProperty, "Term6Data");

            var term7Data = new Label();
            term7Data.SetBinding(Label.TextProperty, "Term7Data");

            var term8Data = new Label();
            term8Data.SetBinding(Label.TextProperty, "Term8Data");

            var term9Data = new Label();
            term9Data.SetBinding(Label.TextProperty, "Term9Data");

            var term10Data = new Label();
            term10Data.SetBinding(Label.TextProperty, "Term10Data");

            var term11Data = new Label();
            term11Data.SetBinding(Label.TextProperty, "Term11Data");

            var term12Data = new Label();
            term12Data.SetBinding(Label.TextProperty, "Term12Data");

            var term13Data = new Label();
            term13Data.SetBinding(Label.TextProperty, "Term13Data");

            var term14Data = new Label();
            term14Data.SetBinding(Label.TextProperty, "Term14Data");

            var term15Data = new Label();
            term15Data.SetBinding(Label.TextProperty, "Term15Data");

            var term16Data = new Label();
            term16Data.SetBinding(Label.TextProperty, "Term16Data");

            var term17Data = new Label();
            term17Data.SetBinding(Label.TextProperty, "Term17Data");

            var term18Data = new Label();
            term18Data.SetBinding(Label.TextProperty, "Term18Data");

            var term19Data = new Label();
            term19Data.SetBinding(Label.TextProperty, "Term19Data");

            var term20Data = new Label();
            term20Data.SetBinding(Label.TextProperty, "Term20Data");
            #endregion

            #region Create & Populate Grid
            var dataGrid = new Grid
            {
                HorizontalOptions = LayoutOptions.Center,
                RowDefinitions = {
                    new RowDefinition { Height = new GridLength(1, GridUnitType.Star) },
                    new RowDefinition { Height = new GridLength(1, GridUnitType.Star) },
                    new RowDefinition { Height = new GridLength(1, GridUnitType.Star) },
                    new RowDefinition { Height = new GridLength(1, GridUnitType.Star) },
                    new RowDefinition { Height = new GridLength(1, GridUnitType.Star) },
                    new RowDefinition { Height = new GridLength(1, GridUnitType.Star) },
                    new RowDefinition { Height = new GridLength(1, GridUnitType.Star) },
                    new RowDefinition { Height = new GridLength(1, GridUnitType.Star) },
                    new RowDefinition { Height = new GridLength(1, GridUnitType.Star) },
                    new RowDefinition { Height = new GridLength(1, GridUnitType.Star) },
                    new RowDefinition { Height = new GridLength(1, GridUnitType.Star) },
                    new RowDefinition { Height = new GridLength(1, GridUnitType.Star) },
                    new RowDefinition { Height = new GridLength(1, GridUnitType.Star) },
                    new RowDefinition { Height = new GridLength(1, GridUnitType.Star) },
                    new RowDefinition { Height = new GridLength(1, GridUnitType.Star) },
                    new RowDefinition { Height = new GridLength(1, GridUnitType.Star) },
                    new RowDefinition { Height = new GridLength(1, GridUnitType.Star) },
                    new RowDefinition { Height = new GridLength(1, GridUnitType.Star) },
                    new RowDefinition { Height = new GridLength(1, GridUnitType.Star) },
                },
                ColumnDefinitions = {
                    new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) },
                    new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) },
                }
            };
            dataGrid.Children.Add(term1Label, 0, 0);
            dataGrid.Children.Add(term2Label, 0, 1);
            dataGrid.Children.Add(term3Label, 0, 2);
            dataGrid.Children.Add(term4Label, 0, 3);
            dataGrid.Children.Add(term5Label, 0, 4);
            dataGrid.Children.Add(term6Label, 0, 5);
            dataGrid.Children.Add(term7Label, 0, 6);
            dataGrid.Children.Add(term8Label, 0, 7);
            dataGrid.Children.Add(term9Label, 0, 8);
            dataGrid.Children.Add(term10Label, 0, 9);
            dataGrid.Children.Add(term11Label, 0, 10);
            dataGrid.Children.Add(term12Label, 0, 11);
            dataGrid.Children.Add(term13Label, 0, 12);
            dataGrid.Children.Add(term14Label, 0, 13);
            dataGrid.Children.Add(term15Label, 0, 14);
            dataGrid.Children.Add(term16Label, 0, 15);
            dataGrid.Children.Add(term17Label, 0, 16);
            dataGrid.Children.Add(term18Label, 0, 17);
            dataGrid.Children.Add(term19Label, 0, 18);
            dataGrid.Children.Add(term20Label, 0, 19);

            dataGrid.Children.Add(term1Data, 1, 0);
            dataGrid.Children.Add(term2Data, 1, 1);
            dataGrid.Children.Add(term3Data, 1, 2);
            dataGrid.Children.Add(term4Data, 1, 3);
            dataGrid.Children.Add(term5Data, 1, 4);
            dataGrid.Children.Add(term6Data, 1, 5);
            dataGrid.Children.Add(term7Data, 1, 6);
            dataGrid.Children.Add(term8Data, 1, 7);
            dataGrid.Children.Add(term9Data, 1, 8);
            dataGrid.Children.Add(term10Data, 1, 9);
            dataGrid.Children.Add(term11Data, 1, 10);
            dataGrid.Children.Add(term12Data, 1, 11);
            dataGrid.Children.Add(term13Data, 1, 12);
            dataGrid.Children.Add(term14Data, 1, 13);
            dataGrid.Children.Add(term15Data, 1, 14);
            dataGrid.Children.Add(term16Data, 1, 15);
            dataGrid.Children.Add(term17Data, 1, 16);
            dataGrid.Children.Add(term18Data, 1, 17);
            dataGrid.Children.Add(term19Data, 1, 18);
            dataGrid.Children.Add(term20Data, 1, 19);
            #endregion

            var termsScrollView = new ScrollView
            {
                Content = dataGrid
            };

            var pageNumberLabel = new Label
            {
                Text = $"Terms Page {pageNumber} of {totalPageNumbers}",
                FontAttributes = FontAttributes.Bold,
                HorizontalOptions = LayoutOptions.Center
            };

            var scenarioListStack = new StackLayout
            {
                Children = {
                    pageNumberLabel,
                    scenarioStack,
                    termsScrollView
                }
            };
            Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5);
            Content = scenarioListStack;
        }