Example #1
0
		protected override void Init ()
		{
			var listView = new ListView ();

			var selection = new Selection ();
			listView.SetBinding (ListView.ItemsSourceProperty, "Items");

			listView.ItemTemplate = new DataTemplate (() => {
				var cell = new SwitchCell ();
				cell.SetBinding (SwitchCell.TextProperty, "Name");
				cell.SetBinding (SwitchCell.OnProperty, "IsSelected", BindingMode.TwoWay);
				return cell;
			});

			var instructions = new Label {
				FontSize = 16,
				Text =
					"The label at the bottom should equal the number of switches which are in the 'on' position. Flip some of the switches. If the number at the bottom does not equal the number of 'on' switches, the test has failed."
			};

			var label = new Label { FontSize = 24 };
			label.SetBinding (Label.TextProperty, "SelectedCount");

			Content = new StackLayout {
				VerticalOptions = LayoutOptions.Fill,
				Children = {
					instructions,
					listView,
					label
				}
			};

			BindingContext = selection;
		}
Example #2
0
        public Issue1762()
        {
            StackLayout stack = new StackLayout
            {
            };

            stack.Children.Add(new ListView {
                ItemsSource  = Objs,
                ItemTemplate = new DataTemplate(() => {
                    SwitchCell cell = new SwitchCell();
                    cell.SetBinding <MyObj> (SwitchCell.TextProperty, m => m.DisplayText);
                    cell.SetBinding <MyObj> (SwitchCell.OnProperty, m => m.IsSelected);
                    return(cell);
                }),
                IsGroupingEnabled   = true,
                GroupDisplayBinding = new Binding("Key")
            });
            Button b = new Button {
                Text = "add"
            };

            b.Clicked += (sender, e) => {
                Random r = new Random();
                Objs.Add(new MyObj {
                    DisplayText = r.Next().ToString(),
                    IsSelected  = r.Next() % 2 == 0
                });
            };
            stack.Children.Add(b);

            Content = stack;
        }
Example #3
0
 private void CreateComponent(CreateTrainingDayViewModel viewModel)
 {
     if (viewModel != null && viewModel.EditMode == BodyReport.Message.TEditMode.Edit)
     {
         SwitchCell convertionSwitchCell = new SwitchCell();
         convertionSwitchCell.BindingContext = viewModel;
         convertionSwitchCell.SetBinding(SwitchCell.TextProperty, (CreateTrainingDayViewModel source) => source.AutomaticalUnitConvertionLabel, mode: BindingMode.OneWay);
         convertionSwitchCell.SetBinding(SwitchCell.OnProperty, (CreateTrainingDayViewModel source) => source.BindingTrainingDay.AutomaticalUnitConvertion, mode: BindingMode.TwoWay);
         tableSection.Add(convertionSwitchCell);
     }
 }
Example #4
0
 public FilterGenderLanguagePage(TherapistFilter filter)
 {
     InitializeComponent();
     BindingContext = filter;
     foreach (var filterLanguage in filter.Languages)
     {
         var switchCell = new SwitchCell
         {
             BindingContext = filterLanguage
         };
         switchCell.SetBinding(SwitchCell.TextProperty, "DisplayName");
         switchCell.SetBinding(SwitchCell.OnProperty, "Set");
         LanguageTableSection.Add(switchCell);
     }
 }
Example #5
0
        protected override void OnAppearing()
        {
            base.OnAppearing();

            ViewModel.GetExpenseStatus();

            int count   = 0;
            var section = new TableSection("Statuses");

            foreach (var es in ViewModel.ExpenseStatuses)
            {
                var cell = new SwitchCell {
                    Text = es.Name
                };

                Binding binding = new Binding();
                binding.Source = ViewModel.ExpenseStatuses[count];
                binding.Path   = "Status";
                binding.Mode   = BindingMode.TwoWay;
                cell.SetBinding(SwitchCell.OnProperty, binding);

                section.Add(cell);

                count++;
            }
            expenseTableView.Root.Add(section);
        }
Example #6
0
 public ListViewSwitchCell()
 {
     Content = new ListView()
     {
         ItemTemplate = new DataTemplate(() =>
         {
             var cell = new SwitchCell();
             cell.SetBinding(SwitchCell.OnProperty, "On");
             cell.SetBinding(SwitchCell.TextProperty, "Text");
             return(cell);
         }),
         ItemsSource = Enumerable.Range(0, 100)
                       .Select(i => (i % 2 == 0) ? new { Text = "Switch ", On = true } : new { Text = "Switch ", On = false })
                       .ToList()
     };
 }
Example #7
0
        public TestPage()
        {
            this.BindingContext = new TestPageViewModel();

            var ed = new Editor {
                Text = "BindingTo TextValue"
            };

            ed.SetBinding(Editor.TextProperty, "TextValue", mode: BindingMode.OneWayToSource);
            var lb = new Label {
                Text = ""
            };

            lb.SetBinding(Label.TextProperty, "TextValue");

            var sw = new Switch();

            sw.SetBinding(Switch.IsToggledProperty, "BoolValue", mode: BindingMode.TwoWay);

            var sc = new SwitchCell {
                Text = "BindingTo BoolValue"
            };

            sc.SetBinding(SwitchCell.OnProperty, "BoolValue", mode: BindingMode.TwoWay);

            var tc = new TextCell {
                Text = ""
            };

            tc.SetBinding(TextCell.TextProperty, "BoolValue", stringFormat: "Value: {0}");

            var tv = new TableView
            {
                Intent = TableIntent.Settings,
                Root   = new TableRoot
                {
                    new TableSection("TableView")
                    {
                        sc,
                        tc,
                    },
                }
            };

            Content = new StackLayout
            {
                Padding  = 20,
                Children =
                {
                    new Label {
                        Text     = "INotifyPropertyChanged Test",
                        FontSize = 30,
                    },
                    ed,
                    lb,
                    sw,
                    tv,
                }
            };
        }
        protected override void OnAppearing()
        {
            base.OnAppearing();

            ViewModel.GetExpenseStatus();


            // dynamically add rows to the TableView
            int count = 0;

            foreach (var es in ViewModel.ExpenseStatuses)
            {
                var cell = new SwitchCell {
                    Text = es.Name
                };

                Binding binding = new Binding
                {
                    Source = ViewModel.ExpenseStatuses[count],
                    Path   = "Status",
                    Mode   = BindingMode.TwoWay
                };
                cell.SetBinding(SwitchCell.OnProperty, binding);

                var section = new TableSection("Statuses");
                section.Add(cell);
                expenseTableView.Root.Add(section);

                count++;
            }
        }
Example #9
0
        public RecommendationsView()
        {
            Grid grd = new Grid();
            var  lst = new ListView
            {
                ItemTemplate = new DataTemplate(() =>
                {
                    var swittch = new SwitchCell();
                    swittch.SetBinding(SwitchCell.TextProperty, new Binding("Name"));
                    swittch.SetBinding(SwitchCell.OnProperty, new Binding("IsBusy"));
                    return(swittch);
                })
            };

            lst.SetBinding(ListView.ItemsSourceProperty, new Binding("Recommendations"));
            grd.Children.Add(lst);
            Content = grd;
        }
Example #10
0
        private static object CellGenerate()
        {
            var sc = new SwitchCell {
            };

            sc.SetBinding(SwitchCell.TextProperty, "Description");
            // sc.SetBinding(SwitchCell.OnProperty, "Content",  BindingMode.TwoWay, new Options.Setting.ContentConverter());       //*/

            return(sc);
        }
        internal static Cell BoolCell(PropertyInfo property, IContact context, Page parent = null)
        {
            var label      = CreateLabel(property);
            var switchCell = new SwitchCell();

            switchCell.SetValue(SwitchCell.TextProperty, label);
            switchCell.SetBinding(SwitchCell.OnProperty, property.Name);
            switchCell.BindingContext = context;
            return(switchCell);
        }
        public SettingsPage()
        {
            var svm = new SettingsViewModel {
                AirplaneMode = true
            };

            BindingContext = svm;

            var airplaneModeCell = new SwitchCell {
                Text = "Airplane Mode"
            };

            airplaneModeCell.SetBinding(SwitchCell.OnProperty, "AirplaneMode");

            Title   = "Settings";
            Content = new TableView {
                Root = new TableRoot {
                    new TableSection(" ")
                    {
                        airplaneModeCell,
                        new SwitchCell {
                            Text = "Notifications"
                        }
                    },
                    new TableSection(" ")
                    {
                        new EntryCell {
                            Label = "Login", Placeholder = "username"
                        }
                        , new EntryCell {
                            Label = "Password", Placeholder = "password"
                        }
                    },
                    new TableSection("Silent")
                    {
                        new SwitchCell {
                            Text = "Vibrate",
                        },
                        new ViewCell {
                            View = new Slider()
                        }
                    },

                    new TableSection("Ring")
                    {
                        new SwitchCell {
                            Text = "New Voice Mail"
                        },
                        new SwitchCell {
                            Text = "New Mail", On = true
                        }
                    },
                },
            };
        }
Example #13
0
        protected override void Init()
        {
            var listView = new ListView();

            var selection = new Selection();

            listView.SetBinding(ListView.ItemsSourceProperty, "Items");

            listView.ItemTemplate = new DataTemplate(() =>
            {
                var cell = new SwitchCell();
                cell.SetBinding(SwitchCell.TextProperty, "Name");
                cell.SetBinding(SwitchCell.OnProperty, "IsSelected", BindingMode.TwoWay);
                return(cell);
            });

            var instructions = new Label
            {
                FontSize = 16,
                Text     =
                    "The label at the bottom should equal the number of switches which are in the 'on' position. Flip some of the switches. If the number at the bottom does not equal the number of 'on' switches, the test has failed."
            };

            var label = new Label {
                FontSize = 24
            };

            label.SetBinding(Label.TextProperty, "SelectedCount");

            Content = new StackLayout
            {
                VerticalOptions = LayoutOptions.Fill,
                Children        =
                {
                    instructions,
                    listView,
                    label
                }
            };

            BindingContext = selection;
        }
Example #14
0
        public SettingsPage()
        {
            BindingContext = new SettingsModel();

            var cameraSwitch = new SwitchCell {
                Text = "Rear Camera"
            };

            cameraSwitch.SetBinding(SwitchCell.OnProperty, new Binding("DefaultCameraRear"));

            var timerEntry = new EntryCell {
                Label = "Seconds", Keyboard = Keyboard.Numeric
            };

            timerEntry.SetBinding(EntryCell.TextProperty, new Binding("TimerInterval", BindingMode.TwoWay));

            var clearDataLabel = new TextCell {
                Text = "Clear All Data"
            };

            clearDataLabel.Tapped += async(s, e) =>
            {
                var result = await DisplayAlert("Delete All Data", "Are you sure you wish to clear all stored data online?", "YES", "Cancel");

                if (result)
                {
                    var response = await(BindingContext as SettingsModel).ResetData();
                    DisplayAlert(response, "", "Ok");
                }
            };

            Title   = "Settings";
            Content = new TableView
            {
                Root = new TableRoot {
                    new TableSection("Default Camera")
                    {
                        cameraSwitch
                    },
                    new TableSection("Data")
                    {
                        clearDataLabel
                    },
                    new TableSection("Identify Interval")
                    {
                        timerEntry
                    }
                }
            };

            //
        }
Example #15
0
        public FilterSelection(Planning handle)
        {
            Title = "Filtres";
            ToolbarItems.Add(new ToolbarItem("OK", null, new Action(delegate {
                handle.DisplayContent(handle.Data);
                Navigation.PopModalAsync(true);
            })));

            SwitchCell subscribed = new SwitchCell {
                Text = "Inscrit à l'évènement",
            };

            subscribed.SetBinding(SwitchCell.OnProperty, new Binding("OnlyDisplayRegisteredEvent", BindingMode.TwoWay, null, null));

            SwitchCell tosubscribe = new SwitchCell {
                Text = "Inscription possible",
            };

            tosubscribe.SetBinding(SwitchCell.OnProperty, new Binding("OnlyDisplayEventToRegister", BindingMode.TwoWay, null, null));

            SwitchCell registeredmodule = new SwitchCell {
                Text = "Inscrit au module",
            };

            registeredmodule.SetBinding(SwitchCell.OnProperty, new Binding("OnlyDisplayEventFromRegisteredModule", BindingMode.TwoWay, null, null));

            SwitchCell pastevent = new SwitchCell {
                Text = "Afficher évènement passés",
            };

            pastevent.SetBinding(SwitchCell.OnProperty, new Binding("DisplayPastEvent", BindingMode.TwoWay, null, null));


            TableView tableView = new TableView {
                Intent = TableIntent.Form,
                Root   = new TableRoot {
                    new TableSection("Filtres")
                    {
                        subscribed, tosubscribe, registeredmodule, pastevent
                    }
                }
            };

            Content = new StackLayout {
                Children =
                {
                    tableView
                }
            };
        }
Example #16
0
    public FilterPage()
    {
        var      restaurantTypes = new[] { "Pizza", "China", "German" }; // Database.RestaurantTypes
        ListView types           = new ListView();

        types.ItemTemplate = new DataTemplate(() =>
        {
            var cell = new SwitchCell();
            cell.SetBinding(SwitchCell.TextProperty, ".");
            return(cell);
        });
        types.ItemsSource = restaurantTypes;
        Content           = types;
    }
Example #17
0
        protected override void OnAppearing()
        {
            base.OnAppearing();
            ViewModel.GetExpenseStatus();

            //counter variable for the collection
            int counter = 0;

            //creates a switchcell obj
            var cell = new SwitchCell();

            //iterates all of the state objes and then assigns a binding to each iteration
            foreach (var item in ViewModel.ExpensesStates)
            {
                //Assigns the 'text' property
                //to the observable collection 'Name' property
                cell = new SwitchCell()
                {
                    Text = item.Name
                };

                //creates a binding object
                Binding bindingSWcell = new Binding();

                //Assigns the binding and fills the properties
                bindingSWcell.Source = ViewModel.ExpensesStates[counter]; //the source of the data in the cell
                bindingSWcell.Path   = "Status";                          // what the cell binds to in xaml
                bindingSWcell.Mode   = BindingMode.TwoWay;                //creates a two way data binding

                //Adds the binding to the cell obj
                cell.SetBinding(SwitchCell.OnProperty, bindingSWcell);
                //changes the height?
                cell.Height = 25d;
                //adds the bindable object (cell) to the section object
                //-->var section = new TableSection() { cell };
                var section = new TableSection()
                {
                    cell
                };
                //section.Add(cell);

                //adds the cell with its binding to the element in the view
                tbvDisplayExpenses.Root.Add(section);

                //increments the count before the next iteration
                counter++;
            }
        }
Example #18
0
        protected override void OnAppearing()
        {
            base.OnAppearing();

            // Complex example with Statuses continues
            _viewModel.GetExpenseStatus();

            // Set Bindings to Statuses collection from c# code.
            var count = 0;

            foreach (var viewModelExpenseStatus in _viewModel.ExpenseStatuses)
            {
                var cell = new SwitchCell {
                    Text = viewModelExpenseStatus.Name
                };

                // create a new binding (similar to any "Binding" from xaml files)
                Binding binding = new Binding();
                // we set source binding to certain element, not for variable inside foreach loop.
                binding.Source = _viewModel.ExpenseStatuses[count];
                // Binding to property like in the next string: "{Binding Source={StaticResource viewModel}, Path=SaveExpense}"
                binding.Path = "Status";
                binding.Mode = BindingMode.TwoWay;

                // Create a cell and set this binding between this cell and previously created binding
                cell.SetBinding(SwitchCell.OnProperty, binding);

                // Create a new TableSection on UI
                var section = new TableSection("Statuses");
                section.Add(cell);

                // Using x:Name from our TableView which is presented in xaml code - we add our section with a cell
                // To check how it works - set a breakpoint in InsertExpense method
                ExpenseTableView.Root.Add(section);

                count++;
            }
        }
        protected override void OnAppearing()
        {
            base.OnAppearing();

            ViewModel.GetExpenseStatus();

            // enclosing TableSection could be defined in xaml but generated here in C# code-behind - neater in leaving previous xaml layout undisturbed
            var section = new TableSection("Statuses");

            // I'd rather do this with a for loop
            int count = 0;

            foreach (var expenseStatus in ViewModel.ExpenseStatuses)
            {
                var cell = new SwitchCell {
                    Text = expenseStatus.Name
                };
                // simple assignation of cell.On=expenseStatus.Status would *not* be binding ...

                // ... so make a Binding in C# code - cf the xaml way, with Source (to VM) and Path (method or property member eg Observable)
                Binding binding = new Binding();
                binding.Source = ViewModel.ExpenseStatuses[count]; // iterate through each individual row (as per ItemsSource)
                binding.Path   = "Status";                         // bind Path by using string name of property - cf xaml
                binding.Mode   = BindingMode.TwoWay;
                // could set binding.Converter to process boolean to integer a la IEValueConverter
                cell.SetBinding(SwitchCell.OnProperty, binding);

                section.Add(cell);

                count++;
                // i.e. 1 binding for each record in ExpensesStatuses
            }

            expenseTableView.Root.Add(section);     // Add the assembled section (of cells) to the element named expenseTableView
            // NB expenseTableView was a TableView element named with x:Name (hence no C# declaration) - not the done thing in MVVM if binding working ok
        }
        public App()
        {
            ToggleIt = new Command(() => IsToggled = !IsToggled);


            SwitchCell mySwitch = new SwitchCell();

            mySwitch.SetBinding(SwitchCell.OnProperty, "IsToggled", 0);
            var myButton = new Button()
            {
                Text    = "CLICK IT! CLICK IT! CLICK IT!  YOU KNOW YOU WANT TO",
                Command = ToggleIt
            };

            MainPage = new ContentPage {
                BindingContext = this,
                Content        = new StackLayout {
                    VerticalOptions = LayoutOptions.Center,
                    Children        =
                    {
                        myButton,
                        new TableView
                        {
                            Intent = TableIntent.Form,
                            Root   = new TableRoot
                            {
                                new TableSection
                                {
                                    mySwitch
                                }
                            }
                        }
                    }
                }
            };
        }
Example #21
0
        public override Element GetEditor(EditableField field, object parent)
        {
            Element view = null;

            if (view == null)
            {
                if (field.PropertyData.Readonly)
                {
                    view = new TextCell()
                    {
                        Text           = ObjectEditor.Translate(field.PropertyData.Title),
                        BindingContext = field,
                        Detail         = field.Value.ToString()
                    };
                    view.SetBinding(TextCell.DetailProperty, nameof(field.Value));
                }
                else
                {
                    var type = field.SourceProperty.PropertyType;
                    if (field.PropertyData.RelationTo != null)
                    {
                        var inst = Activator.CreateInstance(field.PropertyData.RelationTo);
                        if (inst is IEditorRelation rel)
                        {
                            view = new RelationCell(rel)
                            {
                                Text = ObjectEditor.Translate(field.PropertyData.Title)
                            };
                            view.SetBinding(DateCell.ValueProperty, nameof(field.Value));
                        }
                    }
                    else if (type == typeof(string) || type == typeof(int))
                    {
                        view = new EntryCell()
                        {
                            Label = ObjectEditor.Translate(field.PropertyData.Title)
                        };
                        view.SetBinding(EntryCell.TextProperty, nameof(field.Value));
                    }
                    else if (type == typeof(bool))
                    {
                        view = new SwitchCell()
                        {
                            Text = ObjectEditor.Translate(field.PropertyData.Title)
                        };
                        view.SetBinding(SwitchCell.OnProperty, nameof(field.Value));
                    }
                    else if (type == typeof(DateTime))
                    {
                        view = new DateCell()
                        {
                            Text = ObjectEditor.Translate(field.PropertyData.Title)
                        };
                        view.SetBinding(DateCell.ValueProperty, nameof(field.Value));
                    }
                    if (view != null)
                    {
                        view.BindingContext = field;
                    }
                }
            }
            return(view as Element);
        }
Example #22
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;
        }
Example #23
0
        public SettingsPage()
        {
            BindingContext = new SettingsViewModel();

            var cameraSwitch = new SwitchCell {
                Text = "Rear Camera"
            };

            cameraSwitch.SetBinding(SwitchCell.OnProperty, new Binding("DefaultCameraRear", BindingMode.TwoWay));

            var clearDb = new TextCell()
            {
                Text = "Delete All Local Entries"
            };

            clearDb.SetBinding(TextCell.CommandProperty, new Binding("ClearDatabaseCommand"));

            var userIdCell = new EntryCell()
            {
                Label = "User Id"
            };

            userIdCell.SetBinding(EntryCell.TextProperty, new Binding("UserId", BindingMode.TwoWay));

            var endpointCell = new EntryCell()
            {
                Label = "Endpoint"
            };

            endpointCell.SetBinding(EntryCell.TextProperty, new Binding("Endpoint", BindingMode.TwoWay));

            var apiKeyCell = new EntryCell()
            {
                Label = "Api Key"
            };

            apiKeyCell.SetBinding(EntryCell.TextProperty, new Binding("ApiKey", BindingMode.TwoWay));

            var modelNameCell = new EntryCell()
            {
                Label = "Published Model Name"
            };

            modelNameCell.SetBinding(EntryCell.TextProperty, new Binding("PublishedModelName", BindingMode.TwoWay));

            Title   = "Settings";
            Content = new TableView
            {
                Root = new TableRoot {
                    new TableSection("Configuration")
                    {
                        userIdCell,
                        endpointCell,
                        apiKeyCell,
                        modelNameCell
                    },
                    new TableSection("Camera")
                    {
                        cameraSwitch
                    },
                    new TableSection("Database")
                    {
                        clearDb
                    },
                }
            };
        }
        public SettingsPage()
        {
            BindingContext = new SettingsViewModel();

            var cameraSwitch = new SwitchCell {
                Text = "Rear Camera"
            };

            cameraSwitch.SetBinding(SwitchCell.OnProperty, new Binding("DefaultCameraRear"));

            var cameraLocation = new EntryCell {
                Label = "Camera Location", Keyboard = Keyboard.Default
            };

            cameraLocation.SetBinding(EntryCell.TextProperty, new Binding("CameraLocation", BindingMode.TwoWay));

            var timerEntry = new EntryCell {
                Label = "Camera Refresh", Keyboard = Keyboard.Numeric
            };

            timerEntry.SetBinding(EntryCell.TextProperty, new Binding("TimerInterval", BindingMode.TwoWay));

            var historyEntry = new EntryCell {
                Label = "History Refresh", Keyboard = Keyboard.Numeric
            };

            timerEntry.SetBinding(EntryCell.TextProperty, new Binding("HistoryInterval", BindingMode.TwoWay));

            //var clearDataLabel = new TextCell { Text = "Clear All Data" };
            //clearDataLabel.Tapped += async (s, e) =>
            //{
            //	var result = await DisplayAlert("Delete All Data", "Are you sure you wish to clear all stored data online?", "YES", "Cancel");
            //	if (result)
            //	{
            //		var response = await (BindingContext as SettingsModel).ResetData();
            //		DisplayAlert(response, "", "Ok");
            //	}
            //};

            Title   = "Settings";
            Content = new TableView
            {
                Root = new TableRoot {
                    new TableSection("Camera")
                    {
                        cameraLocation,
                        cameraSwitch
                    },

                    new TableSection("Monitor Interval")
                    {
                        timerEntry
                    },

                    new TableSection("History Interval")
                    {
                        timerEntry
                    },

                    //new TableSection("Data"){
                    //	clearDataLabel
                    //},
                }
            };
        }
        public SettingsPage()
        {
            NavigationPage.SetHasNavigationBar(this, true);

            Title = "Settings";

            //Nothing is programaticaly added
            //Entry Cells and Notifications Linked to Data.cs
            //

            #region EmailEntryCellandLogic
            EntryCell therapistEmail = new EntryCell
            {
                Label       = "Therapist Email:",
                Placeholder = "*****@*****.**",
                Keyboard    = Keyboard.Email,
            };

            if (rawData.therapistEmailAd != "")
            {
                therapistEmail.Text = rawData.therapistEmailAd;
            }

            Binding bindingSetup = new Binding("therapistEmailAd");
            bindingSetup.Source = rawData;
            bindingSetup.Mode   = BindingMode.TwoWay;
            therapistEmail.SetBinding(EntryCell.TextProperty, bindingSetup);

            EmailCells.Add(therapistEmail);

            #region AdditionalContacts

            string[] str = new string[] { rawData.contact1, rawData.contact2, rawData.contact3, rawData.contact4, rawData.contact5 };

            for (int i = 0; i < str.Length; i++)
            {
                emailCellCreation(i + 1, str[i]);
            }

            str = null;

            #endregion AdditionalContacts

            #endregion EmailEntryCellandLogic

            #region DateTimePickers

            #region WakeTimer

            Label WakeUpLable = new Label
            {
                Text = "What time do you wake up?"
            };
            WakeUpLable.VerticalOptions = LayoutOptions.Center;

            TimeSpan wakeTimeSpan = new TimeSpan();

            TimePicker WakeUpTime = new TimePicker();
            WakeUpTime.HorizontalOptions = LayoutOptions.EndAndExpand;

            WakeUpTime.Time = rawData.WakeTimes != null ? rawData.WakeTimes : TimeSpan.Zero;

            WakeUpTime.PropertyChanging += (sender, e) =>
            {
                wakeTimeSpan = WakeUpTime.Time;
            };

            StackLayout WakeView = new StackLayout();
            WakeView.Orientation = StackOrientation.Horizontal;
            WakeView.Children.Add(WakeUpLable);
            WakeView.Children.Add(WakeUpTime);

            #endregion WakeTimer

            #region EatTimer

            Label EatLabel = new Label
            {
                Text = "What time do you eat? ",
            };
            EatLabel.VerticalOptions = LayoutOptions.Center;

            TimePicker EatTime = new TimePicker();
            EatTime.HorizontalOptions = LayoutOptions.EndAndExpand;

            EatTime.Time = rawData.EatTime != null ? rawData.EatTime : TimeSpan.Zero;

            TimeSpan eatSpan = new TimeSpan();
            EatTime.PropertyChanging += (sender, e) =>
            {
                eatSpan = EatTime.Time;
            };

            StackLayout EatView = new StackLayout();
            EatView.Orientation = StackOrientation.Horizontal;
            EatView.Children.Add(EatLabel);
            EatView.Children.Add(EatTime);

            #endregion EatTimer

            #region EmailReminderPicker

            Label EmailLabel = new Label()
            {
                Text = "When do you want a Reminder? ",
            };
            EmailLabel.VerticalOptions = LayoutOptions.Center;

            Picker EmailReminder = new Picker();
            EmailReminder.Items.Add("Never");
            EmailReminder.Items.Add("Once a Week");
            EmailReminder.Items.Add("Every Other Week");
            EmailReminder.Items.Add("Once a Month");

            EmailReminder.HorizontalOptions = LayoutOptions.FillAndExpand;

            EmailReminder.SelectedIndex = rawData.EmailReminder;

            EmailReminder.SelectedIndexChanged += (sender, e) =>
            {
                rawData.EmailReminder = EmailReminder.SelectedIndex;

                DateTime tempTime = DateTime.Now;

                bool schedule = false;

                switch (EmailReminder.SelectedIndex)
                {
                case 1:
                    schedule = true;
                    tempTime = tempTime.AddDays(7);
                    break;

                case 2:
                    schedule = true;
                    tempTime = tempTime.AddDays(14);
                    break;

                case 3:
                    schedule = true;
                    tempTime = tempTime.AddMonths(1);
                    break;

                default: break;
                }
                NotificationChanged(schedule, "Send Email", "", "Time to Send Your Email!", "4", tempTime);
            };

            StackLayout EmailView = new StackLayout();
            EmailView.Orientation = StackOrientation.Horizontal;
            EmailView.Children.Add(EmailLabel);
            EmailView.Children.Add(EmailReminder);

            #endregion EmailReminderPicker

            #endregion DateTimePickers

            #region NotificationButtons

            MessagingCenter.Subscribe <SettingsPage, bool>(this, "Notifications", (sender, args) =>
            {
                foreach (SwitchCell sc in NotificationCells)
                {
                    sc.On = args;
                }
            });

            #region AllNotifications
            SwitchCell notification = new SwitchCell()
            {
                Text = "All Notifications",
            };

            notification.OnChanged += (sender, e) => MessagingCenter.Send <SettingsPage, bool>(this, "Notifications", notification.On);

            bindingSetup        = new Binding("notificationstate");
            bindingSetup.Source = rawData;
            bindingSetup.Mode   = BindingMode.TwoWay;
            notification.SetBinding(SwitchCell.OnProperty, bindingSetup);

            NotificationCells.Add(notification);
            #endregion AllNotifications


            #region Medication
            SwitchCell Medication = new SwitchCell()
            {
                Text = "Medication",
            };

            bindingSetup        = new Binding("Medication");
            bindingSetup.Source = rawData;
            bindingSetup.Mode   = BindingMode.TwoWay;
            Medication.SetBinding(SwitchCell.OnProperty, bindingSetup);

            Medication.OnChanged += (sender, e) =>
            {
                NotificationChanged(Medication.On, "Medication Reminder", "", "Time to take your Medications", "0", DateTime.Now.AddSeconds(15));
            };

            NotificationCells.Add(Medication);


            #endregion Medication


            #region Eating
            SwitchCell Eating = new SwitchCell()
            {
                Text = "Eating",
            };

            bindingSetup        = new Binding("Eating");
            bindingSetup.Source = rawData;
            bindingSetup.Mode   = BindingMode.TwoWay;
            Eating.SetBinding(SwitchCell.OnProperty, bindingSetup);

            Eating.OnChanged += (sender, e) =>
            {
                for (int i = 0; i < 3; i++)
                {
                    if (eatSpan == EatTime.Time)
                    {
                        NotificationChanged(Eating.On, "Time to Eat", "", "Time to find something tasty.", "1",
                                            new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, EatTime.Time.Hours + (i * 4), EatTime.Time.Minutes, 0));
                    }
                    else
                    {
                        NotificationChanged(Eating.On, "Time to Eat", "", "Time to find something tasty.", "1",
                                            new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, eatSpan.Hours + (i * 4), eatSpan.Minutes, 0));
                    }
                }
            };

            NotificationCells.Add(Eating);
            #endregion Eating


            #region Sleeping
            SwitchCell Sleeping = new SwitchCell()
            {
                Text = "Sleeping",
            };

            bindingSetup        = new Binding("Sleeping");
            bindingSetup.Source = rawData;
            bindingSetup.Mode   = BindingMode.TwoWay;
            Sleeping.SetBinding(SwitchCell.OnProperty, bindingSetup);

            Sleeping.OnChanged += (sender, e) =>
            {
                if (wakeTimeSpan == WakeUpTime.Time)
                {
                    NotificationChanged(Sleeping.On, "Sleep Input", "", "How much sleep did you get?", "2",
                                        new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, wakeTimeSpan.Hours, wakeTimeSpan.Minutes, 0));
                }
                else
                {
                    NotificationChanged(Sleeping.On, "Sleep Input", "", "How much sleep did you get?", "2",
                                        new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, WakeUpTime.Time.Hours, WakeUpTime.Time.Minutes, 0));
                }
            };
            NotificationCells.Add(Sleeping);
            #endregion Sleeping


            #region Journal
            SwitchCell Journal = new SwitchCell()
            {
                Text = "Journal",
            };

            bindingSetup        = new Binding("Journal");
            bindingSetup.Source = rawData;
            bindingSetup.Mode   = BindingMode.TwoWay;
            Journal.SetBinding(SwitchCell.OnProperty, bindingSetup);

            Journal.OnChanged += (sender, e) =>
            {
                if (wakeTimeSpan == WakeUpTime.Time)
                {
                    DateTime temp = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, WakeUpTime.Time.Hours, WakeUpTime.Time.Minutes, 0);
                    temp.AddMinutes(30);
                    temp.AddHours(14);

                    NotificationChanged(Journal.On, "Journal Entries", "", "Time to fill out a note about your day today", "3", temp);
                }
                else
                {
                    DateTime temp = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, wakeTimeSpan.Hours, wakeTimeSpan.Minutes, 0);
                    temp.AddMinutes(30);
                    temp.AddHours(14);

                    NotificationChanged(Journal.On, "Journal Entries", "", "Time to fill out a note about your day today", "3", temp);
                }
            };

            NotificationCells.Add(Journal);
            #endregion Journal

            #endregion NotificationButtons

            //Add content to this
            WakeUpTime.PropertyChanged += (sender, e) =>
            {
                if (Sleeping.On)
                {
                    Sleeping.On = false;
                    Sleeping.On = true;
                }

                if (Journal.On)
                {
                    Journal.On = false;
                    Journal.On = true;
                }

                wakeTimeSpan = WakeUpTime.Time;

                rawData.WakeTimes = WakeUpTime.Time;
            };

            EatTime.PropertyChanged += (sender, e) =>
            {
                if (Eating.On)
                {
                    Eating.On = false;
                    Eating.On = true;
                }

                eatSpan = EatTime.Time;

                rawData.EatTime = EatTime.Time;
            };

            #region Views

            TableView notifTable = new TableView
            {
                Intent = TableIntent.Settings,
                Root   = new TableRoot
                {
                    new TableSection("Notifications")
                    {
                        NotificationCells,
                    }
                }
            };

            TableView emailTable = new TableView
            {
                Intent = TableIntent.Settings,
                Root   = new TableRoot
                {
                    new TableSection("Email")
                    {
                        EmailCells
                    }
                }
            };

            StackLayout MainStack = new StackLayout
            {
                Spacing  = 0,
                Children =
                {
                    emailTable,
                    EatView,
                    WakeView,
                    notifTable,
                    EmailView,
                }
            };

            ScrollView scroll = new ScrollView
            {
                Content           = MainStack,
                HorizontalOptions = LayoutOptions.CenterAndExpand,
            };

            #endregion Views

            this.Content = scroll;

            InitializeComponent();
        }
        public SettingsPage(LaneModel laneModelTapped)
        {
            var viewModel = new SettingsViewModel(laneModelTapped);

            BindingContext = viewModel;

            #region create the IsOpen Switch
            var isOpenSwitch = new SwitchCell
            {
                Text = "Is Open"
            };
            isOpenSwitch.SetBinding(SwitchCell.OnProperty, "IsOpen");
            #endregion

            #region Create the Needs Maintenance Switch
            var needsMaintenanceSwitch = new SwitchCell
            {
                Text = "Needs Maintenance"
            };
            needsMaintenanceSwitch.SetBinding(SwitchCell.OnProperty, "NeedsMaintenance");
            #endregion

            #region create the IP Address Entry
            var ipAddressText = new EntryCell
            {
                Label = "IP Address",
                HorizontalTextAlignment = TextAlignment.End
            };
            ipAddressText.SetBinding(EntryCell.TextProperty, "IPAddress");
            #endregion

            #region Create Image Cell
            var imageCell = new ImageCell();
            imageCell.SetBinding(ImageCell.ImageSourceProperty, "ImageCellIcon");
            #endregion

            #region Create the Icon Toggle Button
            var iconToggleButton = new Button();
            iconToggleButton.SetBinding(Button.CommandProperty, "IconToggleButtonTapped");
            iconToggleButton.SetBinding(Button.TextProperty, "ToggleButtonText");
            #endregion

            #region create the TableView
            var tableView = new TableView
            {
                Intent = TableIntent.Settings,
                Root   = new TableRoot
                {
                    new TableSection {
                        isOpenSwitch,
                        needsMaintenanceSwitch,
                        ipAddressText,
                        imageCell
                    }
                }
            };
            #endregion

            #region Create StackLayout to Include a Button
            var settingsStack = new StackLayout
            {
                Children =
                {
                    tableView,
                    iconToggleButton
                }
            };
            #endregion

            NavigationPage.SetTitleIcon(this, "cogwheel_navigation");

            Title   = $"Lane {laneModelTapped.ID + 1} Settings";
            Content = settingsStack;
        }
Example #27
0
        private void InitTableView()
        {
            var bindingContext = BindingContext as VisitResultViewModel;
            int paddingLeft    = Convert.ToInt32(Application.Current.Resources["paddingLeftFormViewCell"]);

            TableView tableView = new TableView
            {
                Intent        = TableIntent.Form,
                Root          = new TableRoot("Esito visita"),
                HasUnevenRows = true
            };

            tableView.SetBinding(TableView.IsVisibleProperty, nameof(bindingContext.IsReady));

            #region Clients List Picker
            Picker clientsListPicker = new Picker();
            clientsListPicker.Title = "Seleziona cliente";
            clientsListPicker.SetBinding(Picker.ItemsSourceProperty, nameof(bindingContext.ClientsList));
            clientsListPicker.SetBinding(Picker.SelectedItemProperty, nameof(bindingContext.ClientName));
            tableView.Root.Add(new TableSection("Cliente")
            {
                new ViewCell()
                {
                    View = clientsListPicker
                }
            });
            #endregion

            #region Contact
            EntryCell contactName = new EntryCell();
            contactName.Label       = "Contatto:";
            contactName.Placeholder = "Nome Contatto";
            contactName.SetBinding(EntryCell.TextProperty, nameof(bindingContext.ContactName));
            EntryCell contactPhone = new EntryCell();
            contactPhone.Label       = "Telefono:";
            contactPhone.Placeholder = "Numero di telefono";
            contactPhone.Keyboard    = Keyboard.Telephone;
            contactPhone.SetBinding(EntryCell.TextProperty, nameof(bindingContext.ContactPhone));
            EntryCell contactEmail = new EntryCell();
            contactEmail.Label       = "Email:";
            contactEmail.Placeholder = "Indirizzo email";
            contactEmail.Keyboard    = Keyboard.Email;
            contactEmail.SetBinding(EntryCell.TextProperty, nameof(bindingContext.ContactEmail));
            EntryCell contactWebSite = new EntryCell();
            contactWebSite.Label       = "Web:";
            contactWebSite.Placeholder = "Indirizzo sito web";
            contactWebSite.Keyboard    = Keyboard.Url;
            contactWebSite.SetBinding(EntryCell.TextProperty, nameof(bindingContext.ContactWebSite));
            tableView.Root.Add(new TableSection("Contatto")
            {
                contactName,
                contactPhone,
                contactEmail,
                contactWebSite
            });
            #endregion

            #region Visit Date and Time
            DatePicker visitDatePicker = new DatePicker();
            visitDatePicker.SetBinding(DatePicker.DateProperty, nameof(bindingContext.VisitDate));
            TimePicker visitTimePicker = new TimePicker();
            visitTimePicker.SetBinding(TimePicker.TimeProperty, nameof(bindingContext.VisitTime));
            tableView.Root.Add(new TableSection("Data e Ora Visita")
            {
                new ViewCell()
                {
                    View = new StackLayout()
                    {
                        Orientation       = StackOrientation.Horizontal,
                        HorizontalOptions = LayoutOptions.Center,
                        Children          = { visitDatePicker, visitTimePicker }
                    }
                }
            });
            #endregion

            #region Visit Interview

            #region Is Interested
            SwitchCell isInterested = new SwitchCell()
            {
                Text = "Interessato"
            };
            isInterested.SetBinding(SwitchCell.OnProperty, nameof(bindingContext.IsInterested));
            #endregion

            #region Quantity
            Entry quantity = new Entry()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand, HorizontalTextAlignment = TextAlignment.End
            };
            quantity.SetBinding(Entry.TextProperty, nameof(bindingContext.Quantity));
            Stepper quantityStepper = new Stepper();
            quantityStepper.SetBinding(Stepper.ValueProperty, nameof(bindingContext.Quantity));
            #endregion

            #region Rating
            Entry rating = new Entry()
            {
                HorizontalOptions = LayoutOptions.FillAndExpand, HorizontalTextAlignment = TextAlignment.End
            };
            rating.SetBinding(Entry.TextProperty, nameof(bindingContext.Rating));
            Slider ratingSlider = new Slider()
            {
                Minimum = 0, Maximum = 10
            };
            ratingSlider.SetBinding(Slider.ValueProperty, nameof(bindingContext.Rating));
            ratingSlider.HorizontalOptions = LayoutOptions.FillAndExpand;
            #endregion

            #region Comment
            Editor comment = new Editor();
            comment.SetBinding(Editor.TextProperty, nameof(bindingContext.Comment));
            comment.HorizontalOptions = LayoutOptions.FillAndExpand;
            comment.VerticalOptions   = LayoutOptions.FillAndExpand;
            #endregion

            #region Add controls to the Table Section
            tableView.Root.Add(new TableSection("Intervista")
            {
                isInterested,
                new ViewCell()
                {
                    View = new StackLayout()
                    {
                        Orientation = StackOrientation.Horizontal,
                        Padding     = new Thickness()
                        {
                            Left = paddingLeft
                        },
                        Children =
                        {
                            new Label()
                            {
                                Text = "Quantità",
                                HorizontalOptions = LayoutOptions.StartAndExpand,
                                VerticalOptions   = LayoutOptions.Center,
                            },
                            quantity,
                            quantityStepper
                        }
                    }
                },
                new ViewCell()
                {
                    View = new StackLayout()
                    {
                        Orientation = StackOrientation.Horizontal,
                        Padding     = new Thickness()
                        {
                            Left = paddingLeft
                        },
                        Children =
                        {
                            new Label()
                            {
                                Text = "Valutazione",
                                HorizontalOptions = LayoutOptions.StartAndExpand,
                                VerticalOptions   = LayoutOptions.Center,
                            },
                            rating,
                            ratingSlider
                        }
                    }
                },
                new ViewCell()
                {
                    View = new StackLayout()
                    {
                        Orientation = StackOrientation.Horizontal,
                        Padding     = new Thickness()
                        {
                            Left = paddingLeft
                        },
                        Children =
                        {
                            new Label()
                            {
                                Text = "Commento",
                                HorizontalOptions = LayoutOptions.Start,
                                VerticalOptions   = LayoutOptions.Center,
                            },
                            comment
                        }
                    }
                }
            });
            #endregion

            #endregion

            #region Addresses
            //List<AddressViewCell> addressViewsList = new List<AddressViewCell>();
            //TableSection addressesTableSection = new TableSection("Indirizzi");
            //foreach (AddressModel addressModel in bindingContext.AddressesList)
            //{
            //    addressesTableSection.Add(new AddressViewCell() { BindingContext = addressModel });
            //}
            //tableView.Root.Add(addressesTableSection);

            Button btnAddAddress = new Button()
            {
                Text = "Aggiungi indirizzo"
            };
            btnAddAddress.Clicked += BtnAddAddress_Clicked;
            //stackLayout.Children.Add(btnAddAddress);

            ListView addressesViews = new ListView();
            addressesViews.SetBinding(ListView.ItemsSourceProperty, nameof(bindingContext.AddressesList));
            addressesViews.ItemTemplate = new DataTemplate(typeof(AddressViewCell));
            addressesViews.RowHeight    = 200;
            //stackLayout.Children.Add(addressesViews);

            tableView.Root.Add(new TableSection("Indirizzi")
            {
                new ViewCell()
                {
                    View = btnAddAddress
                },
                new ViewCell()
                {
                    View = addressesViews
                }
            });
            #endregion

            stackLayout.Children.Add(tableView);
        }
Example #28
0
        public RelayCardPage()
        {
            //Bind the name of the card to the title of the page
            this.SetBinding(Page.TitleProperty, "Name");

            //Enable NavigationBar
            NavigationPage.SetHasNavigationBar(this, true);

            // Create the Name Section
            var nameSection = new TableSection();

            nameSection.Title = "Name of the card";
            //Create the name cell and bind it to the Name
            var nameCell = new EntryCell();

            nameCell.SetBinding(EntryCell.TextProperty, "Name");
            nameCell.Label = "Name:";
            //add the name cell to the section
            nameSection.Add(nameCell);
            //Create the username cell and bind it to the Username
            var loginCell = new EntryCell();

            loginCell.SetBinding(EntryCell.TextProperty, "Username");
            loginCell.Label = "Username:"******"Password");
            passwordCell.Label = "Password:"******"Local Network Settings";
            var localIPCell = new EntryCell();

            localIPCell.Label = "Local IP:";
            localIPCell.SetBinding(EntryCell.TextProperty, "LocalIp");
            var localPortCell = new EntryCell();

            localPortCell.Label = "Local Port:";
            localPortCell.SetBinding(EntryCell.TextProperty, "LocalPort");
            localPortCell.Keyboard = Keyboard.Numeric;
            localNetworkSection.Add(localIPCell);
            localNetworkSection.Add(localPortCell);


            //External Table Section
            var externalNetworkSection = new TableSection();

            externalNetworkSection.Title = "Extern Network Settings";
            var externIPCell = new EntryCell();

            externIPCell.Label = "External IP:";
            externIPCell.SetBinding(EntryCell.TextProperty, "ExternalIp");
            var externPortCell = new EntryCell();

            externPortCell.Label = "External Port:";
            externPortCell.SetBinding(EntryCell.TextProperty, "ExternalPort");
            externPortCell.Keyboard = Keyboard.Numeric;
            externalNetworkSection.Add(externIPCell);
            externalNetworkSection.Add(externPortCell);

            var localConnectSection = new TableSection();

            localConnectSection.Title = "CONNECT TO LOCAL IP";
            var localConnectCell = new SwitchCell();

            localConnectCell.Text = "Connect to local network;";
            localConnectCell.SetBinding(SwitchCell.OnProperty, "ConnectLocal");
            localConnectSection.Add(localConnectCell);

            //Create Scan Button
            var scanButton = new Button {
                Text = "Scan"
            };

            //
            scanButton.Clicked += (object sender, EventArgs e) => {
                var discoveryPage = new RelayCardDiscoveryPage();

                discoveryPage.BindingContext = BindingContext;

                Navigation.PushAsync(discoveryPage);
            };

            var cancelButton = new Button {
                Text = "Cancel"
            };

            cancelButton.Clicked += (sender, e) => this.Navigation.PopAsync();

            Content = new StackLayout {
                VerticalOptions = LayoutOptions.StartAndExpand,
                Children        =
                {
                    new TableView {
                        Intent = TableIntent.Form,
                        Root   = new TableRoot("RelayCard")
                        {
                            nameSection,
                            localNetworkSection,
                            externalNetworkSection,
                            localConnectSection
                        }
                    }, scanButton
                }
            };
        }
Example #29
0
        public SettingsPage(LaneModel laneModelTapped)
        {
            var viewModel = new SettingsViewModel(laneModelTapped);

            BindingContext = viewModel;

            var isOpenSwitch = new SwitchCell
            {
                Text = "Is Open"
            };

            isOpenSwitch.SetBinding(SwitchCell.OnProperty, nameof(viewModel.IsOpen));

            var needsMaintenanceSwitch = new SwitchCell
            {
                Text = "Needs Maintenance"
            };

            needsMaintenanceSwitch.SetBinding(SwitchCell.OnProperty, nameof(viewModel.NeedsMaintenance));

            var ipAddressText = new EntryCell
            {
                Label = "IP Address",
                HorizontalTextAlignment = TextAlignment.End
            };

            ipAddressText.SetBinding(EntryCell.TextProperty, nameof(viewModel.IPAddress));

            var imageCell = new ImageCell();

            imageCell.SetBinding(ImageCell.ImageSourceProperty, nameof(viewModel.ImageCellIcon));


            var iconToggleButton = new Button();

            iconToggleButton.SetBinding(Button.CommandProperty, nameof(viewModel.IconToggleButtonCommand));
            iconToggleButton.SetBinding(Button.TextProperty, nameof(viewModel.ToggleButtonText));

            var tableView = new TableView
            {
                Intent = TableIntent.Settings,
                Root   = new TableRoot
                {
                    new TableSection {
                        isOpenSwitch,
                        needsMaintenanceSwitch,
                        ipAddressText,
                        imageCell
                    }
                }
            };

            var settingsStack = new StackLayout
            {
                Children =
                {
                    tableView,
                    iconToggleButton
                }
            };

            NavigationPage.SetTitleIcon(this, "cogwheel_navigation");

            Title   = $"Lane {laneModelTapped.ID + 1} Settings";
            Content = settingsStack;
        }
