public FootballPlayerPage()
        {
            InitializeComponent ();

            this.BindingContext = new FootballPlayerListViewModel();

            ViewCell vc = new ViewCell ();
        }
示例#2
0
 public static LongPressGestureRecognizer CreateGesture(UITableView tableView, ViewCell cell)
 {
     return new LongPressGestureRecognizer(OnRecognizing)
     {
         TableView = new WeakReference<UITableView>(tableView),
         ViewCell = new WeakReference<ViewCell>(cell),
     };
 }
		/// <summary>
		/// Updates the cell.
		/// </summary>
		/// <param name="cell">The cell.</param>
		private void UpdateCell (ViewCell cell)
		{
			if (_viewCell != null) {
				//this.viewCell.SendDisappearing ();
				_viewCell.PropertyChanged -= new PropertyChangedEventHandler (HandlePropertyChanged);
			}
			_viewCell = cell;
			_viewCell.PropertyChanged += new PropertyChangedEventHandler (HandlePropertyChanged);
			//this.viewCell.SendAppearing ();
			UpdateView ();
		}
        /// <summary>
        /// Updates the cell.
        /// </summary>
        /// <param name="cell">The cell.</param>
        private void UpdateCell (ViewCell cell)
        {
            if (this._viewCell != null) 
            {
                //this.viewCell.SendDisappearing ();
                this._viewCell.PropertyChanged -= this.HandlePropertyChanged;
            }

            this._viewCell = cell;
            this._viewCell.PropertyChanged += this.HandlePropertyChanged;
            //this.viewCell.SendAppearing ();
            UpdateView ();
        }
 protected override Cell CreateDefault(object item)
 {
     var template = _currentItemSelector?.SelectTemplate(item, this);
     if (template == null) return base.CreateDefault(item);
     var templateInstance = template.CreateContent();
     // see if it's a view or a cell
     var templateView = templateInstance as View;
     var templateCell = templateInstance as Cell;
     if (templateView == null && templateCell == null)
         throw new InvalidOperationException("DataTemplate must be either a Cell or a View");
     if (templateView != null) // we got a view, wrap in a cell
         templateCell = new ViewCell { View = templateView };
     return templateCell;
 }
        /// <summary>
        /// Cells for.
        /// </summary>
        /// <param name="This">The this.</param>
        /// <param name="item">The item.</param>
        /// <param name="selector">The selector.</param>
        /// <returns>Cell.</returns>
        /// <exception cref="System.InvalidOperationException">DataTemplate must be either a Cell or a View</exception>
        public static Cell CellFor(this BindableObject This, object item, DataTemplateSelector selector)
        {
            if (selector != null)
            {
                var template = selector.SelectTemplate(item, This);
                if (template != null)
                {
                    var templateInstance = template.CreateContent();
                    // see if it's a view or a cell
                    var templateView = templateInstance as View;
                    var templateCell = templateInstance as Cell;

                    if (templateView == null && templateCell == null)
                        throw new InvalidOperationException("DataTemplate must be either a Cell or a View");

                    if (templateView != null) // we got a view, wrap in a cell
                        templateCell = new ViewCell { View = templateView };

                    return templateCell;
                }
            }

            return null;
        }
        public App()
        {
            CartCollection = new ObservableCollection<ItemForSale>();
            //			CartCollection.CollectionChanged += (sender, e) => {
            //				forSale.ItemsSource=null;
            //				forSale.ItemsSource = ((ShopingViewModel)BindingContext).ItemsForSale;
            //			};

            this.BindingContext = new ShopingViewModel ();

            // The root page of your application
            var grid = new Grid {
                VerticalOptions = LayoutOptions.FillAndExpand,
                RowDefinitions = { new RowDefinition{ Height = GridLength.Auto } ,
                 new RowDefinition{ Height = new GridLength (1, GridUnitType.Star) } },
                ColumnDefinitions = {
                    new ColumnDefinition{ Width = new GridLength(1,GridUnitType.Star) },
                    new ColumnDefinition{ Width = new GridLength(1,GridUnitType.Star) }
                }
            };
            forSale = new ListView (){
                BackgroundColor=Color.Red,
                ItemTemplate = new DataTemplate(() =>
                    {
                        // Create views with bindings for displaying each property.
                        Label nameLabel = new Label();
                        nameLabel.SetBinding(Label.TextProperty, "Name");

                        Label priceLabel = new Label(){HorizontalOptions=LayoutOptions.End};
                        priceLabel.SetBinding(Label.TextProperty,"Price");

                        Image addedorNot = new Image();
                        var addedOrNotImageBinding = new Binding("IsAddedToCart",0, new ImagePathConvertor());
                        addedorNot.SetBinding(Image.SourceProperty,addedOrNotImageBinding);

                        var vc= new ViewCell
                        {
                            View = new StackLayout
                            {
                                Orientation = StackOrientation.Horizontal,
                                Children =
                                {
                                    new StackLayout
                                    {
                                        Orientation=StackOrientation.Horizontal,
                                        VerticalOptions = LayoutOptions.Center,
                                        Spacing = 0,
                                        Children =
                                        {
                                            addedorNot,
                                            nameLabel
                                        }
                                        }
                                }
                                }
                        };

                        vc.Tapped+=(s,e)=>{
                            ViewCell viewCell = (ViewCell)s;
                            ItemForSale item = (ItemForSale)viewCell.BindingContext;
                            if(item.IsAddedToCart)
                            {
                                item.IsAddedToCart = false;
                                CartCollection.Remove(item);
                            }
                            else
                            {
                                item.IsAddedToCart = true;
                                CartCollection.Add(item);
                            }
                        };
                        return vc;
                    })

            };
            forSale.SetBinding(ListView.ItemsSourceProperty,new Binding("ItemsForSale"));

            cart = new ListView (){
                BackgroundColor=Color.Green,
                    ItemTemplate = new DataTemplate(() =>
                        {

                            // Create views with bindings for displaying each property.
                            Label nameLabel = new Label();
                            nameLabel.SetBinding(Label.TextProperty, "Name");

                            Label priceLabel = new Label(){HorizontalOptions=LayoutOptions.End};
                            priceLabel.SetBinding(Label.TextProperty,"Price");

                            var vc= new ViewCell
                            {
                                View = new StackLayout
                                {
                                    Orientation = StackOrientation.Horizontal,
                                    Children =
                                    {
                                        new StackLayout
                                        {
                                            Orientation=StackOrientation.Horizontal,
                                            VerticalOptions = LayoutOptions.Center,
                                            Spacing = 0,
                                            Children =
                                            {

                                                nameLabel,
                                                priceLabel
                                            }
                                            }
                                    }
                                    }
                            };
                            return vc;
                        })

            };
            grid.Children.Add (cart, 1, 1);
            grid.Children.Add (new Label (){Text="For Sale",HorizontalOptions =LayoutOptions.CenterAndExpand}, 0, 0);
            grid.Children.Add (new Label (){Text="Cart",HorizontalOptions=LayoutOptions.CenterAndExpand}, 1, 0);

            MainPage = new ContentPage {
                Content = grid
            };
            Binding cartBinding = new Binding ();
            cartBinding.Source = CartCollection;

            cart.SetBinding(ListView.ItemsSourceProperty,cartBinding);
            grid.Children.Add (forSale, 0, 1);
        }
示例#8
0
 private static void OnRecognizing(LongPressGestureRecognizer recognizer, UITableView tableView, ViewCell cell)
 {
     NSIndexPath indexPath = tableView.IndexPathForRowAtPoint(recognizer.LocationInView(tableView));
     switch (recognizer.State)
     {
         case UIGestureRecognizerState.Began:
             if (indexPath != null)
             {
                 // Remember the source row
                 recognizer.sourceIndexPath = indexPath;
                 recognizer.destinationIndexPath = indexPath;
                 cell.View.BackgroundColor = Color.Gray;
             }
             break;
         case UIGestureRecognizerState.Changed:
             if (recognizer.destinationIndexPath != null && indexPath != null && recognizer.destinationIndexPath != indexPath)
             {
                 // Dragged to a new row location, so show it to the user with animation
                 tableView.MoveRow(recognizer.destinationIndexPath, indexPath);
                 recognizer.destinationIndexPath = indexPath;
             }
             break;
         case UIGestureRecognizerState.Cancelled:
         case UIGestureRecognizerState.Failed:
             recognizer.sourceIndexPath = null;
             cell.View.BackgroundColor = Color.Transparent;
             break;
         case UIGestureRecognizerState.Recognized:
             // Move the data source finally
             if (recognizer.sourceIndexPath != null && recognizer.destinationIndexPath != null && recognizer.sourceIndexPath != recognizer.destinationIndexPath)
             {
                 // Reset the move because otherwise the underneath control will get out of sync with
                 // the Xamarin.Forms element. The next line will drive the real change from ItemsSource
                 tableView.MoveRow(recognizer.destinationIndexPath, recognizer.sourceIndexPath);
                 tableView.Source.MoveRow(tableView, recognizer.sourceIndexPath, recognizer.destinationIndexPath);
             }
             recognizer.sourceIndexPath = null;
             recognizer.destinationIndexPath = null;
             cell.View.BackgroundColor = Color.Transparent;
             break;
     }
 }
 internal static Cell AddressCell(PropertyInfo property, IContact context, Page parent = null)
 {
     var label = CreateLabel(property);
     var viewCell = new ViewCell 
     {
         Height = 150D
     };
     var pin = new Pin { Label = label };
     pin.SetBinding(Pin.AddressProperty, new Binding(property.Name, converter: AddressToStringConverter));
     pin.SetBinding(Pin.PositionProperty, new Binding(property.Name, converter: AddressConverter));
     var map = new Map(MapSpan.FromCenterAndRadius(pin.Position, Distance.FromMiles(0.1D)))
     {
         IsShowingUser = false,
         InputTransparent = false,
     };
     pin.PropertyChanged  += (sender, e) => {
         Console.WriteLine("Pin." + e.PropertyName + " Changed");
         map.MoveToRegion(MapSpan.FromCenterAndRadius(pin.Position, Distance.FromMiles(0.1D)));
     };
     map.PropertyChanging += (sender, e) => 
         Console.WriteLine("Map." + e.PropertyName + " Changed");
     pin.BindingContext = context;
     map.Pins.Add(pin);
     viewCell.View = map;
     return viewCell;
 }
示例#10
0
        // Voting Page
        public VoteLayout(VoteResponse VResponse, ContentPageController ViewController)
        {
            var inputs = VResponse.PlayerAnswers;
            var RoundNumber = VResponse.RoundNumber;

            var RoundLabel = new Label
            {
                Text = "Round " + RoundNumber,
                FontSize = 30,
                HorizontalOptions = LayoutOptions.Center
                //HeightRequest = 150
            };

            var AnswerImage = new Image
            {
                Source = "answer_now.png"
            };

            listview = new ListView
            {
                ItemsSource = inputs,
                HeightRequest = 30,
                ItemTemplate = new DataTemplate(() =>
                {
                    var textlabel = new Label
                    {
                        TextColor = Color.FromRgb(31, 174, 206)
                    };

                    var cell = new ViewCell
                    {
                        View = new StackLayout
                        {
                            Children =
                            {
                                textlabel
                            }
                        }
                    };

                    textlabel.SetBinding(Label.TextProperty, "Answer");

                    /*
                    TextCell cell = new TextCell();
                    cell.SetBinding(TextCell.TextProperty, "Answer");
                    */
                    return cell;
                })
                //RowHeight = 150,
            };

            VLayout = new StackLayout
            {
                Children =
                {
                    RoundLabel,
                    AnswerImage,
                    listview
                },
                Padding = new Thickness(10, Device.OnPlatform(20, 0, 0), 10, 5)
            };

            listview.ItemSelected += async (sender, args) =>
            {
                ViewController.Invoke(() => listview.IsEnabled = false);
                // GameManager.ViewController.Invoke(() => GameManager.CurrentGame.CurrentVoteChoice = ((PlayerInput)args.SelectedItem).PlayerID);

                var item = args.SelectedItem as PlayerAnswer;
                await GameManager.Vote(item.PlayerId);
                ViewController.Invoke(() => listview.IsEnabled = true);
                ViewController.Invoke(() => ((ListView) sender).SelectedItem = null);
            };

            Display(ViewController);
        }
        public RegistrationPage(bool isUpdate, Page parent, UserAccount userAccount = null)
        {
            InitializeComponent();
            if (!isUpdate)
            {
                Title = "Registration";
            }
            else
            {
                Title = "Update Information";
            }
            _tableView.Intent = TableIntent.Menu;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                var toolbarItem = new ToolbarItem
                {
                    Text = "Done",
                    Command = _onDoneButtonClicked,
                };
                this.ToolbarItems.Add(toolbarItem);
            }
        }
        public JobDetailsPage()
        {
            TableSection mainSection = new TableSection();     
            
            mainSection.Add(new DataElementCell("Title", "Description"));
            mainSection.Add(new DataElementCell("Customer.FullName", "Customer"));
            mainSection.Add(new DataElementCell("Customer.Address", "Address") { Height = 60 });
            mainSection.Add(new DataElementCell("Customer.PrimaryContactNumber", "Telephone"));

            var statusCell = new DataElementCell("Status");
            statusCell.ValueLabel.SetBinding<Job>(Label.TextColorProperty, job => job.Status, converter: new JobStatusToColorConverter());
            mainSection.Add(statusCell);

            var equipmentSection = new TableSection("Equipment");            
            var equipmentRowTemplate = new DataTemplate(typeof(ImageCell));            
            equipmentRowTemplate.SetBinding(ImageCell.TextProperty, "Name");
            equipmentRowTemplate.SetBinding(ImageCell.DetailProperty, "Description");

			// I don't have images working on Android yet
			if (Device.OS == TargetPlatform.iOS) 			
				equipmentRowTemplate.SetBinding (ImageCell.ImageSourceProperty, "ThumbImage");

            var equipmentListView = new ListView {
                RowHeight = 50,
                ItemTemplate = equipmentRowTemplate
            };
            equipmentListView.SetBinding<Job>(ListView.ItemsSourceProperty, job => job.Equipments);            

            var equipmentCell = new ViewCell { View = equipmentListView };            
            equipmentSection.Add(equipmentCell);

            var actionsSection = new TableSection("Actions");
            
            TextCell completeJob = new TextCell { 
                Text = "Mark Job as Complete",
				TextColor = AppStyle.DefaultActionColor
            };            
            completeJob.Tapped += async delegate {
                await this.CompleteJobAsync();
            };
            actionsSection.Add(completeJob);
            
            var table = new TableView
            {
                Intent = TableIntent.Form,
                VerticalOptions = LayoutOptions.FillAndExpand,
                HasUnevenRows = true,
                Root = new TableRoot("Root")
                {
                    mainSection, actionsSection, equipmentSection
                }
            };
            table.SetBinding<Job>(TableView.BackgroundColorProperty, job => job.Status, converter: new JobStatusToColorConverter(useLightTheme: true));
            
            this.Title = "Job Details";
            this.Content = new StackLayout
            {
                Orientation = StackOrientation.Vertical,
                Children = { new JobHeaderView(), table }
            };

            this.BindingContextChanged += delegate
            {
                if (SelectedJob != null && SelectedJob.Equipments != null)
                    equipmentCell.Height = SelectedJob.Equipments.Count * equipmentListView.RowHeight;
            };
        }
示例#13
0
 public static FluentViewCell ViewCell(ViewCell instance = null)
 {
     return new FluentViewCell (instance);
 }
 Cell GetHookedCell()
 {
     var content = new ViewCell();
     content.BindingContextChanged += OnBindingContextChanged;
     return content;
 }
示例#15
0
        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));
            };
        }
示例#16
0
        // Constructor
        public LoginPage(NavPage returnTo)
        {
            // Sets the page to return to when login completes.
            instanceToReturn = returnTo;

            // Initialize all views to be used.
            titleCell = new ViewCell
            {
                Height = 100.0,
                View = new StackLayout
                {
                    VerticalOptions = LayoutOptions.CenterAndExpand,
                    Orientation = StackOrientation.Horizontal,
                    HorizontalOptions = LayoutOptions.CenterAndExpand,
                    Padding = new Thickness(0.0, 10.0),
                    Children = {
                        new Label {
                            Text = language.notifiqueMeText,
                            FontSize = 25,
                            HorizontalOptions = LayoutOptions.Start
                        },
                        new Label {
                            Text = "Alpha",
                            VerticalOptions = LayoutOptions.Start
                        }
                    }
                }
            };

            username = new Entry();
            username.Placeholder = "@poli.ufrj.br";
            username.HorizontalOptions = LayoutOptions.FillAndExpand;

            usernameCell = new ViewCell
            {
                View = new StackLayout
                {
                    VerticalOptions = LayoutOptions.Center,
                    Orientation = StackOrientation.Horizontal,
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                    Spacing = 10,
                    Padding = new Thickness(10.0, 0.0),
                    Children = {
                        new Label {
                            Text = language.usernameText,
                            FontSize = 18,
                            VerticalOptions = LayoutOptions.Center,
                            HorizontalOptions = LayoutOptions.Start
                        },
                        username
                    }
                }
            };

            password = new Entry();
            password.IsPassword = true;
            password.HorizontalOptions = LayoutOptions.FillAndExpand;

            passwordCell = new ViewCell
            {
                View = new StackLayout
                {
                    VerticalOptions = LayoutOptions.Center,
                    Orientation = StackOrientation.Horizontal,
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                    Spacing = 10.0,
                    Padding = new Thickness(10.0, 0.0),
                    Children = {
                        new Label {
                            Text = language.passwordText,
                            FontSize = 18,
                            HorizontalOptions = LayoutOptions.Start,
                            VerticalOptions = LayoutOptions.Center
                        },
                        password
                    }
                }
            };


            login = new Button()
            {
                Text = language.loginText,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Command = new Command(async o =>
                {
                    await LoginButtonPressed();
                    if (isLoggedIn == true)
                    {
                        await Navigation.PopModalAsync();
                        instanceToReturn.credentialsValid = true;
                        instanceToReturn.user = username.Text;
                        instanceToReturn.Resume();
                    }
                })
            };

            signup = new Button()
            {
                Text = language.signupText,
                HorizontalOptions = LayoutOptions.End,
                Command = new Command(async o =>
                {
                    SignupButtonPressed();
                    if (isLoggedIn == true) await Navigation.PopModalAsync();
                })
            };
        }
		/// <summary>
		/// Initializes a new instance of the <see cref="RepeaterViewPage"/> class.
		/// </summary>
		public RepeaterViewPage()
		{
			var viewModel = new RepeaterViewViewModel();
			BindingContext = viewModel;

			var repeater = new RepeaterView<Thing>
			{
				Spacing = 10,
				ItemsSource = viewModel.Things,
				ItemTemplate = new DataTemplate(() =>
				{
					var nameLabel = new Label { Font = Font.SystemFontOfSize(NamedSize.Medium) };
					nameLabel.SetBinding(Label.TextProperty, RepeaterViewViewModel.ThingsNamePropertyName);

					var descriptionLabel = new Label { Font = Font.SystemFontOfSize(NamedSize.Small) };
					descriptionLabel.SetBinding(Label.TextProperty, RepeaterViewViewModel.ThingsDescriptionPropertyName);

					ViewCell cell = new ViewCell
					{
						View = new StackLayout
						{
							Spacing = 0,
							Children =
							{
								nameLabel,
								descriptionLabel
							}
						}
					};

					return cell;
				})
			};

			var removeButton = new Button
			{
				Text = "Remove 1st Item",      
				HorizontalOptions = LayoutOptions.Start
			};

			removeButton.SetBinding(Button.CommandProperty, RepeaterViewViewModel.RemoveFirstItemCommandName);

			var addButton = new Button
			{
				Text = "Add New Item",
				HorizontalOptions = LayoutOptions.Start
			};

			addButton.SetBinding(Button.CommandProperty, RepeaterViewViewModel.AddItemCommandName);

			Content = new StackLayout
			{
				Padding = 20,
				Spacing = 5,
				Children = 
				{
					new Label 
					{ 
						Text = "RepeaterView Demo", 
						Font = Font.SystemFontOfSize(NamedSize.Large)
					},
					repeater,
					removeButton,
					addButton
				}
			};

			viewModel.LoadData();
		}
        public JobDetailsPage(JobService service)
        {
            this.jobService = service;

            this.Title = "Appointment Details";

            TableSection mainSection = new TableSection("Customer Details");     
            
            mainSection.Add(new DataElementCell("CustomerName", "Customer"));
            mainSection.Add(new DataElementCell("Title", "Customer Notes"));
            mainSection.Add(new DataElementCell("CustomerAddress", "Address") { Height = 60 });
            mainSection.Add(new DataElementCell("CustomerPhoneNumber", "Telephone"));

            var statusCell = new DataElementCell("Status");
            statusCell.ValueLabel.SetBinding<Job>(Label.TextColorProperty, job => job.Status, converter: new JobStatusToColorConverter());
            mainSection.Add(statusCell);

            var workSection = new TableSection("Work Performed");            
            var workRowTemplate = new DataTemplate(typeof(SwitchCell));            
            workRowTemplate.SetBinding(SwitchCell.TextProperty, "Name");
            workRowTemplate.SetBinding(SwitchCell.OnProperty, "Completed");
            //workRowTemplate.SetValue(TextCell.TextColorProperty, Color.White);

            // I don't have images working on Android yet
            //if (Device.OS == TargetPlatform.iOS) 			
            //	equipmentRowTemplate.SetBinding (ImageCell.ImageSourceProperty, "ThumbImage");

            var workListView = new ListView {
                RowHeight = 50,
                ItemTemplate = workRowTemplate
            };
            workListView.SetBinding<Job>(ListView.ItemsSourceProperty, job => job.Items);

            var workCell = new ViewCell { View = workListView };
       
            workSection.Add(workCell);

            var actionsSection = new TableSection("Actions");
            
            TextCell completeJob = new TextCell { 
                Text = "Mark Completed",
                TextColor = AppStyle.DefaultActionColor
            };   
         
            completeJob.Tapped += async delegate {
                await this.CompleteJobAsync();
            };

            actionsSection.Add(completeJob);
            
            var table = new TableView
            {
                Intent = TableIntent.Form,
                VerticalOptions = LayoutOptions.FillAndExpand,
                HasUnevenRows = true,
                Root = new TableRoot("Root")
                {
                    mainSection, workSection, actionsSection, 
                }
            };
            
            this.Content = new ScrollView {
                Orientation = ScrollOrientation.Vertical,
                Content = new StackLayout
                {
                    Orientation = StackOrientation.Vertical,
                    Children = { new JobHeaderView(leftPadding: 10, colorBackground: true), table }
                }
            };

            this.BindingContextChanged += delegate
            {
                if (SelectedJob != null && SelectedJob.Items != null)
                    workCell.Height = SelectedJob.Items.Count * workListView.RowHeight;
            };
        }
        public void addViewCell()
        {
            filterImages.Clear ();
            // cmment
            for (int m = 0; m < filterList.Count; m++) {
                var f = filterList [m];

                var image = new Image () {
                    Source = FileImageSource.FromFile ("check_mark.jpg"),
                    HorizontalOptions = LayoutOptions.EndAndExpand
                };
                filterImages.Add (image);

                //default filter
                for (int k = 0; k < filterImages.Count; k++){
                    filterImages[k].Opacity = 0;
                }
                filterImages [0].Opacity = 1;

                ViewCell vc = new ViewCell {
                    View = new StackLayout {
                        Orientation = StackOrientation.Horizontal,
                        HorizontalOptions = LayoutOptions.Start,
                        Children = {
                            new Label () {
                                Text = "   " + filterList[m].filterName + "           ",
                                YAlign = TextAlignment.Center,
                                GestureRecognizers = {
                                    new TapGestureRecognizer() {
                                        Command = new Command(() => {
                                            block = f.block;
                                            level = f.level;
                                            name = f.name;
                                            for (int k = 0; k < filterImages.Count; k++){
                                                filterImages[k].Opacity = 0;
                                            }
                                            image.Opacity = 1;
                                            GetFacilityTable();
                                            this.SetValue(MasterDetailPage.IsPresentedProperty,(object) false);
                                        }),
                                    }
                                }
                            },
                            image
                        }
                    }
                };
                tableView.Root [0].Add (vc);
            }
        }
        public AndroidViewCellPageCS()
        {
            Button button = new Button
            {
                Text = "Toggle Legacy Mode"
            };

            button.SetBinding(Button.CommandProperty, "ToggleLegacyMode");

            DataTemplate oneItemTemplate = new DataTemplate(() =>
            {
                Label label = new Label();
                label.SetBinding(Label.TextProperty, "Text");

                ViewCell viewCell = new ViewCell
                {
                    View = label
                };
                button.Clicked += (s, e) =>
                {
                    viewCell.On <Android>().SetIsContextActionsLegacyModeEnabled(!viewCell.On <Android>().GetIsContextActionsLegacyModeEnabled());
                };

                MenuItem menuItem = new MenuItem();
                menuItem.SetBinding(MenuItem.TextProperty, "Item1Text");

                viewCell.ContextActions.Add(menuItem);
                return(viewCell);
            });

            DataTemplate twoItemsTemplate = new DataTemplate(() =>
            {
                Label label = new Label();
                label.SetBinding(Label.TextProperty, "Text");

                ViewCell viewCell = new ViewCell
                {
                    View = label
                };

                button.Clicked += (s, e) =>
                {
                    viewCell.On <Android>().SetIsContextActionsLegacyModeEnabled(!viewCell.On <Android>().GetIsContextActionsLegacyModeEnabled());
                };

                MenuItem menuItem1 = new MenuItem();
                menuItem1.SetBinding(MenuItem.TextProperty, "Item1Text");
                MenuItem menuItem2 = new MenuItem();
                menuItem2.SetBinding(MenuItem.TextProperty, "Item2Text");

                viewCell.ContextActions.Add(menuItem1);
                viewCell.ContextActions.Add(menuItem2);
                return(viewCell);
            });

            ItemDataTemplateSelector itemDataTemplateSelector = new ItemDataTemplateSelector
            {
                OneItemTemplate  = oneItemTemplate,
                TwoItemsTemplate = twoItemsTemplate
            };

            ListView listView = new ListView
            {
                ItemTemplate = itemDataTemplateSelector
            };

            listView.SetBinding(ItemsView <Cell> .ItemsSourceProperty, "Items");

            BindingContext = new AndroidViewCellPageViewModel();
            Title          = "ViewCell Context Actions";
            Content        = new StackLayout
            {
                Children =
                {
                    new StackLayout
                    {
                        Margin   = new Thickness(20),
                        Children =
                        {
                            button,
                            listView
                        }
                    }
                }
            };
        }
