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; }
public ActionResult GetReferenceToViewAzureBlob(string referenceToBlob, string extensionName) { CloudBlobContainer container = GetCloudBlobContainer(); CloudBlockBlob blob = container.GetBlockBlobReference(referenceToBlob); string filePath = blob.SnapshotQualifiedUri.ToString(); var viewModel = new ViewDocumentViewModel { PathToFile = filePath, Extension = extensionName }; return(View("ViewDocument", viewModel)); }
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(); } } }
public IEnumerable<IResult> Save(ViewDocumentViewModel document, bool doQuickSave, System.Action<string> fileSelected) { if(doQuickSave && !string.IsNullOrEmpty(document.FileName)){ fileSelected(document.FilePath); event_aggregator.Publish(new StatusBarMessageChangedEvent(StringParser.Parse("${res:BVEEditor:StringResources:StatusBar.Messages.SavedFile}", new StringTagPair("fileName", document.FileName))) ); yield return new DummyResult(); }else{ var result = result_factory.ShowFileDialog(StringParser.Parse("${res:BVEEditor:StringResources:Common.Dialogs.Captions.SaveAs}"), "All files(*.*)|*.*", FileDialogMode.Save, document.FileName); yield return result; if(!string.IsNullOrEmpty(result.File)){ fileSelected(result.File); event_aggregator.Publish(new StatusBarMessageChangedEvent(StringParser.Parse( "${res:BVEEditor:StringResources:StatusBar.Messages.SavedFileAs}", new StringTagPair("newFileName", result.File))) ); } yield return new DummyResult(); } }
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; }; }
public ActiveViewDocumentChangedEvent(ViewDocumentViewModel viewDoc) { ViewDocument = viewDoc; }
/// <summary> /// Creates a new <see cref="BVEEditor.Events.ViewDocumentAddedEvent"/> instance. /// </summary> /// <param name="document">The ViewDocument being added</param> /// <param name="showOnAdded">If true, the ViewDocument will be shown when added</param> public ViewDocumentAddedEvent(ViewDocumentViewModel document, bool showOnAdded = true) { Document = document; ShowOnAdded = showOnAdded; }