Ejemplo n.º 1
0
        public void outputData()
        {
            _database = new YangDb();
            var users = _database.GetUsers();

            foreach (var user in users)
            {
                Debug.WriteLine("user name is " + user.Name
                                + ", pwd is " + user.Password + ", pin is " + user.Pin
                                + ", url is " + user.Url);
            }
        }
Ejemplo n.º 2
0
        // Constructor
        public KeypadViewModel()
        {
            _database = new YangDb();

            this.AddCharCommand = new Command <string>((key) =>
            {
                // Add the key to the input string.
                this.InputString += key;
            });

            this.DeleteCharCommand = new Command((nothing) =>
            {
                if (string.IsNullOrEmpty(InputString))
                {
                    return;
                }
                Debug.WriteLine("input is " + InputString);
                // Strip a character from the input string.
                this.InputString = this.InputString.Substring(0,
                                                              this.InputString.Length - 1);
                int len = InputString.Length;
                switch (len)
                {
                case 0:
                    Pin1 = "";
                    ((Command)this.DeleteCharCommand).ChangeCanExecute();
                    break;

                case 1:
                    Pin2 = "";
                    break;

                case 2:
                    Pin3 = "";
                    break;

                case 3:
                    Pin4 = "";
                    break;

                case 4:
                    Pin5 = "";
                    break;
                }
            },
                                                 (nothing) =>
            {
                // Return true if there's something to delete.
                return(this.InputString.Length > 0);
            });
        }
Ejemplo n.º 3
0
        public RegisterPageCS(KeyPadCS parent)
        {
            _database    = new YangDb();
            messageLabel = new Label {
                Margin = new Thickness(20, 5), TextColor = Color.Red
            };
            this.BackgroundColor = Color.FromHex("BBDEFB");
            usernameEntry        = new Entry
            {
                Placeholder = "Input username",
                Margin      = new Thickness(20, 5),
                Keyboard    = Keyboard.Create(KeyboardFlags.None)
            };
            passwordEntry = new Entry
            {
                Placeholder = "Input password",
                IsPassword  = true,
                Margin      = new Thickness(20, 5)
            };
            pinEntry = new Entry()
            {
                Placeholder = "Input 5 digit pin",
                Keyboard    = Keyboard.Numeric,
                Margin      = new Thickness(20, 5)
            };
            pinEntry.TextChanged += Entry_TextChanged;
            urlEntry              = new Entry()
            {
                Placeholder = "Input your prefered URL",
                Margin      = new Thickness(20, 5),
                Keyboard    = Keyboard.Create(KeyboardFlags.None),
                Text        = Url
            };

            var signUpButton = new Button
            {
                Text            = "Sign Up",
                BackgroundColor = Color.White
            };

            signUpButton.Clicked += OnSignUpButtonClicked;

            Title = "Sign Up";

            Content = new StackLayout
            {
                VerticalOptions = LayoutOptions.CenterAndExpand,
                Children        =
                {
                    new Label {
                        Text = "Username", Margin = new Thickness(20, 5)
                    },
                    usernameEntry,
                    new Label {
                        Text = "Password", Margin = new Thickness(20, 5)
                    },
                    passwordEntry,
                    new Label {
                        Text = "5 Digital Pin", Margin = new Thickness(20, 5)
                    },
                    pinEntry,
                    new Label {
                        Text = "URL", Margin = new Thickness(20, 5)
                    },
                    urlEntry,
                    signUpButton,
                    messageLabel
                }
            };
        }
Ejemplo n.º 4
0
        public AddPathCS(PathEntity pathEntity)
        {
            this.pathEntity      = pathEntity;
            this.BackgroundColor = Color.FromHex("BBDEFB");

            _database    = new YangDb();
            App.PathList = _database.GetPaths(App.UserEntity.ID);

            Title     = "Custom Paths";
            PathEntry = new Entry
            {
                Margin   = new Thickness(20, 5),
                Keyboard = Keyboard.Create(KeyboardFlags.None)
            };
            TopLevelSelector = new Picker
            {
                Margin = new Thickness(20, 5),
                Title  = "Top Level",
            };
            // fill parents picker
            // firstly add a No Parent option
            TopLevelSelector.Items.Add(NO_PARENT);

            foreach (var item in App.PathList)
            {
                TopLevelSelector.Items.Add(item.Path);
                // itself can not be its parent
                if (pathEntity != null && pathEntity.Path.Equals(item.Path))
                {
                    TopLevelSelector.Items.Remove(item.Path);
                }
            }

            if (pathEntity != null && pathEntity.Parent != null)
            {
                TopLevelSelector.SelectedItem = pathEntity.Parent;
            }


            // Grid container for buttons
            Grid btnCtn = new Grid
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Margin            = new Thickness(20, 5),
            };

            // warnging label
            messageLabel = new Label()
            {
                TextColor = Color.Red, Margin = new Thickness(20, 5)
            };

            Button btnSave = new Button()
            {
                Text = "Save", BackgroundColor = Color.White
            };

            btnSave.Clicked += OnSaveAsync;
            btnCtn.Children.Add(btnSave, 0, 0);

            // only when editing the path, there is delete option
            if (pathEntity != null)
            {
                PathEntry.Text = pathEntity.Path;

                Button btnDelete = new Button()
                {
                    Text = "Delete", BackgroundColor = Color.White
                };
                btnDelete.Clicked += OnDelete;
                btnCtn.Children.Add(btnDelete, 0, 1);
            }

            Content = new StackLayout()
            {
                BackgroundColor = Color.FromHex("BBDEFB"),
                VerticalOptions = LayoutOptions.StartAndExpand,
                Children        =
                {
                    new Label {
                        Text = "Path", Margin = new Thickness(20, 15, 0, 5)
                    },
                    PathEntry,
                    new Label {
                        Text = "Choose a Top Level", Margin = new Thickness(20, 5)
                    },
                    TopLevelSelector,
                    btnCtn,
                }
            };
        }
Ejemplo n.º 5
0
        //Grid gridCtn;
        //ListView lvPaths;

        //string url = "https://cirro.nimbus.co.nz/zd1";
        //string username = "******";
        //string password = "******";

        public PersonalInfoPageCS()
        {
            Debug.WriteLine("on construction");
            _database            = new YangDb();
            this.BackgroundColor = Color.FromHex("BBDEFB");
            App.PathList         = _database.GetPaths(App.UserEntity.ID);
            messageLabel         = new Label()
            {
                TextColor = Color.Red, Margin = new Thickness(20, 5)
            };
            usernameEntry = new Entry
            {
                Margin   = new Thickness(20, 5),
                Keyboard = Keyboard.Create(KeyboardFlags.None)
            };
            passwordEntry = new Entry
            {
                IsPassword = true,
                Margin     = new Thickness(20, 5)
            };
            pinEntry = new Entry()
            {
                Keyboard = Keyboard.Numeric,
                Margin   = new Thickness(20, 5)
            };
            pinEntry.TextChanged += Pin_Control;
            urlEntry              = new Entry()
            {
                Margin   = new Thickness(20, 5),
                Keyboard = Keyboard.Create(KeyboardFlags.None)
            };
            // Path container
            RelativeLayout pathTitleContainer = new RelativeLayout()
            {
                Margin = new Thickness(20, 5)
            };
            // path title
            Label pathTitle = new Label {
                Text = "Path"
            };

            pathTitleContainer.Children.Add(pathTitle,
                                            Constraint.Constant(0),
                                            Constraint.Constant(0)
                                            );

            // add ADD button
            Button btnAdd = new Button()
            {
                Text = "Add More Path", BackgroundColor = Color.White
            };

            btnAdd.Clicked += OnAddMoreClickedAsync;
            pathTitleContainer.Children.Add(btnAdd,
                                            Constraint.RelativeToView(pathTitle, (parent, sibling) => { return(sibling.X + sibling.Width + 20); }),
                                            Constraint.RelativeToParent((parent) => { return(-10); })
                                            );

            var saveButton = new Button
            {
                Text = "Save",
                MinimumHeightRequest = 40,
                BackgroundColor      = Color.White,
                Margin = new Thickness(20, 5)
            };

            saveButton.Clicked += OnSaveButtonClicked;

            Title    = "Personal Info";
            mContent = new StackLayout()
            {
                VerticalOptions = LayoutOptions.CenterAndExpand,
                Children        =
                {
                    new Label {
                        Text = "Username", Margin = new Thickness(20, 5)
                    },
                    usernameEntry,
                    new Label {
                        Text = "Password", Margin = new Thickness(20, 5)
                    },
                    passwordEntry,
                    new Label {
                        Text = "5 Digital Ping", Margin = new Thickness(20, 5)
                    },
                    pinEntry,
                    new Label {
                        Text = "URL", Margin = new Thickness(20, 5)
                    },
                    urlEntry,
                    pathTitleContainer,
                }
            };


            //int index = 0;
            //foreach (var item in App.PathList)
            //{
            //	//if()
            //	// add path
            //             mContent.Children.Add(MakeNewPath(item));

            //	index++;
            //}

            //isInit = false;
            mContent.Children.Add(saveButton);
            mContent.Children.Add(messageLabel);


            Content = new ScrollView {
                Content = mContent, Margin = new Thickness(0, 20)
            };
        }
