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.Title = "MatterControl: Export File";
|
||||||
saveParams.ActionButtonLabel = "Export";
|
saveParams.ActionButtonLabel = "Export";
|
||||||
|
|
||||||
System.IO.Stream streamToSaveTo = FileDialog.SaveFileDialog(ref saveParams);
|
FileDialog.SaveFileDialog(saveParams, onExportGcodeFileSelected);
|
||||||
if (streamToSaveTo != null)
|
|
||||||
{
|
|
||||||
streamToSaveTo.Close ();
|
|
||||||
|
|
||||||
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 == "")
|
if(extension == "")
|
||||||
{
|
{
|
||||||
File.Delete(gcodePathAndFilenameToSave);
|
File.Delete(gcodePathAndFilenameToSave);
|
||||||
gcodePathAndFilenameToSave += ".gcode";
|
gcodePathAndFilenameToSave += ".gcode";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Path.GetExtension(printItemWrapper.FileLocation).ToUpper() == ".STL")
|
if (Path.GetExtension(printItemWrapper.FileLocation).ToUpper() == ".STL")
|
||||||
{
|
{
|
||||||
Close();
|
Close();
|
||||||
SlicingQueue.Instance.QueuePartForSlicing(printItemWrapper);
|
SlicingQueue.Instance.QueuePartForSlicing(printItemWrapper);
|
||||||
printItemWrapper.SlicingDone.RegisterEvent(sliceItem_Done, ref unregisterEvents);
|
printItemWrapper.SlicingDone.RegisterEvent(sliceItem_Done, ref unregisterEvents);
|
||||||
}
|
}
|
||||||
else if (partIsGCode)
|
else if (partIsGCode)
|
||||||
{
|
{
|
||||||
Close();
|
Close();
|
||||||
SaveGCodeToNewLocation(printItemWrapper.FileLocation, gcodePathAndFilenameToSave);
|
SaveGCodeToNewLocation(printItemWrapper.FileLocation, gcodePathAndFilenameToSave);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ExportX3G_Click(object state)
|
void ExportX3G_Click(object state)
|
||||||
|
|
@ -338,11 +341,13 @@ namespace MatterHackers.MatterControl
|
||||||
saveParams.Title = "MatterControl: Export File";
|
saveParams.Title = "MatterControl: Export File";
|
||||||
saveParams.ActionButtonLabel = "Export";
|
saveParams.ActionButtonLabel = "Export";
|
||||||
|
|
||||||
System.IO.Stream streamToSaveTo = FileDialog.SaveFileDialog(ref saveParams);
|
FileDialog.SaveFileDialog(saveParams, onExportX3gFileSelected);
|
||||||
if (streamToSaveTo != null)
|
}
|
||||||
{
|
|
||||||
streamToSaveTo.Close ();
|
|
||||||
|
|
||||||
|
void onExportX3gFileSelected(SaveFileDialogParams saveParams)
|
||||||
|
{
|
||||||
|
if (saveParams.FileName != null)
|
||||||
|
{
|
||||||
x3gPathAndFilenameToSave = saveParams.FileName;
|
x3gPathAndFilenameToSave = saveParams.FileName;
|
||||||
string extension = Path.GetExtension(x3gPathAndFilenameToSave);
|
string extension = Path.GetExtension(x3gPathAndFilenameToSave);
|
||||||
if(extension == "")
|
if(extension == "")
|
||||||
|
|
@ -455,28 +460,30 @@ namespace MatterHackers.MatterControl
|
||||||
saveParams.ActionButtonLabel = "Export";
|
saveParams.ActionButtonLabel = "Export";
|
||||||
saveParams.FileName = printItemWrapper.Name;
|
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)
|
void sliceItem_Done(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
PrintItemWrapper sliceItem = (PrintItemWrapper)sender;
|
PrintItemWrapper sliceItem = (PrintItemWrapper)sender;
|
||||||
|
|
|
||||||
|
|
@ -948,14 +948,18 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||||
SaveFileDialogParams saveParams = new SaveFileDialogParams("Save Slice Preset|*." + configFileExtension, documentsPath);
|
SaveFileDialogParams saveParams = new SaveFileDialogParams("Save Slice Preset|*." + configFileExtension, documentsPath);
|
||||||
saveParams.FileName = presetNameInput.Text;
|
saveParams.FileName = presetNameInput.Text;
|
||||||
|
|
||||||
System.IO.Stream streamToSaveTo = FileDialog.SaveFileDialog(ref saveParams);
|
FileDialog.SaveFileDialog(saveParams, onSaveFileSelected);
|
||||||
if (streamToSaveTo != null)
|
|
||||||
{
|
|
||||||
streamToSaveTo.Close();
|
|
||||||
GenerateConfigFile(saveParams.FileName);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void onSaveFileSelected(SaveFileDialogParams saveParams)
|
||||||
|
{
|
||||||
|
if (saveParams.FileName != null)
|
||||||
|
{
|
||||||
|
GenerateConfigFile(saveParams.FileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void GenerateConfigFile(string fileName)
|
public void GenerateConfigFile(string fileName)
|
||||||
{
|
{
|
||||||
List<string> configFileAsList = new List<string>();
|
List<string> configFileAsList = new List<string>();
|
||||||
|
|
|
||||||
|
|
@ -116,14 +116,18 @@ namespace MatterHackers.MatterControl
|
||||||
string documentsPath = System.Environment.GetFolderPath (System.Environment.SpecialFolder.Personal);
|
string documentsPath = System.Environment.GetFolderPath (System.Environment.SpecialFolder.Personal);
|
||||||
SaveFileDialogParams saveParams = new SaveFileDialogParams("Save Project|*.mcp", initialDirectory: documentsPath);
|
SaveFileDialogParams saveParams = new SaveFileDialogParams("Save Project|*.mcp", initialDirectory: documentsPath);
|
||||||
|
|
||||||
System.IO.Stream streamToSaveTo = FileDialog.SaveFileDialog(ref saveParams);
|
FileDialog.SaveFileDialog(saveParams, onSaveFileSelected);
|
||||||
if (streamToSaveTo != null)
|
|
||||||
{
|
|
||||||
streamToSaveTo.Close();
|
|
||||||
ExportToJson(saveParams.FileName);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void onSaveFileSelected(SaveFileDialogParams saveParams)
|
||||||
|
{
|
||||||
|
if (saveParams.FileName != null)
|
||||||
|
{
|
||||||
|
ExportToJson(saveParams.FileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static string applicationDataPath = ApplicationDataStorage.Instance.ApplicationUserDataPath;
|
static string applicationDataPath = ApplicationDataStorage.Instance.ApplicationUserDataPath;
|
||||||
static string defaultPathAndFileName = applicationDataPath + "/data/default.mcp";
|
static string defaultPathAndFileName = applicationDataPath + "/data/default.mcp";
|
||||||
public void ExportToJson(string savedFileName = null)
|
public void ExportToJson(string savedFileName = null)
|
||||||
|
|
|
||||||
|
|
@ -155,14 +155,17 @@ namespace MatterHackers.MatterControl
|
||||||
string documentsPath = System.Environment.GetFolderPath (System.Environment.SpecialFolder.Personal);
|
string documentsPath = System.Environment.GetFolderPath (System.Environment.SpecialFolder.Personal);
|
||||||
SaveFileDialogParams saveParams = new SaveFileDialogParams("Save Project|*.zip", initialDirectory: documentsPath);
|
SaveFileDialogParams saveParams = new SaveFileDialogParams("Save Project|*.zip", initialDirectory: documentsPath);
|
||||||
|
|
||||||
System.IO.Stream streamToSaveTo = FileDialog.SaveFileDialog(ref saveParams);
|
FileDialog.SaveFileDialog(saveParams, onSaveFileSelected);
|
||||||
if (streamToSaveTo != null)
|
|
||||||
{
|
|
||||||
streamToSaveTo.Close();
|
|
||||||
ExportToProjectArchive(saveParams.FileName);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void onSaveFileSelected(SaveFileDialogParams saveParams)
|
||||||
|
{
|
||||||
|
if (saveParams.FileName != null)
|
||||||
|
{
|
||||||
|
ExportToProjectArchive(saveParams.FileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static string applicationDataPath = ApplicationDataStorage.Instance.ApplicationUserDataPath;
|
static string applicationDataPath = ApplicationDataStorage.Instance.ApplicationUserDataPath;
|
||||||
static string defaultManifestPathAndFileName = Path.Combine(applicationDataPath, "data", "temp", "project-assembly", "manifest.json");
|
static string defaultManifestPathAndFileName = Path.Combine(applicationDataPath, "data", "temp", "project-assembly", "manifest.json");
|
||||||
static string defaultProjectPathAndFileName = Path.Combine(applicationDataPath, "data", "default.zip");
|
static string defaultProjectPathAndFileName = Path.Combine(applicationDataPath, "data", "default.zip");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue