Ejemplo n.º 1
0
 // Set next item in carousel view
 private void ShowNext(object sender, System.EventArgs e)
 {
     if (Carousel.Position != Carousel.ItemsSource.Count() - 1)
     {
         Carousel.ScrollTo(Carousel.Position + 1);
     }
 }
Ejemplo n.º 2
0
 // Set previous item in carousel view
 private void ShowPrevious(object sender, System.EventArgs e)
 {
     if (Carousel.Position != 0)
     {
         Carousel.ScrollTo(Carousel.Position - 1);
     }
 }
Ejemplo n.º 3
0
        private void Subscribe()
        {
            MessagingCenter.Subscribe <ProductListView, ProductItemDTO>(
                this, GlobalEventSender.PAYMENT_DELETE_PRODUCT, async(sender, arg) =>
            {
                bool choose = await DisplayAlert(
                    "Eliminar producto",
                    "¿Continuar?",
                    "Continuar",
                    "Cancelar");
                if (choose)
                {
                    modelContext.DeleteProduct(arg);
                }
            });

            MessagingCenter.Subscribe <ProductListView, object>(
                this, GlobalEventSender.PAYMENT_ADD_REDEEM_CODE, async(sender, arg) =>
            {
                await modelContext.AddRedeemCode();
            });

            MessagingCenter.Subscribe <ProductListView, object>(
                this, GlobalEventSender.PAYMENT_CONTINUE_TO_PAY, (sender, arg) =>
            {
                Carousel.ScrollTo(1);
            });

            MessagingCenter.Subscribe <UserInfoView, object>(
                this, GlobalEventSender.PAYMENT_COMFIRM_PAY, async(sender, arg) =>
            {
                if ((bool)arg)
                {
                    await modelContext.Submit();
                    return;
                }

                await DisplayAlert(
                    "Alerta",
                    "Verifique los datos proporcionados",
                    "Entendido");
            });

            MessagingCenter.Subscribe <ProductListView, int>(this, GlobalEventSender.PAYMENT_EDIT_PRODUCT_QUANTITY, (sender, arg) =>
            {
                modelContext.EditQuantity((int)arg);
            });
        }
Ejemplo n.º 4
0
        protected override async void OnAppearing()
        {
            //!((string)Carousel.CurrentItem).Equals(Path)
            Console.WriteLine("Current Path: " + ((BindingContext as ViewModel_DiaryEntry).Entry.PhotoLinks[Carousel.Position]));
            Console.WriteLine("Clicked Path" + Path);
            if (InEditState == true)
            {
                ToolbarDelete.IconImageSource = "baseline_delete_24.png";
            }
            else
            {
                ToolbarItems.Remove(ToolbarDelete);
            }


            await Task.Delay(50);//Just realised this is a thing that we need to use in order to scroll automatically more than one item on a carousel

            Carousel.ScrollTo(Path);
            base.OnAppearing();
        }
        private async void EntryAdded(object sender, EventArgs e)
        {
            //This function scrolls the carousel all the way to the end. When a new item is added to the end of the Itemsource.
            //This automatically triggers the Carousel_PositionChanged function as it goes towards the end, saving all subsequent entries.

            //In Xamarin Forms 5.0, there is an IOS bug where the ScrollTo function would always put the current item to the first entry,
            //The fix for this was to set the animate variable to false, so that on IOS it will still take the user to the last entry
            await Task.Delay(500); //Necessary to get the last page displayed as an Editing diary page

            Console.WriteLine("[EntryAdded] Number of Pages " + _viewModel.DiaryEntries.Count);
            if (Device.RuntimePlatform == Device.iOS)
            {
                int num = _viewModel.DiaryEntries.Count - 1;
                Console.WriteLine("Scrolling to position " + num);
                Carousel.ScrollTo(num, animate: false);
            }
            else if (Device.RuntimePlatform == Device.Android)
            {
                Carousel.ScrollTo(index: _viewModel.DiaryEntries.Count - 1);
            }
        }