Exemplo n.º 1
0
        public FileResultModel ShowSaveFileDialog(SaveFileDialogConfigModel config)
        {
            var dialog = windowFactory.CreateSaveFileDialog();

            dialog.Title            = config.Title;
            dialog.InitialDirectory = config.InitialDirectory;
            dialog.FileName         = config.FileName;
            dialog.OverwritePrompt  = config.OverwritePrompt;

            if (config.FileFilters != null)
            {
                foreach (var filter in config.FileFilters)
                {
                    dialog.FileFilters.Add(filter.ToFilter());
                }
            }

            var result = Application.Invoke(() => dialog.Show(parent));

            return(new FileResultModel
            {
                DialogResult = result,
                File = dialog.FileName,
                Files = new string[] { dialog.FileName },
            });
        }
Exemplo n.º 2
0
        public FileResultModel ShowSaveFileDialog(SaveFileDialogConfigModel config)
        {
            var dialog = new SaveFileDialog
            {
                Title            = config.Title,
                InitialDirectory = config.InitialDirectory,
                FileName         = config.FileName,
                OverwritePrompt  = config.OverwritePrompt,
            };

            if (config.FileFilters != null)
            {
                foreach (var filter in config.FileFilters)
                {
                    dialog.FileFilters.Add(filter.ToFilter());
                }
            }

            var result = Application.Invoke(() => dialog.Show(parent));

            return(new FileResultModel
            {
                DialogResult = result,
                File = dialog.FileName,
                Files = dialog.FileName == null?Array.Empty <string>() : new string[]
                {
                    dialog.FileName
                },
            });
        }