/// <summary> /// Gets the name of the current file for a save operation. If no file is /// defined the save dialog box will be shown and that result will be returned. /// </summary> /// <param name="fileChosenCb">A function that is called when a file is chosen with the name of the chosen file.</param> public void saveFile(FileChosen fileChosenCb) { if (currentFile == null) { saveFileAs(fileChosenCb); } else { fileChosenCb(currentFile); } }
/// <summary> /// This will show the save file dialog and will return the newly chosen file. /// </summary> /// <param name="parent">The parent window.</param> /// <returns>The current file or null if the user canceled the dialog.</returns> public void saveFileAs(FileChosen fileChosenCb) { FileSaveDialog save = new FileSaveDialog(ParentWindow, "", DefaultDirectory, "", Filter); save.showModal((result, file) => { if (result == NativeDialogResult.OK && !String.IsNullOrEmpty(file)) { currentFile = file; fileChosenCb(currentFile); } }); }
/// <summary> /// Show the open file dialog and return the chosen file. /// <param name="fileChosenCb">A function that is called when a file is chosen with the name of the chosen file.</param> /// </summary> public void openFile(FileChosen fileChosenCb) { FileOpenDialog fileOpen = new FileOpenDialog(ParentWindow, "", DefaultDirectory, "", Filter, false); fileOpen.showModal((result, files) => { String file = files.FirstOrDefault(); if (result == NativeDialogResult.OK && !String.IsNullOrEmpty(file)) { currentFile = file; fileChosenCb(currentFile); } }); }
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data) { base.OnActivityResult(requestCode, resultCode, data); if (requestCode == 42 && resultCode == Result.Ok) { if (data == null) { return; } Uri uri = null; var stringUri = data.ToUri(IntentUriType.None); uri = new Uri(stringUri); FileChosen?.Invoke(uri); } }
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data) { base.OnActivityResult(requestCode, resultCode, data); if (requestCode == MyPermissions.READ_MEDIA_REQUEST_CODE) { SettingToneViewModel.IsFinding = true; if (resultCode == Result.Ok) { if (data == null) { return; } var _uri = data.Data; var realPath = GetRealPathFromURI(_uri); //var stringUri = data.ToUri(IntentUriType.None); //Uri uri = new Uri(stringUri); FileChosen?.Invoke(realPath); } } }
protected void OnFileChosen(FileMenuArgs args) => FileChosen?.Invoke(this, args);
void OnFileChosen(Uri uri) { FileChosen?.Invoke(uri); _mainActivity.FileChosen -= OnFileChosen; }
void OnFileChosen(string path) { FileChosen?.Invoke(path); _mainActivity.FileChosen -= OnFileChosen; }