commit
b863c4494a
4 changed files with 28 additions and 27 deletions
|
|
@ -34,6 +34,7 @@ using System.Threading.Tasks;
|
||||||
using MatterHackers.Agg.Image;
|
using MatterHackers.Agg.Image;
|
||||||
using MatterHackers.Agg.Platform;
|
using MatterHackers.Agg.Platform;
|
||||||
using MatterHackers.Agg.UI;
|
using MatterHackers.Agg.UI;
|
||||||
|
using MatterHackers.DataConverters3D;
|
||||||
using MatterHackers.Localizations;
|
using MatterHackers.Localizations;
|
||||||
|
|
||||||
namespace MatterHackers.MatterControl.Library.Export
|
namespace MatterHackers.MatterControl.Library.Export
|
||||||
|
|
@ -55,14 +56,7 @@ namespace MatterHackers.MatterControl.Library.Export
|
||||||
|
|
||||||
public Task<bool> Generate(IEnumerable<ILibraryItem> libraryItems, string outputPath)
|
public Task<bool> Generate(IEnumerable<ILibraryItem> libraryItems, string outputPath)
|
||||||
{
|
{
|
||||||
ILibraryContentStream libraryContent = libraryItems.OfType<ILibraryContentStream>().FirstOrDefault();
|
return MeshExport.ExportMesh(libraryItems.FirstOrDefault(), outputPath);
|
||||||
|
|
||||||
if (libraryContent != null)
|
|
||||||
{
|
|
||||||
return MeshExport.ExportMesh(libraryContent, outputPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public GuiWidget GetOptionsPanel() => null;
|
public GuiWidget GetOptionsPanel() => null;
|
||||||
|
|
|
||||||
|
|
@ -38,28 +38,39 @@ namespace MatterHackers.MatterControl.Library.Export
|
||||||
{
|
{
|
||||||
public static class MeshExport
|
public static class MeshExport
|
||||||
{
|
{
|
||||||
public static async Task<bool> ExportMesh(ILibraryContentStream source, string filePathToSave)
|
public static async Task<bool> ExportMesh(ILibraryItem source, string filePathToSave)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(filePathToSave))
|
if (source is ILibraryContentItem contentItem)
|
||||||
{
|
{
|
||||||
if (Path.GetExtension(source.FileName).ToUpper() == Path.GetExtension(filePathToSave).ToUpper())
|
// If the content is an IObject3D, the we need to load it and MeshFileIO save to the target path
|
||||||
|
var content = await contentItem.GetContent(null);
|
||||||
|
return MeshFileIo.Save(content, filePathToSave);
|
||||||
|
}
|
||||||
|
else if (source is ILibraryContentStream streamContent)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(filePathToSave))
|
||||||
{
|
{
|
||||||
using (var result = await source.GetContentStream(null))
|
// If the file is already AMF, it just needs copied to the target path
|
||||||
using (var fileStream = File.Create(filePathToSave))
|
if (Path.GetExtension(streamContent.FileName).ToUpper() == Path.GetExtension(filePathToSave).ToUpper())
|
||||||
{
|
{
|
||||||
result.Stream.CopyTo(fileStream);
|
using (var result = await streamContent.GetContentStream(null))
|
||||||
}
|
using (var fileStream = File.Create(filePathToSave))
|
||||||
|
{
|
||||||
|
result.Stream.CopyTo(fileStream);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
using (var result = await source.GetContentStream(null))
|
|
||||||
{
|
{
|
||||||
IObject3D item = Object3D.Load(result.Stream, Path.GetExtension(source.FileName), CancellationToken.None);
|
// Otherwise we need to load the content and MeshFileIO save to the target path
|
||||||
return MeshFileIo.Save(item, filePathToSave);
|
using (var result = await streamContent.GetContentStream(null))
|
||||||
|
{
|
||||||
|
IObject3D item = Object3D.Load(result.Stream, Path.GetExtension(streamContent.FileName), CancellationToken.None);
|
||||||
|
return MeshFileIo.Save(item, filePathToSave);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -146,6 +146,7 @@ namespace MatterHackers.MatterControl.CustomWidgets
|
||||||
|
|
||||||
public void ClearItems()
|
public void ClearItems()
|
||||||
{
|
{
|
||||||
|
cellIndex = 0;
|
||||||
rowButtonContainer = null;
|
rowButtonContainer = null;
|
||||||
allIconViews.Clear();
|
allIconViews.Clear();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,11 +10,6 @@ namespace MatterControl.Tests.MatterControl
|
||||||
[TestFixture, Category("ConfigIni")]
|
[TestFixture, Category("ConfigIni")]
|
||||||
public class ImportSettingsTests
|
public class ImportSettingsTests
|
||||||
{
|
{
|
||||||
[Test]
|
|
||||||
public void CheckImportIniToPrinter()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void CheckImportPrinterSettingsToPrinter()
|
public void CheckImportPrinterSettingsToPrinter()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue