public string SaveFilePanel(string title, string directory, string defaultName, ExtensionFilter[] extensions) { var fd = new VistaSaveFileDialog(); fd.Title = title; fd.InitialDirectory = directory; fd.FileName = defaultName; if (extensions != null) { fd.Filter = GetFilterFromFileExtensionList(extensions); fd.FilterIndex = 1; fd.DefaultExt = extensions[0].Extensions[0]; fd.AddExtension = true; } else { fd.DefaultExt = string.Empty; fd.Filter = string.Empty; fd.AddExtension = false; } var res = fd.ShowDialog(new WindowWrapper(GetActiveWindow())); var filename = res == DialogResult.OK ? fd.FileName : ""; fd.Dispose(); return(filename); }
public bool SaveFilePanel(ExtensionFilter filter, string defaultFileName, string defExt, out string resultPath) { var fd = new VistaSaveFileDialog(); fd.Title = "Save As"; var finalFilename = ""; if (!string.IsNullOrEmpty(defaultFileName)) { finalFilename += defaultFileName; } fd.FileName = finalFilename; fd.Filter = GetFilterFromFileExtensionList(filter); fd.FilterIndex = 1; fd.DefaultExt = defExt; fd.AddExtension = true; var res = fd.ShowDialog(new WindowWrapper(GetActiveWindow())); var filename = res == DialogResult.OK ? fd.FileName : string.Empty; fd.Dispose(); resultPath = filename; return(!string.IsNullOrEmpty(resultPath)); }
public string SaveFilePanel(BrowserParameters args) { var fd = new VistaSaveFileDialog(); fd.Title = args.Title; var finalFilename = ""; if (!string.IsNullOrEmpty(args.Directory)) { finalFilename = GetDirectoryPath(args.Directory); } if (!string.IsNullOrEmpty(args.DefaultName)) { finalFilename += args.DefaultName; } fd.FileName = finalFilename; if (args.Extensions != null) { fd.Filter = GetFilterFromFileExtensionList(args.Extensions); fd.FilterIndex = (args.FilterIndex > 0) ? args.FilterIndex : 1; if (!string.IsNullOrEmpty(args.DefaultExt)) { fd.DefaultExt = args.DefaultExt; } else { fd.DefaultExt = args.Extensions[0].Extensions[0]; } fd.AddExtension = args.AddExtension; } else { fd.DefaultExt = string.Empty; fd.Filter = string.Empty; fd.AddExtension = false; } var res = fd.ShowDialog(new WindowWrapper(GetActiveWindow())); var filename = res == DialogResult.OK ? fd.FileName : ""; fd.Dispose(); return(filename); }
public void SaveFile(FileToSave file, string title, string directory) { if (isBusy) { return; } isBusy = true; var dialog = new VistaSaveFileDialog(); if (string.IsNullOrEmpty(directory)) { dialog.RestoreDirectory = true; dialog.FileName = file.Name; } else { dialog.FileName = CreateFilenameForSaveDialog(directory, file.Name); } dialog.DefaultExt = file.Extension; if (dialog.DefaultExt.Length > 0) { dialog.AddExtension = true; dialog.SupportMultiDottedExtensions = true; } if (file.FileType != null) { dialog.Filter = EncodeFilters(new [] { file.FileType }); } dialog.Title = title; var result = dialog.ShowDialog(new Win32Window(GetActiveWindow())); isBusy = false; if (result == DialogResult.OK) { NativeFileSOMacWin.SaveFileToPath(file, dialog.FileName); } dialog.Dispose(); }
public string SaveFilePanel(string title, string directory, string defaultName, ExtensionFilter[] extensions) { VistaSaveFileDialog dialog = new VistaSaveFileDialog(); dialog.Title = title; string finalFilename = ""; if (!string.IsNullOrEmpty(directory)) { finalFilename = GetDirectoryPath(directory); } if (!string.IsNullOrEmpty(defaultName)) { finalFilename += defaultName; } dialog.FileName = finalFilename; if (extensions != null) { dialog.Filter = GetFilterFromFileExtensionList(extensions); dialog.FilterIndex = 1; dialog.DefaultExt = extensions[0].Extensions[0]; dialog.AddExtension = true; } else { dialog.DefaultExt = string.Empty; dialog.Filter = string.Empty; dialog.AddExtension = false; } DialogResult result = dialog.ShowDialog(new WindowWrapper(GetActiveWindow())); string filename = result == DialogResult.OK ? dialog.FileName : ""; dialog.Dispose(); return(filename); }
public string SaveFilePanel(string _title, string _directory, string _defaultName, ExtensionFilter[] _extensions) { var fd = new VistaSaveFileDialog(); fd.Title = _title; var finalFilename = ""; if (!string.IsNullOrEmpty(_directory)) { finalFilename = GetDirectoryPath(_directory); } if (!string.IsNullOrEmpty(_defaultName)) { finalFilename += _defaultName; } fd.FileName = finalFilename; if (_extensions != null) { fd.Filter = GetFilterFromFileExtensionList(_extensions); fd.FilterIndex = 1; fd.DefaultExt = _extensions[0].extensions[0]; fd.AddExtension = true; } else { fd.DefaultExt = string.Empty; fd.Filter = string.Empty; fd.AddExtension = false; } var res = fd.ShowDialog(new WindowWrapper(GetActiveWindow())); var filename = res == DialogResult.OK ? fd.FileName : ""; fd.Dispose(); return(filename); }