Save to compressed mcx is working
Don't call save twice
This commit is contained in:
parent
c351af843b
commit
a2aaaf6715
9 changed files with 109 additions and 56 deletions
|
|
@ -2167,11 +2167,13 @@ namespace MatterHackers.MatterControl
|
|||
if (settingsFilePath != null)
|
||||
{
|
||||
using (var file = File.OpenWrite(archivePath))
|
||||
using (var zip = new ZipArchive(file, ZipArchiveMode.Create))
|
||||
{
|
||||
zip.CreateEntryFromFile(sourcePath, "PrinterPlate.mcx");
|
||||
zip.CreateEntryFromFile(settingsFilePath, printer.PrinterName + ".printer");
|
||||
zip.CreateEntryFromFile(gcodeFilePath, "sliced.gcode");
|
||||
using (var zip = new ZipArchive(file, ZipArchiveMode.Create))
|
||||
{
|
||||
zip.CreateEntryFromFile(sourcePath, "PrinterPlate.mcx");
|
||||
zip.CreateEntryFromFile(settingsFilePath, printer.PrinterName + ".printer");
|
||||
zip.CreateEntryFromFile(gcodeFilePath, "sliced.gcode");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -194,7 +194,7 @@ namespace MatterHackers.MatterControl.Library.Export
|
|||
{
|
||||
status.Progress0To1 = percentComplete;
|
||||
progress.Report(status);
|
||||
}, publishAssets: false);
|
||||
}, forceIntoCache: false);
|
||||
}
|
||||
else if (assetStream != null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ either expressed or implied, of the FreeBSD Project.
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using MatterHackers.Agg;
|
||||
|
|
@ -37,6 +38,7 @@ using MatterHackers.Agg.Image;
|
|||
using MatterHackers.Agg.Platform;
|
||||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.DataConverters3D;
|
||||
using MatterHackers.Localizations;
|
||||
using MatterHackers.MatterControl.DataStorage;
|
||||
|
||||
namespace MatterHackers.MatterControl.Library
|
||||
|
|
@ -84,18 +86,83 @@ namespace MatterHackers.MatterControl.Library
|
|||
{
|
||||
if (item is FileSystemFileItem fileItem)
|
||||
{
|
||||
if (fileItem.FilePath.Contains(ApplicationDataStorage.Instance.LibraryAssetsPath))
|
||||
{
|
||||
if (fileItem.FilePath.Contains(ApplicationDataStorage.Instance.ApplicationLibraryDataPath))
|
||||
{
|
||||
// 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)
|
||||
{
|
||||
ApplicationController.Instance.Tasks.Execute(
|
||||
"Saving Changes".Localize(),
|
||||
null,
|
||||
async (reporter, cancellationTokenSource) =>
|
||||
{
|
||||
var status = new ProgressStatus()
|
||||
{
|
||||
Status = "Saving Asset".Localize()
|
||||
};
|
||||
|
||||
// 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));
|
||||
// make sure we have all the mesh items in the cache for saving to the archive
|
||||
await content.PersistAssets((percentComplete, text) =>
|
||||
{
|
||||
status.Progress0To1 = percentComplete * .9;
|
||||
reporter.Report(status);
|
||||
}, forceIntoCache: true);
|
||||
|
||||
var backupName = "";
|
||||
// rename any existing file
|
||||
if (File.Exists(fileItem.FilePath))
|
||||
{
|
||||
var directory = Path.GetDirectoryName(fileItem.FilePath);
|
||||
var filename = Path.GetFileNameWithoutExtension(fileItem.FilePath);
|
||||
backupName = Path.Combine(directory, Path.ChangeExtension(filename + "_bak", ".mcx"));
|
||||
File.Move(fileItem.FilePath, backupName);
|
||||
}
|
||||
|
||||
var persistableItems = content.GetPersistable(true);
|
||||
var persistCount = persistableItems.Count();
|
||||
var savedCount = 0;
|
||||
|
||||
// save to a binary mcx file (a zip with a scene.mcx and an assets folder)
|
||||
using (var file = File.OpenWrite(fileItem.FilePath))
|
||||
{
|
||||
using (var zip = new ZipArchive(file, ZipArchiveMode.Create))
|
||||
{
|
||||
using (var writer = new StreamWriter(zip.CreateEntry("scene.mcx").Open()))
|
||||
{
|
||||
writer.Write(content.ToJson());
|
||||
}
|
||||
|
||||
foreach (var persistMeshItem in persistableItems)
|
||||
{
|
||||
var sourcePath = persistMeshItem.MeshPath;
|
||||
if (!File.Exists(sourcePath))
|
||||
{
|
||||
sourcePath = Path.Combine(ApplicationDataStorage.Instance.LibraryAssetsPath, Path.GetFileName(persistMeshItem.MeshPath));
|
||||
}
|
||||
if (File.Exists(sourcePath))
|
||||
{
|
||||
var assetName = Path.Combine("Assets", Path.GetFileName(sourcePath));
|
||||
zip.CreateEntryFromFile(sourcePath, assetName);
|
||||
}
|
||||
|
||||
savedCount++;
|
||||
status.Progress0To1 = .9 + .1 * (savedCount / persistCount);
|
||||
reporter.Report(status);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Serialize the scene to disk using a modified Json.net pipeline with custom ContractResolvers and JsonConverters
|
||||
this.OnItemContentChanged(new LibraryItemChangedEventArgs(fileItem));
|
||||
|
||||
// remove the existing file after a successfull save
|
||||
if (!string.IsNullOrEmpty(backupName))
|
||||
{
|
||||
File.Delete(backupName);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -550,7 +550,12 @@ namespace MatterHackers.MatterControl.CustomWidgets
|
|||
}
|
||||
else
|
||||
{
|
||||
ApplicationController.Instance.OpenIntoNewTab(new[] { itemModel });
|
||||
void OpenNewTab()
|
||||
{
|
||||
_ = ApplicationController.Instance.OpenIntoNewTab(new[] { itemModel });
|
||||
}
|
||||
|
||||
OpenNewTab();
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -70,6 +70,8 @@ namespace MatterHackers.MatterControl
|
|||
if (librarySelectorWidget.ActiveContainer is ILibraryWritableContainer)
|
||||
{
|
||||
acceptButton.InvokeClick();
|
||||
// And disable it so there are not multiple fires. No need to re-enable, the dialog is going to close.
|
||||
this.AcceptButton.Enabled = false;
|
||||
}
|
||||
};
|
||||
contentRow.AddChild(itemNameWidget);
|
||||
|
|
|
|||
|
|
@ -486,7 +486,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
{
|
||||
this.CloseClicked?.Invoke(this, null);
|
||||
// Must be called after CloseClicked otherwise listeners are cleared before event is invoked
|
||||
this.parentTabControl.CloseTab(this);
|
||||
this.parentTabControl?.CloseTab(this);
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -603,8 +603,6 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
mergeString += ",";
|
||||
}
|
||||
|
||||
// TODO: Use existing AssetsPath property
|
||||
string assetsDirectory = Path.Combine(ApplicationDataStorage.Instance.ApplicationLibraryDataPath, "Assets");
|
||||
var itemWorldMatrix = item.WorldMatrix();
|
||||
if (item is GeneratedSupportObject3D generatedSupportObject3D
|
||||
&& item.Mesh != null)
|
||||
|
|
@ -616,7 +614,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
itemWorldMatrix = itemWorldMatrix.ApplyAtPosition(aabbForCenter.Center.Transform(itemWorldMatrix), Matrix4X4.CreateScale(xyScale, xyScale, 1));
|
||||
}
|
||||
|
||||
outputItems.Add((itemWorldMatrix, Path.Combine(assetsDirectory, item.MeshPath)));
|
||||
outputItems.Add((itemWorldMatrix, Path.Combine(ApplicationDataStorage.Instance.LibraryAssetsPath, item.MeshPath)));
|
||||
mergeString += $"({savedStlCount++}";
|
||||
first = false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,12 +28,6 @@ Translated:%
|
|||
English:(Press 'Skip' to setup connection later)
|
||||
Translated:(Press 'Skip' to setup connection later)
|
||||
|
||||
English:\nBelow you can find a list of each setting that has changed.
|
||||
Translated:\nBelow you can find a list of each setting that has changed.
|
||||
|
||||
English:\nUpdating a default setting will not change any override that you have applied.
|
||||
Translated:\nUpdating a default setting will not change any override that you have applied.
|
||||
|
||||
English:{0} (Update Available)
|
||||
Translated:{0} (Update Available)
|
||||
|
||||
|
|
@ -322,8 +316,8 @@ Translated:Anchor
|
|||
English:and ensure that no filament is stuck to your nozzle.
|
||||
Translated:and ensure that no filament is stuck to your nozzle.
|
||||
|
||||
English:and the hotend to heat to
|
||||
Translated:and the hotend to heat to
|
||||
English:and the hotend to heat to
|
||||
Translated:and the hotend to heat to
|
||||
|
||||
English:Angle
|
||||
Translated:Angle
|
||||
|
|
@ -367,9 +361,6 @@ Translated:Are you sure you want to delete printer '{0}'?
|
|||
English:Are you sure you want to exit while a print is running from SD Card?\n\nNote: If you exit, it is recommended you wait until the print is completed before running MatterControl again.
|
||||
Translated:Are you sure you want to exit while a print is running from SD Card?\n\nNote: If you exit, it is recommended you wait until the print is completed before running MatterControl again.
|
||||
|
||||
English:Are you sure you want to exit while a print is running from SD Card?\n\nNote: If you exit, it is recommended you wait until the print is completed before running MatterControl again.
|
||||
Translated:Are you sure you want to exit while a print is running from SD Card?\n\nNote: If you exit, it is recommended you wait until the print is completed before running MatterControl again.
|
||||
|
||||
English:Are you sure you want to remove the currently selected items?
|
||||
Translated:Are you sure you want to remove the currently selected items?
|
||||
|
||||
|
|
@ -1495,8 +1486,8 @@ Translated:Error: Below Conductive Probe Min Z
|
|||
English:Error: Could not create file for saving. Original error
|
||||
Translated:Error: Could not create file for saving. Original error
|
||||
|
||||
English:Error: Could not read file from disk. Original error:
|
||||
Translated:Error: Could not read file from disk. Original error:
|
||||
English:Error: Could not read file from disk. Original error:
|
||||
Translated:Error: Could not read file from disk. Original error:
|
||||
|
||||
English:Estimated Cost
|
||||
Translated:Estimated Cost
|
||||
|
|
@ -2332,9 +2323,6 @@ Translated:IP Finder
|
|||
English:It appears your last print failed to complete.\n\nWould your like to attempt to recover from the last know position?
|
||||
Translated:It appears your last print failed to complete.\n\nWould your like to attempt to recover from the last know position?
|
||||
|
||||
English:It appears your last print failed to complete.\n\nWould your like to attempt to recover from the last know position?
|
||||
Translated:It appears your last print failed to complete.\n\nWould your like to attempt to recover from the last know position?
|
||||
|
||||
English:It is currently set to {0}.
|
||||
Translated:It is currently set to {0}.
|
||||
|
||||
|
|
@ -2584,6 +2572,9 @@ Translated:Macro Presets
|
|||
English:Macros
|
||||
Translated:Macros
|
||||
|
||||
English:Maintain Proportions
|
||||
Translated:Maintain Proportions
|
||||
|
||||
English:Maintain Surface
|
||||
Translated:Maintain Surface
|
||||
|
||||
|
|
@ -3172,6 +3163,9 @@ Translated:Open Settings View Options
|
|||
English:OpenSCAD not installed
|
||||
Translated:OpenSCAD not installed
|
||||
|
||||
English:Operation
|
||||
Translated:Operation
|
||||
|
||||
English:Optional
|
||||
Translated:Optional
|
||||
|
||||
|
|
@ -3886,9 +3880,6 @@ Translated:Reset View
|
|||
English:Resetting to default values will remove your current overrides and restore your original printer settings.\nAre you sure you want to continue?
|
||||
Translated:Resetting to default values will remove your current overrides and restore your original printer settings.\nAre you sure you want to continue?
|
||||
|
||||
English:Resetting to default values will remove your current overrides and restore your original printer settings.\nAre you sure you want to continue?
|
||||
Translated:Resetting to default values will remove your current overrides and restore your original printer settings.\nAre you sure you want to continue?
|
||||
|
||||
English:Reshape
|
||||
Translated:Reshape
|
||||
|
||||
|
|
@ -4120,6 +4111,9 @@ Translated:SCAD Script
|
|||
English:Scale
|
||||
Translated:Scale
|
||||
|
||||
English:Scale About
|
||||
Translated:Scale About
|
||||
|
||||
English:Scale Offset
|
||||
Translated:Scale Offset
|
||||
|
||||
|
|
@ -4885,9 +4879,6 @@ Translated:The extra distance the raft will extend around the edge of the part.
|
|||
English:The extruder is currently heating and its target temperature cannot be changed until it reaches {0}°C.\n\nYou can set the starting extruder temperature in 'Slice Settings' -> 'Filament'.\n\n{1}
|
||||
Translated:The extruder is currently heating and its target temperature cannot be changed until it reaches {0}°C.\n\nYou can set the starting extruder temperature in 'Slice Settings' -> 'Filament'.\n\n{1}
|
||||
|
||||
English:The extruder is currently heating and its target temperature cannot be changed until it reaches {0}°C.\n\nYou can set the starting extruder temperature in 'Slice Settings' -> 'Filament'.\n\n{1}
|
||||
Translated:The extruder is currently heating and its target temperature cannot be changed until it reaches {0}°C.\n\nYou can set the starting extruder temperature in 'Slice Settings' -> 'Filament'.\n\n{1}
|
||||
|
||||
English:The extruder to use for support material. Default will use whichever extruder active at the time.
|
||||
Translated:The extruder to use for support material. Default will use whichever extruder active at the time.
|
||||
|
||||
|
|
@ -4915,9 +4906,6 @@ Translated:The height of the printer's printable volume, in millimeters. Control
|
|||
English:The inset amount for each side of the bed.\n- As a % of the width or depth\n- Ordered: Left, Front, Right, Back\n- NOTE: The probe offset is added on top of this
|
||||
Translated:The inset amount for each side of the bed.\n- As a % of the width or depth\n- Ordered: Left, Front, Right, Back\n- NOTE: The probe offset is added on top of this
|
||||
|
||||
English:The inset amount for each side of the bed.\n- As a % of the width or depth\n- Ordered: Left, Front, Right, Back\n- NOTE: The probe offset is added on top of this
|
||||
Translated:The inset amount for each side of the bed.\n- As a % of the width or depth\n- Ordered: Left, Front, Right, Back\n- NOTE: The probe offset is added on top of this
|
||||
|
||||
English:The inset amount for nozzle 1 from the bed (Left, Front, Right, Back).
|
||||
Translated:The inset amount for nozzle 1 from the bed (Left, Front, Right, Back).
|
||||
|
||||
|
|
@ -5128,9 +5116,6 @@ Translated:The serial port communication speed of the printers firmware.
|
|||
English:The 'Serial Port' section lists all available serial\nports on your device. Changing which USB port the printer\nis connected to may change the associated serial port.\n\nTip: If you are uncertain, unplug/plug in your printer\nand hit refresh. The new port that appears should be\nyour printer.
|
||||
Translated:The 'Serial Port' section lists all available serial\nports on your device. Changing which USB port the printer\nis connected to may change the associated serial port.\n\nTip: If you are uncertain, unplug/plug in your printer\nand hit refresh. The new port that appears should be\nyour printer.
|
||||
|
||||
English:The 'Serial Port' section lists all available serial\nports on your device. Changing which USB port the printer\nis connected to may change the associated serial port.\n\nTip: If you are uncertain, unplug/plug in your printer\nand hit refresh. The new port that appears should be\nyour printer.
|
||||
Translated:The 'Serial Port' section lists all available serial\nports on your device. Changing which USB port the printer\nis connected to may change the associated serial port.\n\nTip: If you are uncertain, unplug/plug in your printer\nand hit refresh. The new port that appears should be\nyour printer.
|
||||
|
||||
English:The serial port to use while connecting to this printer.
|
||||
Translated:The serial port to use while connecting to this printer.
|
||||
|
||||
|
|
@ -5680,6 +5665,9 @@ Translated:Use G0 for moves rather than G1.
|
|||
English:Use Grade 2
|
||||
Translated:Use Grade 2
|
||||
|
||||
English:Use Percentage
|
||||
Translated:Use Percentage
|
||||
|
||||
English:Use Relative E Distances
|
||||
Translated:Use Relative E Distances
|
||||
|
||||
|
|
@ -5842,12 +5830,6 @@ Translated:Warning, very short print
|
|||
English:WARNING: Disconnecting will stop the current print.\n\nAre you sure you want to disconnect?
|
||||
Translated:WARNING: Disconnecting will stop the current print.\n\nAre you sure you want to disconnect?
|
||||
|
||||
English:WARNING: Disconnecting will stop the current print.\n\nAre you sure you want to disconnect?
|
||||
Translated:WARNING: Disconnecting will stop the current print.\n\nAre you sure you want to disconnect?
|
||||
|
||||
English:WARNING: In order to perform print recovery, your printer must move down to reach its home position.\nIf your print is too large, part of your printer may collide with it when moving down.\nMake sure it is safe to perform this operation before proceeding.
|
||||
Translated:WARNING: In order to perform print recovery, your printer must move down to reach its home position.\nIf your print is too large, part of your printer may collide with it when moving down.\nMake sure it is safe to perform this operation before proceeding.
|
||||
|
||||
English:WARNING: In order to perform print recovery, your printer must move down to reach its home position.\nIf your print is too large, part of your printer may collide with it when moving down.\nMake sure it is safe to perform this operation before proceeding.
|
||||
Translated:WARNING: In order to perform print recovery, your printer must move down to reach its home position.\nIf your print is too large, part of your printer may collide with it when moving down.\nMake sure it is safe to perform this operation before proceeding.
|
||||
|
||||
|
|
@ -6025,9 +6007,6 @@ Translated:You should have at least 3 top layers for this calibration to measure
|
|||
English:Your 3D print has been auto-paused.\n\nLayer {0} reached.
|
||||
Translated:Your 3D print has been auto-paused.\n\nLayer {0} reached.
|
||||
|
||||
English:Your 3D print has been auto-paused.\n\nLayer {0} reached.
|
||||
Translated:Your 3D print has been auto-paused.\n\nLayer {0} reached.
|
||||
|
||||
English:Your 3D print has been paused.\n\nOut of filament, or jam, detected. Please load more filament or clear the jam.
|
||||
Translated:Your 3D print has been paused.\n\nOut of filament, or jam, detected. Please load more filament or clear the jam.
|
||||
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 944f9897b7e2adaa9b1de88960d1fbaff24669ad
|
||||
Subproject commit fc5991cdcc86cef219b6a4215f3551f98904f065
|
||||
Loading…
Add table
Add a link
Reference in a new issue