implementing part of export as x3g

This commit is contained in:
gregory-diaz 2014-08-19 18:10:38 -07:00
parent c8530bc699
commit a9bfdf9fd3
5 changed files with 91 additions and 3 deletions

View file

@ -1,4 +1,5 @@
using System; using System;
using System.Diagnostics;
using System.Text; using System.Text;
using System.Collections.Generic; using System.Collections.Generic;
using System.Globalization; using System.Globalization;
@ -121,6 +122,20 @@ namespace MatterHackers.MatterControl
}); });
middleRowContainer.AddChild(exportToSdCard); middleRowContainer.AddChild(exportToSdCard);
} }
if (ActiveSliceSettings.Instance.IsMakerbotGCodeFlavor() && !PrinterConnectionAndCommunication.Instance.PrinterIsPrinting)
{
string exportAsX3GText = "Export as X3G".Localize();
Button exportAsX3G = textImageButtonFactory.Generate(exportAsX3GText);
exportAsX3G.HAnchor = HAnchor.ParentLeft;
exportAsX3G.Cursor = Cursors.Hand;
exportAsX3G.Click += new ButtonBase.ButtonEventHandler((object sender, MouseEventArgs e) =>
{
UiThread.RunOnIdle(ExportX3G_Click);
});
middleRowContainer.AddChild(exportAsX3G);
}
} }
middleRowContainer.AddChild(new VerticalSpacer()); middleRowContainer.AddChild(new VerticalSpacer());
@ -312,6 +327,45 @@ namespace MatterHackers.MatterControl
} }
} }
void ExportX3G_Click(object state)
{
SaveFileDialogParams saveParams = new SaveFileDialogParams("Export GCode|*.gcode", title: "Export GCode");
saveParams.Title = "MatterControl: Export File";
saveParams.ActionButtonLabel = "Export";
System.IO.Stream streamToSaveTo = FileDialog.SaveFileDialog(ref saveParams);
if (streamToSaveTo != null)
{
streamToSaveTo.Close ();
pathAndFilenameToSave = saveParams.FileName;
string extension = Path.GetExtension(pathAndFilenameToSave);
if(extension == "")
{
File.Delete(pathAndFilenameToSave);
pathAndFilenameToSave += ".gcode";
}
if (Path.GetExtension(printItemWrapper.FileLocation).ToUpper() == ".STL")
{
Close();
SlicingQueue.Instance.QueuePartForSlicing(printItemWrapper);
printItemWrapper.SlicingDone.RegisterEvent(sliceItem_Done, ref unregisterEvents);
/*ProcessStartInfo exportX3GProcess = new ProcessStartInfo(printItemWrapper.PrintItem.Name);
exportX3GProcess.UseShellExecute = true;
exportX3GProcess.FileName = "C:\\Users\\Matter Hackers 1\\GPX\\gpx-win32-1.3\\gpx-win32-1.3\\gpx.exe";
Process.Start(exportX3GProcess);*/
}
else if (partIsGCode)
{
Close();
SaveGCodeToNewLocation(printItemWrapper.FileLocation, pathAndFilenameToSave);
}
}
}
private void SaveGCodeToNewLocation(string source, string dest) private void SaveGCodeToNewLocation(string source, string dest)
{ {
if (ActivePrinterProfile.Instance.DoPrintLeveling) if (ActivePrinterProfile.Instance.DoPrintLeveling)
@ -430,6 +484,10 @@ namespace MatterHackers.MatterControl
printItemWrapper.SlicingDone.UnregisterEvent(sliceItem_Done, ref unregisterEvents); printItemWrapper.SlicingDone.UnregisterEvent(sliceItem_Done, ref unregisterEvents);
SaveGCodeToNewLocation(sliceItem.GetGCodePathAndFileName(), pathAndFilenameToSave); SaveGCodeToNewLocation(sliceItem.GetGCodePathAndFileName(), pathAndFilenameToSave);
ProcessStartInfo exportX3GProcess = new ProcessStartInfo(printItemWrapper.PrintItem.Name);
exportX3GProcess.UseShellExecute = true;
exportX3GProcess.FileName = "C:\\Users\\Matter Hackers 1\\GPX\\gpx-win32-1.3\\gpx-win32-1.3\\gpx.exe";
Process.Start(exportX3GProcess);
} }
} }
} }

View file

