Merge pull request #2492 from jlewin/design_tools

Design tools
This commit is contained in:
johnlewin 2017-09-25 20:57:47 -07:00 committed by GitHub
commit b863c4494a
4 changed files with 28 additions and 27 deletions

View file

@ -34,6 +34,7 @@ using System.Threading.Tasks;
using MatterHackers.Agg.Image;
using MatterHackers.Agg.Platform;
using MatterHackers.Agg.UI;
using MatterHackers.DataConverters3D;
using MatterHackers.Localizations;
namespace MatterHackers.MatterControl.Library.Export
@ -55,14 +56,7 @@ namespace MatterHackers.MatterControl.Library.Export
public Task<bool> Generate(IEnumerable<ILibraryItem> libraryItems, string outputPath)
{
ILibraryContentStream libraryContent = libraryItems.OfType<ILibraryContentStream>().FirstOrDefault();
if (libraryContent != null)
{
return MeshExport.ExportMesh(libraryContent, outputPath);
}
return null;
return MeshExport.ExportMesh(libraryItems.FirstOrDefault(), outputPath);
}
public GuiWidget GetOptionsPanel() => null;

View file

@ -38,28 +38,39 @@ namespace MatterHackers.MatterControl.Library.Export
{
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
{
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))
using (var fileStream = File.Create(filePathToSave))
// If the file is already AMF, it just needs copied to the target path
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;
}
else
{
using (var result = await source.GetContentStream(null))
return true;
}
else
{
IObject3D item = Object3D.Load(result.Stream, Path.GetExtension(source.FileName), CancellationToken.None);
return MeshFileIo.Save(item, filePathToSave);
// Otherwise we need to load the content and MeshFileIO save to the target path
using (var result = await streamContent.GetContentStream(null))
{
IObject3D item = Object3D.Load(result.Stream, Path.GetExtension(streamContent.FileName), CancellationToken.None);
return MeshFileIo.Save(item, filePathToSave);
}
}
}
}

View file

@ -146,6 +146,7 @@ namespace MatterHackers.MatterControl.CustomWidgets
public void ClearItems()
{
cellIndex = 0;
rowButtonContainer = null;
allIconViews.Clear();
}

View file

@ -10,11 +10,6 @@ namespace MatterControl.Tests.MatterControl
[TestFixture, Category("ConfigIni")]
public class ImportSettingsTests
{
[Test]
public void CheckImportIniToPrinter()
{
}
[Test]
public void CheckImportPrinterSettingsToPrinter()
{