protected override bool OnFileDialog(CefBrowser browser, CefFileDialogMode mode, string title, string defaultFilePath, string[] acceptFilters, int selectedAcceptFilter, CefFileDialogCallback callback)
        {
            if (mode == (CefFileDialogMode.Save | CefFileDialogMode.OverwritePromptFlag | CefFileDialogMode.HideReadOnlyFlag))
            {
                var saveFileDialog = new SaveFileDialog();
                saveFileDialog.FileName = defaultFilePath;
                //saveFileDialog.Filter = string.Join("Supported Files|*", acceptFilters);
                if (saveFileDialog.ShowDialog() == DialogResult.OK && saveFileDialog.FileName != "")
                {
                    callback.Continue(selectedAcceptFilter, saveFileDialog.FileNames);
                }
            }
            else if (mode == (CefFileDialogMode.OpenFolder | CefFileDialogMode.OverwritePromptFlag | CefFileDialogMode.HideReadOnlyFlag))
            {
                var dialog = new FolderBrowserDialog();
                if (dialog.ShowDialog() == DialogResult.OK && dialog.SelectedPath != "")
                {
                    callback.Continue(selectedAcceptFilter, new string[] { dialog.SelectedPath });
                }
            }
            else if (mode == (CefFileDialogMode.OverwritePromptFlag | CefFileDialogMode.HideReadOnlyFlag))
            {
                var dialog = new OpenFileDialog();
                dialog.Multiselect = mode == CefFileDialogMode.OpenMultiple;
                if (dialog.ShowDialog() == DialogResult.OK && dialog.FileName != "")
                {
                    callback.Continue(selectedAcceptFilter, dialog.FileNames);
                }
            }
            //else callback.Cancel();

            return(base.OnFileDialog(browser, mode, title, defaultFilePath, acceptFilters, selectedAcceptFilter, callback));
        }
Exemple #2
0
        protected override Boolean OnFileDialog(CefBrowser browser, CefFileDialogMode mode, String title, String defaultFileName, String[] acceptTypes, CefFileDialogCallback callback)
        {
            if (mode == CefFileDialogMode.Open || mode == CefFileDialogMode.OpenMultiple)
            {
                if (this.Client.HandleOpenFileDialog != null)
                {
                    callback.Continue(this.Client.HandleOpenFileDialog(title, defaultFileName, acceptTypes));
                    return(true);
                }
            }
            else if (mode == CefFileDialogMode.Save)
            {
                if (this.Client.HandleSaveFileDialog != null)
                {
                    callback.Continue(this.Client.HandleSaveFileDialog(title, defaultFileName, acceptTypes));
                    return(true);
                }
            }

            Log.Trace("DialogHandler.OnFileDialog( browser: {0}, mode: {1}, title: {2}, defaultFileName: {3}, acceptTypes: {4} )",
                      browser.Identifier,
                      Enum.GetName(typeof(CefFileDialogMode), mode),
                      title,
                      defaultFileName,
                      String.Join(" ", acceptTypes));

            return(false);
            //return base.OnFileDialog( browser, mode, title, defaultFileName, acceptTypes, callback );
        }