public bool OnFileDialog(IWebBrowser webBrowser, IBrowser browser, CefFileDialogMode mode, CefFileDialogFlags flags, string title, string defaultFilePath, List <string> acceptFilters, int selectedAcceptFilter, IFileDialogCallback callback) { var args = new DialogRequestedEventArgs { Element = ToElement(mode), InitialPath = defaultFilePath, Operation = ToOperation(mode), Title = title }; Task.Run(() => { DialogRequested?.Invoke(args); using (callback) { if (args.Success) { callback.Continue(selectedAcceptFilter, new List <string> { args.FullPath }); } else { callback.Cancel(); } } }); return(true); }
private void OnPluginInterfaceDialogRequested(object sender, DialogRequestedEventArgs e) { if (sender is IEltraNavigoPluginService pluginService) { var dialogView = pluginService.ResolveDialogView(e.ViewModel); if (dialogView != null) { var viewModel = e.ViewModel; var dialogViewName = dialogView.GetType().Name; if (!_containerRegistry.IsRegistered(dialogView.GetType())) { var viewType = dialogView.GetType().ToString(); var viewModelType = e.ViewModel.GetType(); ViewModelLocationProvider.Register(viewType, viewModelType); _containerRegistry.Register(typeof(object), dialogView.GetType(), dialogViewName); } ThreadHelper.RunOnMainThread(() => { Action <IDialogResult> dialogResult = (r) => { e.DialogResult = r; }; _dialogService?.ShowDialog(dialogViewName, e.Parameters, dialogResult); }); } } }
private void DialogHandler_DialogRequested(DialogRequestedEventArgs args) { var isDownload = args.Operation == FileSystemOperation.Save; var isUpload = args.Operation == FileSystemOperation.Open; var isAllowed = (isDownload && settings.AllowDownloads) || (isUpload && settings.AllowUploads); if (isAllowed) { var result = fileSystemDialog.Show(args.Element, args.Operation, args.InitialPath, title: args.Title, parent: window); if (result.Success) { args.FullPath = result.FullPath; args.Success = result.Success; logger.Debug($"User selected path '{result.FullPath}' when asked to {args.Operation}->{args.Element}."); } else { logger.Debug($"User aborted file system dialog to {args.Operation}->{args.Element}."); } } else { logger.Info($"Blocked file system dialog to {args.Operation}->{args.Element}, as {(isDownload ? "downloading" : "uploading")} is not allowed."); } }
private void ViewModelBase_DialogRequested(object sender, DialogRequestedEventArgs args) { var dialog = (Window) new ViewLocator().Build(args.ViewModel); dialog.WindowStartupLocation = WindowStartupLocation.CenterOwner; dialog.DataContext = args.ViewModel; if (Dispatcher.UIThread.CheckAccess()) { args.CompletionTask = dialog.ShowDialog(this); } else { Dispatcher.UIThread.Post(() => { args.CompletionTask = dialog.ShowDialog(this); }); } }
private void DialogHandler_DialogRequested(DialogRequestedEventArgs args) { var isDownload = args.Operation == FileSystemOperation.Save; var isUpload = args.Operation == FileSystemOperation.Open; var isAllowed = (isDownload && settings.AllowDownloads) || (isUpload && settings.AllowUploads); var initialPath = default(string); if (isDownload) { initialPath = args.InitialPath; } else { initialPath = string.IsNullOrEmpty(settings.DownAndUploadDirectory) ? KnownFolders.Downloads.ExpandedPath : Environment.ExpandEnvironmentVariables(settings.DownAndUploadDirectory); } if (isAllowed) { var result = fileSystemDialog.Show( args.Element, args.Operation, initialPath, title: args.Title, parent: window, restrictNavigation: !settings.AllowCustomDownAndUploadLocation); if (result.Success) { args.FullPath = result.FullPath; args.Success = result.Success; logger.Debug($"User selected path '{result.FullPath}' when asked to {args.Operation}->{args.Element}."); } else { logger.Debug($"User aborted file system dialog to {args.Operation}->{args.Element}."); } } else { logger.Info($"Blocked file system dialog to {args.Operation}->{args.Element}, as {(isDownload ? "downloading" : "uploading")} is not allowed."); } }
protected virtual void OnDialogRequested(object sender, DialogRequestedEventArgs e) { DialogRequested?.Invoke(this, e); }
public void ShowDialog(object sender, DialogRequestedEventArgs e) { e.Sender = sender; OnDialogRequested(sender, e); }