async void TapGestureRecognizer_Tapped(object sender, ItemTappedEventArgs e) { try{ selectedDocName = e.Group.ToString(); var imageSender = (Image)sender; Image _imgstate = (Image)sender; var stk = (StackLayout)imageSender.Parent; var img = (Image)stk.Children[0]; // if(imageSender.FindByName<ImageSource>("fav")) //overlay ContentView ai = this.FindByName <ContentView>("overlay"); // var answer = await DisplayAlert("", "Would like to mark as favourite", "Yes", "No"); //if (_imgstate) var answer = await DisplayActionSheet("Are you sure to save this pdf to your favorite list? ", "Yes", "No"); if (answer == "Yes") { //imageSender.Source = "fav_selected.png"; img.Source = "fav_selected.png"; //ai.IsVisible = true; //Device.StartTimer(TimeSpan.FromSeconds(0.5), () => //{ // //indicator.IsRunning = false; // ai.IsVisible = false;x // return false; //}); //call the save function App.PoliciesRepo.UpdateFavorites(selectedDocName, "1"); ViewDocumentViewModel vdv = new ViewDocumentViewModel(); vdv.viewDocument(selectedDocName); _favstate = true; } else { img.Source = "fav-unselected.png"; //if exists delete file and update in sqlite App.PoliciesRepo.UpdateFavorites(selectedDocName, "0"); var check = await FileSystem.Current.LocalStorage.CheckExistsAsync(selectedDocName); if (ExistenceCheckResult.FileExists == check) { IFile file = await FileSystem.Current.LocalStorage.GetFileAsync(selectedDocName); await file.DeleteAsync(); } _favstate = false; } } catch (Exception ex) { logger.Error(ex.Message); } }
public async void downloStatus(string DocName) { Device.BeginInvokeOnMainThread(() => { StackLoadingRef.IsVisible = true; }); ViewDocumentViewModel vdm = new ViewDocumentViewModel(); await vdm.viewDocument(DocName); StackLoadingRef.IsVisible = false; }
async void ImgFavourite_Tapped(object sender, ItemTappedEventArgs e) { selectedDocName = e.Group.ToString(); var imageSender = (Image)sender; var stk = (StackLayout)imageSender.Parent; var img = (Image)stk.Children[0]; //overlay ContentView ai = this.FindByName <ContentView>("overlay"); var answer = await DisplayAlert("", "Would like to mark as favourite", "Yes", "No"); if (answer) { //imageSender.Source = "fav_selected.png"; img.Source = "fav_selected.png"; //ai.IsVisible = true; //Device.StartTimer(TimeSpan.FromSeconds(0.5), () => //{ // //indicator.IsRunning = false; // ai.IsVisible = false; // return false; //}); //call the save function App.PoliciesRepo.UpdateFavorites(selectedDocName, "1"); ViewDocumentViewModel vdv = new ViewDocumentViewModel(); vdv.viewDocument(selectedDocName); } else { img.Source = "fav_default.png"; //if exists delete file and update in sqlite App.PoliciesRepo.UpdateFavorites(selectedDocName, "0"); var check = await FileSystem.Current.LocalStorage.CheckExistsAsync(selectedDocName); if (ExistenceCheckResult.FileExists == check) { IFile file = await FileSystem.Current.LocalStorage.GetFileAsync(selectedDocName); await file.DeleteAsync(); } } }
async void OnTapGestureRecognizerTapped(object sender, ItemTappedEventArgs e) { try{ selectedDocName = e.Group.ToString(); var imageSender = (Image)sender; var stk = (StackLayout)imageSender.Parent; var img = (Image)stk.Children[0]; //var item=await //overlay ContentView ai = this.FindByName <ContentView>("overlay"); activityIndicatorLayout.IsVisible = true; var _norefgesture = new TapGestureRecognizer(); _norefgesture.Tapped += async(object sender1, EventArgs e2) => { img.Source = "fav-unselected.png"; //if exists delete file and update in sqlite App.PoliciesRepo.UpdateFavorites(selectedDocName, "0"); var check = await FileSystem.Current.LocalStorage.CheckExistsAsync(selectedDocName); if (ExistenceCheckResult.FileExists == check) { IFile file = await FileSystem.Current.LocalStorage.GetFileAsync(selectedDocName); await file.DeleteAsync(); } activityIndicatorLayout.IsVisible = false; }; nobtnRef.GestureRecognizers.Add(_norefgesture); var _yesrefgesture = new TapGestureRecognizer(); _yesrefgesture.Tapped += (object sender1, EventArgs e2) => { img.Source = "fav_selected.png"; //if exists delete file and update in sqlite App.PoliciesRepo.UpdateFavorites(selectedDocName, "1"); ViewDocumentViewModel vdv = new ViewDocumentViewModel(); vdv.viewDocument(selectedDocName); activityIndicatorLayout.IsVisible = false; }; yesbtnref.GestureRecognizers.Add(_yesrefgesture); } catch (Exception ex) { Debug.WriteLine(ex.Message); } //var answer = await DisplayAlert("", "Would like to mark as favourite", "Yes", "No"); //if (answer) //{ // //imageSender.Source = "fav_selected.png"; // img.Source = "fav_selected.png"; // //ai.IsVisible = true; // //Device.StartTimer(TimeSpan.FromSeconds(0.5), () => // //{ // // //indicator.IsRunning = false; // // ai.IsVisible = false; // // return false; // //}); // //call the save function // App.PoliciesRepo.UpdateFavorites(selectedDocName, "1"); // ViewDocumentViewModel vdv = new ViewDocumentViewModel(); // vdv.viewDocument(selectedDocName); //} //else //{ // img.Source = "fav-unselected.png"; // //if exists delete file and update in sqlite // App.PoliciesRepo.UpdateFavorites(selectedDocName, "0"); // var check = await FileSystem.Current.LocalStorage.CheckExistsAsync(selectedDocName); // if (ExistenceCheckResult.FileExists == check) // { // IFile file = await FileSystem.Current.LocalStorage.GetFileAsync(selectedDocName); // await file.DeleteAsync(); // } //} }
public ViewDocument(string DocName, bool IsFavorite) { InitializeComponent(); MessagingCenter.Subscribe <ViewDocument>(this, "Hi", (sender) => { DisplayAlert("hi", "ravi", "OK"); // do something whenever the "Hi" message is sent }); // StackLoadingRef.IsVisible = true; // if (!IsFavorite) // { //Device.BeginInvokeOnMainThread(() => //{ // StackLoadingRef.IsVisible = false; //}); // Device.StartTimer(new TimeSpan(0, 0, 5), CallWebService); //20 secondss //} TapGestureRecognizer _norefgesture = new TapGestureRecognizer(); _norefgesture.Tapped += async(object sender1, EventArgs e2) => { btnViewFav.Image = "fav_gray.png"; activityIndicatorLayout.IsVisible = false; var check = await FileSystem.Current.LocalStorage.CheckExistsAsync(this.SelectedDocName); if (ExistenceCheckResult.FileExists == check) { App.PoliciesRepo.UpdateFavorites(this.SelectedDocName, "0"); IFile file = await FileSystem.Current.LocalStorage.GetFileAsync(this.SelectedDocName); await file.DeleteAsync(); } IsFavorite = false; }; nobtnRef.GestureRecognizers.Add(_norefgesture); _norefgesture.NumberOfTapsRequired = 1; TapGestureRecognizer _yesrefgesture = new TapGestureRecognizer(); _yesrefgesture.Tapped += async(object sender1, EventArgs e2) => { btnViewFav.Image = "fav_selected.png"; activityIndicatorLayout.IsVisible = false; App.PoliciesRepo.UpdateFavorites(this.SelectedDocName, "1"); IsFavorite = true; ViewDocumentViewModel vdv = new ViewDocumentViewModel(); await vdv.viewDocument(this.SelectedDocName); }; yesbtnref.GestureRecognizers.Add(_yesrefgesture); _yesrefgesture.NumberOfTapsRequired = 1; this.Title = "Policies and procedures"; // NavigationPage.SetHasNavigationBar(this, false); // actIndicator.IsVisible = true; if (IsFavorite) { btnViewFav.Image = "fav_selected.png"; } else { btnViewFav.Image = "fav_gray.png"; } downloStatus(DocName); //ViewDocumentViewModel vdm = new ViewDocumentViewModel(); //vdm.viewDocument(DocName); cwv.Uri = DocName;// "BookPreview2-Ch18-Rel0417.pdf"; this.SelectedDocName = DocName; //actIndicator.IsVisible = false; btnBackB.Clicked += (sender, e) => { Navigation.PopAsync(); }; //cwv.Navigated += (sender, e) => cwv.Navigating += (sender, e) => { StackLoadingRef.IsVisible = true; }; cwv.Navigated += (sender, e) => { StackLoadingRef.IsVisible = false; }; }