Ejemplo n.º 1
1
        public IssueItemCell()
        {
            var key = new Label {
                HorizontalOptions = LayoutOptions.StartAndExpand,
                YAlign = TextAlignment.Center
            };

            key.SetBinding (Label.TextProperty, "Key");

            var summary = new Label {
                HorizontalOptions = LayoutOptions.StartAndExpand,
                YAlign = TextAlignment.Center
            };

            summary.SetBinding (Label.TextProperty, "Summary");

            var editAction = new MenuItem { Text = "Edit" };
            editAction.SetBinding (MenuItem.CommandParameterProperty, new Binding ("."));
            editAction.Clicked += (sender, e) => {
                var mi = (MenuItem) sender;
                var issue = (Issue) mi.CommandParameter;

                var issuePage = new IssuePage(issue.Key);
                issuePage.BindingContext = issue;

                ParentView.Navigation.PushAsync(issuePage);
            };

            var deleteAction = new MenuItem { Text = "Delete", IsDestructive = true };
            deleteAction.SetBinding (MenuItem.CommandParameterProperty, new Binding ("."));
            deleteAction.Clicked += async (sender, e) => {
                var mi = (MenuItem) sender;
                var issue = (Issue) mi.CommandParameter;

                var answer = await App.CurrentPage.DisplayAlert("Delete?", "Would you like to remove this issue?", "Yes", "No");

                if (answer)
                {
                    App.Database.DeleteIssue(issue);

                    if (App.CurrentPage is IssueListPage)
                    {
                        ((IssueListPage)App.CurrentPage).UpdateList();
                    }
                }
            };

            ContextActions.Add (editAction);
            ContextActions.Add (deleteAction);

            View = new StackLayout {
                Padding = new Thickness(20, 5, 0, 0),
                Orientation = StackOrientation.Vertical,
                HorizontalOptions = LayoutOptions.StartAndExpand,
                Children = { key, summary }
            };
        }
Ejemplo n.º 2
0
        private void setUpContextAction()
        {
            if (!Settings.SuccessLogin)               //se non sono loggato, non posso aggiungere o rimuovere corsi dai preferiti
            {
                return;
            }
//			removeAction = new Xamarin.Forms.MenuItem { Text = "Rimuovi", Icon = "ic_bin.png" };
//			removeAction.SetBinding (Xamarin.Forms.MenuItem.CommandParameterProperty, new Binding ("."));
//			removeAction.Clicked += RemoveAction_Clicked;
            //ADD
            addAction = new Xamarin.Forms.MenuItem {
                Text = "Aggiungi ai preferiti"
            };                                                                                 //, Icon = "ic_nostar.png"};
            addAction.SetBinding(Xamarin.Forms.MenuItem.CommandParameterProperty, new Binding("."));
            addAction.Clicked += AddAction_Clicked;

            ContextActions.Add(addAction);
//			ContextActions.Add (removeAction);

//			if (_db.CheckAppartieneMieiCorsi (orario)) {
//				ContextActions.Add (removeAction);
//			} else {
//				ContextActions.Add (addAction);
//			}
        }
Ejemplo n.º 3
0
        private void setupRowActions()
        {
            // Define the context actions
            var deleteAction = new Xamarin.Forms.MenuItem
            {
                Text          = "Delete",
                IsDestructive = true
            }; // red background

            deleteAction.SetBinding(Xamarin.Forms.MenuItem.CommandParameterProperty, new Binding("id"));
            deleteAction.Clicked += async(sender, e) =>
            {
                var mi = ((Xamarin.Forms.MenuItem)sender);

                var recId = (int)mi.CommandParameter;

                TaskCompletionSource <bool> tcs = new TaskCompletionSource <bool>();

                await Task.Factory.StartNew(async() =>
                {
                    // Call the webservice for vehicle makes list
                    var deleteResult = await WorkService.delete(recId);
                    if (!deleteResult.isOK)
                    {
                        Device.BeginInvokeOnMainThread(async() =>
                        {
                            await App.AppMainWindow.DisplayAlert("Error", "Failed to delete the work record: " + deleteResult.error, "OK");
                        });

                        // Done with waiting
                        tcs.SetResult(false);
                        return;
                    }

                    // Done with waiting
                    tcs.SetResult(true);
                });


                // Wait for the delete operation to finish
                bool result = await tcs.Task;
                if (result)
                {
                    var removedData = this.BindingContext as Record;
                    if (removedData == null)
                    {
                        return;
                    }

                    // Acquire the list context
                    WorkListView lvParent = (removedData.context as WorkListView);

                    // Motify the list of changes
                    lvParent.itemDeleted(removedData);
                }
            };

            // add to the ViewCell's ContextActions property
            ContextActions.Add(deleteAction);
        }
Ejemplo n.º 4
0
        private void setUpContextAction()
        {
            removeAction = new Xamarin.Forms.MenuItem {
                Text = "Rimuovi dai preferiti"
            };                                                                                        //, Icon = "ic_bin.png" };
            removeAction.SetBinding(Xamarin.Forms.MenuItem.CommandParameterProperty, new Binding("."));
            removeAction.Clicked += RemoveAction_Clicked;


            ContextActions.Add(removeAction);
        }
