Example #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 }
            };
        }
        private static async void HandleSubMenu(Xamarin.Forms.MenuItem item, object parameter)
        {
            var cascadeMenuItem = item as CascadeMenuItem;
            var menu            = cascadeMenuItem.SubMenu;

            if (menu == null || !menu.Any())
            {
                return;
            }

            var element = cascadeMenuItem.Page;

            if (element != null)
            {
                var result = await element.DisplayActionSheet(item.Text, cancel : null, destruction : null,
                                                              buttons : menu
                                                              .Select(i => i.Text)
                                                              .ToArray());

                if (result != null)
                {
                    var selectedItem = menu.First(x => x.Text == result);

                    if (selectedItem.Command?.CanExecute(selectedItem) == true)
                    {
                        selectedItem.Command.Execute(parameter);
                    }
                }
            }
        }
        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);
//			}
        }
Example #4
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);
        }
Example #5
0
        public virtual void AddChild(XF.Element child, int physicalSiblingIndex)
        {
            if (child is null)
            {
                throw new ArgumentNullException(nameof(child));
            }

            XF.ShellItem itemToAdd = child switch
            {
                XF.TemplatedPage childAsTemplatedPage => childAsTemplatedPage,       // Implicit conversion
                         XF.ShellContent childAsShellContent => childAsShellContent, // Implicit conversion
                         XF.ShellSection childAsShellSection => childAsShellSection, // Implicit conversion
                         XF.MenuItem childAsMenuItem => childAsMenuItem,             // Implicit conversion
                         XF.ShellItem childAsShellItem => childAsShellItem,
                         _ => throw new NotSupportedException($"Handler of type '{GetType().FullName}' representing element type '{TargetElement?.GetType().FullName ?? "<null>"}' doesn't support adding a child (child type is '{child.GetType().FullName}').")
            };

            if (ShellControl.Items.Count >= physicalSiblingIndex)
            {
                ShellControl.Items.Insert(physicalSiblingIndex, itemToAdd);
            }
            else
            {
                Debug.WriteLine($"WARNING: {nameof(AddChild)} called with {nameof(physicalSiblingIndex)}={physicalSiblingIndex}, but ShellControl.Items.Count={ShellControl.Items.Count}");
                ShellControl.Items.Add(itemToAdd);
            }
        }
Example #6
0
        void NavigateTo(MenuItem menu)
        {
            Page displayPage = (Page)Activator.CreateInstance(menu.TargetType);
            Detail = new NavigationPage(displayPage);

            IsPresented = false;
        }
Example #7
0
 private XF.ShellItem GetItemForElement(XF.Element child)
 {
     return(child switch
     {
         XF.TemplatedPage childAsTemplatedPage => GetItemForTemplatedPage(childAsTemplatedPage),
         XF.ShellContent childAsShellContent => GetItemForContent(childAsShellContent),
         XF.ShellSection childAsShellSection => GetItemForSection(childAsShellSection),
         XF.MenuItem childAsMenuItem => GetItemForMenuItem(childAsMenuItem),
         XF.ShellItem childAsShellItem => childAsShellItem,
         _ => null
     });
 public MenuItemHandler(NativeComponentRenderer renderer, XF.MenuItem menuItemControl) : base(renderer, menuItemControl)
 {
     MenuItemControl          = menuItemControl ?? throw new ArgumentNullException(nameof(menuItemControl));
     MenuItemControl.Clicked += (s, e) =>
     {
         if (ClickEventHandlerId != default)
         {
             renderer.Dispatcher.InvokeAsync(() => renderer.DispatchEventAsync(ClickEventHandlerId, null, e));
         }
     };
 }
Example #9
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);
        }
Example #10
0
        private static bool IsShellItemWithMenuItem(XF.ShellItem shellItem, XF.MenuItem menuItem)
        {
            // Xamarin.Forms.MenuShellItem is internal so we have to use reflection to check that
            // its MenuItem property is the same as the MenuItem we're looking for.
            if (!MenuShellItemType.IsAssignableFrom(shellItem.GetType()))
            {
                return(false);
            }
            var menuItemInMenuShellItem = MenuShellItemMenuItemProperty.GetValue(shellItem);

            return(menuItemInMenuShellItem == menuItem);
        }
        public override void UpdateView()
        {
            base.UpdateView ();

            Workshops sessions = (Workshops)Model;
            WorkshopsPage page = (WorkshopsPage)View;

            page.Title = sessions.RelatedWorkshopSet.Name;

            TableSection section = new TableSection ();

            foreach (Workshop session in sessions.workshops) {

                TextLabelCell cell = new TextLabelCell {
                    Label = session.topic,
                    HasArrow = true
                };

                //Simple theme
                if (((WorkshopsPage)View).BackgroundColor.A == 1) {

                    var cellAction = new MenuItem ();

                    if (session.BookingStatus == BookingStatuses.Booked) {

                        cellAction.Text = "Cancel";
                        cellAction.IsDestructive = true;
                        cellAction.Clicked += (sender, e) => CancelWorkShop (session);

                    } else if (session.BookingStatus == BookingStatuses.NotBooked) {

                        cellAction.Text = "Book";
                        cellAction.IsDestructive = false;
                        cellAction.Clicked += (sender, e) => BookWorkShop (session);
                    } else if (session.BookingStatus == BookingStatuses.Booking) {

                        cellAction.Text = "Booking";
                        cellAction.IsDestructive = false;
                    } else {

                        cellAction.Text = "Canceling";
                        cellAction.IsDestructive = false;
                    }

                    cell.ContextActions.Add (cellAction);
                }

                cell.Tapped += (object sender, EventArgs e) => ShowSelectedWorkshop (session);
                section.Add (cell);
            }

            (page.WorkshopsListView.Root = new TableRoot ()).Add (section);
        }
		void NavigateTo(MenuItem menu)
		{
			if (menu == null)
				return;

			Page displayPage = (Page)Activator.CreateInstance(menu.TargetType);

			Detail = new NavigationPage(displayPage);

			Menu.SelectedItem = null;
			IsPresented = false;
		}
Example #13
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 }
					}
				}
			};
		}
Example #16
0
        public void NavigateTo(MenuItem menu)
        {
            try
            {
                App.ClearToolbarItems();

                if (menu == null)
                    return;

                Children.Clear();

                Page displayPage = (Page)Activator.CreateInstance(menu.TargetType);
                Detail = new NavigationPage(displayPage);

                if (menu.TargetType != typeof(CalendarDayView))
                    Detail.Title = "SUBPAGE";
                else
                    Detail.Title = "MAINPAGE";

                Children.Add(Detail);
                Detail.Layout(new Rectangle(0, 0, Width, Height));

                Children.Remove(MasterPage);
                Children.Add(MasterPage);

                Children.Remove(ShortCutPage);
                Children.Add(ShortCutPage);

                doSmoothClose();
                doShortcutSmoothClose();

                ToolbarItems.Clear();

                for (int i = 4; i >= 0; i--)
                {
                    if (App.toolbarItems[i] != null)
                        ToolbarItems.Add(App.toolbarItems[i]);
                }
            }
            catch (Exception ex)
            {
                DisplayAlert("", ex.Message, "");
            }
        }
Example #17
0
        public virtual void RemoveChild(XF.Element child)
        {
            if (child is null)
            {
                throw new ArgumentNullException(nameof(child));
            }

            var itemToRemove = child switch
            {
                XF.TemplatedPage childAsTemplatedPage => GetItemForTemplatedPage(childAsTemplatedPage),
                XF.ShellContent childAsShellContent => GetItemForContent(childAsShellContent),
                XF.ShellSection childAsShellSection => GetItemForSection(childAsShellSection),
                XF.MenuItem childAsMenuItem => GetItemForMenuItem(childAsMenuItem),
                XF.ShellItem childAsShellItem => childAsShellItem,
                _ => throw new NotSupportedException($"Handler of type '{GetType().FullName}' representing element type '{TargetElement?.GetType().FullName ?? "<null>"}' doesn't support removing a child (child type is '{child.GetType().FullName}').")
            };

            ShellControl.Items.Remove(itemToRemove);
        }
		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 SampleViewCell()
        {
            try
            {
                InitializeComponent();

                _overRideItemmenuitem = new MenuItem();
                _overRideItemmenuitem.Text = "Over Ride";
                _overRideItemmenuitem.IsDestructive = true;
                _overRideItemmenuitem.Clicked += OverRide_Clicked;

                //this.ContextActions.Add(OverRideItemmenuitem);

                //Height = 300;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
		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;
        }
Example #24
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);
		}
			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);







			}
            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 MenuItemHandler(NativeComponentRenderer renderer, XF.MenuItem menuItemControl) : base(renderer, menuItemControl)
        {
            MenuItemControl = menuItemControl ?? throw new ArgumentNullException(nameof(menuItemControl));

            Initialize(renderer);
        }
        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;
        }
Example #29
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 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);
		}
Example #31
0
 private XF.ShellItem GetItemForMenuItem(XF.MenuItem childAsMenuItem)
 {
     // MenuItem is wrapped in ShellMenuItem, which is internal type.
     // Not sure how to identify this item correctly.
     return(ShellControl.Items.FirstOrDefault(item => IsShellItemWithMenuItem(item, childAsMenuItem)));
 }
	    void SetContextActions()
        {
            try
            {
                if (BindingContext != null)
                {
                    var obj = (CheckListDetails)BindingContext;

                    if (obj.ChecklistStatus == CheckListStatus.Default)
                    {
                        if (ContextActions.Count == 0)
                        {
                            ContextActions.Add(_overRideItemmenuitem);
                        }
                    }
                    else if (obj.ChecklistStatus == CheckListStatus.Completed)
                    {
                        if (ContextActions.Count > 0)
                        {

                            ContextActions.Remove(_overRideItemmenuitem);
                            if (_overRideItemmenuitem != null)
                            {
                                _overRideItemmenuitem.Clicked -= OverRide_Clicked;
                                _overRideItemmenuitem = null;
                            }
                        }


                    }
                    else if (obj.ChecklistStatus == CheckListStatus.Pending)
                    {
                        if (ContextActions.Count == 0)
                        {
                            ContextActions.Add(_overRideItemmenuitem);
                        }


                    }
                    else if (obj.ChecklistStatus == CheckListStatus.OverRide)
                    {
                        if (ContextActions.Count > 0)
                        {
                            ContextActions.Remove(_overRideItemmenuitem);
                            if (_overRideItemmenuitem != null)
                            {
                                _overRideItemmenuitem.Clicked -= OverRide_Clicked;
                                _overRideItemmenuitem = null;
                            }

                        }
                    }

                }


            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
		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);
		}
Example #34
0
		public CartridgeListCell()
		{
			var grid = new Grid() {
				BackgroundColor = App.Colors.Background,
				Padding = new Thickness(10, 10),
				ColumnSpacing = 10,
				ColumnDefinitions = new ColumnDefinitionCollection(),
				RowDefinitions = new RowDefinitionCollection(),
				HorizontalOptions = LayoutOptions.FillAndExpand,
				VerticalOptions = LayoutOptions.FillAndExpand,
			};

			grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength((0.25 * DependencyService.Get<IScreen>().Width), GridUnitType.Absolute) });
			grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) });

			grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) });
			grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) });

//			var boxPoster = new BoxView()
//				{
//					BackgroundColor = App.Colors.DirectionColor,
//					InputTransparent = true,
//					HorizontalOptions = LayoutOptions.FillAndExpand,
//					VerticalOptions = LayoutOptions.FillAndExpand,
//				};
//
//			grid.Children.Add(boxPoster, 0, 1, 0, 2);

			var imagePoster = new Image() 
				{
					Aspect = Aspect.AspectFit,
					HorizontalOptions = LayoutOptions.CenterAndExpand,
					VerticalOptions = LayoutOptions.StartAndExpand,
					WidthRequest = 48,
					HeightRequest = 48,
				};

			imagePoster.SetBinding(Image.SourceProperty, CartridgeStore.CartridgeIconPropertyName, BindingMode.Default, convMediaToImageSource);

			grid.Children.Add(imagePoster, 0, 1, 0, 2);

//			var boxHeader = new BoxView()
//				{
//					BackgroundColor = App.Colors.DirectionBackground,
//					InputTransparent = true,
//					HorizontalOptions = LayoutOptions.FillAndExpand,
//					VerticalOptions = LayoutOptions.FillAndExpand,
//				};
//
//			grid.Children.Add(boxHeader, 1, 2, 0, 1);

			var layoutHeader = new StackLayout() 
				{
					Orientation = StackOrientation.Vertical,
					Padding = 0,
					Spacing = 0,
					HorizontalOptions = LayoutOptions.FillAndExpand,
					VerticalOptions = LayoutOptions.Fill,
				};

			var labelHeader = new ExtendedLabel() 
				{
					HorizontalOptions = LayoutOptions.StartAndExpand,
					VerticalOptions = LayoutOptions.StartAndExpand,
					XAlign = TextAlignment.Start,
					YAlign = TextAlignment.Start,
					LineBreakMode = LineBreakMode.WordWrap,
					UseMarkdown = false,
					TextColor = App.Colors.Text,
					FontSize = Device.OnPlatform<int>(18, 20, 18),
				};

			labelHeader.SetBinding(Label.TextProperty, CartridgeStore.CartridgeNamePropertyName);

			layoutHeader.Children.Add(labelHeader);

			grid.Children.Add(layoutHeader, 1, 2, 0, 1);

			var layoutDetail = new StackLayout() 
				{
					Orientation = StackOrientation.Vertical,
					Padding = 0,
					Spacing = 0,
					HorizontalOptions = LayoutOptions.FillAndExpand,
					VerticalOptions = LayoutOptions.Fill,
				};

			var labelAuthor = new ExtendedLabel() 
				{
					HorizontalOptions = LayoutOptions.StartAndExpand,
					VerticalOptions = LayoutOptions.Start,
					LineBreakMode = LineBreakMode.TailTruncation,
					UseMarkdown = false,
					TextColor = App.Colors.Text,
					FontSize = Device.OnPlatform<int>(11, 12, 11),
				};

			labelAuthor.SetBinding(Label.TextProperty, CartridgeStore.CartridgeAuthorNamePropertyName, BindingMode.Default, convStringFormat, Catalog.GetString("Author:  {0}"));

			layoutDetail.Children.Add(labelAuthor);

			var labelVersion = new ExtendedLabel() 
				{
					HorizontalOptions = LayoutOptions.StartAndExpand,
					VerticalOptions = LayoutOptions.Start,
					UseMarkdown = false,
					TextColor = App.Colors.Text,
					FontSize = Device.OnPlatform<int>(11, 12, 11),
				};

			labelVersion.SetBinding(Label.TextProperty, CartridgeStore.CartridgeVersionPropertyName, BindingMode.Default, convStringFormat, Catalog.GetString("Version: {0}"));

			layoutDetail.Children.Add(labelVersion);

			var labelActivityType = new ExtendedLabel() 
				{
					HorizontalOptions = LayoutOptions.StartAndExpand,
					VerticalOptions = LayoutOptions.StartAndExpand,
					UseMarkdown = false,
					TextColor = App.Colors.Text,
					FontSize = Device.OnPlatform<int>(11, 12, 11),
				};

			labelActivityType.SetBinding(Label.TextProperty, CartridgeStore.CartridgeActivityTypePropertyName, BindingMode.Default, convStringFormat, Catalog.GetString("Activity: {0}"));

			layoutDetail.Children.Add(labelActivityType);

			grid.Children.Add(layoutDetail, 1, 2, 1, 2);

			View = grid;

			var update = new MenuItem 
				{
					Text = Catalog.GetString("Update"),
					IsDestructive = false,
				};

//			ContextActions.Add(update);

			var delete = new MenuItem 
				{
					Text = Catalog.GetString("Delete"),
					IsDestructive = true,
					Command = new Command(DeleteCommand),
					CommandParameter = this,
				};

			ContextActions.Add(delete);
		}
        public NotificationViewCell()
        {
            var EmpImage = new CircleImage()
             {
                 HorizontalOptions = LayoutOptions.Start,
                 BorderThickness = 5,
                 Source = "NainaSharma.png",
                 BorderColor = Color.White,
                 Aspect = Aspect.Fill,
             };
           // EmpImage.SetBinding(Image.SourceProperty, new Binding("ImageUri"));
            var nameLabel = new Label
            {
                HorizontalOptions = LayoutOptions.Start,
                FontSize=15,
                TextColor=Xamarin.Forms.Color.White
            };

            nameLabel.SetBinding(Label.TextProperty, "FullName");
            var daysLabel = new Label
            {
                HorizontalOptions = LayoutOptions.Start,
                TextColor = Xamarin.Forms.Color.White
            };

            daysLabel.SetBinding(Label.TextProperty, "ApprovedDays");
            var subjectLabel = new Label
            {
                HorizontalOptions = LayoutOptions.Start,
                TextColor = Xamarin.Forms.Color.White
            };

            subjectLabel.SetBinding(Label.TextProperty, "Notes");
            EmpImage.WidthRequest = EmpImage.HeightRequest = 70;

            var toDate = new Label
            {
                HorizontalOptions = LayoutOptions.Start,
                TextColor = Xamarin.Forms.Color.White
            };
            toDate.SetBinding(Label.TextProperty, "LeaveDate");

            var fromDate = new Label
            {
                HorizontalOptions = LayoutOptions.Start,
                TextColor = Xamarin.Forms.Color.White
            };
            fromDate.SetBinding(Label.TextProperty, new Binding("FromDate") { StringFormat = "{0:dd-MMM-yyyy}" });

            Button btnApproved = new Button { 
                Text="Approved",
                BackgroundColor=Color.Green,
                FontSize = 10,
            };

            Button btnRejected = new Button
            {
                Text = "Reject",
                BackgroundColor = Color.Red,
                FontSize=10,
            };
            View flagView = new StackLayout {  };

            //TODO: Have to add pending color
            flagView.SetBinding(View.BackgroundColorProperty, new Binding("IsApproved", BindingMode.Default, LeaveFlagColorConverter.OneWay<bool, Color>((status) => status ? InsideInning.Helper.Color.LightGreen.ToFormsColor() : InsideInning.Helper.Color.LightRed.ToFormsColor())));

            #region Adding Context Actions To List view Cell

            var actionApproved = new MenuItem { Text = "Approved" };
            actionApproved.Clicked += async (sender, e) =>
            {
                
                flagView.BackgroundColor = Color.Green;
            };
            var actionReject = new MenuItem { Text = "Reject",IsDestructive=true };
            actionReject.Clicked += async (sender, e) =>
            {
               
                flagView.BackgroundColor = Color.Red;
            };
            ContextActions.Add(actionApproved);
            ContextActions.Add(actionReject);

            #endregion
            
            RelativeLayout MainView = new RelativeLayout
            {
                HorizontalOptions = LayoutOptions.Start,
                Padding = new Thickness(20, 10, 5, 5),
            };

            MainView.Children.Add(EmpImage, Constraint.Constant(5), Constraint.Constant(10),
                 Constraint.Constant(60),
                 Constraint.Constant(60));
            MainView.Children.Add(subjectLabel, Constraint.Constant(80), Constraint.Constant(50), Constraint.RelativeToParent(parent => { return parent.Width; }), Constraint.Constant(40));
            MainView.Children.Add(nameLabel, Constraint.Constant(80), Constraint.Constant(5), Constraint.RelativeToParent(parent => { return parent.Width; }), Constraint.Constant(20));

            MainView.Children.Add(toDate, Constraint.Constant(80), Constraint.Constant(27), Constraint.RelativeToParent(parent => { return parent.Width- daysLabel.Width; }), Constraint.Constant(40));
            //MainView.Children.Add(fromDate, Constraint.Constant(180), Constraint.Constant(27), Constraint.Constant(100), Constraint.Constant(40));
            MainView.Children.Add(daysLabel, Constraint.Constant(290), Constraint.Constant(27), Constraint.Constant(50), Constraint.Constant(20));
            //MainView.Children.Add(btnApproved, Constraint.Constant(290), Constraint.Constant(5), Constraint.Constant(60), Constraint.Constant(30));
            //MainView.Children.Add(btnRejected, Constraint.Constant(290), Constraint.Constant(40), Constraint.Constant(60), Constraint.Constant(30));
            MainView.Children.Add(flagView, Constraint.RelativeToParent(parent => { return parent.Width-7; }), Constraint.Constant(2), Constraint.Constant(7), Constraint.Constant(76));

            View = MainView;
        }
Example #36
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 UserViewCell()
        {
            var roundedImage = new RoundedImage
            {
                BorderColor = Color.Black,
                Aspect = Aspect.AspectFill,
                BorderWidth = 2.0,
            };
            roundedImage.SetBinding(Image.SourceProperty, "ProfilePicture");

            var lblName = new Label
            {
                TextColor = Color.FromHex("#A5A5A5"),
                FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)),
                XAlign = TextAlignment.Start,
                YAlign = TextAlignment.Center
            };
            lblName.SetBinding(Label.TextProperty, "Name");

            var lblUsername = new Label
            {
                TextColor = Color.FromHex("#A5A5A5"),
                FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)),
                XAlign = TextAlignment.Start,
                YAlign = TextAlignment.Center
            };
            lblUsername.SetBinding(Label.TextProperty, "Username");

            var textLayout = new StackLayout
            {
                Orientation = StackOrientation.Vertical,
                Spacing = 2,
                HorizontalOptions = LayoutOptions.StartAndExpand,
                VerticalOptions = LayoutOptions.CenterAndExpand
            };
            textLayout.Children.Add(lblName);
            textLayout.Children.Add(lblUsername);

            #region Configure layout
            var layout = new RelativeLayout
            {
                Padding = new Thickness(0, 2, 0, 2),
                BackgroundColor = Color.White
            };
            layout.Children.Add(roundedImage,
                Constraint.RelativeToParent(p => p.Width * 0.03),
                Constraint.RelativeToParent(p => p.Width * 0.01),
                Constraint.RelativeToParent(p => p.Width * 0.15),
                Constraint.RelativeToParent(p => p.Width * 0.15));
            layout.Children.Add(textLayout,
                Constraint.RelativeToView(roundedImage, (p, v) => v.X + v.Width + 15),
                Constraint.RelativeToView(roundedImage, (p, v) => v.Y),
                Constraint.RelativeToView(roundedImage, (p, v) => p.Width - v.X - v.Width - 20),
                Constraint.RelativeToView(roundedImage, (p, v) => v.Height));
            #endregion

            View = layout;

            var editMenu = new MenuItem() { Text = "Edit" };
            editMenu.Clicked += (sender, e) =>
            {
                Application.Current.MainPage.DisplayAlert("Edit", "You want to edit this entry", "Ok");
            };

            var deleteMenu = new MenuItem() { Text = "Delete", IsDestructive = true };
            deleteMenu.Clicked += (sender, e) =>
            {
                Application.Current.MainPage.DisplayAlert("Deleted", "You delete this entry", "Ok");
            };

            ContextActions.Add(editMenu);
            ContextActions.Add(deleteMenu);
        }
		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;
           
		}
		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;
           
		}
Example #40
0
        private void SetBindings()
        {
            PhoneLabel.SetBinding(Label.TextProperty, "Contact");       // Address
            TimeLabel.SetBinding(Label.TextProperty, "Time");
            ValueLabel.SetBinding(Label.TextProperty, "Label");
            CapacityLabel.SetBinding(Label.TextProperty, "Count"); //*/
            SimLabel.SetBinding(Label.TextProperty, "Sim");        //*/


            if (hideSpam == false)
            {
                var opacityConverter = new UniversalConverter(b =>
                {
                    if (b is bool isSpam && isSpam)
                    {
                        return(0.1f);
                    }
                    return(1);
                });


                PhoneLabel.SetBinding(Label.OpacityProperty, "IsSpam", BindingMode.OneWay, opacityConverter);
                ValueLabel.SetBinding(Label.OpacityProperty, "IsSpam", BindingMode.OneWay, opacityConverter);
                CapacityLabel.SetBinding(Label.OpacityProperty, "IsSpam", BindingMode.OneWay, opacityConverter);
                TimeLabel.SetBinding(Label.OpacityProperty, nameof(Dialog.IsSpam), BindingMode.OneWay, opacityConverter);
            }
            //*/

            // SimLabel.SetBinding(Label.TextColorProperty, "SimBackColor");//*/

            StateFrame.SetBinding(Frame.BackgroundColorProperty, "LastMsgState", BindingMode.OneWay, new MessageStateConverter());
            StateImage.SetBinding(Image.IsVisibleProperty, "LastIsOutGoing");
            // StateImage.SetBinding(Image.SourceProperty, "LastMsgState");



            spamBtn = new Xamarin.Forms.MenuItem {
                Text = "В спам", Command = new DialogCommander(d =>
                {
                    d.IsSpam = !d.IsSpam;
                    if (d.IsSpam)
                    {
                        Api.Funcs.Toast("Вы можете скрыть сообщения, помеченные как спам, в настройках приложения, передернув рычаг");
                        // if (Options.ModelSettings.HideSpam) Options.ModelSettings.HideSpam = false;
                    }
                })
            };

            rmBtn = new Xamarin.Forms.MenuItem()
            {
                Text    = "Удалить",
                Command = new DialogCommander(async d =>
                {
                    if (await navPage.DisplayAlert("Подтверждение", "Вы уверены, что хотите удалить весь диалог?", "Да", "Нет"))
                    {
                        ((navPage.RootPage as MainPage).Dialogs.ItemsSource as IList <Dialog>).Remove(d);

                        // Cache.database.Execute("DELETE FROM Messages WHERE Address = ?", new string[] { d.Address });
                    }
                })
            };
            this.ContextActions.AddRange(spamBtn, rmBtn);
        }
Example #41
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);
        }
Example #42
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;
            }
        public FootballPlayerListCell()
        {
            FootballPlayer footballplayercollection = (FootballPlayer)this.BindingContext;
            var deleteAction = new MenuItem { Text = "", IsDestructive = true };
            deleteAction.Clicked += DeleteAction_Clicked;
            this.ContextActions.Add (deleteAction);
            deleteAction.Text = "Delete";
            var Favourites = new MenuItem { IsDestructive = false };
            Favourites.Clicked += Favourites_Clicked;
            FootballPlayer foot = new FootballPlayer ();
            if (foot.fav) {
                Favourites.Text = "UnFavourite";
            } else {
                Favourites.Text = "Mark Favourite";
            }
            this.ContextActions.Add (Favourites);

            nameLabel = new Label () {
                FontFamily = "HelveticaNeue-Medium",
                FontSize = 18,
                TextColor = Color.Black,

                WidthRequest = 100

            };

            var DOB = new Label () {
                FontFamily = "HelveticaNeue-Medium",
                FontSize = 18,
                TextColor = Color.Black,

                WidthRequest = 100
            };

            var ageLabel = new Label () {
                FontFamily = "HelveticaNeue-Medium",
                FontSize = 18,
                TextColor = Color.Black,
                Text = "age",
                WidthRequest = 100

            };

            var countryimg = new Image ();
            countryimg.SetBinding (Image.SourceProperty, "countryImage");
            countryimg.GetSizeRequest (15, 15);

            var Lname = new Label () {
                FontFamily = "HelveticaNeue-Medium",
                FontSize = 18,
                TextColor = Color.Black,

                WidthRequest = 100

            };

            nameLabel.SetBinding(Label.TextProperty,"PFName");
            DOB.SetBinding (Label.TextProperty, "PlayerAge");
            Lname.SetBinding (Label.TextProperty, "PLName");

            var cellLayout = new StackLayout {
                Spacing = 5,
                Padding = new Thickness (5, 5, 5, 5),

                Orientation = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Children = { nameLabel, Lname ,

                new StackLayout {
                    Orientation = StackOrientation.Vertical,
                    Spacing = 5,
                        Children = { ageLabel, DOB }
                },

                    countryimg
                }
            };

            this.View = cellLayout;
        }
        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;
        }