Add custom extensions to save dialogs.
This commit is contained in:
parent
aee94a3b2b
commit
b16d03857f
@ -68,7 +68,7 @@ namespace FirstPlugin
|
||||
|
||||
public IEnumerable<STGenericTexture> ExportableTextures => TextureList;
|
||||
|
||||
public override string ExportFilter => Utils.GetAllFilters(new BFRES());
|
||||
public override string ExportFilter => Utils.GetAllFilters(this);
|
||||
|
||||
//Stores the skeleton and models in this
|
||||
public DrawableContainer DrawableContainer = new DrawableContainer();
|
||||
@ -914,7 +914,7 @@ namespace FirstPlugin
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
public void Save(System.IO.Stream stream)
|
||||
public void Save(Stream stream)
|
||||
{
|
||||
var Models = GetModels();
|
||||
if (Models != null && !IsParticlePrimitive)
|
||||
|
@ -288,15 +288,26 @@ namespace Toolbox.Library
|
||||
{
|
||||
List<IFileFormat> f = new List<IFileFormat>();
|
||||
f.Add(format);
|
||||
return GetAllFilters(f);
|
||||
return GetAllFilters(f, format);
|
||||
}
|
||||
|
||||
public static string GetAllFilters(IEnumerable<IFileFormat> format)
|
||||
public static string GetAllFilters(IEnumerable<IFileFormat> format, IFileFormat targetFormat = null)
|
||||
{
|
||||
var alltypes = format;
|
||||
|
||||
string Filter = "All Supported Files|";
|
||||
List<string> FilterEach = new List<string>();
|
||||
|
||||
//Set the current extension used by the target's file information if used
|
||||
if (targetFormat != null && targetFormat.FilePath != null) {
|
||||
string extension = Path.GetExtension(targetFormat.FilePath);
|
||||
if (extension != "" && !format.Any(x => x.Extension.Contains($"*{extension}")))
|
||||
{
|
||||
Filter += $"*{extension};";
|
||||
FilterEach.Add($"({extension}) |*{extension}|");
|
||||
}
|
||||
}
|
||||
|
||||
foreach (IFileFormat f in format)
|
||||
{
|
||||
for (int i = 0; i < f.Extension.Length; i++)
|
||||
|
@ -416,6 +416,7 @@ namespace Toolbox
|
||||
formats.Add((IFileFormat)fileFormat);
|
||||
}
|
||||
sfd.Filter = Utils.GetAllFilters(formats);
|
||||
sfd.DefaultExt = Path.GetExtension(format.FilePath);
|
||||
|
||||
if (sfd.ShowDialog() != DialogResult.OK)
|
||||
return;
|
||||
@ -438,6 +439,7 @@ namespace Toolbox
|
||||
SaveFileDialog sfd = new SaveFileDialog();
|
||||
sfd.Filter = Utils.GetAllFilters(format);
|
||||
sfd.FileName = format.FileName;
|
||||
sfd.DefaultExt = Path.GetExtension(format.FilePath);
|
||||
|
||||
if (sfd.ShowDialog() != DialogResult.OK)
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user