private async void InitializeThePetPictures()
        {
            thisPet = GlobalVariables.ConvertMyPetListToPet(GlobalVariables.Mypetlist.Where(u => u.petid == petid).FirstOrDefault());

            await GetFollowers();

            currentWidth = Application.Current.MainPage.Width;

            optimalWidth = currentWidth / 3;

            Title = thisPet.Name;

            ageLabel.Text = new Segédfüggvények().HowOld(thisPet.Age).ToString();

            kindLabel.Text = thisPet.PetType;

            profilePictureImage.HeightRequest = optimalWidth;
            profilePictureImage.WidthRequest  = optimalWidth;

            if (thisPet.Profilepicture != null)
            {
                profilePictureImage.Source = ImageSource.FromStream(() => new System.IO.MemoryStream(thisPet.Profilepicture));
            }
            else
            {
                profilePictureImage.Source = "account.png";
            }

            await GetPetsPictures();
        }
        private void Init()
        {
            Task.Run(() =>
            {
                ageDatePicker.MaximumDate = DateTime.Now;

                thisPet = GlobalVariables.ConvertMyPetListToPet(GlobalVariables.Mypetlist.Where(i => i.petid == petid).FirstOrDefault());

                Device.BeginInvokeOnMainThread(() =>
                {
                    nameEntry.Placeholder = thisPet.Name;
                    ageDatePicker.Date    = thisPet.Age;
                    typeEntry.Placeholder = thisPet.PetType;

                    if (thisPet.Profilepicture != null)
                    {
                        profilePictureImage.Source = ImageSource.FromStream(() => new System.IO.MemoryStream(thisPet.Profilepicture));
                    }

                    if (thisPet.HaveAnOwner == 0)
                    {
                        shelterpetSwitch.IsToggled = true;
                    }
                    else
                    {
                        shelterpetSwitch.IsToggled = false;
                    }
                });
            });
        }
Esempio n. 3
0
        protected override void OnAppearing()
        {
            var currentWidth = Application.Current.MainPage.Width;

            var optimalWidth = currentWidth / 3;

            profilePictureImage.HeightRequest = optimalWidth;
            profilePictureImage.WidthRequest  = optimalWidth;

            if (!String.IsNullOrEmpty(GlobalVariables.ActualUser.ProfilePictureURL))
            {
                profilePictureImage.Source = ImageSource.FromUri(new Uri(GlobalVariables.ActualUser.ProfilePictureURL));
            }
            else
            {
                profilePictureImage.Source = "";
            }

            userNameLabel.Text = GlobalVariables.ActualUser.FirstName + " " + GlobalVariables.ActualUser.LastName;

            listViewWithPictureAndSomeText = new List <ListViewWithPictureAndSomeText>();

            foreach (var item in GlobalVariables.Mypetlist)
            {
                listViewWithPictureAndSomeText.Add(new ListViewWithPictureAndSomeText()
                {
                    pet            = GlobalVariables.ConvertMyPetListToPet(item),
                    ProfilePicture = item.ProfilePictureURL == string.Empty ? "" : ImageSource.FromUri(new Uri(item.ProfilePictureURL)),
                    Name           = item.Name
                });
            }

            petListView.ItemsSource = listViewWithPictureAndSomeText;
        }
        public UpdatePetProfilePage(int petid)
        {
            this.petid = petid;

            InitializeComponent();

            thisPet = GlobalVariables.ConvertMyPetListToPet(GlobalVariables.Mypetlist.Where(i => i.petid == petid).FirstOrDefault());

            nameEntry.Placeholder = thisPet.Name;
            ageEntry.Placeholder  = thisPet.Age.ToString();
            typeEntry.Placeholder = thisPet.PetType;

            if (!String.IsNullOrEmpty(thisPet.ProfilePictureURL))
            {
                profilePictureImage.Source = ImageSource.FromUri(new Uri(thisPet.ProfilePictureURL));
            }

            if (thisPet.HaveAnOwner == 0)
            {
                shelterpetSwitch.IsToggled = true;
            }
            else
            {
                shelterpetSwitch.IsToggled = false;
            }
        }
        private async Task Initialize()
        {
            await Task.Run(() =>
            {
                thisPet = GlobalVariables.ConvertMyPetListToPet(GlobalVariables.Mypetlist.Where(u => u.petid == petpictures.PetID).FirstOrDefault());
                Device.BeginInvokeOnMainThread(() =>
                {
                    nameLabel.Text = thisPet.Name;

                    profilePictureImage.Source = ImageSource.FromUri(new Uri(thisPet.ProfilePictureURL));

                    pictureImage.Source = ImageSource.FromUri(new Uri(petpictures.PictureURL));
                });

                var asd = GlobalVariables.seePictureFragmentViewModel.GetHashtags(petpictures.id).Split(' ');

                foreach (var item2 in asd)
                {
                    Device.BeginInvokeOnMainThread(() =>
                    {
                        Label hashtagLabel = new Label()
                        {
                            Text   = item2,
                            Style  = GlobalVariables.NormalLabel,
                            Margin = Thickness
                        };

                        var onHashtagClickedTap = new TapGestureRecognizer()
                        {
                            NumberOfTapsRequired = 1
                        };
                        onHashtagClickedTap.Tapped += (s, e) =>
                        {
                            SearchFragmentViewModel searchFragmentViewModel = new SearchFragmentViewModel();

                            List <SearchModel> searchModelList = searchFragmentViewModel.GetSearchModel();

                            var asd24 = (from q in searchModelList where q.hashtag == item2 select q);

                            Navigation.PushAsync(new SearchResultPage(asd24.First().petpicturesList, item2.Split('#')[1]));
                        };

                        hashtagLabel.GestureRecognizers.Add(onHashtagClickedTap);

                        mainStackLayout.Children.Add(hashtagLabel);
                    });
                }
                Device.BeginInvokeOnMainThread(() =>
                {
                    likes = GlobalVariables.seePictureFragmentViewModel.GetLikes(petpictures.id);

                    howmanylike = likes.Count;

                    howmanyLikesLabel.Text = howmanylike.ToString() + English.GetLike();

                    haveiliked = GlobalVariables.seePictureFragmentViewModel.HaveILiked(petpictures.id);
                });
            });
        }
        private async void Initialize()
        {
            await Task.Run(() =>
            {
                thisPet = GlobalVariables.ConvertMyPetListToPet(GlobalVariables.Mypetlist.Where(u => u.petid == petpictures.PetID).FirstOrDefault());

                Device.BeginInvokeOnMainThread(() =>
                {
                    nameLabel.Text = thisPet.Name;

                    profilePictureImage.Source = ImageSource.FromStream(() => new System.IO.MemoryStream(thisPet.Profilepicture));

                    pictureImage.Source = ImageSource.FromStream(() => new System.IO.MemoryStream(petpictures.PictureURL));
                });

                var hashtags = GlobalVariables.seePictureFragmentViewModel.GetHashtags(petpictures.id).Split(' ');

                foreach (var item2 in hashtags)
                {
                    Device.BeginInvokeOnMainThread(() =>
                    {
                        Label hashtagLabel = new Label()
                        {
                            Text   = item2,
                            Style  = GlobalVariables.NormalLabel,
                            Margin = Thickness
                        };

                        var onHashtagClickedTap = new TapGestureRecognizer()
                        {
                            NumberOfTapsRequired = 1
                        };
                        onHashtagClickedTap.Tapped += (s, e) =>
                        {
                            Navigation.PushAsync(new SearchResultPage(item2.Split('#')[1]));
                        };

                        hashtagLabel.GestureRecognizers.Add(onHashtagClickedTap);

                        mainStackLayout.Children.Add(hashtagLabel);
                    });
                }

                likes = GlobalVariables.seePictureFragmentViewModel.GetLikes(petpictures.id);

                Device.BeginInvokeOnMainThread(() =>
                {
                    howmanylike = likes.Count;

                    howmanyLikesLabel.Text = howmanylike.ToString() + English.GetLike();
                });
            });
        }
        public string DeletePet(int petid)
        {
            var petpictureList = DependencyService.Get <IDBAccess.IBlobStorage>().GetPetpictureByID(petid);

            foreach (var item in petpictureList)
            {
                bool successD = GlobalVariables.seePictureFragmentViewModel.DeletePicture(item);

                if (!successD)
                {
                    return(English.SomethingWentWrong());
                }
            }

            Pet pet = GlobalVariables.ConvertMyPetListToPet(GlobalVariables.Mypetlist.Where(i => i.petid == petid).FirstOrDefault());

            bool success = DependencyService.Get <IDBAccess.IBlobStorage>().DeletePet(pet);

            if (!success)
            {
                return(English.SomethingWentWrong());
            }
            else
            {
                int i = 0;

                foreach (var item in GlobalVariables.Mypetlist)
                {
                    if (item.petid == petid)
                    {
                        GlobalVariables.Mypetlist.RemoveAt(i);
                        GlobalVariables.MyPetsString.RemoveAt(i);

                        break;
                    }

                    i++;
                }

                GlobalVariables.AddedPet = true;

                return(English.Empty());
            }
        }
Esempio n. 8
0
        private async Task InitializeThePetPictures()
        {
            await Task.Run(() =>
            {
                thisPet = GlobalVariables.ConvertMyPetListToPet(GlobalVariables.Mypetlist.Where(u => u.petid == petid).FirstOrDefault());

                petPictureListfromDB = GlobalVariables.petProfileFragmentViewModel.GetPetPictureURL(petid);
                Device.BeginInvokeOnMainThread(() =>
                {
                    followersLabel.Text = GlobalVariables.followersViewModel.GetUserList(this.petid).Count + " followers";

                    currentWidth = Application.Current.MainPage.Width;

                    optimalWidth = currentWidth / 3;

                    petnameLabel.Text = thisPet.Name;

                    profilePictureImage.HeightRequest = optimalWidth;
                    profilePictureImage.WidthRequest  = optimalWidth;

                    profilePictureImage.Source = thisPet.ProfilePictureURL == "" ? "" : ImageSource.FromUri(new Uri(thisPet.ProfilePictureURL));
                });
                int left = 0;
                int top  = 0;

                int i = 1;

                foreach (var item in petPictureListfromDB)
                {
                    Device.BeginInvokeOnMainThread(() =>
                    {
                        Image image = new Image();

                        image.Source = ImageSource.FromUri(new Uri(item.PictureURL));

                        image.HeightRequest = optimalWidth;

                        image.GestureRecognizers.Add(new TapGestureRecognizer()
                        {
                            NumberOfTapsRequired = 1,
                            TappedCallback       = delegate
                            {
                                OnPictureClicked(item);
                            }
                        });

                        image.Aspect = Aspect.AspectFill;

                        pictureListGrid.Children.Add(image, top, left);

                        if (i == 3)
                        {
                            left++;
                            i   = 1;
                            top = 0;
                        }
                        else
                        {
                            i++;
                            top++;
                        }
                    });
                }
            });
        }