@ -38,7 +38,6 @@
<BootstrapperEnabled>true</BootstrapperEnabled> <BootstrapperEnabled>true</BootstrapperEnabled>
<ProductVersion>8.0.30703</ProductVersion> <ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion> <SchemaVersion>2.0</SchemaVersion>
<ReleaseVersion>0.8.2</ReleaseVersion>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>True</DebugSymbols> <DebugSymbols>True</DebugSymbols>
@ -48,7 +47,6 @@
<DefineConstants>TRACE;DEBUG;USE_OPENGL;IS_WINDOWS;IS_WINDOWS_FORMS</DefineConstants> <DefineConstants>TRACE;DEBUG;USE_OPENGL;IS_WINDOWS;IS_WINDOWS_FORMS</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
<PlatformTarget>x86</PlatformTarget> <PlatformTarget>x86</PlatformTarget>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
@ -244,6 +242,11 @@
<Compile Include="EeProm\EePromRepetierStorage.cs" /> <Compile Include="EeProm\EePromRepetierStorage.cs" />
<Compile Include="PartPreviewWindow\SaveAsWindow.cs" /> <Compile Include="PartPreviewWindow\SaveAsWindow.cs" />
<Compile Include="DataStorage\SQLiteAndroid.cs" /> <Compile Include="DataStorage\SQLiteAndroid.cs" />
<Compile Include="ExportX3GToFolderProcess.cs" />
<Compile Include="SlicerConfiguration\SlicerMapping\SliceEngineInfo.cs" />
<Compile Include="SlicerConfiguration\CuraEngineInfo.cs" />
<Compile Include="SlicerConfiguration\MatterSliceInfo.cs" />
<Compile Include="SlicerConfiguration\Slic3rInfo.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Reference Include="ICSharpCode.SharpZipLib"> <Reference Include="ICSharpCode.SharpZipLib">
@ -389,7 +392,7 @@
<Project>{865172A0-A1A9-49C2-9386-F2FDB4E141B7}</Project> <Project>{865172A0-A1A9-49C2-9386-F2FDB4E141B7}</Project>
<Name>MatterControlPluginSystem</Name> <Name>MatterControlPluginSystem</Name>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\agg-sharp\agg\Agg.csproj"> <ProjectReference Include="..\agg-sharp\Agg\Agg.csproj">
<Project>{657DBC6D-C3EA-4398-A3FA-DDB73C14F71B}</Project> <Project>{657DBC6D-C3EA-4398-A3FA-DDB73C14F71B}</Project>
<Name>Agg</Name> <Name>Agg</Name>
</ProjectReference> </ProjectReference>

View file

@ -94,6 +94,8 @@ namespace MatterHackers.MatterControl.PrintQueue
menuItems.Add(new Tuple<string,Func<bool>>(LocalizedString.Get(" Export to Zip"), exportQueueToZipMenu_Click)); menuItems.Add(new Tuple<string,Func<bool>>(LocalizedString.Get(" Export to Zip"), exportQueueToZipMenu_Click));
menuItems.Add(new Tuple<string,Func<bool>>("GCode", null)); menuItems.Add(new Tuple<string,Func<bool>>("GCode", null));
menuItems.Add(new Tuple<string,Func<bool>>(LocalizedString.Get(" Export to Folder"), exportGCodeToFolderButton_Click)); menuItems.Add(new Tuple<string,Func<bool>>(LocalizedString.Get(" Export to Folder"), exportGCodeToFolderButton_Click));
menuItems.Add(new Tuple<string, Func<bool>>("X3G", null));
menuItems.Add(new Tuple<string, Func<bool>>(LocalizedString.Get("Export to Folder"), exportX3GButton_Click));
if (ActiveSliceSettings.Instance.HasSdCardReader()) if (ActiveSliceSettings.Instance.HasSdCardReader())
{ {
@ -196,6 +198,20 @@ namespace MatterHackers.MatterControl.PrintQueue
return true; return true;
} }
bool exportX3GButton_Click()
{
if (ActivePrinterProfile.Instance.ActivePrinter == null)
{
UiThread.RunOnIdle(MustSelectPrinterMessage);
}
else
{
UiThread.RunOnIdle(SelectLocationToExportGCode);
}
return true;
}
void ExportToFolderFeedbackWindow_Closed(object sender, EventArgs e) void ExportToFolderFeedbackWindow_Closed(object sender, EventArgs e)
{ {
this.exportingWindow = null; this.exportingWindow = null;

View file

@ -200,6 +200,11 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
return GetActiveValue("has_sd_card_reader") == "1"; return GetActiveValue("has_sd_card_reader") == "1";
} }
public bool IsMakerbotGCodeFlavor()
{
return GetActiveValue("gcode_flavor") == "makerbot";
}
public bool HasHeatedBed() public bool HasHeatedBed()
{ {
return GetActiveValue("has_heated_bed") == "1"; return GetActiveValue("has_heated_bed") == "1";

View file

@ -2532,3 +2532,9 @@ Translated:The angle the support infill will be drawn.
English:Infill Angle English:Infill Angle
Translated:Infill Angle Translated:Infill Angle
English:Export to Folder
Translated:Export to Folder
English:Export as X3G
Translated:Export as X3G