Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何访问图片Xamarin.Forms,SQLite,C#_C#_Sqlite_Xamarin.forms - Fatal编程技术网

如何访问图片Xamarin.Forms,SQLite,C#

如何访问图片Xamarin.Forms,SQLite,C#,c#,sqlite,xamarin.forms,C#,Sqlite,Xamarin.forms,我正在创建一个移动应用程序,用户可以发布带有图片和文本的广告。我正在使用詹姆斯·蒙特马诺的媒体插件。这很有效。此外,用户应该能够点击图片进行查看,并可能删除。我不知道如何访问这些图片,我不知道它们存储在哪里,所以即使我想删除它们,我也不知道如何访问每个图片。你能帮帮我吗? 用户可以拍摄多张图像,然后将其显示在主页上。我希望用户能够再次审查他们,然后如果他继续与他们的第二页,他将上传一些其他数据,在第三页,它应该都显示在一起。如何在第三页上显示图片 public partial class Add

我正在创建一个移动应用程序,用户可以发布带有图片和文本的广告。我正在使用詹姆斯·蒙特马诺的媒体插件。这很有效。此外,用户应该能够点击图片进行查看,并可能删除。我不知道如何访问这些图片,我不知道它们存储在哪里,所以即使我想删除它们,我也不知道如何访问每个图片。你能帮帮我吗? 用户可以拍摄多张图像,然后将其显示在主页上。我希望用户能够再次审查他们,然后如果他继续与他们的第二页,他将上传一些其他数据,在第三页,它应该都显示在一起。如何在第三页上显示图片

public partial class AddingPage : ContentPage
    {
        AdLogEntry adLogEntry = new AdLogEntry();
        //CameraService cameraService = new CameraService();
        public byte[] imageAsBytes;
        public string pathLabel;
        private const int MaxColumns = 3;
        private int _currentRow = 0;
        private int _currentColumn = 0;


        public AddingPage()
        {
            InitializeComponent();

        }

        protected override async void OnAppearing()
        {
            base.OnAppearing();

            await MainProgressBar.ProgressTo(0, 250, Easing.Linear); ;
        }
        private async void NextStep_Clicked(object sender, EventArgs e)
        {
            await Navigation.PushAsync(new Informations());
        }

        private async void TakePicture_Clicked(object sender, EventArgs e)
        {

            await TakePicture();

        }

private async Task TakePicture()
        {
            MediaFile file = null;

            await CrossMedia.Current.Initialize();

            if (!CrossMedia.Current.IsCameraAvailable || !CrossMedia.Current.IsTakePhotoSupported)
            {
                await DisplayAlert("Nemáme přístup", "Nelze nalézt kameru", "OK");
                return;
            }

            var imageSource = await DisplayActionSheet("Foto", "Cancel", null, new string[] { "Pořídit novou fotku", "Nahrát foto z galerie" });
            var photoName = Guid.NewGuid().ToString() + ".jpg";

            switch (imageSource)
            {
                case "Pořídit novou fotku":
                    file = await CrossMedia.Current.TakePhotoAsync(new StoreCameraMediaOptions
                    {
                        SaveToAlbum = true,
                        Directory = "Photos",
                        Name = photoName
                    });
                    //Get the public album path
                    var aPpath = file.AlbumPath;

                    //Get private path
                    var path = file.Path;

                    break;

                case "Nahrát foto z galerie":
                    file = await CrossMedia.Current.PickPhotoAsync();
                    //Directory.GetFiles( "Photos");
                    break;

                default:
                    break;
            }

            if (file == null)
                return;

            // Photo => Grid 
            _currentColumn++;

            if (_currentColumn > MaxColumns - 0)
            {
                _currentColumn++;
                _currentRow++;

                // Add a new row definition by copying the first row.
                ImageGridContainer.RowDefinitions.Add(ImageGridContainer.RowDefinitions[0]);
            }

            var newImage = new Image()
            {
                Source = ImageSource.FromFile(file.Path),
                VerticalOptions = LayoutOptions.FillAndExpand,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                Aspect = Aspect.AspectFill,
                Scale = 0
            };

            ImageGridContainer.Children.Add(newImage, _currentColumn, _currentRow);

            await Task.Delay(250);

            await newImage.ScaleTo(1, 250, Easing.SpringOut);
}

“我不知道如何访问这些图片”-您刚刚发布的代码正在使用媒体插件返回的MediaFile对象访问这些图片。您可以获取相册路径,file.Path,这就是这些图片存储的位置。@JackHua MSFT Hi,好的,我如何获取?用户可以拍摄多张图像,然后将其显示在主页上。我希望用户能够再次查看它们,然后如果他继续查看第二页,他将上载一些其他数据,并在第三页上一起显示。用户可以在控件
newImage
中看到这些图片,您可以将newImage的源设置为空值,以删除
newImage
中的图片“我不知道如何访问这些图片”-您刚才发布的代码正在使用媒体插件返回的MediaFile对象访问图片。您可以获取AlbumPath、file.Path、,这就是这些图片的存储位置。@JackHua MSFT嗨,好吧,我怎么才能得到它?用户可以拍摄多张图像,然后将其显示在主页上。我希望用户能够再次查看它们,然后如果他继续查看第二页,他将上载一些其他数据,并在第三页上一起显示。用户可以在控件
newImage
中看到这些图片,您可以将newImage的源设置为空值,以删除
newImage
中的图片。