Ejemplo n.º 5
0
        private void setUpContextAction()
        {
            if (!Settings.SuccessLogin)               //se non sono loggato, non posso aggiungere o rimuovere corsi dai preferiti
            {
                return;
            }
            //ADD
            addAction = new Xamarin.Forms.MenuItem {
                Text = "Aggiungi ai preferiti"
            };
            addAction.SetBinding(Xamarin.Forms.MenuItem.CommandParameterProperty, new Binding("."));
            addAction.Clicked += AddAction_Clicked;

            ContextActions.Add(addAction);
        }
        public FootballPlayerListviewCellPage()
        {
            InitializeComponent ();
            //			FootballPlayer footballplayercollection = (FootballPlayer)this.BindingContext;
            this.FootBallPlayerName.SetBinding (Label.TextProperty, "FullName");
            this.DateofBirthWithYears.SetBinding (Label.TextProperty, "DateOfBithWithAge");
            this.CountryImage.SetBinding (Image.SourceProperty, "CountryImage");
            this.CellView.BackgroundColor = Color.FromHex ("#eee");
            var deleteAction = new MenuItem {
                Text = "Delete", IsDestructive = true
            };

            deleteAction.SetBinding (MenuItem.CommandParameterProperty, new Binding ("."));
            deleteAction.Clicked += (sender, e) => {
                FootballPlayer player;
                var mi = ((MenuItem)sender);
                player= (FootballPlayer)mi.CommandParameter;
                SQLiteHelper databaseHelper = new SQLiteHelper();
                databaseHelper.DeletePlayerWithName(player);
                MessagingCenter.Send(this,"ItemDeleted");
            };
            this.ContextActions.Add (deleteAction);

            var favouriteAction = new MenuItem {
                Text = "Favourite", IsDestructive = false
            };
            favouriteAction.SetBinding (MenuItem.CommandParameterProperty, new Binding ("."));
            favouriteAction.Clicked += (sender, e) => {
                FootballPlayer player;
                var mi = ((MenuItem)sender);
                player = (FootballPlayer)mi.CommandParameter;
                SQLiteHelper databaseHelper = new SQLiteHelper();
                databaseHelper.DeletePlayerWithName(player);
                player.IsFavourite = !player.IsFavourite;
                if (player.IsFavourite) {
                    this.CellView.BackgroundColor = Color.Green;
                }
                else
                {
                    this.CellView.BackgroundColor = Color.FromHex("#eee");
                }

                databaseHelper.Save(player);
                MessagingCenter.Send(this,"ItemDeleted");
            };

            this.ContextActions.Add (favouriteAction);
        }
		public ContextActionsCell ()
		{
			var label1 = new Label { Text = "Label 1", FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)), FontAttributes = FontAttributes.Bold };
			label1.SetBinding(Label.TextProperty, new Binding("."));
			var hint = Device.OnPlatform ("Tip: swipe left for context action", "Tip: long press for context action", "Tip: long press for context action");
			var label2 = new Label { Text = hint, FontSize=Device.GetNamedSize(NamedSize.Micro, typeof(Label)) };

			//
			// define context actions
			//
			var moreAction = new MenuItem { Text = "More" };
			moreAction.SetBinding (MenuItem.CommandParameterProperty, new Binding ("."));
			moreAction.Clicked += (sender, e) => {
				var mi = ((MenuItem)sender);
				Debug.WriteLine("More Context Action clicked: " + mi.CommandParameter);
			};

			var deleteAction = new MenuItem { Text = "Delete", IsDestructive = true }; // red background
			deleteAction.SetBinding (MenuItem.CommandParameterProperty, new Binding ("."));
			deleteAction.Clicked += (sender, e) => {
				var mi = ((MenuItem)sender);
				Debug.WriteLine("Delete Context Action clicked: " + mi.CommandParameter);
			};

			//
			// add context actions to the cell
			//
			ContextActions.Add (moreAction);
			ContextActions.Add (deleteAction);



			View = new StackLayout {
				Orientation = StackOrientation.Horizontal,
				HorizontalOptions = LayoutOptions.StartAndExpand,
				Padding = new Thickness (15, 5, 5, 15),
				Children = {
					new StackLayout {
						Orientation = StackOrientation.Vertical,
						Children = { label1, label2 }
					}
				}
			};
		}
		private Cell GetCustomCell()
		{
			var cell = new TextCell ();
			var editItem = new MenuItem () {
				Text = "Edit"
			};
			editItem.Clicked += EditItem_Clicked;
			editItem.SetBinding (MenuItem.CommandParameterProperty, ".");
			cell.ContextActions.Add(editItem);

			var deleteItem = new MenuItem () {
				Text = "Delete",
				IsDestructive = true
			};
			deleteItem.SetBinding (MenuItem.CommandParameterProperty, ".");
			deleteItem.Clicked += DeleteItem_Clicked;
			cell.ContextActions.Add(deleteItem);
			return cell;
		}
        public MainPageArticoloViewCell()
        {
            var label = new Label ();
            label.FontSize = 22;
            label.VerticalOptions = LayoutOptions.Center;
            label.HorizontalOptions = LayoutOptions.FillAndExpand;
            label.SetBinding (Label.TextProperty, Articolo.FIELD_NAME_art_DESC);

            immagineArticolo = new Image ();
            immagineArticolo.HorizontalOptions = LayoutOptions.End;
            // immagineArticolo.SetBinding (Image.SourceProperty, Articolo.FIELD_NAME_ImageFullFileName);
            immagineArticolo.SetBinding (Image.SourceProperty, Articolo.FIELD_NAME_UrlImg);
            immagineArticolo.HeightRequest = immagineArticolo.WidthRequest = 40;

            StackLayout contenitore = new StackLayout (){
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Orientation = StackOrientation.Horizontal,
                Padding = new Thickness(10),
                Children = {label, immagineArticolo}
            };

            this.View = contenitore;

            var moreAction = new MenuItem { Text = "Sposta Img", Icon = "arrow.png" };
            moreAction.SetBinding (MenuItem.CommandParameterProperty, new Binding ("."));
            moreAction.Clicked += async (sender, e) => {
                var mi = ((MenuItem)sender);
                Debug.WriteLine("More Context Action clicked: " + mi.CommandParameter);

                await immagineArticolo.TranslateTo (-100, 0, 2000, Easing.CubicIn);
                // immagineArticolo.TranslationX = -100;
            };
            var deleteAction = new MenuItem { Text = "Delete", IsDestructive = true }; // red background
            deleteAction.IsDestructive = true;
            deleteAction.SetBinding (MenuItem.CommandParameterProperty, new Binding ("."));
            deleteAction.Clicked += async (sender, e) => {
                var mi = ((MenuItem)sender);
                Debug.WriteLine("Delete Context Action clicked: " + mi.CommandParameter);
            };
            // add to the ViewCell's ContextActions property
            ContextActions.Add (moreAction);
            ContextActions.Add (deleteAction);
        }
		public JBEventCell ()
		{
			var summaryLabel = new Label
			{
				HorizontalOptions= LayoutOptions.StartAndExpand,
				FontSize = 13,
				FontAttributes = FontAttributes.Bold
			};
			summaryLabel.SetBinding(Label.TextProperty, "summary");

			var moreAction = new MenuItem { Text = "More" };
			moreAction.SetBinding (MenuItem.CommandParameterProperty, new Binding ("."));
			moreAction.Clicked += async (sender, e) => {
				var mi = ((MenuItem)sender);
				Debug.WriteLine("More Context Action clicked: " + mi.CommandParameter);

			};
			var deleteAction = new MenuItem { Text = "Add Me", IsDestructive = true }; // red background
			deleteAction.SetBinding (MenuItem.CommandParameterProperty, new Binding ("."));
			deleteAction.Clicked += async (sender, e) => {
				var mi = ((MenuItem)sender);
				Debug.WriteLine("Add To Calendar Action clicked: " + mi.CommandParameter);
			};
			// add to the ViewCell's ContextActions property
			ContextActions.Add (moreAction);
			ContextActions.Add (deleteAction);



			var ctrlayout = CreateMiddleSide ();

			var rghtlayout = CreateRightSide ();

			var leftImageLayout = new StackLayout()
			{
				//Spacing = 2,
				Padding = new Thickness (5, 5, 0, 5),
				VerticalOptions = LayoutOptions.Center,
				Orientation = StackOrientation.Vertical,
				Children = {summaryLabel, rghtlayout}
			};
			View = leftImageLayout;
		}
		public textViewCell()
		{
			StackLayout layout = new StackLayout ();
			layout.Padding = new Thickness (15, 0);
			Label label = new Label ();

			label.SetBinding (Label.TextProperty, ".");
			layout.Children.Add (label);

			var moreAction = new MenuItem { Text = "More" };
			moreAction.SetBinding (MenuItem.CommandParameterProperty, new Binding ("."));
			moreAction.Clicked += OnMore;

			var deleteAction = new MenuItem { Text = "Delete", IsDestructive = true }; // red background
			deleteAction.SetBinding (MenuItem.CommandParameterProperty, new Binding ("."));
			deleteAction.Clicked += OnDelete;

			this.ContextActions.Add (moreAction);
			this.ContextActions.Add (deleteAction);
			View = layout;
		}
        public LinkedAccountListItemCell()
        {
            Label accountName = new Label {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                FontSize = 18,
                TextColor = Colours.LINKED_ACCOUNTS_MEDIUM,
                BackgroundColor = Color.White
            };
            accountName.SetBinding (Label.TextProperty, "AccountName");

            StackLayout viewLayout = new StackLayout {
                HorizontalOptions = LayoutOptions.StartAndExpand,
                Orientation = StackOrientation.Horizontal,
                Children = { accountName },
                Padding = 10,
                BackgroundColor = Color.White
            };

            MenuItem delete = new MenuItem { Text = "Unlink", IsDestructive = true };
            delete.SetBinding (MenuItem.CommandParameterProperty, new Binding ("."));
            delete.Clicked += async (sender, e) => {
                MenuItem mi = ((MenuItem)sender);
                LinkedAccountListItem item = (LinkedAccountListItem)mi.CommandParameter;
                StackLayout sl = (StackLayout)viewLayout.ParentView;
                ListView lv = (ListView)sl.ParentView;
                LinkedAccountsListPage listPage = (LinkedAccountsListPage)lv.ParentView;
                try {
                    await OnlineDataLoader.unlinkAccount(item.SiteID, item.SiteCustomerID, item.AccountID);
                    listPage.removeAccountFromList(item);
                } catch (Exception ex) {
                    listPage.DisplayAlert("Error", "Failed to unlink account.", "OK");
                }
            };

            ContextActions.Add (delete);

            View = viewLayout;
        }
Ejemplo n.º 13
0
		public ExpenseCell()
		{
			var grid = new Grid { Padding = new Thickness(10, 0) };
			grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(2, GridUnitType.Star) });
			grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1.5d, GridUnitType.Star) });
			grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1.5d, GridUnitType.Star) });
			grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(3, GridUnitType.Star) });

			var date = new Label { TextColor = AppColors.DarkGray, VerticalTextAlignment = TextAlignment.Center };
			var man = new Label { TextColor = AppColors.Blue, VerticalTextAlignment = TextAlignment.Center };
			var woman = new Label { TextColor = AppColors.Red, VerticalTextAlignment = TextAlignment.Center };
			var details = new Label { TextColor = AppColors.DarkGray, VerticalTextAlignment = TextAlignment.Center };

			date.SetBinding<ExpenseItemViewModel>(Label.TextProperty, vm => vm.Expense.AddedOn, BindingMode.Default, new DateStringValueConverter());
			man.SetBinding<ExpenseItemViewModel>(Label.TextProperty, vm => vm.Expense.ManExpense, BindingMode.Default, new FloatCurrenyValueConverter());
			woman.SetBinding<ExpenseItemViewModel>(Label.TextProperty, vm => vm.Expense.WomanExpense, BindingMode.Default, new FloatCurrenyValueConverter());
			details.SetBinding<ExpenseItemViewModel>(Label.TextProperty, vm => vm.Expense.Details);

			grid.Children.Add(date);
			Grid.SetColumn(date, 0);
			grid.Children.Add(man);
			Grid.SetColumn(man, 1);
			grid.Children.Add(woman);
			Grid.SetColumn(woman, 2);
			grid.Children.Add(details);
			Grid.SetColumn(details, 3);

			View = grid;

			var deleteAction = new MenuItem { Text = "Supprimer", IsDestructive = true }; // red background
			deleteAction.SetBinding<ExpenseItemViewModel>(MenuItem.CommandProperty, vm => vm.DeleteCommand);
//			deleteAction.Clicked += async (sender, e) =>
//			{
//				var mi = ((MenuItem)sender);
//			};
			ContextActions.Add(deleteAction);
		}