Ejemplo n.º 6
0
        public LoginPageCS()
        {
            //InitializeComponent();
            _database = new YangDb();

            Title = "Login";
            Grid grid = new Grid
            {
                VerticalOptions   = LayoutOptions.Center,
                WidthRequest      = 200,
                HorizontalOptions = LayoutOptions.Center,
            };

            grid.RowDefinitions.Add(new RowDefinition {
                Height = 50
            });
            grid.ColumnDefinitions.Add(new ColumnDefinition {
                Width = 50
            });
            grid.ColumnDefinitions.Add(new ColumnDefinition {
                Width = 50
            });
            grid.ColumnDefinitions.Add(new ColumnDefinition {
                Width = 50
            });
            grid.ColumnDefinitions.Add(new ColumnDefinition {
                Width = 50
            });

            pin1.TextChanged += Entry_TextChanged;
            pin2.TextChanged += Entry_TextChanged;
            pin3.TextChanged += Entry_TextChanged;
            pin4.TextChanged += Last_LastEntry;

            mlist.Add(pin1);
            mlist.Add(pin2);
            mlist.Add(pin3);
            mlist.Add(pin4);

            grid.Children.Add(pin1, 0, 0);
            grid.Children.Add(pin2, 1, 0);
            grid.Children.Add(pin3, 2, 0);
            grid.Children.Add(pin4, 3, 0);

            // login button
            var LoginButton = new Button
            {
                Text = "Login"
            };
            var RegisterButton = new Button
            {
                Text = "Register"
            };

            LoginButton.Clicked    += Login;
            RegisterButton.Clicked += Register_ClickAsync;


            RelativeLayout mainStackLayOut = new RelativeLayout
            {
                BackgroundColor   = Color.Yellow,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand,
            };

            Func <View, View, double> getSwitchWidth  = (parent, self) => self.Measure(parent.Width, parent.Height).Request.Width;
            Func <View, View, double> getSwitchHeight = (parent, self) => self.Measure(parent.Width, parent.Height).Request.Height;

            mainStackLayOut.Children.Add(grid,
                                         Constraint.RelativeToParent((parent) => parent.Width / 2 - getSwitchWidth(parent, grid) / 2),
                                         Constraint.RelativeToParent((parent) => parent.Height / 2 - getSwitchHeight(parent, grid) * 2)
                                         );

            warning.Text      = "";
            warning.TextColor = Color.Red;
            mainStackLayOut.Children.Add(warning,
                                         Constraint.RelativeToParent((parent) => parent.Width / 2 - getSwitchWidth(parent, warning) / 2),
                                         Constraint.RelativeToParent((parent) => parent.Height / 2 - getSwitchHeight(parent, grid) - 100)
                                         );

            mainStackLayOut.Children.Add(LoginButton,
                                         Constraint.RelativeToParent((parent) => parent.Width / 2 - getSwitchWidth(parent, LoginButton) / 2),
                                         Constraint.RelativeToParent(parent => parent.Height / 2));
            mainStackLayOut.Children.Add(RegisterButton,
                                         Constraint.RelativeToParent((parent) => parent.Width / 2 - getSwitchWidth(parent, RegisterButton) / 2),
                                         Constraint.RelativeToParent((parent) => parent.Height - 100)
                                         );

            this.Content = mainStackLayOut;
        }