示例#21
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;
        }
示例#22
0
 private void AddGestures(ViewCell cell, UITableViewCell tableViewCell, UITableView tableView)
 {
     tableViewCell.AddGestureRecognizer(LongPressGestureRecognizer.CreateGesture(tableView, cell));
 }
示例#23
0
        public ConfigView(ConfigViewModel configViewModel)
        {
            BindingContext = configViewModel;
            Title = "Configurações";

            ToolbarItems.Add (new ToolbarItem {
                Text = "Sair",
                Order = ToolbarItemOrder.Primary,
                Command = new Command (ActionSair)
            });

            datePickerInicio = new DatePicker {
                Format = "dd, MMM",
                VerticalOptions = LayoutOptions.CenterAndExpand,

            };
            datePickerFim = new DatePicker {
                Format = "dd, MMM",
                VerticalOptions = LayoutOptions.CenterAndExpand,

            };

            // Accomodate iPhone status bar.
            this.Padding = new Thickness (10, Device.OnPlatform (0, 0, 0), 1, 1);

            StackLayout stack = new StackLayout {
                Orientation = StackOrientation.Horizontal,
                Padding = new Thickness (10, 0, 10, 0),
                VerticalOptions = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Children = {
                    new StackLayout {
                        Orientation = StackOrientation.Horizontal,
                        VerticalOptions = LayoutOptions.FillAndExpand,
                        HorizontalOptions = LayoutOptions.StartAndExpand,
                        Children = {
                            new Label {
                                VerticalOptions = LayoutOptions.CenterAndExpand,
                                HorizontalOptions = LayoutOptions.StartAndExpand,
                                Text = "Inicial",
                                Style = Styles.DefaultCellText
                            },
                            datePickerInicio
                        }
                    },
                    new StackLayout {
                        Orientation = StackOrientation.Horizontal,
                        VerticalOptions = LayoutOptions.FillAndExpand,
                        HorizontalOptions = LayoutOptions.CenterAndExpand,
                        Children = {
                            new Label {
                                VerticalOptions = LayoutOptions.CenterAndExpand,
                                HorizontalOptions = LayoutOptions.StartAndExpand,
                                Text = "Final",
                                Style = Styles.DefaultCellText
                            },
                            datePickerFim
                        }
                    }
                }
            };

            SwitchCell EnableHolidaySwitch = new SwitchCell {
                Text = "Habilitar horário de verão",
                On = Settings.HolidayState
            };

            ViewCell viewCell = new ViewCell { View = stack };

            //			EnableHolidaySwitch.SetBinding (IsVisibleProperty, "IsVisible");
            //			viewCell.SetBinding (IsVisibleProperty, "IsVisible");
            TableSection firstSection = new TableSection ("Horario de verão") {
                viewCell,
                EnableHolidaySwitch
            };

            ConfigTable = new TableView {
                Intent = TableIntent.Settings,
                BackgroundColor = Color.Transparent,
                Root = new TableRoot {
                    firstSection,
                    new TableSection () {
                        new SwitchCell { Text = "Segurança" },
                    },
                    new TableSection ("Rede") {
                        new SwitchCell { Text = "Sincronizar apenas via Wi-Fi" }
                    },
                }
            };

            try {
                datePickerInicio.SetBinding (DatePicker.DateProperty, "MysafetyUser.IVerao", BindingMode.TwoWay, new StringDateConverter ());
                datePickerInicio.DateSelected += datePickerInicio_DateSelected;
                datePickerFim.SetBinding (DatePicker.DateProperty, "MysafetyUser.FVerao", BindingMode.TwoWay, new StringDateConverter ());
                datePickerFim.DateSelected += datePickerFim_DateSelected;
            } catch (Exception ex) {
                Debug.WriteLine ("Exception " + ex.Message);
            }

            ConfigTable.GetSwitchCell (1, 0).SetBinding (SwitchCell.OnProperty, "MysafetyUser.Stext", BindingMode.TwoWay, new NullBoolenConverter ());
            ConfigTable.GetSwitchCell (1, 0).OnChanged += (object sender, ToggledEventArgs e) => {
                if (ConfigTable.GetSwitchCell (1, 0).On)
                    Navigation.PushModalAsync (new LockScreen (new LockScreenViewModel (Navigation)), true);
                else
                    Navigation.PushModalAsync (new LockScreen (new LockScreenViewModel (Navigation, LockScreenViewModel.Actions.DisablePassword)), true);
                ((ConfigViewModel)BindingContext).Save ();
            };

            ConfigTable.GetSwitchCell (2, 0).SetBinding (SwitchCell.OnProperty, "MysafetyUser.SyncWiFi", BindingMode.TwoWay, new NullBoolenConverter ());
            ConfigTable.GetSwitchCell (2, 0).OnChanged += (object sender, ToggledEventArgs e) => {
                ((ConfigViewModel)BindingContext).Save ();
            };

            ConfigTable.GetSwitchCell (0, 1).OnChanged += (object sender, ToggledEventArgs e) => {
                if (ConfigTable.GetSwitchCell (0, 1).On) {
                    datePickerInicio.IsEnabled = true;
                    datePickerFim.IsEnabled = true;

                } else {
                    datePickerInicio.IsEnabled = false;
                    datePickerFim.IsEnabled = false;
                }
                Settings.HolidayState = ConfigTable.GetSwitchCell (0, 1).On;
            };

            Content = ConfigTable;

            //			if (App.Gates.Count > 0)
            //				ConfigTable.Root.Insert (0, firstSection);
            //			else
            //				ConfigTable.Root.Remove (firstSection);
        }