コード例 #1
0
        public RegisterPage()
        {
            this.Title = "Login";
            var marginEdge = 30;

            NavigationPage.SetHasBackButton(this, false);
            NavigationPage.SetHasNavigationBar(this, false);
            this.BackgroundColor = CoreStyles.LightOrangeBackground;

            var img = new Image()
            {
                Source = "registerheader.png",
                Aspect = Aspect.AspectFill
            };

            this.Padding = new Thickness(-9, -6, -9, -6);

            var lblHeader = new Label()
            {
                FontSize          = 32,
                Text              = "Create Account",
                Margin            = new Thickness(marginEdge, 5, marginEdge, 20),
                HorizontalOptions = LayoutOptions.Center
            };

            var txtUserName = new CoreUnderlineEntry()
            {
                Placeholder = "User Name",
                Style       = CoreStyles.LoginEntryStyle,
            };

            txtUserName.SetBinding(CoreUnderlineEntry.TextProperty, "UserName");

            var txtPassword = new CoreUnderlineEntry()
            {
                Placeholder = "Password",
                IsPassword  = true,
                Style       = CoreStyles.LoginEntryStyle,
            };

            txtPassword.SetBinding(CoreUnderlineEntry.TextProperty, "Password");

            var txtConfirmPassword = new CoreUnderlineEntry()
            {
                Placeholder = "Confirm Password",
                IsPassword  = true,
                Style       = CoreStyles.LoginEntryStyle,
            };

            txtConfirmPassword.SetBinding(CoreUnderlineEntry.TextProperty, "ConfirmPassword");

            var spacer = new StackLayout()
            {
                VerticalOptions = LayoutOptions.FillAndExpand
            };


            var btnCreate = new CoreButton()
            {
                Text   = "CREATE",
                Style  = CoreStyles.LightOrangeButton,
                Margin = new Thickness(marginEdge, 10, marginEdge, 25)
            };

            btnCreate.SetBinding(CoreButton.CommandProperty, "RegisterUser");

            var pageContent = new StackLayout()
            {
                Children =
                {
                    img,
                    lblHeader,
                    txtUserName,
                    txtPassword,
                    txtConfirmPassword,
                    spacer,
                    btnCreate
                }
            };

            Content = new ScrollView()
            {
                Padding = 0,
                Margin  = 0,
                Content = pageContent
            };
        }
コード例 #2
0
        public LoginPage()
        {
            this.Title = "Login";
            var marginEdge = 30;

            NavigationPage.SetHasBackButton(this, false);
            NavigationPage.SetHasNavigationBar(this, false);
            this.BackgroundColor = CoreStyles.LightOrangeBackground;

            var img = new Image()
            {
                Source = "loginheader.png",
                Aspect = Aspect.AspectFill
            };

            this.Padding = new Thickness(-9, -6, -9, -6);

            var lblHeader = new Label()
            {
                FontSize          = 32,
                Text              = "Task Manager",
                Margin            = new Thickness(marginEdge, 5, marginEdge, 20),
                HorizontalOptions = LayoutOptions.Center
            };
            var txtUserName = new CoreUnderlineEntry()
            {
                Placeholder = "User Name",
                Style       = CoreStyles.LoginEntryStyle,
            };

            txtUserName.SetBinding(CoreUnderlineEntry.TextProperty, "UserName");

            var txtPassword = new CoreUnderlineEntry()
            {
                Placeholder = "Password",
                IsPassword  = true,
                Style       = CoreStyles.LoginEntryStyle,
            };

            txtPassword.SetBinding(CoreUnderlineEntry.TextProperty, "Password");

            var spacer = new StackLayout()
            {
                VerticalOptions = LayoutOptions.FillAndExpand
            };

            var btnLogin = new CoreButton()
            {
                Text   = "LOGIN",
                Style  = CoreStyles.LightOrangeButton,
                Margin = new Thickness(marginEdge, 10, marginEdge, 10)
            };

            btnLogin.SetBinding(CoreButton.CommandProperty, "LoginUser");

            var btnRegister = new CoreButton()
            {
                Text    = "REGISTER",
                Style   = CoreStyles.LightOrangeButton,
                Margin  = new Thickness(marginEdge, 10, marginEdge, 25),
                Command = new Command(async(obj) => {
                    await Navigation.PushAsync(new RegisterPage());
                })
            };

            Content = new StackLayout()
            {
                Padding  = 0,
                Spacing  = 0,
                Children =
                {
                    img,
                    lblHeader,
                    txtUserName,
                    txtPassword,
                    spacer,
                    btnLogin,
                    btnRegister
                }
            };
        }
コード例 #3
0
        public CalendarEventPage()
        {
            this.Title = "Calendar Wizard";

            var lblExplain = new Label()
            {
                Text = "Please enter the required fields to create a calendar event."
            };

            var evtName = new Label()
            {
                TextColor = Color.Gray,
                Text      = "Event Name",
                FontSize  = 14,
                Margin    = new Thickness(5, 5, 5, 1)
            };

            evtNameEntry = new CoreUnderlineEntry()
            {
                Margin     = new Thickness(5, 1, 5, 1),
                EntryColor = Color.DarkGray,
            };
            evtNameEntry.SetBinding(Entry.TextProperty, new Binding(path: "Appt.Title", mode: BindingMode.TwoWay));

            var evtDescription = new Label()
            {
                TextColor    = Color.Gray,
                Text         = "Description",
                FontSize     = 14,
                Margin       = new Thickness(5, 5, 5, 1),
                AutomationId = "evtDescription"
            };

            var evtDescriptionEntry = new CoreUnderlineEntry()
            {
                Margin       = new Thickness(5, 1, 5, 1),
                EntryColor   = Color.DarkGray,
                AutomationId = "evtDescriptionEntry"
            };

            evtDescriptionEntry.SetBinding(Entry.TextProperty, "Appt.Description");

            var calendarSelect = CreateCalendarSelectionPanel();
            var startTime      = CreateStartDateTimePanel();
            var endTime        = CreateEndDateTimePanel();

            var evtHasReminder = new Label()
            {
                TextColor = Color.Gray,
                Text      = "Has Reminder",
                FontSize  = 14,
                Margin    = new Thickness(5, 5, 5, 1)
            };
            var swReminder = new Switch()
            {
                Margin       = 5,
                AutomationId = "swReminder"
            };

            swReminder.SetBinding(Switch.IsToggledProperty, "Appt.HasReminder");

            var btnCreate = new CoreButton()
            {
                Text         = "Create Event",
                Style        = CoreStyles.LightOrange,
                Margin       = 5,
                AutomationId = "btnCreate"
            };

            btnCreate.SetBinding(CoreButton.CommandProperty, "CreateEvent");

            Content = new CompressedStackLayout()
            {
                Padding  = 15,
                Children =
                {
                    lblExplain,
                    evtName,
                    evtNameEntry,
                    evtDescription,
                    evtDescriptionEntry,
                    calendarSelect,
                    startTime,
                    endTime,
                    evtHasReminder,
                    swReminder,
                    btnCreate
                }
            };

            this.SetAutomationIds();
        }
コード例 #4
0
        public EncryptionPage()
        {
            this.Title = "Encryption";

            var lbl = new Label()
            {
                TextColor = Color.Gray,
                Text      = "Clear Text",
                FontSize  = 14,
                Margin    = new Thickness(5, 5, 5, 1)
            };

            var clearEntry = new CoreUnderlineEntry()
            {
                Margin       = new Thickness(5, 1, 5, 1),
                AutomationId = "clearEntry"
            };

            clearEntry.SetBinding(CoreUnderlineEntry.TextProperty, "ClearText");

            var encryptedLabel = new Label()
            {
                FontSize     = 14,
                Margin       = new Thickness(5, 1, 5, 1),
                AutomationId = "encryptedLabel"
            };

            encryptedLabel.SetBinding(Label.TextProperty, "EncryptedText");

            var btnEncrypt = new CoreButton()
            {
                Text         = "Encryption",
                Style        = CoreStyles.LightOrange,
                Margin       = 5,
                AutomationId = "btnEncrypt"
            };

            btnEncrypt.SetBinding(Button.CommandProperty, "EncryptText");


            var md5Label1 = new Label()
            {
                TextColor    = Color.Gray,
                Text         = "Hash 1",
                FontSize     = 14,
                Margin       = new Thickness(5, 5, 5, 1),
                AutomationId = "md5Label1"
            };
            var clearHash1 = new CoreUnderlineEntry()
            {
                Margin       = new Thickness(5, 1, 5, 1),
                AutomationId = "clearHash1"
            };

            clearHash1.SetBinding(CoreUnderlineEntry.TextProperty, "ClearHash1");

            var md5Label2 = new Label()
            {
                TextColor    = Color.Gray,
                Text         = "Hash 2",
                FontSize     = 14,
                Margin       = new Thickness(5, 5, 5, 1),
                AutomationId = "md5Label2"
            };
            var clearHash2 = new CoreUnderlineEntry()
            {
                Margin       = new Thickness(5, 1, 5, 1),
                AutomationId = "clearHash2"
            };

            clearHash2.SetBinding(CoreUnderlineEntry.TextProperty, "ClearHash2");

            var btnHash = new CoreButton()
            {
                Text         = "Compare Clear Hash",
                Style        = CoreStyles.LightOrange,
                Margin       = 5,
                AutomationId = "btnHash"
            };

            btnHash.SetBinding(Button.CommandProperty, "HashText");

            var hashMatch = new Label()
            {
                TextColor    = Color.Red,
                AutomationId = "hashMatch"
            };

            hashMatch.SetBinding(Label.TextProperty, "HashMatchMessage");

            Content = new CompressedStackLayout()
            {
                Padding  = 15,
                Children = { lbl, clearEntry, encryptedLabel, btnEncrypt, md5Label1, clearHash1, md5Label2, clearHash2, btnHash, hashMatch }
            };
        }
コード例 #5
0
        public AddTodoPage()
        {
            this.Title = "Add Todo Item";
            var marginEdge = 20;

            var img = new CachedImage()
            {
                Source = "featherimage.png",
                Margin = 5
            };
            var txtTitle = new Label()
            {
                Text      = "Create a new item and specify the date for completion.",
                FontSize  = 22,
                Margin    = 5,
                TextColor = Color.DarkGray
            };

            var topPanel = new StackLayout()
            {
                Margin      = new Thickness(20, 25, 20, 25),
                Orientation = StackOrientation.Horizontal,
                Children    = { img, txtTitle }
            };

            var lblDescription = new Label()
            {
                Text  = "Description",
                Style = CoreStyles.LabelHeader,
            };
            var txtDescription = new CoreUnderlineEntry()
            {
                Style = CoreStyles.TodoEntryStyle
            };

            txtDescription.SetBinding(CoreUnderlineEntry.TextProperty, "CurrentItem.Description");

            var lblDueDate = new Label()
            {
                Text  = "Due Date",
                Style = CoreStyles.LabelHeader,
            };
            var pickerDueDate = new CoreDatePicker()
            {
                Style = CoreStyles.TodoPickerStyle
            };

            pickerDueDate.SetBinding(CoreDatePicker.DateProperty, new Binding(path: "CurrentItem.CompleteByDate", mode: BindingMode.TwoWay, converter: AppConverters.DateLong));

            var spacer = new StackLayout()
            {
                VerticalOptions = LayoutOptions.FillAndExpand
            };

            var btnSave = new CoreButton()
            {
                Text   = "SAVE",
                Style  = CoreStyles.LightOrangeButton,
                Margin = new Thickness(marginEdge, 10, marginEdge, 25),
            };

            btnSave.SetBinding(CoreButton.CommandProperty, "SaveCurrentItem");

            Content = new StackLayout()
            {
                Children =
                {
                    topPanel,
                    lblDescription,
                    txtDescription,
                    lblDueDate,
                    pickerDueDate,
                    spacer,
                    btnSave
                }
            };
        }
コード例 #6
0
        public BehaviorsMain()
        {
            this.Title = "Behaviors";

            var explanation = new Label()
            {
                AutomationId = "explanation",
                Margin       = new Thickness(5, 5, 5, 15),
                Text         = "Enter and remove content in the fields below to see behaviors work.  Enter the name 'Jack Sparrow' to see custom behavior."
            };

            var lbl = new Label()
            {
                TextColor = Color.Gray,
                Text      = "First Name",
                FontSize  = 14,
                Margin    = new Thickness(5, 5, 5, 1)
            };

            var fNameEntry = new CoreUnderlineEntry()
            {
                AutomationId = "fNameEntry",
                Margin       = new Thickness(5, 1, 5, 1),
                EntryColor   = Color.DarkGray
            };

            fNameEntry.SetBinding(Entry.TextProperty, "FirstName");
            fNameEntry.Behaviors.Add(new RegExBehavior()
            {
                ErrorMessage = "Requred Field",
                RegexExp     = @"^[\s\t\r\n]*\S+"
            });

            var errorLabel = new Label()
            {
                FontSize     = 14,
                TextColor    = Color.Red,
                Margin       = new Thickness(5, 1, 5, 1),
                AutomationId = "errorLabel"
            };

            errorLabel.SetBinding(Label.TextProperty, new Binding(
                                      source: fNameEntry.Behaviors[0],
                                      path: "ErrorMessage",
                                      mode: BindingMode.OneWay));
            errorLabel.SetBinding(Label.IsVisibleProperty, new Binding(
                                      source: fNameEntry.Behaviors[0],
                                      path: "HasError",
                                      mode: BindingMode.OneWay));


            var lblPhone = new Label()
            {
                TextColor    = Color.Gray,
                Text         = "Phone Number",
                FontSize     = 14,
                Margin       = new Thickness(5, 5, 5, 1),
                AutomationId = "lblPhone"
            };
            var phoneEntry = new CoreUnderlineEntry()
            {
                Margin       = new Thickness(5, 1, 5, 1),
                AutomationId = "phoneEntry",
                EntryColor   = Color.DarkGray
            };

            phoneEntry.Behaviors.Add(new PhoneMaskBehavior());
            phoneEntry.Behaviors.Add(new RegExBehavior()
            {
                ErrorMessage = "Requred Field",
                RegexExp     = @"^[\s\t\r\n]*\S+"
            });

            var phoneErrorLabel = new Label()
            {
                FontSize     = 14,
                TextColor    = Color.Red,
                Margin       = new Thickness(5, 1, 5, 1),
                AutomationId = "phoneErrorLabel"
            };

            phoneErrorLabel.SetBinding(Label.TextProperty, new Binding(source: phoneEntry.Behaviors[1], path: "ErrorMessage", mode: BindingMode.OneWay));
            phoneErrorLabel.SetBinding(Label.IsVisibleProperty, new Binding(source: phoneEntry.Behaviors[1], path: "HasError", mode: BindingMode.OneWay));


            var lblBindingEvent = new Label()
            {
                TextColor = Color.Gray,
                Text      = "Event To Command Binding - (numbers only)",
                FontSize  = 14,
                Margin    = new Thickness(5, 5, 5, 1)
            };
            var bindingEntry = new CoreUnderlineEntry()
            {
                Margin       = new Thickness(5, 1, 5, 1),
                AutomationId = "bindingEntry",
                EntryColor   = Color.DarkGray
            };

            bindingEntry.Behaviors.Add(new EventToCommandBehavior()
            {
                EventName = "TextChanged"
            });
            bindingEntry.Behaviors[0].SetBinding(EventToCommandBehavior.CommandProperty, "BindingTextChanged");
            bindingEntry.SetBinding(CoreUnderlineEntry.TextProperty, "BindingTextValue");

            var customLabel = new Label()
            {
                Margin = 5, AutomationId = "customLabel"
            };

            customLabel.Behaviors.Add(new PropertyChangedBehavior(VM, (prop, ctrl) =>
            {
                if (prop == "FirstName")
                {
                    if (VM.FirstName == "Jack Sparrow")
                    {
                        var ctrlLabel       = (Label)ctrl;
                        ctrlLabel.IsVisible = true;
                        ctrlLabel.TextColor = Color.Green;
                        ctrlLabel.Text      = "You like a pirate that has a bird for a friend!";
                    }
                    else
                    {
                        ctrl.IsVisible = false;
                    }
                }
            }));

            var btnCanExecute = new CoreButton()
            {
                Margin = new Thickness(5, 5, 5, 1),
                Text   = "Can Execute",
                Style  = CoreStyles.LightOrange
            };

            btnCanExecute.SetBinding(CoreButton.CommandProperty, "CanExecute");

            Content = new StackContainer(true)
            {
                Padding  = 15,
                Children = { explanation, lbl, fNameEntry, errorLabel, lblPhone, phoneEntry, phoneErrorLabel, customLabel, lblBindingEvent, bindingEntry, btnCanExecute }
            };
        }
コード例 #7
0
        public ProfilePage()
        {
            this.Title = "Profile";
            var marginEdge = 20;
            var img        = new CachedImage()
            {
                Source = "featherimage.png",
                Margin = 5
            };
            var txtTitle = new Label()
            {
                Text      = "Update your profile to include your image on the left.",
                FontSize  = 22,
                Margin    = 5,
                TextColor = Color.DarkGray
            };

            var topPanel = new StackLayout()
            {
                Margin      = new Thickness(20, 25, 20, 25),
                Orientation = StackOrientation.Horizontal,
                Children    = { img, txtTitle }
            };

            var lblFName = new Label()
            {
                Text  = "First Name",
                Style = CoreStyles.LabelHeader,
            };
            var txtFName = new CoreUnderlineEntry()
            {
                Style = CoreStyles.TodoEntryStyle
            };

            txtFName.SetBinding(CoreUnderlineEntry.TextProperty, "CurrentUser.FirstName");

            var lblLName = new Label()
            {
                Text  = "Last Name",
                Style = CoreStyles.LabelHeader,
            };
            var txtLName = new CoreUnderlineEntry()
            {
                Style = CoreStyles.TodoEntryStyle
            };

            txtLName.SetBinding(CoreUnderlineEntry.TextProperty, "CurrentUser.LastName");

            var lblPassword = new Label()
            {
                Text  = "Password",
                Style = CoreStyles.LabelHeader
            };
            var txtPassword = new CoreUnderlineEntry()
            {
                Style      = CoreStyles.TodoEntryStyle,
                IsPassword = true
            };

            txtPassword.SetBinding(CoreUnderlineEntry.TextProperty, "Password");

            var lblConfirmPassword = new Label()
            {
                Text  = "Confirm Password",
                Style = CoreStyles.LabelHeader,
            };
            var txtConfirmPassword = new CoreUnderlineEntry()
            {
                Style = CoreStyles.TodoEntryStyle
            };

            txtConfirmPassword.SetBinding(CoreUnderlineEntry.TextProperty, "ConfirmPassword");


            var btnSave = new CoreButton()
            {
                Text   = "SAVE",
                Style  = CoreStyles.LightOrangeButton,
                Margin = new Thickness(marginEdge, 10, marginEdge, 25),
            };

            btnSave.SetBinding(CoreButton.CommandProperty, "SaveProfile");

            var content = new StackLayout()
            {
                Children =
                {
                    topPanel,
                    lblFName,
                    txtFName,
                    lblLName,
                    txtLName,
                    lblPassword,
                    txtPassword,
                    lblConfirmPassword,
                    txtConfirmPassword,
                    btnSave
                }
            };

            Content = new ScrollView {
                Content = content
            };
        }