Revise shared export implementation to support GCode
This commit is contained in:
parent
342a9b1573
commit
e60e77eba7
1 changed files with 15 additions and 26 deletions
|
|
@ -76,35 +76,15 @@ namespace MatterHackers.MatterControl
|
||||||
contentRow.AddChild(exportAsAmfButton);
|
contentRow.AddChild(exportAsAmfButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RadioButton exportGCode = new RadioButton("Export as".Localize() + " G-Code", textColor: ActiveTheme.Instance.PrimaryTextColor);
|
||||||
|
exportGCode.Name = "Export as GCode Button";
|
||||||
|
exportGCode.Margin = commonMargin;
|
||||||
|
exportGCode.HAnchor = HAnchor.Left;
|
||||||
|
exportGCode.Cursor = Cursors.Hand;
|
||||||
|
|
||||||
bool showExportGCodeButton = ActiveSliceSettings.Instance.PrinterSelected || partIsGCode;
|
bool showExportGCodeButton = ActiveSliceSettings.Instance.PrinterSelected || partIsGCode;
|
||||||
if (showExportGCodeButton)
|
if (showExportGCodeButton)
|
||||||
{
|
{
|
||||||
Button exportGCode = textImageButtonFactory.Generate("Export as".Localize() + " G-Code");
|
|
||||||
exportGCode.Name = "Export as GCode Button";
|
|
||||||
exportGCode.Margin = commonMargin;
|
|
||||||
exportGCode.HAnchor = HAnchor.Left;
|
|
||||||
exportGCode.Cursor = Cursors.Hand;
|
|
||||||
exportGCode.Click += (s, e) =>
|
|
||||||
{
|
|
||||||
this.Parent.CloseOnIdle();
|
|
||||||
UiThread.RunOnIdle(() =>
|
|
||||||
{
|
|
||||||
FileDialog.SaveFileDialog(
|
|
||||||
new SaveFileDialogParams("Export GCode|*.gcode", title: "Export GCode")
|
|
||||||
{
|
|
||||||
Title = "MatterControl: Export File",
|
|
||||||
ActionButtonLabel = "Export",
|
|
||||||
FileName = Path.GetFileNameWithoutExtension(printItemWrapper.Name)
|
|
||||||
},
|
|
||||||
(saveParams) =>
|
|
||||||
{
|
|
||||||
if (!string.IsNullOrEmpty(saveParams.FileName))
|
|
||||||
{
|
|
||||||
ExportGcodeCommandLineUtility(saveParams.FileName);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
contentRow.AddChild(exportGCode);
|
contentRow.AddChild(exportGCode);
|
||||||
|
|
||||||
foreach (ExportGcodePlugin plugin in PluginFinder.CreateInstancesOf<ExportGcodePlugin>())
|
foreach (ExportGcodePlugin plugin in PluginFinder.CreateInstancesOf<ExportGcodePlugin>())
|
||||||
|
|
@ -238,6 +218,11 @@ namespace MatterHackers.MatterControl
|
||||||
fileTypeFilter = "Save as AMF|*.amf";
|
fileTypeFilter = "Save as AMF|*.amf";
|
||||||
targetExtension = ".amf";
|
targetExtension = ".amf";
|
||||||
}
|
}
|
||||||
|
else if (exportGCode.Checked)
|
||||||
|
{
|
||||||
|
fileTypeFilter = "Export GCode|*.gcode";
|
||||||
|
targetExtension = ".gcode";
|
||||||
|
}
|
||||||
|
|
||||||
this.Parent.CloseOnIdle();
|
this.Parent.CloseOnIdle();
|
||||||
UiThread.RunOnIdle(() =>
|
UiThread.RunOnIdle(() =>
|
||||||
|
|
@ -276,6 +261,10 @@ namespace MatterHackers.MatterControl
|
||||||
{
|
{
|
||||||
result = SaveAmf(sourceContent, savePath);
|
result = SaveAmf(sourceContent, savePath);
|
||||||
}
|
}
|
||||||
|
else if (exportGCode.Checked)
|
||||||
|
{
|
||||||
|
ExportGcodeCommandLineUtility(savePath);
|
||||||
|
}
|
||||||
|
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue