Esempio n. 1
0
        public ExpenseViewCell()
        {
            nameLabel = new Label {
                Style = (Style)App.Current.Resources["whiteTextLabel"]
            };
            shortDescriptionLabel = new Label {
                Style = (Style)App.Current.Resources["whiteTextLabel"], Font = Font.SystemFontOfSize(NamedSize.Small), TextColor = Color.FromRgb(200, 200, 200)
            };
            priceLabel = new Label {
                Style = (Style)App.Current.Resources["whiteTextLabel"]
            };
            dateLabel = new Label {
                Style = (Style)App.Current.Resources["whiteTextLabel"], Font = Font.SystemFontOfSize(NamedSize.Small), TextColor = Color.FromRgb(200, 200, 200)
            };

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

            layout.Children.Add(nameLabel, new Rectangle(0.05, 0.05, 0.75, 0.5));
            layout.Children.Add(shortDescriptionLabel, new Rectangle(0.05, 0.95, 0.75, 0.5));
            layout.Children.Add(priceLabel, new Rectangle(1, 0.05, 0.25, 0.5));
            layout.Children.Add(dateLabel, new Rectangle(1, 0.95, 0.25, 0.5));

            AbsoluteLayout.SetLayoutFlags(nameLabel, AbsoluteLayoutFlags.All);
            AbsoluteLayout.SetLayoutFlags(shortDescriptionLabel, AbsoluteLayoutFlags.All);
            AbsoluteLayout.SetLayoutFlags(priceLabel, AbsoluteLayoutFlags.All);
            AbsoluteLayout.SetLayoutFlags(dateLabel, AbsoluteLayoutFlags.All);

            nameLabel.SetBinding(Label.TextProperty, "Name");
            shortDescriptionLabel.SetBinding(Label.TextProperty, "ShortDescription");
            priceLabel.SetBinding(Label.TextProperty, "FormattedPrice");
            dateLabel.SetBinding(Label.TextProperty, "FormattedDate");

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

            deleteItem.Clicked += OnDelete;

            ContextActions.Add(deleteItem);
            View = layout;
        }
Esempio n. 2
0
        public GeStockItemCell()
        {
            Label name = new Label();

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

            Label quantity = new Label();

            quantity.SetBinding(Label.TextProperty, "Quantity");
            quantity.TextColor         = Color.Gray;
            quantity.HorizontalOptions = LayoutOptions.EndAndExpand;

            name.VerticalOptions = quantity.VerticalOptions = LayoutOptions.Center;

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

            View = layout;

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

            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, GeStockItem> ((ListView)Parent, IdMessage, (GeStockItem)mi.CommandParameter);
                };

                ContextActions.Add(deleteAction);
            }
        }
Esempio n. 3
0
        //Custom cell for displaying tickets
        public CustomImageCell()
        {
            var moreAction = new MenuItem {
                Text = "View Ticket"
            };

            moreAction.SetBinding(MenuItem.CommandParameterProperty, new Binding("."));
            moreAction.Clicked += MoreAction_Clicked;

            var deleteAction = new MenuItem {
                Text = "Delete Ticket", IsDestructive = true
            };                                                                                // red background

            deleteAction.SetBinding(MenuItem.CommandParameterProperty, new Binding("."));
            deleteAction.Clicked += DeleteAction_Clicked;

            ContextActions.Add(moreAction);
            ContextActions.Add(deleteAction);
        }
Esempio n. 4
0
        /**
         * Display option for the match cell and how it will be displayed on page
         * */
        public matchCell()
        {
            database = App.Database;

            lblFullName = new Label {
                FontAttributes = FontAttributes.Bold
            };

            Label lblDate = new Label {
                FontSize = 12
            };

            lblDate.SetBinding(Label.TextProperty, "mDate", stringFormat: "{0:D}");

            lblGameName = new Label {
                FontSize = 12
            };
            // Menu item to be able to delete a match
            MenuItem menuItem = new MenuItem
            {
                Text          = "Delete Match?",
                IsDestructive = true
            };

            menuItem.Clicked += (sender, e) =>
            {
                // Get parent's list to remove item
                ListView parent = (ListView)this.Parent;
                // Remove item from database
                database.DeleteMatch(this.BindingContext as Matches);
                // Update list
                parent.ItemsSource = database.GetAllMatches();
            };

            ContextActions.Add(menuItem);

            View = new StackLayout
            {
                Spacing  = 2,
                Padding  = 5,
                Children = { lblFullName, lblDate, lblGameName }
            };
        }
Esempio n. 5
0
        private void inicializarMenu()
        {
            var excluiPercurso = new MenuItem
            {
                Text = "Excluir"
            };

            excluiPercurso.SetBinding(MenuItem.CommandParameterProperty, new Binding("."));
            excluiPercurso.Clicked += (sender, e) =>
            {
                PercursoInfo percurso      = (PercursoInfo)((MenuItem)sender).BindingContext;
                PercursoBLL  regraPercurso = PercursoFactory.create();
                regraPercurso.excluir(percurso.Id);

                ListView percursoListView = this.Parent as ListView;

                percursoListView.SetBinding(ListView.ItemsSourceProperty, new Binding("."));

                var percursos = regraPercurso.listar();
                percursoListView.BindingContext = percursos;
                percursoListView.ItemTemplate   = new DataTemplate(typeof(PercursoPageCell));
            };

            var simulaPercurso = new MenuItem
            {
                Text = "Simular"
            };

            simulaPercurso.SetBinding(MenuItem.CommandParameterProperty, new Binding("."));
            simulaPercurso.Clicked += (sender, e) =>
            {
                PercursoInfo percurso = (PercursoInfo)((MenuItem)sender).BindingContext;
                if (percurso != null)
                {
                    GPSUtils.simularPercurso(percurso.Id);
                }
                OnAppearing();
            };

            ContextActions.Add(simulaPercurso);
            ContextActions.Add(excluiPercurso);
        }
        public CustomAssessmentCell()
        {
            var deleteAction = new MenuItem {
                Text = "Delete", IsDestructive = true
            };

            ContextActions.Add(deleteAction);

            //instantiate each of our views
            //var image = new Image();
            StackLayout cellWrapper      = new StackLayout();
            StackLayout horizontalLayout = new StackLayout();
            Label       orgName          = new Label();
            Label       trackingNo       = new Label();

            trackingNo.FontSize  = 10;
            trackingNo.TextColor = Color.Gray;
            Label status = new Label();

            //status.Text = "Not Started";
            status.FontSize  = 10;
            status.TextColor = Color.Gray;

            //set bindings
            trackingNo.SetBinding(Label.TextProperty, "AssessmentTrackingNumber");
            orgName.SetBinding(Label.TextProperty, "OrganizationName");
            status.SetBinding(Label.TextProperty, "AssessmentStatus");
            //image.SetBinding(Image.SourceProperty, "image");

            //Set properties for desired design
            //cellWrapper.BackgroundColor = Color.FromHex("#eee");
            horizontalLayout.Orientation = StackOrientation.Horizontal;
            status.HorizontalOptions     = LayoutOptions.EndAndExpand;

            //add views to the view hierarchy
            //horizontalLayout.Children.Add(image);
            cellWrapper.Children.Add(orgName);
            horizontalLayout.Children.Add(trackingNo);
            horizontalLayout.Children.Add(status);
            cellWrapper.Children.Add(horizontalLayout);
            View = cellWrapper;// horizontalLayout;//cellWrapper;
        }
Esempio n. 7
0
        public MyCell(MyPage 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);

            var actionAdd = new MenuItem
            {
                Text = "Add",
            };

            actionAdd.SetBinding(MenuItem.CommandParameterProperty, new Binding("."));

            //actionAdd.Clicked += async (s, e) =>
            //{
            //    var itemMenu = ((MenuItem)s);
            //    await myPage.DisplayAlert(itemMenu.Text, (string)itemMenu.CommandParameter, "OK");
            //};

            actionAdd.Clicked += (s, a) => myPage.Action((MenuItem)s);
            ContextActions.Add(actionAdd);

            View = new StackLayout
            {
                Padding  = 10,
                Children = { label }
            };
        }
Esempio n. 8
0
            public TestCell()
            {
                _content = new Label();

                if (s_index % 2 == 0)
                {
                    _content.GestureRecognizers.Add(new TapGestureRecognizer
                    {
                        Command = new Command(() =>
                        {
                            s_tapGestureFired.Text = TapGestureSucess;
                        })
                    });
                }

                View = _content;
                ContextActions.Add(new MenuItem {
                    Text = s_index++ + " Action"
                });
            }
 private void inicializarExcluirButton()
 {
     _excluirButton = new MenuItem
     {
         CommandParameter = "{Binding .}",
         Text             = "Excluir",
         IsDestructive    = true
     };
     _excluirButton.Clicked += (object sender, EventArgs e) =>
     {
         RadarInfo radar      = (RadarInfo)((MenuItem)sender).BindingContext;
         RadarBLL  regraRadar = RadarFactory.create();
         regraRadar.excluir(radar);
         var radarListView = (ListView)this.Parent;
         var contentPagina = (ContentPage)radarListView.Parent;
         var pagina        = (RadarListaPage)contentPagina.Parent;
         pagina.atualizarRadar();
     };
     ContextActions.Add(_excluirButton);
 }
Esempio n. 10
0
            public _46363Template()
            {
                var label = new Label();

                label.SetBinding(Label.TextProperty, ".");
                View = new StackLayout {
                    Children = { label }
                };

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

                View.GestureRecognizers.Add(new TapGestureRecognizer
                {
                    Command = s_tapCommand
                });
            }
Esempio n. 11
0
        public DebtCell()
        {
            InitializeComponent();

            var deleteAction = new MenuItem {
                Text = AppStrings.PayDebt, IsDestructive = true, Icon = "substract"
            };

            deleteAction.Clicked += (s, a) =>
            {
                var argument = new DebtManipulationViewModel
                {
                    Id     = Debt?.Id,
                    Name   = Debt?.Name,
                    Amount = Debt.Balance
                };
                MessagingCenter.Send(this, "deleted", argument);
            };

            ContextActions.Add(deleteAction);
        }
Esempio n. 12
0
            public ContextActionTemplate()
            {
                MenuItem newMenuItem = new MenuItem {
                    Text = "Click"
                };

                newMenuItem.Clicked += NewMenuItem_Clicked;
                ContextActions.Add(newMenuItem);

                View = new StackLayout {
                    Children =
                    {
                        new Label {
                            Text              = "Click and hold",
                            AutomationId      = "ListViewItem",
                            VerticalOptions   = LayoutOptions.Center,
                            HorizontalOptions = LayoutOptions.Center
                        }
                    }
                };
            }
Esempio n. 13
0
        void SetMenuItem(MainPage main)
        {
            var actionDelete = new MenuItem()
            {
                Text = "削除",
            };

            actionDelete.SetBinding(MenuItem.CommandParameterProperty, new Binding("."));
            actionDelete.Clicked += (s, e) => main.Action((MenuItem)s);


            var detail = new MenuItem()
            {
                Text = "会計",
            };

            detail.SetBinding(MenuItem.CommandParameterProperty, new Binding("."));
            detail.Clicked += (s, e) => main.Action((MenuItem)s);
            ContextActions.Add(detail);
            ContextActions.Add(actionDelete);
        }
Esempio n. 14
0
        public MyModelListCell()
        {
            TextColor = MainTabbedPage.barColor;    // COLOR OF MENU ITEMS IN MY NETWORKS PAGE
            // DetailColor = Color.Brown;

            var renameAction = new MenuItem {
                Text = "Rename"
            };

            renameAction.SetBinding(MenuItem.CommandParameterProperty, new Binding("."));
            renameAction.Clicked += async(object sender, EventArgs e) => {
                var mi        = ((MenuItem)sender);
                var modelInfo = (ModelInfo)(mi.CommandParameter);
                RenamePage.renameModelInfo = modelInfo;
                await MainTabbedPage.theModelListPageNavigation.PushAsync(new RenamePage());
            };
            ContextActions.Add(renameAction);

            var deleteAction = new MenuItem {
                Text = "Delete", IsDestructive = true
            };                                                                         // red background

            deleteAction.SetBinding(MenuItem.CommandParameterProperty, new Binding("."));
            deleteAction.Clicked += async(object sender, EventArgs e) => {
                var mi        = ((MenuItem)sender);
                var modelInfo = (ModelInfo)(mi.CommandParameter);
                var ok        = await MainTabbedPage.theModelEntryPage.DisplayAlert("Confirm delete", modelInfo.title, "Ok", "Cancel");

                if (ok)
                {
                    if (File.Exists(modelInfo.filename))
                    {
                        File.Delete(modelInfo.filename);
                        MainTabbedPage.theModelEntryPage.SetModel(new ModelInfo(), editable: true);
                    }
                    MainTabbedPage.theModelListPage.RegenerateList();
                }
            };
            ContextActions.Add(deleteAction);
        }
            public textViewCell()
            {
                StackLayout layout = new StackLayout();

                layout.Padding = new Thickness(15, 0);
                Label SafetyLabel = new Label();

                SafetyLabel.SetBinding(Label.TextProperty, ".");
                SafetyLabel.TextColor = Color.Black;
                layout.Children.Add(SafetyLabel);


                var deleteAction = new MenuItem {
                    Text = "Delete", IsDestructive = true
                };                                                                         // red background shown on iphone

                deleteAction.SetBinding(MenuItem.CommandParameterProperty, new Binding("."));
                deleteAction.Clicked += OnDelete;

                ContextActions.Add(deleteAction);
                View = layout;
            }
Esempio n. 16
0
            public ICell()
            {
                var label = new Label();

                label.SetBinding(Label.TextProperty, "Description");
                label.AutomationId = "pandabear";
                var menu = new MenuItem {
                    Text = "Remove"
                };

                menu.Command = new Command(() => ((ListItemViewModel)BindingContext).Remove.Execute((this, BindingContext)));
                ContextActions.Add(menu);
                var stack = new StackLayout
                {
                    Children =
                    {
                        label
                    }
                };

                View = stack;
            }
Esempio n. 17
0
        public CustomQuestionCell()
        {
            //var createAction = new MenuItem { Text = "Créer" };
            //createAction.SetBinding(MenuItem.CommandParameterProperty, new Binding("."));
            //createAction.Clicked += (sender, e) =>
            //{
            //    var mi = ((MenuItem)sender);
            //    var quest = (QuestionAnswerViewModel)mi.CommandParameter;
            //    ((ContentPage)((StackLayout)((ListView)Parent).Parent).Parent).Navigation.PushAsync(new CreateQuestionAnswer(quest));
            //};
            var editAction = new MenuItem {
                Text = "Editer"
            };

            editAction.SetBinding(MenuItem.CommandParameterProperty, new Binding("."));
            editAction.Clicked += (sender, e) =>
            {
                var mi    = ((MenuItem)sender);
                var quest = (QuestionAnswerViewModel)mi.CommandParameter;
                ((ContentPage)((StackLayout)((ListView)Parent).Parent).Parent).Navigation.PushAsync(new CreateQuestionAnswer(quest));
            };

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

            deleteAction.SetBinding(MenuItem.CommandParameterProperty, new Binding("."));
            deleteAction.Clicked += (sender, e) =>
            {
                var mi      = ((MenuItem)sender);
                var quest   = (QuestionAnswerViewModel)mi.CommandParameter;
                int deleted = quest.DeleteQuestionById(quest.QuestionId);
                ((ContentPage)((StackLayout)((ListView)Parent).Parent).Parent).DisplayAlert("Info", "La question a été supprimée!", "OK");
            };

            //ContextActions.Add(createAction);
            ContextActions.Add(editAction);
            ContextActions.Add(deleteAction);
        }
Esempio n. 18
0
        private void inicializarMenu()
        {
            var removerButton = new MenuItem
            {
                Text          = "Remover",
                Icon          = "fa-remove",
                IsDestructive = true,
                //IconColor = Estilo.Current.BarTitleColor,
            };

            removerButton.SetBinding(MenuItem.CommandParameterProperty, new Binding("."));
            removerButton.Clicked += (sender, e) =>
            {
                var menu      = (MenuItem)sender;
                var listaPage = buscarPagina(this.Parent);
                if (listaPage != null)
                {
                    var cartao = (CartaoInfo)menu.CommandParameter;
                    listaPage.excluir(cartao);
                }
            };
            ContextActions.Add(removerButton);
        }
        protected override void OnBindingContextChanged()
        {
            base.OnBindingContextChanged();
            Reset();

            if (ViewModel != null)
            {
                var foodstuff  = ViewModel.Foodstuff;
                var amountText = ViewModel.RequiredAmount.Match(
                    a => $"{ViewModel.Amount} / {a} {foodstuff.BaseAmount.Unit.ToString()}",
                    _ => foodstuff.BaseAmount.WithCount(ViewModel.Amount).ToString()
                    );

                NameLabel.Text        = ViewModel.Foodstuff.Name;
                AmountLabel.Text      = amountText;
                MinusButton.IsVisible = ViewModel.OnMinus != null;
                Image.Source          = ViewModel.Foodstuff.ImageUrl;

                var actions = ViewModel.MenuActions.Select(a => Controls.Controls.MenuItem(a));
                ContextActions.Clear();
                actions.ForEach(a => ContextActions.Add(a));
            }
        }
Esempio n. 20
0
            public CaCell()
            {
                var label = new Label();

                label.SetBinding(Label.TextProperty, new Binding("."));
                var menu = new MenuItem {
                    Text = "Delete", IsDestructive = true
                };

                menu.SetBinding(MenuItem.CommandParameterProperty, new Binding("."));
                var menu1 = new MenuItem {
                    Text = "Settings"
                };

                menu1.SetBinding(MenuItem.CommandParameterProperty, new Binding("."));
                ContextActions.Add(menu);
                ContextActions.Add(menu1);

                var stack = new StackLayout();

                stack.Children.Add(label);
                View = stack;
            }
Esempio n. 21
0
            public PendingScriptTextCell()
            {
                MenuItem deleteMenuItem = new MenuItem {
                    Text = "Delete", IsDestructive = true
                };

                deleteMenuItem.SetBinding(MenuItem.CommandParameterProperty, ".");
                deleteMenuItem.Clicked += async(sender, e) =>
                {
                    Script scriptToDelete = (sender as MenuItem).CommandParameter as Script;

                    if (SensusServiceHelper.Get().RemoveScripts(scriptToDelete))
                    {
                        await SensusServiceHelper.Get().IssuePendingSurveysNotificationAsync(PendingSurveyNotificationMode.Badge, scriptToDelete.Runner.Probe.Protocol);
                    }

                    // let the script agent know and store a datum to record the event
                    await(scriptToDelete.Runner.Probe.Agent?.ObserveAsync(scriptToDelete, ScriptState.Deleted) ?? Task.CompletedTask);
                    scriptToDelete.Runner.Probe.Protocol.LocalDataStore.WriteDatum(new ScriptStateDatum(ScriptState.Deleted, DateTimeOffset.UtcNow, scriptToDelete), CancellationToken.None);
                };

                ContextActions.Add(deleteMenuItem);
            }
        public EditoraListViewCell()
        {
            InitializeComponent();

            lblNome.SetBinding(Label.TextProperty, nameof(Editora.Nome));
            lblCodigo.SetBinding(Label.TextProperty, nameof(Editora.Codigo));
            lblSite.SetBinding(Label.TextProperty, nameof(Editora.Site));

            var detalhesAction = new MenuItem {
                Text = "Detalhes"
            };

            detalhesAction.Clicked += DetalhesAction_Clicked;

            var excluirAction = new MenuItem {
                Text = "Excluir", IsDestructive = true
            };

            excluirAction.Clicked += ExcluirAction_Clicked;

            ContextActions.Add(detalhesAction);
            ContextActions.Add(excluirAction);
        }
Esempio n. 23
0
        public PageTwoCell()
        {
            try
            {
                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 }
                };
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Esempio n. 24
0
        public DatatumCell()
        {
            this.Height = 45;

            lblFullName = new Label()
            {
                Margin = new Thickness(10, 10, 10, 10)
            };
            lblFullName.SetBinding(Label.TextProperty,
                                   new Binding(path: "name"));


            ContextActions.Add(new MenuItem()
            {
                Text          = "More Info",
                IsDestructive = true,
                Command       = new Command((obj) =>
                {
                    Device.BeginInvokeOnMainThread(() => {
                        var n = ((Datum)BindingContext).name;
                        DependencyService.Get <IDialogPrompt>().ShowMessage(new Prompt()
                        {
                            Title        = "Row Selected",
                            Message      = $"You chose {((Datum)BindingContext).name}",
                            ButtonTitles = new string[] { "OK" }
                        });
                    });
                })
            });

            View = new StackContainer(true)
            {
                Orientation = StackOrientation.Horizontal,
                Children    = { lblFullName }
            };
        }
Esempio n. 25
0
            public ListItemCell()
            {
                Label titleLabel = new Label
                {
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                    FontSize          = 25,
                    FontAttributes    = Xamarin.Forms.FontAttributes.Bold,
                    TextColor         = Color.White
                };

                titleLabel.SetBinding(Label.TextProperty, "Title");

                Label descLabel = new Label
                {
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                    FontSize          = 12,
                    TextColor         = Color.White
                };

                descLabel.SetBinding(Label.TextProperty, "Description");


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

                Label priceLabel = new Label
                {
                    HorizontalOptions = LayoutOptions.End,
                    FontSize          = 25,
                    TextColor         = Color.Aqua
                };

                priceLabel.SetBinding(Label.TextProperty, "Price");

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

                View = viewLayout;

                var moreAction = new MenuItem {
                    Text = "More"
                };

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

                deleteAction.SetBinding(MenuItem.CommandParameterProperty, new Binding("."));
                deleteAction.Clicked += (sender, e) =>
                {
                    var mi   = ((MenuItem)sender);
                    var item = (ListItem)mi.CommandParameter;
                    Debug.WriteLine("Delete clicked on row: " + item.Title.ToString());
                    //((ContentPage)((ListView)viewLayout.ParentView).ParentView).DisplayAlert("Delete Clicked", "On row: " + item.Title.ToString(), "OK");
                };
                ContextActions.Add(moreAction);
                ContextActions.Add(deleteAction);
            }
        public DogPhotoBlobViewCell()
        {
            var dogImage = new Image()
            {
            };
            var myTextProperty = new Label()
            {
            };                                               //Text = "Text" };
            var myDetailProperty = new Label()
            {
            };                                                  //Text = "Details" };

            var model = BindingContext as Dog;

            //			dogImage.SetBinding(Image.SourceProperty, nameof(model.DogPictureSource));
            dogImage.SetBinding(Image.SourceProperty, nameof(model.DogPictureURLBlob));
            myTextProperty.SetBinding(Label.TextProperty, nameof(model.Name));
            myDetailProperty.SetBinding(Label.TextProperty, nameof(model.FurColor));


            var textStack = new StackLayout
            {
                //Padding = 10, //E
                //HorizontalOptions = LayoutOptions.FillAndExpand, //NE
                Margin = new Thickness(0, 3, 0, 0),
                //VerticalOptions = LayoutOptions.FillAndExpand, //NE
                Orientation = StackOrientation.Vertical,
                Children    =
                {
                    myTextProperty,
                    myDetailProperty
                }
            };

            var cellLayoutStack = new StackLayout
            {
                Margin = new Thickness(0, 0, 0, 0),
                //Spacing = 10, //default is 6
                Orientation = StackOrientation.Horizontal,
                Children    =
                {
                    dogImage,
                    textStack
                }
            };

            View = cellLayoutStack;


            //MenuItem ITEM AND CONTEXT ACTIONS

            //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);
            //};
            // add to the ViewCell's ContextActions property
            //ContextActions.Add(moreAction);


            _deleteAction = new MenuItem {
                Text = "Delete", IsDestructive = true
            };                                                                                  // red background
            _deleteAction.SetBinding(MenuItem.CommandParameterProperty, new Binding("."));

            //_deleteAction.Clicked += async (sender, e) =>
            //{
            //    var mi = ((MenuItem)sender);
            //    Debug.WriteLine("Delete Context Action clicked: " + mi.CommandParameter);
            //};

            ContextActions.Add(_deleteAction);
        }
Esempio n. 27
0
            void Init(bool fast)
            {
                _photo = new Image
                {
                    HeightRequest = 52,
                    WidthRequest  = 52,
                };


                _mainLabel = new Label()
                {
                    HeightRequest = 40, FontSize = 24, TranslationY = 5, LineBreakMode = LineBreakMode.TailTruncation
                };
                _mainLabel.SetBinding(Label.TextProperty, "PrimaryLabelText");

                _secondaryLabel = new Label()
                {
                    HeightRequest = 40, FontSize = 16, TranslationY = -5, LineBreakMode = LineBreakMode.TailTruncation
                };
                _secondaryLabel.SetBinding(Label.TextProperty, "SecondaryLabelText");

#pragma warning disable 618
                _distanceLabel = new Label()
                {
                    XAlign = TextAlignment.End, HorizontalOptions = LayoutOptions.EndAndExpand, FontSize = 11, LineBreakMode = LineBreakMode.NoWrap
                };
#pragma warning restore 618
                _distanceLabel.SetBinding(Label.TextProperty, "OtherLabelText");

                _statusCircle = new Label()
                {
                    HorizontalOptions = LayoutOptions.EndAndExpand,
                    FontSize          = 30,
                    TranslationY      = 0,
                };

                _primaryContent = new StackLayout()
                {
                    HorizontalOptions = LayoutOptions.StartAndExpand,
                    Orientation       = StackOrientation.Vertical,
                    Children          =
                    {
                        _mainLabel,
                        _secondaryLabel,
                    },
                    Padding = new Thickness(12, 0, 0, 0),
                };

                _secondaryContent = new StackLayout()
                {
                    MinimumWidthRequest = 50,
                    HorizontalOptions   = LayoutOptions.EndAndExpand,
                    Children            =
                    {
                        _distanceLabel,
                        _statusCircle,
                    },
                    Padding = new Thickness(0, 5, 5, 0),
                };

                _stackLayout = new StackLayout
                {
                    Orientation = StackOrientation.Horizontal,
                    Children    =
                    {
                        _photo,
                        _primaryContent,
                        _secondaryContent,
                    },
                    Padding = new Thickness(5, 0, 0, 0)
                };

                if (!fast)
                {
                    View = _stackLayout;
                }
                else
                {
                    _quickCompleteMenu = new MenuItem {
                        Text = "Complete", IsDestructive = false
                    };
                    _quickCompleteMenu.SetBinding(MenuItem.CommandParameterProperty, new Binding("."));

                    // Delete context menu action
                    _quickCompleteMenu.Clicked += (sender, e) =>
                    {
                        FastCompleteForCmd(sender);
                    };

                    // Add this action to the cell
                    ContextActions.Add(_quickCompleteMenu);

                    _masterLayout = new AbsoluteLayout();

                    _masterLayout.Children.Add(_stackLayout);

                    AbsoluteLayout.SetLayoutFlags(_stackLayout, AbsoluteLayoutFlags.All);
                    AbsoluteLayout.SetLayoutBounds(_stackLayout, new Rectangle(0.0, 0.0, 1.0f, 1.0f));

                    View = _masterLayout;
                }
            }
        protected override void OnAppearing()
        {
            base.OnAppearing();

            ContextActions.Add(_menuItem);
        }
        public OpportunitiesViewCell()
        {
            var model = BindingContext as OpportunityModel;

            #region Create Image
            var beaconFundingImage = new Image {
                Source = "beaconfundingicon"
            };
            #endregion

            #region Create Topic Stack
            var topicLabel = new Label
            {
                Text           = "Topic",
                FontAttributes = FontAttributes.Bold
            };

            var topic = new Label();
            topic.SetBinding(Label.TextProperty, nameof(model.Topic));

            var topicStack = new StackLayout
            {
                Children =
                {
                    topicLabel,
                    topic
                }
            };
            #endregion

            #region Create Company
            var companyLabel = new Label
            {
                Text           = "Company",
                FontAttributes = FontAttributes.Bold
            };

            var company = new Label();
            company.SetBinding(Label.TextProperty, nameof(model.Company));

            var companyStack = new StackLayout
            {
                Children =
                {
                    companyLabel,
                    company
                }
            };
            #endregion

            #region Create LeaseAmount
            var leaseAmountLabel = new Label
            {
                Text           = "LeaseAmount",
                FontAttributes = FontAttributes.Bold
            };

            var leaseAmount = new Label();
            leaseAmount.SetBinding(Label.TextProperty, nameof(model.LeaseAmountAsCurrency));

            var leaseAmountStack = new StackLayout
            {
                Children =
                {
                    leaseAmountLabel,
                    leaseAmount
                }
            };
            #endregion

            #region Create LeaseAmount
            var ownerLabel = new Label
            {
                Text           = "Owner",
                FontAttributes = FontAttributes.Bold
            };

            var owner = new Label();
            owner.SetBinding(Label.TextProperty, nameof(model.Owner));

            var ownerStack = new StackLayout
            {
                Children =
                {
                    ownerLabel,
                    owner
                }
            };
            #endregion

            #region Create MenuItem
            _deleteAction = new MenuItem
            {
                Text          = "Delete",
                IsDestructive = true
            };
            ContextActions.Add(_deleteAction);
            #endregion

            StackLayout cellStack;
            #region Create Cell Horizontal StackLayout for Phone
            if (Device.Idiom == TargetIdiom.Phone)
            {
                topic.LineBreakMode = LineBreakMode.NoWrap;
                cellStack           = new StackLayout
                {
                    HorizontalOptions = LayoutOptions.Fill,
                    Padding           = 10,
                    Spacing           = 20,
                    Orientation       = StackOrientation.Horizontal,
                    Children          =
                    {
                        beaconFundingImage,
                        topicStack
                    }
                };
            }
            #endregion

            #region Create Cell Horizontal StackLayout for Tablet or Desktop
            else
            {
                cellStack = new StackLayout
                {
                    HorizontalOptions = LayoutOptions.Fill,
                    Padding           = 10,
                    Spacing           = 20,
                    Orientation       = StackOrientation.Horizontal,
                    Children          =
                    {
                        beaconFundingImage,
                        topicStack,
                        companyStack,
                        leaseAmountStack,
                        ownerStack
                    }
                };
            }
            #endregion

            View = cellStack;
        }
        public NotificationCellView()
        {
            cellWrapper = new StackLayout()
            {
                VerticalOptions = LayoutOptions.FillAndExpand, Orientation = StackOrientation.Horizontal, Spacing = 15
            };
            time = new Label()
            {
                Text = "", HorizontalOptions = LayoutOptions.EndAndExpand, VerticalTextAlignment = TextAlignment.Center, LineBreakMode = LineBreakMode.NoWrap, TextColor = Color.FromHex("#888888")
            };
            separator = new BoxView()
            {
                Color = Color.Black, HeightRequest = 1
            };
            messageLayout = new StackLayout()
            {
                Spacing = 10, HorizontalOptions = LayoutOptions.FillAndExpand
            };
            icon        = new Image();
            icon.Source = Icon;
            title       = new Label()
            {
                FontAttributes = FontAttributes.Bold, VerticalTextAlignment = TextAlignment.Center
            };
            message = new Label()
            {
                VerticalTextAlignment = TextAlignment.Center, VerticalOptions = LayoutOptions.Center
            };
            cellWrapper.Children.Add(icon);
            messageLayout.Children.Add(title);
            messageLayout.Children.Add(message);
            //messageLayout.Children.Add(separator);
            messageLayout.Children.Add(time);
            cellWrapper.Children.Add(messageLayout);
            if (Device.RuntimePlatform == Device.iOS)
            {
                cellWrapper.BackgroundColor = Color.White;
            }

            cellWrapper.Padding = new Thickness(20, 10, 10, 10);
            View = cellWrapper;



            var deleteAction = new MenuItem {
                Text = AppResources.SupprimerBouton, IsDestructive = true
            };                                                                                                         // red background

            deleteAction.SetBinding(MenuItem.CommandParameterProperty, new Binding("notificationDeleteAction"));
            deleteAction.Clicked += async(sender, e) =>
            {
                try
                {
                    var notification = await DatabaseHelper.Database.GetItem <Notification>(NoSeq);

                    App.NotificationManager.DeleteNotification(notification);
                }
                catch (Exception ex)
                {
                    Debug.WriteLine("Notification Delete: " + ex.Message);
                }
            };

            // add to the ViewCell's ContextActions property
            ContextActions.Add(deleteAction);
            SetTime();
        }