Ejemplo n.º 14
0
		public CustomViewCellTwoTextTwoButton ()
		{
			var titleLabel = new Label {
				VerticalOptions = LayoutOptions.Center,
				TextColor = Color.Black,
				FontSize = 20
			};

			var secondaryLabel = new Label {
				VerticalOptions = LayoutOptions.Center,
				FontSize = 14,
				TextColor = Color.Black,
				FontAttributes = FontAttributes.None
			};

			var buttonOne = new CustomImageButton () {
				Style = (Style)Application.Current.Resources ["assignButtonStyleSmall"],
				VerticalOptions = LayoutOptions.Center,
				HorizontalOptions = LayoutOptions.End
			};


			buttonOne.Clicked += (sender, args) => {

				TemplateViewModel template = SimpleTemplate;

				if (template.SelectedUser == null) {
					Insights.Track ("Clicked to go to page to assign a member to a template from 'TemplateListPage'", new Dictionary<string, string> () {
						{ "template name", template.TemplateName },
						{ "template id", template.LocalUserExerciseGroupID.ToString () }
					});
					this.ParentView.Navigation.PushAsync (new ModalAssignMemberWorkoutPage (template), true);
				} else {
					buttonOne.IsEnabled = false;
					buttonOne.Opacity = .5;
					template.ParentTemplateViewModel.IsBusy = true;
					template.AssignTemplateCommand.Execute (template);
				}

			};

			var buttonTwo = new CustomImageButton () {
				Style = (Style)Application.Current.Resources ["greenReviewButtonStyleSmall"],
				VerticalOptions = LayoutOptions.Center,
				HorizontalOptions = LayoutOptions.End

			};

			buttonTwo.Clicked += (sender, args) => {

				var template = SimpleTemplate;
				//Uses session tracking
				//LocalUserExerciseGroupID 
				Insights.Track ("Reviewed template button click", new Dictionary<string, string> () {
					{ "template name", template.TemplateName },
					{ "template id", template.LocalUserExerciseGroupID.ToString () }
				});
				this.ParentView.Navigation.PushAsync (new ReviewPage (new ReviewPageViewModel (), template));
			};

			#region listview item actions

			//------ Creating Contact Action 1 Start --------//

			var deleteAction = new MenuItem { Text = "Delete", IsDestructive = true }; // red background
			deleteAction.SetBinding (MenuItem.CommandParameterProperty, new Binding ("."));
			deleteAction.Clicked += (sender, e) => {
				var mi = ((MenuItem)sender);
				if (mi.CommandParameter is TemplateViewModel) {

					Action action = async () => {
						TemplateViewModel templateViewModel = mi.CommandParameter as TemplateViewModel;

						//retrieve workout template from the db
						var template = await WorkoutTemplateDAL.GetWorkoutTemplateByID (App.WorkoutCreatorContext.StaffMember.GymID, templateViewModel.Id);

						template.IsSoftDeleted = true;
						await WorkoutTemplateDAL.AddModifyTemplate (template);

						var group = templateViewModel.ParentTemplateViewModel.SimpleTemplateGroups.Where (row => row.Key == templateViewModel.TemplateName.Substring (0, 1)).FirstOrDefault ();
						group.Remove (templateViewModel);

						//Uses session tracking
						Insights.Track ("Deleted workout template on 'TemplatelistPage'", new Dictionary<string, string> () {
							{ "template name", templateViewModel.TemplateName },
							{ "group id", templateViewModel.Id.ToString () }
						});

					};
					DependencyService.Get<ICustomDialog> ().Display ("Are you sure you want to delete this template?", "No", "Yes", action);
				}
			};

			ContextActions.Add (deleteAction);

			#endregion

			titleLabel.SetBinding (Label.TextProperty, "TemplateName");
			secondaryLabel.SetBinding (Label.TextProperty, "TemplateDescription");
			buttonOne.SetBinding (Button.IsVisibleProperty, "IsAssignVisible");



			Grid grid = new Grid {
				VerticalOptions = LayoutOptions.FillAndExpand,
				RowDefinitions = {
					new RowDefinition { Height = GridLength.Auto },
					new RowDefinition { Height = GridLength.Auto },
				},
				ColumnDefinitions = {
					new ColumnDefinition { Width = new GridLength (6, GridUnitType.Star) },
					new ColumnDefinition { Width = new GridLength (Device.OnPlatform<double> (1, 2.2, 1), GridUnitType.Star) },
					new ColumnDefinition { Width = new GridLength (Device.OnPlatform<double> (1, 2.2, 1), GridUnitType.Star) }
				}
			};

			grid.Children.Add (titleLabel, 0, 0);
			grid.Children.Add (secondaryLabel, 0, 1);
			grid.Children.Add (buttonOne, 1, 2, 0, 2);
			grid.Children.Add (buttonTwo, 2, 3, 0, 2);
			grid.Padding = new Thickness (10, 10, 20, 10);

			this.View = grid;
           
		}
Ejemplo n.º 15
0
        public CPListCell()
        {

            var titleLabel = new Label()
            {
                FontFamily = "HelveticaNeue-Medium",
                FontSize = 18,
                TextColor = Color.Black
            };
            titleLabel.SetBinding(Label.TextProperty, "title");

            var discriptionLabel = new Label()
            {
                FontAttributes = FontAttributes.Bold,
                FontSize = 12,
                TextColor = Color.FromHex("#666")
            };
            discriptionLabel.SetBinding(Label.TextProperty, "summary");


            var starLabel = new Label()
            {
                FontSize = 12,
                TextColor = Color.Gray
            };
            starLabel.SetBinding(Label.TextProperty, "rating");

            var starImage = new Image()
            {
                Source = "star.png",
                HeightRequest = 12,
                WidthRequest = 12
            };

            var ratingStack = new StackLayout()
            {
                Spacing = 3,
                Orientation = StackOrientation.Horizontal,
                Children = { starImage, starLabel }
            };

            var statusLayout = new StackLayout
            {
                Orientation = StackOrientation.Horizontal,
                Children = { discriptionLabel }
            };

            var vetDetailsLayout = new StackLayout
            {
                Padding = new Thickness(10, 0, 0, 0),
                Spacing = 0,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Children = { titleLabel, statusLayout, ratingStack }
            };


            //------ Creating Contact Action 1 Start --------//
            var moreAction = new MenuItem { Text = "Favorite" };
            moreAction.SetBinding(MenuItem.CommandParameterProperty, new Binding("."));
            moreAction.Clicked += async (sender, e) => {
                await Task.Run(() => {
                    var mi = ((MenuItem)sender) ;

                    var favListItems = mi.CommandParameter as CPMobile.Models.Item;
                    FavoriteDataService.SaveListItems(favListItems);
                    //Debug.WriteLine("More Context Action clicked: " + mi.CommandParameter as CPMobile.Models.Item);
                });
            };
            ContextActions.Add(moreAction);
            //var tapImage = new Image()
            //{
            //    Source = "tap.png",
            //    HorizontalOptions = LayoutOptions.End,
            //    HeightRequest = 12,
            //};

            var cellLayout = new StackLayout
            {
                Spacing = 0,
                Padding = new Thickness(10, 5, 10, 5),
                Orientation = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Children = { vetDetailsLayout }
            };

            this.View = cellLayout;
        }
		public TasksPage (SQLiteAsyncConnection connection)
		{
			db = connection;

			Title = "Tasks";

			Content = new StackLayout {
				VerticalOptions = LayoutOptions.FillAndExpand,
				Children = {
					(listView = new ListView {
						ItemTemplate = new DataTemplate (() => {
							// edit button
							var editItem = new MenuItem {
								Text = "Edit",
								Command = new Command (async param => {
									var task = (TaskItem)param;
									await EditItem (task);
								})
							};
							editItem.SetBinding (MenuItem.CommandParameterProperty, new Binding ("."));

							// delete button
							var deleteItem = new MenuItem {
								Text = "Delete",
								IsDestructive = true,
								Command = new Command (async param => {
									var task = (TaskItem)param;
									await DeleteItem (task);
								})
							};
							deleteItem.SetBinding (MenuItem.CommandParameterProperty, new Binding ("."));

							// list item
							var cell = new TaskItemCell {
								ContextActions = {
									editItem,
									deleteItem
								}
							};
							return cell;
						}),
					})
				}
			};

			listView.ItemSelected += async (sender, e) => {
				if (e.SelectedItem != null) {
					var task = (TaskItem)e.SelectedItem;
					await CompleteItem (task);

					listView.SelectedItem = null;
				}
			};

			var addButton = new ToolbarItem {
				Text = "Add",
				Command = new Command (async () => {
					await EditItem (null);
				})
			};
			ToolbarItems.Add (addButton);
		}
Ejemplo n.º 17
0
            public ListItemCell()
            {

                Label titleLabel = new Label
                {
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                    FontSize = 25,
                    FontAttributes = Xamarin.Forms.FontAttributes.Bold,
                    TextColor = Color.White
                };
                titleLabel.SetBinding(Label.TextProperty, "Title");

                Label descLabel = new Label
                {
                    HorizontalOptions = LayoutOptions.FillAndExpand,
					FontSize = 12,
					TextColor = Color.White
                };
                descLabel.SetBinding(Label.TextProperty, "Description");


                StackLayout viewLayoutItem = new StackLayout()
                {
                    HorizontalOptions = LayoutOptions.StartAndExpand,
                    Orientation = StackOrientation.Vertical,
                    Children = { titleLabel, descLabel }
                };

                Label priceLabel = new Label
                {
                    HorizontalOptions = LayoutOptions.End,
                    FontSize = 25,
                    TextColor = Color.Aqua
                };
                priceLabel.SetBinding(Label.TextProperty, "Price");

                StackLayout viewLayout = new StackLayout()
                {
                    HorizontalOptions = LayoutOptions.StartAndExpand,
                    Orientation = StackOrientation.Horizontal,
                    Padding = new Thickness(25, 10, 55, 15),
                    Children = { viewLayoutItem, priceLabel }
                };

                View = viewLayout;

                var moreAction = new MenuItem { Text = "More" };
                moreAction.SetBinding(MenuItem.CommandParameterProperty, new Binding("."));
                moreAction.Clicked += (sender, e) =>
                {
                    var mi = ((MenuItem)sender);
                    var item = (ListItem)mi.CommandParameter;
                    Debug.WriteLine("More clicked on row: " + item.Title.ToString());
                    //((ContentPage)((ListView)viewLayout.ParentView).ParentView).DisplayAlert("More Clicked", "On row: " + item.Title.ToString(), "OK");             
                };
                var deleteAction = new MenuItem { Text = "Delete", IsDestructive = true }; 
                deleteAction.SetBinding(MenuItem.CommandParameterProperty, new Binding("."));
                deleteAction.Clicked += (sender, e) =>
                {
                    var mi = ((MenuItem)sender);
                    var item = (ListItem)mi.CommandParameter;
                    Debug.WriteLine("Delete clicked on row: " + item.Title.ToString());
                    //((ContentPage)((ListView)viewLayout.ParentView).ParentView).DisplayAlert("Delete Clicked", "On row: " + item.Title.ToString(), "OK");
                };
                ContextActions.Add(moreAction);
                ContextActions.Add(deleteAction);
            }
        public AlertListItemCell()
        {
            Label messageSubject = new Label {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                FontSize = 18,
                FontAttributes = FontAttributes.Bold
            };
            messageSubject.SetBinding (Label.TextProperty, "Title");
            messageSubject.SetBinding (Label.TextColorProperty, "TitleColor");

            Label messageContent = new Label {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                FontSize = 12
            };
            messageContent.SetBinding (Label.TextProperty, "Content");

            Label messageDate = new Label {
                HorizontalOptions = LayoutOptions.End,
                FontSize = 12,
                VerticalOptions = LayoutOptions.Center,
                MinimumWidthRequest = 80
            };
            messageDate.SetBinding (Label.TextProperty, "DateTimeFormat");
            messageDate.SetBinding (Label.TextColorProperty, "DateTimeColor");

            StackLayout viewLayout = new StackLayout {
                HorizontalOptions = LayoutOptions.StartAndExpand,
                Orientation = StackOrientation.Vertical,
                Children = { messageSubject, messageContent }
            };

            StackLayout stackLayout = new StackLayout () {
                //BackgroundColor = Color.FromHex("#34495E"),
                HorizontalOptions = LayoutOptions.StartAndExpand,
                Orientation = StackOrientation.Horizontal,
                Padding = new Thickness(10, 10, 10, 10),
                Children = { viewLayout, messageDate }
            };
            stackLayout.SetBinding (VisualElement.BackgroundColorProperty, "BackgroundColor");

            MenuItem markAsRead = new MenuItem { Text = "Mark as read"};
            markAsRead.SetBinding (MenuItem.CommandParameterProperty, new Binding ("."));
            markAsRead.Clicked += async (sender, e) => {
                MenuItem mi = ((MenuItem)sender);
                AlertListItem item = (AlertListItem)mi.CommandParameter;
                await OnlineDataLoader.markAlertMessageAsRead(new List<int>{item.AlertID});
                item.TitleColor = Color.Gray;
                item.DateTimeColor = Color.Gray;
                // Also need to grey out the alert in other pages
                StackLayout sl = (StackLayout)viewLayout.ParentView;
                ListView lv = (ListView)sl.ParentView;
                AlertListPage listPage = (AlertListPage)lv.ParentView;
                if (String.Equals(listPage.getPageType(), AlertListPage.ALERTS_UNREAD)) {
                    listPage.removeAlertFromList(item);
                }
            };

            MenuItem markAsUnread = new MenuItem { Text = "Mark as unread" };
            markAsUnread.SetBinding (MenuItem.CommandParameterProperty, new Binding ("."));
            markAsUnread.Clicked += async (sender, e) => {
                MenuItem mi = ((MenuItem)sender);
                AlertListItem item = (AlertListItem)mi.CommandParameter;
                await OnlineDataLoader.markAlertMessageAsUnread(new List<int>{item.AlertID});
                item.TitleColor = Colours.ALERTS_MEDIUM;
                item.DateTimeColor = Color.Black;
                StackLayout sl = (StackLayout)viewLayout.ParentView;
                ListView lv = (ListView)sl.ParentView;
                AlertListPage alp = (AlertListPage)lv.ParentView;
                TabbedPage tp = (TabbedPage) alp.ParentView;
                foreach (AlertListPage a in tp.Children) {
                    if (a.getPageType().Equals(AlertListPage.ALERTS_UNREAD)) {
                        a.addAlertToList(item);
                    }
                }

            };

            MenuItem delete = new MenuItem { Text = "Delete", IsDestructive = true };
            delete.SetBinding (MenuItem.CommandParameterProperty, new Binding ("."));
            delete.Clicked += async (sender, e) => {
                MenuItem mi = ((MenuItem)sender);
                AlertListItem item = (AlertListItem)mi.CommandParameter;
                await OnlineDataLoader.markAlertMessageAsDeleted(new List<int>{item.AlertID});
                StackLayout sl = (StackLayout)viewLayout.ParentView;
                ListView lv = (ListView)sl.ParentView;
                AlertListPage listPage = (AlertListPage)lv.ParentView;
                TabbedPage tp = (TabbedPage) listPage.ParentView;
                foreach (AlertListPage a in tp.Children) {
                    a.removeAlertFromList(item);
                }
            };

            ContextActions.Add (markAsRead);
            ContextActions.Add (markAsUnread);
            ContextActions.Add (delete);

            View = stackLayout;
        }
Ejemplo n.º 19
0
        public CartCell()
        {
            var cellLayout = new StackLayout();
            var detailsLayout = new StackLayout();
            var priceLayout = new StackLayout();

            var nameLabel = new Label();
            var nameContentView = new ContentView();
            var qtyLabel = new Label();
            var qtyContentView = new ContentView();
            var priceLabel = new Label();
            var priceContentView = new ContentView();
            var costLabel = new Label();
            var costContentView = new ContentView();

            nameLabel.SetBinding(Label.TextProperty, "Name");
            qtyLabel.SetBinding(Label.TextProperty, new Binding("Quantity", BindingMode.TwoWay, new IntToStringConverter()));
            priceLabel.SetBinding(Label.TextProperty, new Binding("Price", stringFormat: "Price: ${0:0.00}"));
            costLabel.SetBinding(Label.TextProperty, new Binding("Cost", stringFormat: "Cost: ${0:0.00}"));

            cellLayout.Orientation = StackOrientation.Horizontal;
            cellLayout.Spacing = 0;
            detailsLayout.Spacing = 0;
            priceLayout.Orientation = StackOrientation.Horizontal;
            priceLayout.Spacing = 0;
            qtyLabel.FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label));
            qtyLabel.TextColor = Color.Red;
            qtyLabel.VerticalOptions = LayoutOptions.CenterAndExpand;
            qtyLabel.FontAttributes = FontAttributes.Bold;
            priceLabel.FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label));
            priceLabel.TextColor = Color.Gray;
            costLabel.FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label));
            costLabel.TextColor = Color.Gray;
            nameContentView.Padding = new Thickness(5);
            qtyContentView.Padding = new Thickness(10);
            priceContentView.Padding = new Thickness(5);
            costContentView.Padding = new Thickness(5);

            nameContentView.Content = nameLabel;
            qtyContentView.Content = qtyLabel;
            priceContentView.Content = priceLabel;
            costContentView.Content = costLabel;
            cellLayout.Children.Add(qtyContentView);
            cellLayout.Children.Add(detailsLayout);
            detailsLayout.Children.Add(nameContentView);
            detailsLayout.Children.Add(priceLayout);
            priceLayout.Children.Add(priceContentView);
            priceLayout.Children.Add(costContentView);
            View = cellLayout;

            var deleteAction = new MenuItem { Text = "Delete", IsDestructive = true }; // red background
            deleteAction.SetBinding(MenuItem.CommandParameterProperty, new Binding("."));
            deleteAction.Clicked += async (sender, e) =>
            {
                var mi = ((MenuItem)sender);

                var cellModel = (CartCellViewModel) mi.CommandParameter;
                cellModel.DeleteClicked(cellModel, new EventArgs());
            };
            ContextActions.Add(deleteAction);
        }
		public CustomViewUserExerciseGroup ()
		{
			var groupNameLabel = new Label {
				VerticalOptions = LayoutOptions.EndAndExpand,
				TextColor = Color.Black,
				FontSize = 20
			};

			var groupDescriptionLabel = new Label {
				VerticalOptions = LayoutOptions.StartAndExpand,
				FontSize = 14,
				TextColor = Color.Black,
				FontAttributes = FontAttributes.None
			};

			var buttonOne = new Button () {
				Style = (Style)Application.Current.Resources ["reviewButtonStyleSmall"]
			};

			buttonOne.Clicked += (sender, args) => {
				UserExerciseGroupViewModel userExerciseGroupViewModel = UserExerciseGroupViewModel_Property;

                Insights.Track("Clicked to go to page to view/modify a member's userexercisesgroup from 'UserExerciseGroupsPage'", new Dictionary<string, string>()
					{
						{"group name", UserExerciseGroupViewModel_Property.ExerciseGroupName},
						{"group id", UserExerciseGroupViewModel_Property.ID.ToString()}
					});
				((VisualElement)this.Parent).Navigation.PushAsync (new ExistingMemberReviewPage (userExerciseGroupViewModel.SelectedUser.ProfileID, userExerciseGroupViewModel.ID));

			};

		
 
			groupNameLabel.SetBinding (Label.TextProperty, "ExerciseGroupName");
			groupDescriptionLabel.SetBinding (Label.TextProperty, "ExerciseGroupDescription");


			RelativeLayout relativeLayout = new RelativeLayout {
				HorizontalOptions = LayoutOptions.FillAndExpand,
				VerticalOptions = LayoutOptions.FillAndExpand
			};

			StackLayout labelLayout = new StackLayout {
				Orientation = StackOrientation.Vertical,
				VerticalOptions = LayoutOptions.FillAndExpand,
				HorizontalOptions = LayoutOptions.StartAndExpand,
				Children = {
					groupNameLabel, groupDescriptionLabel
				}

			};
			relativeLayout.Children.Add (labelLayout,
				Constraint.RelativeToParent ((parent) => {
					labelLayout.WidthRequest = parent.Width * .60;
					return 20;
				}),
				Constraint.RelativeToParent ((parent) => {
					return (parent.Height / 2) - (labelLayout.Height / 2);
				}));
					
			relativeLayout.Children.Add (buttonOne,
				Constraint.RelativeToParent ((parent) => {
					return parent.Width - (buttonOne.Width * 2 + 30);
				}),
				Constraint.RelativeToParent ((parent) => {
					return (parent.Height / 2) - (buttonOne.Height / 2);
				}));


			#region listview item actions

			//------ Creating Contact Action 1 Start --------//

			var deleteAction = new MenuItem { Text = "Delete", IsDestructive = true }; // red background
			deleteAction.SetBinding (MenuItem.CommandParameterProperty, new Binding ("."));
			deleteAction.Clicked += async (sender, e) => await Task.Run ( async () => {
				var mi = ((MenuItem)sender);
				if (mi.CommandParameter is UserExerciseGroupViewModel) {
					UserExerciseGroupViewModel userExerciseGroupViewModel = mi.CommandParameter as UserExerciseGroupViewModel;

					//Mark us UserExerciseGroup object as deleted
					UserExerciseGroup userExerciseGroup = await UserExerciseGroupDAL.GetUserExerciseGroupByLocalExerciseGroupID(userExerciseGroupViewModel.ID);
					userExerciseGroup.IsDeleted = true;
					userExerciseGroup.ExerisesDirty = true;

					await UserExerciseGroupDAL.AddModify(userExerciseGroup);


					//Remove the exercisegroupviewmodel object from the list
					userExerciseGroupViewModel.UserExerciseGroupViewModelList.Remove (userExerciseGroupViewModel);

					//Uses session tracking
					Insights.Track ("Deleted user exercise group from a member's user exercise group list on 'UserExerciseGroupsPage'", new Dictionary<string, string> () {
						{ "group name", userExerciseGroupViewModel.ExerciseGroupName },
						{ "group id", userExerciseGroupViewModel.ID.ToString () }
					});
				}
			});
			ContextActions.Add (deleteAction);

			#endregion
				
			this.View = relativeLayout;
           
		}
Ejemplo n.º 21
0
		public CustomExerciseImageCell ()
		{
			var moveDownAction = new MenuItem { Text = "Down" };
			moveDownAction.SetBinding (MenuItem.CommandParameterProperty, new Binding ("."));
			moveDownAction.Clicked += async (sender, e) => await Task.Run (() => {
				var mi = ((MenuItem)sender);
				if (mi.CommandParameter is ExerciseViewModel) {
					ExerciseViewModel exercise = mi.CommandParameter as ExerciseViewModel;
					int currentIndex = exercise.SimpleExerciseCollection.IndexOf (exercise);
					if (currentIndex < exercise.SimpleExerciseCollection.Count - 1) {
						exercise.SimpleExerciseCollection.Remove (exercise);
						exercise.SimpleExerciseCollection.Insert (currentIndex + 1, exercise);

						//Uses session tracking
						Insights.Track("Moved exercise down in member exercise list", new Dictionary<string, string>()
							{
								{"exercise", exercise.Exercise.Exercisename},
								{"exercise id", exercise.Exercise.ExerciseID.ToString()}
							});
					}
				}
			});
			ContextActions.Add (moveDownAction);
			var moveUpAction = new MenuItem { Text = "Up" };
			moveUpAction.SetBinding (MenuItem.CommandParameterProperty, new Binding ("."));
			moveUpAction.Clicked += async (sender, e) => await Task.Run (() => {
				var mi = ((MenuItem)sender);
				if (mi.CommandParameter is ExerciseViewModel) {
					ExerciseViewModel exercise = mi.CommandParameter as ExerciseViewModel;
					int currentIndex = exercise.SimpleExerciseCollection.IndexOf (exercise);
					if (currentIndex > 0) {
						exercise.SimpleExerciseCollection.Remove (exercise);
						exercise.SimpleExerciseCollection.Insert (currentIndex - 1, exercise);

						//Uses session tracking
						Insights.Track("Moved exercise up in member exercise list", new Dictionary<string, string>()
							{
								{"exercise", exercise.Exercise.Exercisename},
								{"exercise id", exercise.Exercise.ExerciseID.ToString()}
							});
					}
				}
			});
			ContextActions.Add (moveUpAction);
			//------ Creating Contact Action 1 Start --------//

			var deleteAction = new MenuItem { Text = "Delete", IsDestructive = true }; // red background
			deleteAction.SetBinding (MenuItem.CommandParameterProperty, new Binding ("."));
			deleteAction.Clicked += async (sender, e) => await Task.Run (() => {
				var mi = ((MenuItem)sender);
				if (mi.CommandParameter is ExerciseViewModel) {
					ExerciseViewModel exercise = mi.CommandParameter as ExerciseViewModel;
					exercise.SimpleExerciseCollection.Remove (exercise);
					//Uses session tracking
					Insights.Track("Deleted exercise in member exercise list", new Dictionary<string, string>()
						{
							{"exercise", exercise.Exercise.Exercisename},
							{"exercise id", exercise.Exercise.ExerciseID.ToString()}
						});
				}
			});
			ContextActions.Add (deleteAction);
		}
        public FootballPlayerCell()
        {
            connection = new SQLiteConnection (App.Path);

            MenuItem favouriteAction = new MenuItem { Text = "Favourite" };
            favouriteAction.SetBinding (MenuItem.CommandParameterProperty, new Binding("."));
            favouriteAction.Clicked += async (sender, e) => {
                await Task.Run (() => {
                    Player player;
                    var menuItem = ((MenuItem)sender);
                    player = (Player) menuItem.CommandParameter;

                    bool isFavourite = !(player.IsFavourite);

                    SQLiteCommand command = connection.CreateCommand("UPDATE FootballPlayer SET IsFavourite = ? where Name = ?", isFavourite, player.Name);
                    command.ExecuteNonQuery();

                });
                MessagingCenter.Send<FootballPlayerCell> (this, "Favourite");
            };

            ContextActions.Add (favouriteAction);

            MenuItem deleteAction = new MenuItem { Text = "Delete", IsDestructive = true };
            deleteAction.SetBinding (MenuItem.CommandParameterProperty, new Binding ("."));
            deleteAction.Clicked += async (sender, e) => {
                await Task.Run (() => {
                    Player player;
                    var menuItem = ((MenuItem)sender);
                    player = (Player) menuItem.CommandParameter;

                    SQLiteCommand command = connection.CreateCommand("DELETE from FootballPlayer where Name = ?", player.Name);
                    command.ExecuteNonQuery();

                });
                MessagingCenter.Send<FootballPlayerCell> (this, "Delete");
            };

            ContextActions.Add (deleteAction);

            Image PlayerImage = new Image
            {
                WidthRequest = 50,
                HeightRequest = 50
            };
            PlayerImage.SetBinding (Image.SourceProperty, "PlayerImage");

            Image PlayerFlag = new Image
            {
                WidthRequest = 50,
                HeightRequest = 30
            };
            PlayerFlag.SetBinding (Image.SourceProperty, "PlayerFlag");

            Label Name = new Label
            {
                TextColor = Color.Black
            };
            Name.SetBinding (Label.TextProperty, "Name");

            Label DateOfBirth = new Label
            {
                TextColor = Color.Black
            };
            DateOfBirth.SetBinding (Label.TextProperty, "DateOfBirth");

            Label Age = new Label
            {
                TextColor = Color.Black,
            };
            Age.SetBinding (Label.TextProperty, "Age");

            StackLayout descriptionLayout = new StackLayout
            {
                Orientation = StackOrientation.Horizontal,
                Spacing = 10,
                Children =
                {
                    DateOfBirth,
                    Age
                }
            };

            StackLayout detailsLayout = new StackLayout
            {
                Orientation = StackOrientation.Vertical,
                Spacing = 20,
                Children =
                {
                    Name,
                    descriptionLayout
                }
            };

            var cellLayout = new StackLayout
            {
                Spacing = 30,
                Padding = new Thickness (10, 5, 10, 5),
                Orientation = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Children =
                {
                    PlayerImage,
                    detailsLayout,
                    PlayerFlag
                }
            };

            this.View = cellLayout;
        }
Ejemplo n.º 23
0
        public ViewCell EmpleadoCellTemplate()
        {
            var TemplateEmpleado = new ViewCell();

//			Labels del template
            var nombreLabel     = new Label();
            var apellidoLabel   = new Label();
            var fotoPerfilImage = new CircleImage
            {
                Aspect            = Aspect.AspectFit,
                BorderColor       = Color.Black,
                BorderThickness   = 3,
                HeightRequest     = 25,
                WidthRequest      = 25,
                VerticalOptions   = LayoutOptions.Center,
                HorizontalOptions = LayoutOptions.Start,
                FillColor         = Color.Black
            };

//			Asignamos las propiedades bindeables, estas propiedades son las del BindingContext,
//			el cual es el modelo de nuestra Collection en este caso es Empleado.

            nombreLabel.SetBinding(Label.TextProperty, "Nombre");
            apellidoLabel.SetBinding(Label.TextProperty, "Apellido");
            fotoPerfilImage.SetBinding(Image.SourceProperty, "FotoPerfil");

            /*
             * Creamos Context Actions, los cuales responderan a un swipe sobre un item  en IOS
             * y long press en Android
             */
            Xamarin.Forms.MenuItem delete = new Xamarin.Forms.MenuItem();
            delete.Text          = "Eliminar";
            delete.IsDestructive = true;
            delete.SetBinding(Xamarin.Forms.MenuItem.CommandParameterProperty, ".");
            delete.Clicked += (object sender, EventArgs e) =>
            {
                var mi   = ((Xamarin.Forms.MenuItem)sender);
                var item = mi.CommandParameter as Empleado;
                ListData.Remove(item);
            };
            TemplateEmpleado.ContextActions.Add(delete);

            Xamarin.Forms.MenuItem edit = new Xamarin.Forms.MenuItem();
            edit.SetBinding(Xamarin.Forms.MenuItem.CommandParameterProperty, ".");
            edit.Clicked += (object sender, EventArgs e) =>
            {
                var mi   = (Xamarin.Forms.MenuItem)sender;
                var item = mi.CommandParameter as Empleado;
//				Aqui podriamos Abrir unPage ParamArrayAttribute edicion de datos del Empleado
//				Navigation.PushModalAsync(new EmpleadoInfo(item));
            };
            edit.Text = "Editar";

            TemplateEmpleado.ContextActions.Add(edit);

            var stack = new StackLayout {
                Orientation = StackOrientation.Horizontal,
                Spacing     = 10,
                Padding     = 5,
                Children    =
                {
                    fotoPerfilImage,
                    new StackLayout {
                        Orientation = StackOrientation.Vertical,
                        Spacing     = 2,
                        Children    =
                        {
                            nombreLabel,
                            apellidoLabel
                        }
                    }
                }
            };

            TemplateEmpleado.View = stack;
            return(TemplateEmpleado);
        }
Ejemplo n.º 24
0
			public ListItemCell ()
			{
				// ....custom labels and layouts...



				//Label
				Label titleLabel = new Label
				{
					HorizontalOptions = LayoutOptions.Start,
					FontSize = 25,
					FontAttributes = Xamarin.Forms.FontAttributes.Bold,
					TextColor = Color.White
				};
				titleLabel.SetBinding(Label.TextProperty,"Title");


				Label desclabel = new Label
				{
					HorizontalOptions = LayoutOptions.FillAndExpand,
					FontSize = 12,
					TextColor = Color.White
				};
				desclabel.SetBinding(Label.TextProperty,"Description");
				Label priceLabel = new Label
				{
					HorizontalOptions = LayoutOptions.End,
					FontSize = 25,
					TextColor = Color.Aqua
				};
				priceLabel.SetBinding(Label.TextProperty,"Price");

			
//
//				//Button
//				var button = new Button
//				{
//					Text = "Buy Now",
//					BackgroundColor = Color.Teal,
//					HorizontalOptions = LayoutOptions.EndAndExpand
//				};
//				button.SetBinding(Button.CommandParameterProperty, new Binding("."));
//				button.Clicked += (sender, e) => 
//				{
//					var b = (Button)sender;
//					var item = (ListItem)b.CommandParameter;
//					((ContentPage)((ListView)((StackLayout)((StackLayout)b.ParentView).ParentView).ParentView).ParentView).DisplayAlert("Clicked", item.Title.ToString() + " button was clicked", "OK");
//				};
//
//

//
//				StackLayout viewButton = new StackLayout()
//				{
//					HorizontalOptions = LayoutOptions.EndAndExpand,
//					Orientation = StackOrientation.Horizontal,
//					WidthRequest = 260,
//					Children = { priceLabel, button}
//				};

			
						
				StackLayout viewLayoutItem = new StackLayout()
				{
					HorizontalOptions = LayoutOptions.StartAndExpand,
					Orientation = StackOrientation.Vertical,
					Children = {titleLabel,desclabel}
				};
						
				StackLayout viewLayout = new StackLayout()
				{
					HorizontalOptions = LayoutOptions.StartAndExpand,
					Orientation = StackOrientation.Horizontal,
					Padding = new Thickness(25,10,55,15),
					Children = {viewLayoutItem, priceLabel}
				};
						

				View = viewLayout;


				var moreAction = new MenuItem {Text = "More"};
				moreAction.SetBinding(MenuItem.CommandParameterProperty, new Binding("."));
				moreAction.Clicked += (sender, e) => 
				{
					var mi = ((MenuItem)sender);
					var item = (ListItem)mi.CommandParameter;
					Debug.WriteLine("More clicked on row: " + item.Title.ToString());
				};
				var deleteAction = new MenuItem {Text = "Delete", IsDestructive = true};
				deleteAction.SetBinding(MenuItem.CommandParameterProperty,new Binding("."));
				deleteAction.Clicked += (sender, e) => 
				{
					var mi = ((MenuItem)sender);
					var item = (ListItem)mi.CommandParameter;
					Debug.WriteLine("Delete clicked on row: " + item.Title.ToString());
				};

				ContextActions.Add(moreAction);
				ContextActions.Add(deleteAction);







			}
Ejemplo n.º 25
0
            public ListItemCell()
            {
                var moreAction = new MenuItem { Text = "More" };
                moreAction.SetBinding(MenuItem.CommandParameterProperty, new Binding("."));
                moreAction.Clicked += (sender, e) =>
                {
                    var mi = ((MenuItem)sender);
                    var item = (AppTask)mi.CommandParameter;
                };
                var deleteAction = new MenuItem { Text = "Delete", IsDestructive = true };
                deleteAction.SetBinding(MenuItem.CommandParameterProperty, new Binding("."));
                deleteAction.Clicked += async (sender, e) =>
                {

                    var mi = ((MenuItem)sender);
                    var item = (AppTask)mi.CommandParameter;

                    bool willDelete = await App.Current.MainPage.DisplayAlert("Delete Confirmation", "Are you sure you want to remove this task?", "Yes", "No");

                    if (willDelete)
                    {

                        Core.GetCore().GetScheduler().RemoveTask(item.TaskID);
                        ((Main)((Xamarin.Forms.NavigationPage)App.Current.MainPage).CurrentPage).OnAppearing();
                    }
                };

                ContextActions.Add(moreAction);
                ContextActions.Add(deleteAction);

                Label titleLabel = new Label { Text = "Task Name" };
                titleLabel.SetBinding(Label.TextProperty, "TaskName");

                StackLayout viewLayoutItem = new StackLayout()
                {
                    HorizontalOptions = LayoutOptions.StartAndExpand,
                    Orientation = StackOrientation.Vertical,
                    Children = { titleLabel }

                };

                View = viewLayoutItem;
            }