Ability to load binary mcx files (that are zips)

This commit is contained in:
Lars Brubaker 2022-02-01 16:44:11 -08:00
parent 9bc29a1ddd
commit 981e569192
6 changed files with 29 additions and 4 deletions

View file

@ -882,7 +882,10 @@ namespace MatterHackers.MatterControl
"Design Apps".Localize(),
StaticData.Instance.LoadIcon(Path.Combine("Library", "folder.png")),
StaticData.Instance.LoadIcon(Path.Combine("Library", "design_apps_icon.png")),
() => this.Library.DesignAppsCollectionContainer));
() => this.Library.DesignAppsCollectionContainer)
{
IsReadOnly = true
});
if (File.Exists(ApplicationDataStorage.Instance.CustomLibraryFoldersPath))
{

View file

@ -103,7 +103,7 @@ namespace MatterHackers.MatterControl
}
}
internal void Save(IObject3D scene)
public void Save(IObject3D scene)
{
if (!this.FreezeGCode)
{

View file

@ -36,6 +36,8 @@ using MatterHackers.Agg;
using MatterHackers.Agg.Image;
using MatterHackers.Agg.Platform;
using MatterHackers.Agg.UI;
using MatterHackers.DataConverters3D;
using MatterHackers.MatterControl.DataStorage;
namespace MatterHackers.MatterControl.Library
{
@ -78,6 +80,26 @@ namespace MatterHackers.MatterControl.Library
}
}
public override void Save(ILibraryItem item, IObject3D content)
{
if (item is FileSystemFileItem fileItem)
{
if (fileItem.FilePath.Contains(ApplicationDataStorage.Instance.LibraryAssetsPath))
{
// save using the normal uncompressed mcx file
base.Save(item, content);
}
else
{
// save to a binary mcx file (a zip with a scene.mcx and an assets folder)
// Serialize the scene to disk using a modified Json.net pipeline with custom ContractResolvers and JsonConverters
File.WriteAllText(fileItem.FilePath, content.ToJson());
this.OnItemContentChanged(new LibraryItemChangedEventArgs(fileItem));
}
}
}
public override void SetThumbnail(ILibraryItem item, int width, int height, ImageBuffer imageBuffer)
{
#if DEBUG

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.7 KiB

After

Width:  |  Height:  |  Size: 6 KiB

Before After
Before After

@ -1 +1 @@
Subproject commit e7992a7dc95711814717f0d72a2cdd306b31720f
Subproject commit 852f10964058e9179e48da89917c93ad07194486

@ -1 +1 @@
Subproject commit 36d15c1a124e28738491f7ebc2cbbe5e0f00dcf7
Subproject commit 944f9897b7e2adaa9b1de88960d1fbaff24669ad