internal static Cell IntCell(PropertyInfo property, IContact context, Page parent = null)
 {
     var label = CreateLabel(property);
     var entryCell = new EntryCell();
     entryCell.SetValue(EntryCell.LabelProperty, label);
     entryCell.LabelColor = Color.FromHex("999999");
     entryCell.SetBinding(EntryCell.TextProperty, new Binding(property.Name, mode: BindingMode.TwoWay, converter: DefaultConverter));
     entryCell.BindingContext = context;
     return entryCell;
 }
Beispiel #2
0
		public NewEntryPage ()
		{
			Title = "New Entry";

			// Form fields
			var title = new EntryCell { Label = "Titel" };
			title.SetBinding (EntryCell.TextProperty, "Title", BindingMode.TwoWay);

			var latitude = new EntryCell { Label = "Latitude", Keyboard = Keyboard.Numeric };
			latitude.SetBinding (EntryCell.TextProperty, "Latitude", BindingMode.TwoWay);

			var longitude = new EntryCell {Label = "Longitude", Keyboard = Keyboard.Numeric };
			longitude.SetBinding (EntryCell.TextProperty, "Longitude", BindingMode.TwoWay);


			var date = new DatePickerEntryCell {Label = "Date"};
			date.SetBinding (DatePickerEntryCell.DateProperty,
				"Date",BindingMode.TwoWay);


			var rating = new EntryCell { Label = "Rating", Keyboard = Keyboard.Numeric };
			rating.SetBinding (EntryCell.TextProperty, "Rating", BindingMode.TwoWay);


			var notes = new EntryCell { Label = "Notes" };
			notes.SetBinding (EntryCell.TextProperty, "Notes", BindingMode.TwoWay);


			// Form
			var entryForm = new TableView {
				Intent = TableIntent.Form,
				Root = new TableRoot {
					new TableSection () {
						title,
						latitude,
						longitude,
						date,
						rating,
						notes
					}
				}
			};

			Content = entryForm;

			var save = new ToolbarItem {
				Text = "Save"
			};
			save.SetBinding (ToolbarItem.CommandProperty, "SaveCommand");

			ToolbarItems.Add (save);
		}
        protected override Cell CreateDefault(object item)
        {
            var pi = (PropertyInfo)item;
            if (pi.PropertyType == typeof(double))
            {
                Binding b = new Binding()
                {
                    Source = Target,
                    Path = pi.Name
                };

                var cell = new EntryCell() { Label = pi.Name };
                cell.SetBinding(EntryCell.TextProperty, b);
                return cell;
                //return CreateSpinnerCell(pi);
            }
            return base.CreateDefault(item);
        }
 internal static Cell DecimalCell(PropertyInfo property, IContact context, Page parent = null)
 {
     var label = CreateLabel(property);
     var currencyAttrib = property.GetCustomAttribute<CurrencyAttribute>();
     var entryCell = new EntryCell();
     entryCell.SetValue(EntryCell.LabelProperty, label);
     entryCell.LabelColor = Color.FromHex("999999");
     entryCell.SetBinding(EntryCell.TextProperty, new Binding(property.Name, mode: BindingMode.TwoWay, converter: DefaultConverter, converterParameter: currencyAttrib));
     entryCell.BindingContext = context;
     return entryCell;
 }
		public SettingsPage(LanesViewModel viewModel)
		{
			BindingContext = viewModel;

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

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

			#region create the IP Address Entry
			var ipAddressText = new EntryCell
			{
				Label = "IP Address",
				HorizontalTextAlignment = TextAlignment.End
			};
			ipAddressText.SetBinding(EntryCell.TextProperty, "LaneTappedIPAddress");
			#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, "IconToggleButton");
			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 {viewModel.LanesList.IndexOf(viewModel.LaneTapped)+1} Settings";
			Content = settingsStack;
		}
        public LoginPage()
        {
            InitializeComponent();
            Title = "Login to Your Account";

            _viewModel = new LoginPageViewModel();
            this.BindingContext = _viewModel;

            var tableView = new TableView
            {
                Intent = TableIntent.Menu,
            };
            this.Content = tableView;

            var usernameSection = new TableSection();
            tableView.Root.Add(usernameSection);

            var usernameCell = new EntryCell
            {
                Label = "Login",
                Placeholder = "username",
                Keyboard = Keyboard.Email,
            };
            usernameSection.Add(usernameCell);
            usernameCell.SetBinding(EntryCell.TextProperty, "Username");

//            var passwordCell = new EntryCell
//            {
//                Label = "Password",
//                Placeholder = "password",
//                Keyboard = Keyboard.Text,
//            };
            var passwordCell = new ExtendedEntryCell
            {
                Label = "Password",
                Placeholder = "password",
                Keyboard = Keyboard.Text,
                IsPassword = true,
            };
            usernameSection.Add(passwordCell);
            passwordCell.SetBinding(EntryCell.TextProperty, "Password");

            var forgotPasswordViewCell = new ViewCell();
            usernameSection.Add(forgotPasswordViewCell);

            var forgotPasswordLayout = new StackLayout
            { 
                Padding = new Thickness(5, 0, 5, 0),
            };
            forgotPasswordViewCell.View = forgotPasswordLayout;

            var forgotPasswordButton = new Button
            {
                Text = "Forgot your Password?",
                HorizontalOptions = LayoutOptions.End,
            };
            forgotPasswordLayout.Children.Add(forgotPasswordButton);
            forgotPasswordButton.Clicked += async (sender, e) =>
            {
                ResetPassword(usernameCell.Text);
            };

            var loginSection = new TableSection();
            tableView.Root.Add(loginSection);

            var loginButtonViewCell = new ViewCell();
            loginSection.Add(loginButtonViewCell);
            loginButtonViewCell.Tapped += async (sender, e) =>
            {
                await Login(usernameCell.Text, passwordCell.Text);
            };

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

            var loginButton = new Button
            {
                Text = "Login",
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                TextColor = Color.White,
            };
            loginButtonLayout.Children.Add(loginButton);
            loginButton.Clicked += async (sender, e) =>
            {
                // Maybe just make the call to be Login() and determine the parameters in the VM is better!!
                await Login(usernameCell.Text, passwordCell.Text);
            };

            var signUpSection = new TableSection();
            tableView.Root.Add(signUpSection);

            var signUpCell = new ViewCell();
            signUpSection.Add(signUpCell);

            var signUpLayout = new StackLayout
            {
                Padding = new Thickness(5, 0, 5, 0),
            };
            signUpCell.View = signUpLayout;

            var signUpButton = new Button
            {
                Text = "Don't have an account yet? Sign up",
            };
            signUpLayout.Children.Add(signUpButton);
            signUpButton.Clicked += (sender, e) =>
            {
                this.Navigation.PushAsync(new RegistrationPage(false, this));
            };
        }
        //View
        public ContactEditPage(ContactRepository database)
        {
            //Initialize
            _database = database;

            //Create EntryCells
            var firstNameCell = new EntryCell {Label = "First Name:"};
            var lastNameCell = new EntryCell {Label = "Last Name:"};
            var typeCell = new EntryCell {Label = "Contact Type:"};
            var dateCell = new EntryCell { Label = "Date of Birth:"};

            //Set DataBinding
            firstNameCell.SetBinding(EntryCell.TextProperty, "FirstName");
            lastNameCell.SetBinding(EntryCell.TextProperty, "LastName");
            typeCell.SetBinding(EntryCell.TextProperty, "Type");
            dateCell.SetBinding(EntryCell.TextProperty, "DateOfBirth");

            //Save Btn
            var saveBtn = new Button
            {
                Text = "   Save Contact   ",
                FontSize = Device.GetNamedSize(NamedSize.Medium, typeof (Button)),
                HorizontalOptions = LayoutOptions.CenterAndExpand
            };
            saveBtn.Clicked += async (sender, args) =>
            {
                //Validate Text Fields
                if (firstNameCell.Text == string.Empty
                    || lastNameCell.Text == string.Empty
                    || typeCell.Text == string.Empty
                    || dateCell.Text == string.Empty)
                {
                    await DisplayAlert
                        ("Warning", "Please Fill In All Fields", "OK");
                }
                else
                {
                    //Saves Changes to Database
                    var contactItem = (Contact) BindingContext;
                    _database.SaveContact(contactItem);

                    await Navigation.PopAsync();
                    SortContacts();
                }
            };

            //Delete Btn
            var deleteBtn = new Button
            {
                Text = "  Delete Contact  ",
                FontSize = Device.GetNamedSize(NamedSize.Medium, typeof (Button)),
                HorizontalOptions = LayoutOptions.CenterAndExpand
            };
            deleteBtn.Clicked += async (sender, e) =>
            {
                //Deletes Contact from Database
                var contactItem = (Contact) BindingContext;
                _database.DeleteContact(contactItem);

                await Navigation.PopAsync();
                SortContacts();
            };

            //Cancel Btn
            var cancelBtn = new Button
            {
                Text = "       Cancel       ",
                FontSize = Device.GetNamedSize(NamedSize.Medium, typeof (Button)),
                HorizontalOptions = LayoutOptions.CenterAndExpand
            };
            cancelBtn.Clicked += async (sender, args) => { await Navigation.PopAsync(); };

            //Create TableView
            var tableView = new TableView
            {
                HeightRequest = 275,
                Intent = TableIntent.Form,
                Root = new TableRoot
                {
                    new TableSection("Edit/Delete a Contact")
                    {
                        firstNameCell,
                        lastNameCell,
                        dateCell,
                        typeCell
                    }
                }
            };

            //Build Button Layout
            var btnLayout = new StackLayout
            {
                Orientation = StackOrientation.Horizontal,
                Children = {saveBtn, deleteBtn, cancelBtn}
            };

            //Build Main Page
            var main = new StackLayout
            {
                VerticalOptions = LayoutOptions.Start,
                Children = {tableView, btnLayout}
            };

            Content = main;
        }
		public AddOpportunityPage()
		{
			var viewModel = new AddOpportunityViewModel(this);
			BindingContext = viewModel;

			#region Create Topic Entry
			var topicText = new EntryCell
			{
				Label = "Topic"
			};
			topicText.SetBinding(EntryCell.TextProperty, "Topic");
			#endregion

			#region Create Company Entry
			var companyText = new EntryCell
			{
				Label = "Company"
			};
			companyText.SetBinding(EntryCell.TextProperty, "Company");
			#endregion

			#region Create DBA Entry
			var dbaText = new EntryCell
			{
				Label = "DBA"
			};
			dbaText.SetBinding(EntryCell.TextProperty, "DBA");
			#endregion

			#region Create LeaseAmount Entry
			var leaseAmountNumber = new EntryCell
			{
				Label = "Lease Amount",
				Keyboard = Keyboard.Numeric
			};
			leaseAmountNumber.SetBinding(EntryCell.TextProperty, "LeaseAmount");
			#endregion

			#region Create Owner Entry
			var ownerText = new EntryCell
			{
				Label = "Owner",
			};
			ownerText.SetBinding(EntryCell.TextProperty, "Owner");
			#endregion

			#region create the TableView
			var tableView = new TableView
			{
				Intent = TableIntent.Settings,
				Root = new TableRoot
				{
					new TableSection{
						topicText,
						companyText,
						leaseAmountNumber,
						ownerText,
						dbaText,
					}
				}
			};
			#endregion

			#region Create Save Button
			var saveButtonToolBar = new ToolbarItem();
			saveButtonToolBar.Text = "Save";
			saveButtonToolBar.SetBinding(ToolbarItem.CommandProperty, "SaveButtonTapped");
			saveButtonToolBar.Priority = 0;
			ToolbarItems.Add(saveButtonToolBar);
			#endregion

			#region Create Cancel Button
			var cancelButtonToolBar = new ToolbarItem();
			cancelButtonToolBar.Text = "Cancel";
			cancelButtonToolBar.Command = new Command (async ()=> await PopModalAsync(true));
			cancelButtonToolBar.Priority = 1;
			ToolbarItems.Add(cancelButtonToolBar);
			#endregion

			Title = "Add Opportunity";

			Content = tableView;

			viewModel.SaveError += HandleSaveError;

			SaveToDatabaseCompleted += async (sender, e) => await PopModalAsync(true);
		}