Example #30
0
        public SwitchPageCS()
        {
            SwitchPageViewModel vm = new SwitchPageViewModel();

            BindingContext = vm;

            var sw0 = new SwitchCell {
                Text = "Toggle sw1 & sw2"
            };

            sw0.SetBinding(SwitchCell.OnProperty, "SwAllValue", BindingMode.OneWayToSource);
            var sw1 = new SwitchCell {
                Text = "Toggle sw1"
            };

            sw1.SetBinding(SwitchCell.OnProperty, "Sw1Value", BindingMode.TwoWay);
            var sw2 = new SwitchCell {
                Text = "Toggle sw2"
            };

            sw2.SetBinding(SwitchCell.OnProperty, "Sw2Value", BindingMode.TwoWay);
            var tc1 = new TextCell {
                Text = "sw1 value"
            };

            tc1.SetBinding(TextCell.DetailProperty, "Sw1Value");
            var tc2 = new TextCell {
                Text = "sw2 value"
            };

            tc2.SetBinding(TextCell.DetailProperty, "Sw2Value");

            var tv = new TableView
            {
                Intent = TableIntent.Menu,
                Root   = new TableRoot
                {
                    new TableSection("Toggle all")
                    {
                        sw0,
                    },

                    new TableSection("Toggle each")
                    {
                        sw1,
                        sw2,
                    },
                    new TableSection("Values of ViewModel")
                    {
                        tc1,
                        tc2,
                    }
                }
            };

            Content = new StackLayout
            {
                Padding  = new Thickness(0, Device.OnPlatform(20, 0, 0), 0, 0),
                Children =
                {
                    tv,
                }
            };
        }
        public HistoryFilterPage()
        {
            BindingContext = new HistoryFilterViewModel();

            var maxDate = DateTime.Now;

            var rangeLabel = new TextCell()
            {
                IsEnabled = false
            };

            rangeLabel.SetBinding(TextCell.TextProperty, new Binding("TotalTimeSpan"));

            var startDatePicker = new DatePicker()
            {
                TextColor = Color.DimGray
            };

            startDatePicker.MaximumDate = maxDate;
            startDatePicker.SetBinding(DatePicker.DateProperty, new Binding("StartDate", BindingMode.TwoWay));

            var startTimePicker = new TimePicker()
            {
                TextColor = Color.DimGray
            };

            startTimePicker.SetBinding(TimePicker.TimeProperty, new Binding("StartTime", BindingMode.TwoWay));

            var endDatePicker = new DatePicker()
            {
                TextColor = Color.DimGray
            };

            endDatePicker.MaximumDate = maxDate;
            endDatePicker.SetBinding(DatePicker.DateProperty, new Binding("EndDate", BindingMode.TwoWay));

            var endTimePicker = new TimePicker()
            {
                TextColor = Color.DimGray
            };

            endTimePicker.SetBinding(TimePicker.TimeProperty, new Binding("EndTime", BindingMode.TwoWay));

            var uniqueMembersSwitch = new SwitchCell()
            {
                Text = "Unique Members Only"
            };

            uniqueMembersSwitch.SetBinding(SwitchCell.OnProperty, new Binding("UniqueMembersOnly", BindingMode.TwoWay));

            var allLocationsSwitch = new SwitchCell()
            {
                Text = "All Locations"
            };

            allLocationsSwitch.SetBinding(SwitchCell.OnProperty, new Binding("UseAllLocations", BindingMode.TwoWay));

            Content = new TableView
            {
                HasUnevenRows = true,
                Root          = new TableRoot {
                    new TableSection("Range")
                    {
                        rangeLabel
                    },
                    new TableSection("Filter")
                    {
                        new LabelledCustomViewCell("Start Date:", startDatePicker),
                        new LabelledCustomViewCell("Start Time:", startTimePicker),
                        new LabelledCustomViewCell("End Date:", endDatePicker),
                        new LabelledCustomViewCell("End Time:", endTimePicker),
                        uniqueMembersSwitch,
                        allLocationsSwitch
                    }
                },
                Intent = TableIntent.Settings
            };
        }