Пример #1
0
        private static async void Viewcell_LongClick(object sender, EventArgs e)
        {
            CustomStackLayout data = sender as CustomStackLayout;
            string            path = (string)data.CustomData;
            Page pg       = new Page();
            var  platform = Services.XServices.Instance.GetService <Services.IPlatformSystem>();


            var action = await pg.DisplayActionSheet(Services.TranslateExtension.TranslateText("delete_question"), Services.TranslateExtension.TranslateText("cancel"), Services.TranslateExtension.TranslateText("delete"));

            if (action != Services.TranslateExtension.TranslateText("cancel"))
            {
                if (action == Services.TranslateExtension.TranslateText("delete"))
                {
                    platform.DeleteFile(path);
                    var db = Services.XServices.Instance.GetService <Services.IDatabase>();
                    if (data.IsPicture)
                    {
                        db.DeletePhoto(path);
                    }
                    else if (data.IsAudio)
                    {
                        db.DeleteAudio(path);
                    }

                    MidiaPanel.Children.Remove(data);
                    MidiaPanel.ForceLayout();
                }
            }
        }
Пример #2
0
        public static View CreateMediaItemForAudio(string path, double width = 90, double height = 90)
        {
            var platform = Services.XServices.Instance.GetService <Services.IPlatformSystem>();

            //audios.Add(path);

            var viewcell = new CustomStackLayout()
            {
                Orientation       = StackOrientation.Horizontal,
                VerticalOptions   = LayoutOptions.Start,
                HorizontalOptions = LayoutOptions.Start,
                Padding           = new Thickness(5, 5),
                IsAudio           = true,
                CustomData        = path,
                BackgroundColor   = Color.Transparent,
            };

            AFButton img = new AFButton
            {
                Text = "\uf028",
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                BackgroundColor   = (Color)Application.Current.Resources["UIFabButton"],
                TextColor         = (Color)Application.Current.Resources["UIFabButtonText"],
                WidthRequest      = width,
                HeightRequest     = height
            };


            viewcell.LongClick += Viewcell_LongClick;

            viewcell.Children.Add(img);

            //TapGestureRecognizer gesture = new TapGestureRecognizer();
            //gesture.Tapped += (object sender, EventArgs e) =>
            //{
            //    platform.PlayAudio(path);
            //};

            //viewcell.GestureRecognizers.Add(gesture);

            img.Clicked += (object sender, EventArgs e) =>
            {
                //AFButton bt = sender as AFButton;
                //if (!play)
                //{
                //bt.Text = "\uf04d";
                platform.PlayAudio(path);
                //    play = true;
                //}
                //else
                //{
                //    //bt.Text = "\uf028";
                //    platform.StopAudio();
                //    play = false;
                //}
            };

            return(viewcell);
        }
Пример #3
0
        public static View CreateMediaItemForImage(byte[] imagesource, string path, string date, double width = 90, double height = 90)
        {
            //images.Add(new ImageHelper() { ImageSource = imagesource, Path = path, Date = date });

            var viewcell = new CustomStackLayout()
                           //var viewcell = new CustomFrame()
            {
                VerticalOptions   = LayoutOptions.Start,
                HorizontalOptions = LayoutOptions.Start,
                Padding           = new Thickness(5, 5),
                BackgroundColor   = Color.Transparent,
                IsPicture         = true,
                CustomData        = path
            };

            FFImageLoading.Forms.CachedImage img = new FFImageLoading.Forms.CachedImage
            {
                HorizontalOptions = LayoutOptions.FillAndExpand,
                VerticalOptions   = LayoutOptions.FillAndExpand,
                BackgroundColor   = Color.Transparent,
                Source            = ImageSource.FromStream(() => new System.IO.MemoryStream(imagesource)),
                WidthRequest      = width,
                HeightRequest     = height,
            };

            viewcell.LongClick += Viewcell_LongClick;
            //viewcell.Content = img;
            //img.Transformations.Add(new FFImageLoading.Transformations.CircleTransformation());

            viewcell.Children.Add(img);

            TapGestureRecognizer gesture = new TapGestureRecognizer();

            gesture.Tapped += (object sender, EventArgs e) =>
            {
                var platform = Services.XServices.Instance.GetService <Services.IPlatformSystem>();
                platform.ShowPicture(path);
            };

            viewcell.GestureRecognizers.Add(gesture);

            return(viewcell);
        }