private async void GetImages(AppPreferences ap)
        {
            if (!String.IsNullOrEmpty(imageNames[0]))
            {
                Bitmap bit = ap.SetImageBitmap(_dir + "/" + imageNames[0]);
                if (bit != null)
                {
                    facilityPhoto.SetImageBitmap(bit);
                }
                else if (bit == null && !String.IsNullOrEmpty(imageNames[0]))
                {
                    PictureViewModel pictureViewModel = new PictureViewModel();
                    Models.Picture   picture          = await pictureViewModel.ExecuteGetPictureCommand(imageNames[0]);

                    if (picture != null)
                    {
                        var _bit = ap.StringToBitMap(picture.File);
                        if (_bit != null)
                        {
                            ap.SaveImage(_bit, imageNames[0]);
                        }
                        facilityPhoto.SetImageBitmap(_bit);
                    }
                }
            }
            if (imageNames.Count > 1)
            {
                Bitmap bit = ap.SetImageBitmap(_dir + "/" + imageNames[1]);
                if (bit != null)
                {
                    secondFacilityPhoto.SetImageBitmap(bit);
                }
                else if (bit == null && !String.IsNullOrEmpty(imageNames[1]))
                {
                    PictureViewModel pictureViewModel = new PictureViewModel();
                    Models.Picture   picture          = await pictureViewModel.ExecuteGetPictureCommand(imageNames[1]);

                    if (picture != null)
                    {
                        var _bit = ap.StringToBitMap(picture.File);
                        if (_bit != null)
                        {
                            ap.SaveImage(_bit, imageNames[1]);
                        }
                        secondFacilityPhoto.SetImageBitmap(_bit);
                    }
                }
            }
        }
        private async void GetImages(AppPreferences ap)
        {
            if (!String.IsNullOrEmpty(imageNames[0]))
            {
                Bitmap bit = ap.SetImageBitmap(ap.CreateDirectoryForPictures() + "/" + imageNames[0]);
                if (bit != null)
                {
                    pictureHolder.SetImageBitmap(bit);
                }
                else if (bit == null && !String.IsNullOrEmpty(imageNames[0]))
                {
                    PictureViewModel pictureViewModel = new PictureViewModel();
                    Models.Picture   picture          = await pictureViewModel.ExecuteGetPictureCommand(imageNames[0]);

                    if (picture != null)
                    {
                        var _bit = ap.StringToBitMap(picture.File);
                        if (_bit != null)
                        {
                            ap.SaveImage(_bit, imageNames[0]);
                        }
                        pictureHolder.SetImageBitmap(_bit);
                    }
                }
            }
        }
示例#3
0
        // Replace the contents of a view (invoked by the layout manager)
        public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position)
        {
            var item = viewModel.Buildings[position];
            // Replace the contents of the view with that element
            var myHolder = holder as MyViewHolder;

            myHolder.TextView.Text       = item.BuildingName;
            myHolder.DetailTextView.Text = item.BuildingNumber;

            AppPreferences ap  = new AppPreferences(Android.App.Application.Context);
            Bitmap         bit = ap.SetImageBitmap(ap.CreateDirectoryForPictures() + "/" + item.Photo);

            if (bit != null)
            {
                myHolder.ImageView.SetImageBitmap(bit);
            }
        }
示例#4
0
        // Replace the contents of a view (invoked by the layout manager)
        public async override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position)
        {
            var            item           = viewModel.Facilities[position];
            Context        mContext       = Android.App.Application.Context;
            AppPreferences appPreferences = new AppPreferences(mContext);

            // Replace the contents of the view with that element
            var myHolder = holder as MyViewHolder;

            myHolder.FacilityName.Text = item.Name;
            myHolder.ClientCode.Text   = item.ClientCode;
            myHolder.Button.Click     += (sender, e) => {
                Submit_Click(item);
            };
            myHolder.Location.LongClick += (sender, e) => {
                Open_Map(item.Location.GPSCoordinates.Latitude, item.Location.GPSCoordinates.Longitude);
            };
            if (item.Location != null)
            {
                myHolder.StreetAddress.Text = String.Format("Address: {0}", item.Location.StreetAddress);
                myHolder.Suburb.Text        = String.Format("               {0}", item.Location.Suburb);
                if (item.Location.GPSCoordinates != null)
                {
                    myHolder.Location.Text = String.Format("Lat: {0} Long: {1}", item.Location.GPSCoordinates.Latitude, item.Location.GPSCoordinates.Longitude);
                }
            }

            myHolder.Location.Text = String.Format("Lat: {0} Long: {1}", 0, 0);
            if (item.Location != null)
            {
                if (item.Location.GPSCoordinates != null)
                {
                    myHolder.Location.Text = String.Format("Lat: {0} Long: {1}", item.Location.GPSCoordinates.Latitude, item.Location.GPSCoordinates.Longitude);
                }
            }

            if (item.IDPicture != null)
            {
                List <string> imageNames = item.IDPicture.Split(',').ToList();

                AppPreferences ap  = new AppPreferences(Android.App.Application.Context);
                Bitmap         bit = ap.SetImageBitmap(ap.CreateDirectoryForPictures() + "/" + imageNames[0]);
                if (bit != null)
                {
                    myHolder.ImageView.SetImageBitmap(bit);
                }
                else
                {
                    PictureViewModel pictureViewModel = new PictureViewModel();
                    Models.Picture   picture          = await pictureViewModel.ExecuteGetPictureCommand(imageNames[0]);

                    if (picture != null)
                    {
                        var _bit = ap.StringToBitMap(picture.File);
                        if (_bit != null)
                        {
                            myHolder.ImageView.SetImageBitmap(_bit);
                        }
                    }
                }
            }
        }