private bool PromptFileSave(IGeometryModel model, out string fileName, out string formatId) { var getExportFormats = Substrate.GetSharedFunction <GetExportFormats>("Reclaimer.Plugins.ModelViewerPlugin.GetExportFormats"); var exportFormats = getExportFormats() .Select(f => new { FormatId = f, Extension = ModelViewerPlugin.GetFormatExtension(f), Description = ModelViewerPlugin.GetFormatDescription(f) }).ToList(); var filter = string.Join("|", exportFormats.Select(f => $"{f.Description}|*.{f.Extension}")); var sfd = new SaveFileDialog { OverwritePrompt = true, FileName = model.Name, Filter = filter, FilterIndex = 1 + exportFormats.TakeWhile(f => f.FormatId != ArchitectSettingsPlugin.Settings.DefaultSaveFormat).Count(), AddExtension = true }; if (sfd.ShowDialog() != true) { fileName = formatId = null; return(false); } fileName = sfd.FileName; formatId = exportFormats[sfd.FilterIndex - 1].FormatId; ArchitectSettingsPlugin.Settings.DefaultSaveFormat = formatId; return(true); }
public ItemCollection GetValues() { var items = ModelViewerPlugin.GetExportFormats() .Select(id => new Item { Value = id, DisplayName = ModelViewerPlugin.GetFormatDescription(id) }) .OrderBy(i => i.DisplayName); var result = new ItemCollection(); result.AddRange(items); return(result); }