Made file saves async compatible.
This commit is contained in:
parent
fbe1333cf0
commit
992c8a2430
4 changed files with 80 additions and 62 deletions
|
|
@ -304,32 +304,35 @@ namespace MatterHackers.MatterControl
|
|||
saveParams.Title = "MatterControl: Export File";
|
||||
saveParams.ActionButtonLabel = "Export";
|
||||
|
||||
System.IO.Stream streamToSaveTo = FileDialog.SaveFileDialog(ref saveParams);
|
||||
if (streamToSaveTo != null)
|
||||
{
|
||||
streamToSaveTo.Close ();
|
||||
FileDialog.SaveFileDialog(saveParams, onExportGcodeFileSelected);
|
||||
|
||||
gcodePathAndFilenameToSave = saveParams.FileName;
|
||||
string extension = Path.GetExtension(gcodePathAndFilenameToSave);
|
||||
}
|
||||
|
||||
void onExportGcodeFileSelected(SaveFileDialogParams saveParams)
|
||||
{
|
||||
if (saveParams.FileName != null)
|
||||
{
|
||||
gcodePathAndFilenameToSave = saveParams.FileName;
|
||||
string extension = Path.GetExtension(gcodePathAndFilenameToSave);
|
||||
if(extension == "")
|
||||
{
|
||||
File.Delete(gcodePathAndFilenameToSave);
|
||||
gcodePathAndFilenameToSave += ".gcode";
|
||||
File.Delete(gcodePathAndFilenameToSave);
|
||||
gcodePathAndFilenameToSave += ".gcode";
|
||||
}
|
||||
|
||||
if (Path.GetExtension(printItemWrapper.FileLocation).ToUpper() == ".STL")
|
||||
{
|
||||
Close();
|
||||
SlicingQueue.Instance.QueuePartForSlicing(printItemWrapper);
|
||||
printItemWrapper.SlicingDone.RegisterEvent(sliceItem_Done, ref unregisterEvents);
|
||||
}
|
||||
else if (partIsGCode)
|
||||
{
|
||||
Close();
|
||||
SaveGCodeToNewLocation(printItemWrapper.FileLocation, gcodePathAndFilenameToSave);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Path.GetExtension(printItemWrapper.FileLocation).ToUpper() == ".STL")
|
||||
{
|
||||
Close();
|
||||
SlicingQueue.Instance.QueuePartForSlicing(printItemWrapper);
|
||||
printItemWrapper.SlicingDone.RegisterEvent(sliceItem_Done, ref unregisterEvents);
|
||||
}
|
||||
else if (partIsGCode)
|
||||
{
|
||||
Close();
|
||||
SaveGCodeToNewLocation(printItemWrapper.FileLocation, gcodePathAndFilenameToSave);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ExportX3G_Click(object state)
|
||||
|
|
@ -338,11 +341,13 @@ namespace MatterHackers.MatterControl
|
|||
saveParams.Title = "MatterControl: Export File";
|
||||
saveParams.ActionButtonLabel = "Export";
|
||||
|
||||
System.IO.Stream streamToSaveTo = FileDialog.SaveFileDialog(ref saveParams);
|
||||
if (streamToSaveTo != null)
|
||||
{
|
||||
streamToSaveTo.Close ();
|
||||
FileDialog.SaveFileDialog(saveParams, onExportX3gFileSelected);
|
||||
}
|
||||
|
||||
void onExportX3gFileSelected(SaveFileDialogParams saveParams)
|
||||
{
|
||||
if (saveParams.FileName != null)
|
||||
{
|
||||
x3gPathAndFilenameToSave = saveParams.FileName;
|
||||
string extension = Path.GetExtension(x3gPathAndFilenameToSave);
|
||||
if(extension == "")
|
||||
|
|
@ -455,28 +460,30 @@ namespace MatterHackers.MatterControl
|
|||
saveParams.ActionButtonLabel = "Export";
|
||||
saveParams.FileName = printItemWrapper.Name;
|
||||
|
||||
System.IO.Stream streamToSaveTo = FileDialog.SaveFileDialog(ref saveParams);
|
||||
FileDialog.SaveFileDialog(saveParams, onExportStlFileSelected);
|
||||
|
||||
if (streamToSaveTo != null)
|
||||
{
|
||||
streamToSaveTo.Close ();
|
||||
Close();
|
||||
}
|
||||
|
||||
string filePathToSave = saveParams.FileName;
|
||||
if (filePathToSave != null && filePathToSave != "")
|
||||
{
|
||||
string extension = Path.GetExtension(filePathToSave);
|
||||
if (extension == "")
|
||||
{
|
||||
File.Delete(filePathToSave);
|
||||
filePathToSave += ".stl";
|
||||
}
|
||||
File.Copy(printItemWrapper.FileLocation, filePathToSave, true);
|
||||
ShowFileIfRequested(filePathToSave);
|
||||
}
|
||||
}
|
||||
|
||||
void onExportStlFileSelected(SaveFileDialogParams saveParams)
|
||||
{
|
||||
Close();
|
||||
if (saveParams.FileName != null)
|
||||
{
|
||||
string filePathToSave = saveParams.FileName;
|
||||
if (filePathToSave != null && filePathToSave != "")
|
||||
{
|
||||
string extension = Path.GetExtension(filePathToSave);
|
||||
if (extension == "")
|
||||
{
|
||||
File.Delete(filePathToSave);
|
||||
filePathToSave += ".stl";
|
||||
}
|
||||
File.Copy(printItemWrapper.FileLocation, filePathToSave, true);
|
||||
ShowFileIfRequested(filePathToSave);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sliceItem_Done(object sender, EventArgs e)
|
||||
{
|
||||
PrintItemWrapper sliceItem = (PrintItemWrapper)sender;
|
||||
|
|
|
|||
|
|
@ -948,14 +948,18 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
SaveFileDialogParams saveParams = new SaveFileDialogParams("Save Slice Preset|*." + configFileExtension, documentsPath);
|
||||
saveParams.FileName = presetNameInput.Text;
|
||||
|
||||
System.IO.Stream streamToSaveTo = FileDialog.SaveFileDialog(ref saveParams);
|
||||
if (streamToSaveTo != null)
|
||||
{
|
||||
streamToSaveTo.Close();
|
||||
GenerateConfigFile(saveParams.FileName);
|
||||
}
|
||||
FileDialog.SaveFileDialog(saveParams, onSaveFileSelected);
|
||||
|
||||
}
|
||||
|
||||
void onSaveFileSelected(SaveFileDialogParams saveParams)
|
||||
{
|
||||
if (saveParams.FileName != null)
|
||||
{
|
||||
GenerateConfigFile(saveParams.FileName);
|
||||
}
|
||||
}
|
||||
|
||||
public void GenerateConfigFile(string fileName)
|
||||
{
|
||||
List<string> configFileAsList = new List<string>();
|
||||
|
|
|
|||
|
|
@ -116,14 +116,18 @@ namespace MatterHackers.MatterControl
|
|||
string documentsPath = System.Environment.GetFolderPath (System.Environment.SpecialFolder.Personal);
|
||||
SaveFileDialogParams saveParams = new SaveFileDialogParams("Save Project|*.mcp", initialDirectory: documentsPath);
|
||||
|
||||
System.IO.Stream streamToSaveTo = FileDialog.SaveFileDialog(ref saveParams);
|
||||
if (streamToSaveTo != null)
|
||||
{
|
||||
streamToSaveTo.Close();
|
||||
ExportToJson(saveParams.FileName);
|
||||
}
|
||||
FileDialog.SaveFileDialog(saveParams, onSaveFileSelected);
|
||||
|
||||
}
|
||||
|
||||
void onSaveFileSelected(SaveFileDialogParams saveParams)
|
||||
{
|
||||
if (saveParams.FileName != null)
|
||||
{
|
||||
ExportToJson(saveParams.FileName);
|
||||
}
|
||||
}
|
||||
|
||||
static string applicationDataPath = ApplicationDataStorage.Instance.ApplicationUserDataPath;
|
||||
static string defaultPathAndFileName = applicationDataPath + "/data/default.mcp";
|
||||
public void ExportToJson(string savedFileName = null)
|
||||
|
|
|
|||
|
|
@ -155,14 +155,17 @@ namespace MatterHackers.MatterControl
|
|||
string documentsPath = System.Environment.GetFolderPath (System.Environment.SpecialFolder.Personal);
|
||||
SaveFileDialogParams saveParams = new SaveFileDialogParams("Save Project|*.zip", initialDirectory: documentsPath);
|
||||
|
||||
System.IO.Stream streamToSaveTo = FileDialog.SaveFileDialog(ref saveParams);
|
||||
if (streamToSaveTo != null)
|
||||
{
|
||||
streamToSaveTo.Close();
|
||||
ExportToProjectArchive(saveParams.FileName);
|
||||
}
|
||||
FileDialog.SaveFileDialog(saveParams, onSaveFileSelected);
|
||||
}
|
||||
|
||||
void onSaveFileSelected(SaveFileDialogParams saveParams)
|
||||
{
|
||||
if (saveParams.FileName != null)
|
||||
{
|
||||
ExportToProjectArchive(saveParams.FileName);
|
||||
}
|
||||
}
|
||||
|
||||
static string applicationDataPath = ApplicationDataStorage.Instance.ApplicationUserDataPath;
|
||||
static string defaultManifestPathAndFileName = Path.Combine(applicationDataPath, "data", "temp", "project-assembly", "manifest.json");
|
||||
static string defaultProjectPathAndFileName = Path.Combine(applicationDataPath, "data", "default.zip");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue