Ejemplo n.º 1
0
        public PageTwoCell()
        {
            lblName = new Label()
            {
                FontSize = 12
            };
            lblPhone = new Label()
            {
                TextColor = Color.Gray,
                FontSize  = 10
            };


            ContextActions.Add(new MenuItem()
            {
                Text          = "Delete",
                IsDestructive = true,
                Command       = new Command((obj) => {
                    var p = (Person)this.BindingContext;
                    CoreDependencyService.SendViewModelMessage <AppViewModel>(CoreSettings.DeletePersonTag, p.Id);
                })
            });

            View = new StackLayout()
            {
                Padding  = new Thickness(10, 5, 0, 5),
                Children = { lblName, lblPhone }
            };
        }
Ejemplo n.º 2
0
        public ReportViewCell()
        {
            nameLabel = new Label {
                Style = (Style)Application.Current.Resources["whiteTextLabel"]
            };
            statusLabel = new Label {
                Style = (Style)Application.Current.Resources["whiteTextLabel"], Font = Font.SystemFontOfSize(NamedSize.Small), TextColor = Color.FromRgb(200, 200, 200)
            };
            totalPriceLabel = new Label {
                Style = (Style)Application.Current.Resources["whiteTextLabel"]
            };

            AbsoluteLayout layout = new AbsoluteLayout {
                Padding = new Thickness(20, 5, 0, 0), HeightRequest = 50
            };

            layout.Children.Add(nameLabel, new Rectangle(0.05, 0.05, 0.8, 0.5));
            layout.Children.Add(statusLabel, new Rectangle(0.05, 0.95, 0.55, 0.5));
            layout.Children.Add(totalPriceLabel, new Rectangle(1, 0.05, 0.25, 0.6));

            AbsoluteLayout.SetLayoutFlags(nameLabel, AbsoluteLayoutFlags.All);
            AbsoluteLayout.SetLayoutFlags(statusLabel, AbsoluteLayoutFlags.All);
            AbsoluteLayout.SetLayoutFlags(totalPriceLabel, AbsoluteLayoutFlags.All);

            var deleteItem = new MenuItem {
                Text = "Delete", IsDestructive = true
            };

            deleteItem.Clicked += OnDelete;

            ContextActions.Add(deleteItem);
            View = layout;
        }
Ejemplo n.º 3
0
        protected override void OnBindingContextChanged()
        {
            base.OnBindingContextChanged();

            var VM = BindingContext as CellViewModelBase;

            if (VM == null)
            {
                return;
            }
            ContextActions.Clear();
            if (VM.IsEditable)
            {
                var menuRemove = new MenuItem
                {
                    Text          = "Rimuovi",
                    IsDestructive = true
                };
                menuRemove.Clicked += (sender, e) =>
                {
                    var item = (CellViewModelBase)BindingContext; if (item == null)
                    {
                        return;
                    }
                };
            }
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 5
0
        public CPFavList()
        {
            var nameLabel = new Label()
            {
                FontFamily = "HelveticaNeue-Medium",
                FontSize   = 18,
                TextColor  = Color.Black
            };

            nameLabel.SetBinding(Label.TextProperty, "title");
            nameLabel.FontSize = Device.OnPlatform(
                Device.GetNamedSize(NamedSize.Small, nameLabel),
                16,
                Device.GetNamedSize(NamedSize.Small, nameLabel)
                );
            var vetDetailsLayout = new StackLayout
            {
                Padding           = new Thickness(10, 0, 0, 0),
                Spacing           = 0,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Children          = { nameLabel }
            };

            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, tapImage }
            };

            //------ Creating Contact Action 1 Start --------//
            var deleteAction = new MenuItem {
                Text = "Delete", IsDestructive = true
            };

            deleteAction.SetBinding(MenuItem.CommandParameterProperty, new Binding("."));
            deleteAction.Clicked += async(sender, e) =>
            {
                await Task.Run(() =>
                {
                    var mi = ((MenuItem)sender);

                    var favListItems = mi.CommandParameter as CPMobile.Models.Item;
                    FavoriteDataService.DeleteFavorite(favListItems);
                    //Debug.WriteLine("More Context Action clicked: " + mi.CommandParameter as CPMobile.Models.Item);
                });
            };
            ContextActions.Add(deleteAction);

            this.View = cellLayout;
        }
Ejemplo n.º 6
0
            public _46363Template_2()
            {
                var label = new Label();

                label.SetBinding(Label.TextProperty, ".");

                var innerStackLayout = new StackLayout {
                    Children = { label }, Padding = new Thickness(4, 4, 4, 10)
                };
                var outerStackLayout = new StackLayout {
                    Children = { innerStackLayout }
                };

                View = outerStackLayout;

                ContextActions.Add(new MenuItem
                {
                    Text    = ContextAction,
                    Command = s_contextCommand
                });

                innerStackLayout.GestureRecognizers.Add(new TapGestureRecognizer
                {
                    Command = s_tapCommand
                });
            }
Ejemplo n.º 7
0
        public ControlKitCell()
        {
            Label name = new Label();

            name.SetBinding(Label.TextProperty, "Name");

            if (_useRedBG)
            {
                name.BackgroundColor = Color.Red;
            }

            name.VerticalOptions = LayoutOptions.Center;

            Button useKit = null;

            if (!_useRedBG)
            {
                useKit      = new Button();
                useKit.Text = "Sortir produits";
                useKit.HorizontalOptions = LayoutOptions.EndAndExpand;

                useKit.Clicked += async(sender, e) => {
                    var answer = await((ControlKitPage)Parent.Parent.Parent).DisplayAlert("Attention", "Êtes vous sûr de vouloir sortir ce kit ?", "Oui", "Non");

                    if (answer)
                    {
                        MessagingCenter.Send <ListView, string> ((ListView)Parent, "useKit", name.Text);
                    }
                };
            }

            StackLayout layout = new StackLayout {
                Padding           = new Thickness(20, 0, 20, 0),
                Orientation       = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.StartAndExpand,
                Children          = { name }
            };

            if (useKit != null)
            {
                layout.Children.Add(useKit);
            }

            View = layout;

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

                    MessagingCenter.Send <ListView, ControlKit> ((ListView)Parent, IdMessage, (ControlKit)mi.CommandParameter);
                };

                ContextActions.Add(deleteAction);
            }
        }
Ejemplo n.º 8
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.º 9
0
            public TimeCell(TipScheduler scheduler, TimeSpan time)
            {
                Text    = "Om " + time.ToString(@"hh\:mm") + " uur";
                Command = new Command(async() =>
                {
                    await ShowSelectTimeAlert(scheduler, time);
                });
                //StyleId = "disclosure";
                var edit = new MenuItem
                {
                    Text = "Wijzig"
                };

                edit.Clicked += async(sender, e) =>
                {
                    await ShowSelectTimeAlert(scheduler, time);
                };
                var delete = new MenuItem
                {
                    Text          = "Verwijder",
                    IsDestructive = true
                };

                delete.Clicked += (sender, e) =>
                {
                    scheduler.RemoveTime(time);
                };
                ContextActions.Add(edit, delete);
            }
Ejemplo n.º 10
0
            public MyCell(NewPage1 myPage)
            {
                var label = new Label
                {
                    VerticalOptions = LayoutOptions.CenterAndExpand,
                };
                //label.SetBinding(Label.TextProperty, new Binding("."));

                var actionDelete = new MenuItem
                {
                    Text          = "Delete",
                    Command       = new Command(p => myPage.DisplayAlert("Delete", p.ToString(), "OK")),
                    IsDestructive = true,
                };

                actionDelete.SetBinding(MenuItem.CommandParameterProperty, new Binding("."));
                actionDelete.Clicked += (s, a) => myPage.Action((MenuItem)s);
                ContextActions.Add(actionDelete);

                View = new StackLayout
                {
                    Padding  = 10,
                    Children = { label }
                };
            }
Ejemplo n.º 11
0
            public MessageCell()
            {
                this.SetBinding(TextProperty, "Subject");
                this.SetBinding(DetailProperty, "MessagePreview");

                var delete = new MenuItem {
                    Text = "Delete", IsDestructive = true
                };

                delete.SetBinding(MenuItem.CommandProperty, "Delete");

                var mark = new MenuItem {
                    Text = "Mark", Icon = "calculator.png"
                };
                var move = new MenuItem {
                    Text = "Move"
                };

                //move.Clicked += async (sender, e) => await Navigation.PopAsync();

                ContextActions.Add(mark);
                ContextActions.Add(delete);
                ContextActions.Add(move);

                var clear = new MenuItem {
                    Text = "Clear Items"
                };

                clear.Clicked += (sender, args) => ContextActions.Clear();
                ContextActions.Add(clear);
            }
Ejemplo n.º 12
0
 public ViewCell32206()
 {
     View = new Label();
     View.SetBinding(Label.TextProperty, ".");
     ContextActions.Add(new MenuItem {
         Text = "Delete"
     });
 }
 private void Reset()
 {
     NameLabel.Text        = "";
     AmountLabel.Text      = "";
     MinusButton.IsVisible = false;
     Image.Source          = null;
     ContextActions.Clear();
 }
Ejemplo n.º 14
0
            public TestCell()
            {
                var menuItem = new MenuItem {
                    Text = "Test Item"
                };

                ContextActions.Add(menuItem);
            }
Ejemplo n.º 15
0
        public RandomUserCell()
        {
            this.Height = 85;
            img         = new CachedImage()
            {
                Margin             = new Thickness(8, 4, 4, 4),
                HeightRequest      = 65,
                WidthRequest       = 65,
                RetryCount         = 0,
                RetryDelay         = 250,
                LoadingPlaceholder = "placeholder.png",
                CacheDuration      = TimeSpan.FromDays(10),
                Transformations    = new System.Collections.Generic.List <ITransformation>()
                {
                    new CircleTransformation()
                },
            };
            img.Effects.Add(new ViewShadowEffect());

            lblFullName = new Label()
            {
                Margin = new Thickness(4, 2, 4, -4)
            };
            lblFullName.SetBinding(Label.TextProperty,
                                   new Binding(path: "FullName", converter: AppConverters.UpperText));

            lblFullAddress = new Label()
            {
                Style = CoreStyles.AddressCell
            };

            var rightPanel = new StackLayout()
            {
                Padding  = 0,
                Children = { lblFullName, lblFullAddress }
            };

            ContextActions.Add(new MenuItem()
            {
                Text          = "More Info",
                IsDestructive = true,
                Command       = new Command((obj) =>
                {
                    DependencyService.Get <IDialogPrompt>().ShowMessage(new Prompt()
                    {
                        Title   = "Row Selected",
                        Message = $"You chose {((RandomUser)BindingContext).FullName}"
                    });
                })
            });

            View = new CompressedStackLayout()
            {
                Orientation = StackOrientation.Horizontal,
                Children    = { img, rightPanel }
            };
        }
        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.RuntimePlatform == Device.iOS ? "Tip: swipe left 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 }
                    }
                }
            };
        }
Ejemplo n.º 17
0
        public ItemCell()
        {
            Label lblName = new Label {
                FontAttributes = FontAttributes.Bold
            };

            lblName.SetBinding(Label.TextProperty, "Name");
            Label lblDepartment = new Label {
                FontAttributes = FontAttributes.Italic
            };

            lblDepartment.SetBinding(Label.TextProperty, "Department");

            CheckBox Checked = new CheckBox()
            {
                TextColor = Color.Black,
                Checked   = false
            };

            Grid TableRow = new Grid();

            TableRow.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(5, GridUnitType.Star)
            });
            TableRow.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(3, GridUnitType.Star)
            });
            TableRow.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(2, GridUnitType.Star)
            });

            TableRow.Children.Add(lblName, 0, 0);
            TableRow.Children.Add(lblDepartment, 1, 0);
            TableRow.Children.Add(Checked, 2, 0);

            View = new StackLayout

            {
                Spacing  = 2,
                Padding  = 5,
                Children = { TableRow }//lblName, lblDepartment, Checked }
            };


            MenuItem mi = new MenuItem {
                Text = "Delete", IsDestructive = true
            };

            mi.Clicked += (sender, e) =>
            {
                ListView parent = (ListView)this.Parent;
                ObservableCollection <ListItem> list = (ObservableCollection <ListItem>)parent.ItemsSource;
                list.Remove(this.BindingContext as ListItem);
            };
            ContextActions.Add(mi);
        }
Ejemplo n.º 18
0
    public CustomCell(Page page)
    {
        var deleteAction = new MenuItem {
            Text = "Delete", IsDestructive = true
        };                                                                                 // red background

        deleteAction.SetBinding(MenuItem.CommandParameterProperty, new Binding("."));
        deleteButton.SetBinding(MenuItem.CommandProperty, new Binding("BindingContext.DeleteCommand", source: page));
        ContextActions.Add(deleteAction);
    }
Ejemplo n.º 19
0
            public ContextActionsCell()
            {
                ContextActions.Add(new MenuItem {
                    Text = "action"
                });
                var label = new Label();

                label.SetBinding(Label.TextProperty, "Name");
                View = label;
            }
Ejemplo n.º 20
0
            public CustomTextCell()
            {
                SetBinding(TextProperty, new Binding("Title"));
                var deleteMenuItem = new MenuItem();

                deleteMenuItem.Text          = "Delete";
                deleteMenuItem.IsDestructive = true;
                deleteMenuItem.SetBinding(MenuItem.CommandProperty, new Binding("DeleteItemCommand"));
                ContextActions.Add(deleteMenuItem);
            }
        public OpponentCell()
        {
            database = App.Database;

            // Display Opponents first name, last name, and phone number on main page
            var firstName = new Label();

            firstName.SetBinding(Label.TextProperty, "oFirstName");

            var lastName = new Label();

            lastName.SetBinding(Label.TextProperty, "oLastName");

            var phone = new Label();

            phone.SetBinding(Label.TextProperty, "oPhone");


            // Adding menu item for long click or swipe
            MenuItem menuItem = new MenuItem
            {
                Text          = "Delete Opponent?",
                IsDestructive = true
            };

            menuItem.Clicked += (sender, e) =>
            {
                // Get the parent's ListView
                ListView parent = (ListView)this.Parent;
                // Remove all matches and opponents
                database.DeleteAllMatches((this.BindingContext as Opponents).ID);
                database.DeleteOpponent(this.BindingContext as Opponents);
                //Update ItemsSource list
                parent.ItemsSource = database.GetAllOpponents();
            };

            ContextActions.Add(menuItem);
            // Place names side-by-side
            var nameStack = new StackLayout
            {
                Spacing     = 4,
                Orientation = StackOrientation.Horizontal,
                Children    = { firstName, lastName }
            };

            // Define what the content will look like
            View = new StackLayout
            {
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                Orientation       = StackOrientation.Horizontal,
                Spacing           = 25,
                Padding           = 10,
                Children          = { nameStack, phone }
            };
        }
Ejemplo n.º 22
0
        public ReminderCell()
        {
            StackLayout cellWrapper    = new StackLayout();
            StackLayout verticalLayout = new StackLayout();
            Label       top            = new Label()
            {
                HorizontalOptions = LayoutOptions.StartAndExpand,
                FontSize          = Device.GetNamedSize(NamedSize.Large, typeof(Label))
            };
            Label bottom = new Label()
            {
                FontSize          = Device.GetNamedSize(NamedSize.Small, typeof(Label)),
                HorizontalOptions = LayoutOptions.StartAndExpand,
                LineBreakMode     = LineBreakMode.TailTruncation
            };

            top.SetBinding(Label.TextProperty, "Title");
            bottom.SetBinding(Label.TextProperty, "Description");

            MenuItem editAction = new MenuItem {
                Text = "Edit"
            };

            editAction.SetBinding(MenuItem.CommandParameterProperty, new Binding("."));
            editAction.Clicked += async(sender, e) =>
            {
                MenuItem mi             = ((MenuItem)sender);
                ReminderDataStructure r = ((ReminderDataStructure)mi.CommandParameter);
                var addPage             = new ReminderCreationPage(top.Text, bottom.Text, r.Time);
                HomePage.notificationManager.deleteNotification(r);
                HomePage.dataAccess.DeleteReminder(r);
                await App.Current.MainPage.Navigation.PushModalAsync(addPage);
            };

            MenuItem deleteAction = new MenuItem {
                Text = "Delete", IsDestructive = true
            };

            deleteAction.SetBinding(MenuItem.CommandParameterProperty, new Binding("."));
            deleteAction.Clicked += (sender, e) =>
            {
                MenuItem mi             = ((MenuItem)sender);
                ReminderDataStructure r = ((ReminderDataStructure)mi.CommandParameter);
                HomePage.notificationManager.deleteNotification(r);
                HomePage.dataAccess.DeleteReminder(r);
            };
            ContextActions.Add(editAction);
            ContextActions.Add(deleteAction);

            verticalLayout.Orientation = StackOrientation.Vertical;
            verticalLayout.Children.Add(top);
            verticalLayout.Children.Add(bottom);
            cellWrapper.Children.Add(verticalLayout);
            View = cellWrapper;
        }
Ejemplo n.º 23
0
        private void CreateMenu()
        {
            var pdfAction = new MenuItem {
                Text = "Vis dokument"
            };

            pdfAction.SetBinding(MenuItem.CommandParameterProperty, new Binding("."));
            pdfAction.Clicked += (sender, e) =>
            {
                var             mi    = ((MenuItem)sender);
                MaintenanceTask _task = (MaintenanceTask)mi.CommandParameter;
                MaintenancePage mp    = new MaintenancePage();
                mp.ShowPDF(_task);
            };

            var doneAction = new MenuItem {
                Text = "Udført"
            };

            doneAction.SetBinding(MenuItem.CommandParameterProperty, new Binding("."));
            doneAction.Clicked += (sender, e) =>
            {
                var             mi    = ((MenuItem)sender);
                MaintenanceTask _task = (MaintenanceTask)mi.CommandParameter;

                MaintenancePage mp = new MaintenancePage();
                mp.SetDone(_task);
            };
            var mapAction = new MenuItem {
                Text = "Kort"
            };

            mapAction.SetBinding(MenuItem.CommandParameterProperty, new Binding("."));
            mapAction.Clicked += (sender, e) =>
            {
                var             mi    = ((MenuItem)sender);
                MaintenanceTask _task = (MaintenanceTask)mi.CommandParameter;
                MaintenancePage mp    = new MaintenancePage();
                mp.ShowOnMap(_task);
            };
            var StopTimeRegAction = new MenuItem {
                Text = "Stop"
            };

            StopTimeRegAction.SetBinding(MenuItem.CommandParameterProperty, new Binding("."));
            StopTimeRegAction.Clicked += async(sender, e) =>
            {
                MaintenanceDetail md = new MaintenanceDetail(new MaintenanceTask());
                md.StopCurrentJobRec();
            };
            //ContextActions.Add(pdfAction);
            //ContextActions.Add(mapAction);
            ContextActions.Add(doneAction);
            ContextActions.Add(StopTimeRegAction);
        }
Ejemplo n.º 24
0
        public Context(IGL gl, IContextInfra infra)
        {
            GL = gl;
            Infra = infra;
            Caps = new ContextCaps(gl);

            Create = new ContextObjectFactory(this);
            Bindings = new ContextBindings(this, Caps);
            States = new ContextStates(this, Caps);
            Actions = new ContextActions(this);
        }
Ejemplo n.º 25
0
        public SampleViewCell(Page page)
        {
            _page = page;

            foreach (var contextAction in CreateContextActions())
            {
                ContextActions.Add(contextAction);
            }

            this.View = CreateGrid();
        }
Ejemplo n.º 26
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.º 27
0
        public TestCell()
        {
            this.SetBinding(TextCell.TextProperty, "Text");

            ContextActions.Add(
                new ToolbarItem
            {
                Text    = "DELETE",
                Command = new Command(Delete)
            }
                );
        }
            public NoSelectionViewCellWithContextActions()
            {
                label = new Label();
                label.SetBinding(Label.TextProperty, ".");
                View = label;

                var delete = new MenuItem {
                    Text = "Delete"
                };

                ContextActions.Add(delete);
            }
Ejemplo n.º 29
0
 public UsersCell() : base()
 {
     ContextActions.Add(new MenuItem()
     {
         Text    = "Make Favorite",
         Command = new Command(async(obj) =>
         {
             var item = ((RandomUser)BindingContext);
             await CoreDependencyService.GetViewModel <AppViewModel>().AddToFavorites(item);
         })
     });
 }
Ejemplo n.º 30
0
        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;
            }
        }
Ejemplo n.º 31
0
        public RelayCardCell()
        {
            var label = new Label {
                YAlign = TextAlignment.Center
            };

            label.SetBinding(Label.TextProperty, "Name");

            this.Tapped += (sender, e) => {
                var b = (RelayCardCell)sender;
                var t = (RelayCard)b.BindingContext;
                var relayCardWebView = new RelayCardWebView();
                relayCardWebView.BindingContext = t;
                ((ContentPage)((StackLayout)((ListView)b.ParentView).ParentView).ParentView).Navigation.PushAsync(relayCardWebView);
            };

            var editAction = new MenuItem {
                Text = "Edit"
            };

            editAction.SetBinding(MenuItem.CommandParameterProperty, new Binding("."));
            editAction.Clicked += async(sender, e) => {
                var mi            = ((MenuItem)sender);
                var relayCardPage = new RelayCardPage();
                relayCardPage.BindingContext = (RelayCard)mi.CommandParameter;
                ((ContentPage)(((StackLayout)((ListView)(this.ParentView)).ParentView).ParentView)).Navigation.PushAsync(relayCardPage);
            };

            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);

                App.Database.DeleteCard(((RelayCard)mi.CommandParameter).ID);
                ((RelayCardListPage)(((StackLayout)((ListView)(this.ParentView)).ParentView).ParentView)).RefreshList();
            };

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

            var layout = new StackLayout {
                Padding           = new Thickness(20, 0, 0, 0),
                Orientation       = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.StartAndExpand,
                Children          = { label }
            };

            View = layout;
        }