Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
SalamiSimon committed May 1, 2024
2 parents e41284c + 0cfb9a9 commit 399be5c
Show file tree
Hide file tree
Showing 30 changed files with 307 additions and 39 deletions.
21 changes: 19 additions & 2 deletions ApplicationSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ public class AddinSettings
{
public string ExportPath { get; set; } = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "AutoExportSW");
public string DataPath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData), "Easy3DPrintSettings_" + Version + ".json");
public const string Version = "V1.0.2";
public FileType QuickSaveType { get; set; } = FileType._STL;
public const string Version = "V1.0.2"; // Oldest compatible settings config file structure

public AddinSettings() { }

public AddinSettings(string path)
public AddinSettings(string path, FileType quickSaveType)
{
ExportPath = path;
QuickSaveType = quickSaveType;
}
}

Expand Down Expand Up @@ -108,5 +110,20 @@ public Slic3rSettings(string path, FileType fileType, bool enabled)
}
}

public class OrcaSettings
{
public string Path { get; set; } = "";
public FileType FileType { get; set; } = FileType._STL;
public bool Enabled { get; set; } = false;

public OrcaSettings() { }

public OrcaSettings(string path, FileType fileType, bool enabled)
{
Path = path;
FileType = fileType;
Enabled = enabled;
}
}
}
}
74 changes: 62 additions & 12 deletions Easy3DPrint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ namespace Easy3DPrint_NetFW

public class Easy3DPrint : SwAddInEx
{
private readonly AddinSettings exportSettings = new AddinSettings();
private readonly AddinSettings addInSettings = new AddinSettings();
private readonly CuraSettings curaSettings = new CuraSettings();
private readonly BambuSettings bambuSettings = new BambuSettings();
private readonly AnkerMakeSettings ankerMakeSettings = new AnkerMakeSettings();
private readonly PrusaSettings prusaSettings = new PrusaSettings();
private readonly Slic3rSettings slic3rSettings = new Slic3rSettings();
private readonly OrcaSettings orcaSettings = new OrcaSettings();

[Title("Easy3DPrint")]
[Description("Open parts directly in slicing apps")]
Expand Down Expand Up @@ -59,11 +60,21 @@ public enum Commands_e
[Icon(typeof(Resources), nameof(Resources.slic3r))]
OpenInSlic3r,

[Title("Open in Orca")]
[Description("Opens the model in Orca")]
[Icon(typeof(Resources), nameof(Resources.orca))]
OpenInOrca,

[Title("Settings")]
[Description("Easy3DPrint Settings")]
[Icon(typeof(Resources), nameof(Resources.settings))]
Settings,

[Title("Quick Save")]
[Description("Quick Export File")]
[Icon(typeof(Resources), nameof(Resources.quicksave))]
QuickSave,

[Title("View Github Repo")]
[Description("Easy3DPrint Github Repo")]
[Icon(typeof(Resources), nameof(Resources.github))]
Expand All @@ -78,9 +89,9 @@ public override void OnConnect()

ShowSettingsDialog();

if (!Directory.Exists(exportSettings.ExportPath))
if (!Directory.Exists(addInSettings.ExportPath))
{
Directory.CreateDirectory(exportSettings.ExportPath);
Directory.CreateDirectory(addInSettings.ExportPath);
}

LoadSettings();
Expand Down Expand Up @@ -110,20 +121,23 @@ private void OnButtonEnable(Commands_e cmd, CommandState state)
case Commands_e.OpenInSlic3r:
state.Enabled = slic3rSettings.Enabled;
break;
case Commands_e.OpenInOrca:
state.Enabled = orcaSettings.Enabled;
break;
}
}

private bool LoadSettings()
{
if (File.Exists(exportSettings.DataPath))
if (File.Exists(addInSettings.DataPath))
{
try
{
string json = File.ReadAllText(exportSettings.DataPath);
string json = File.ReadAllText(addInSettings.DataPath);
var settings = JsonConvert.DeserializeObject<dynamic>(json);

// Load settings
exportSettings.ExportPath = settings.ExportPath;
addInSettings.ExportPath = settings.ExportPath;

curaSettings.Path = settings.CuraPath;
curaSettings.FileType = settings.ExportFormatCura;
Expand All @@ -145,6 +159,13 @@ private bool LoadSettings()
prusaSettings.FileType = settings.ExportFormatPrusa;
prusaSettings.Enabled = settings.PrusaEnabled;

orcaSettings.Path = settings.OrcaPath;
orcaSettings.FileType = settings.ExportFormatOrca;
orcaSettings.Enabled = settings.OrcaEnabled;

if (settings.ExportFormatQuickSave != null)
addInSettings.QuickSaveType = settings.ExportFormatQuickSave;

return true; // Settings loaded successfully
}
catch (Exception ex)
Expand All @@ -159,7 +180,7 @@ private bool LoadSettings()

public void ShowSettingsDialog()
{
SettingsDialog settingsDialog = new SettingsDialog(exportSettings, curaSettings, bambuSettings, ankerMakeSettings, prusaSettings, slic3rSettings);
SettingsDialog settingsDialog = new SettingsDialog(addInSettings, curaSettings, bambuSettings, ankerMakeSettings, prusaSettings, slic3rSettings, orcaSettings);
if (settingsDialog.ShowDialog() == DialogResult.OK)
{
LoadSettings();
Expand All @@ -175,7 +196,7 @@ private void OnCommandClick(Commands_e spec)

if (curaSettings.FileType != FileType._NONE)
{
FilePathCura = SaveCurrentPart(exportSettings.ExportPath, curaSettings.FileType);
FilePathCura = SaveCurrentPart(addInSettings.ExportPath, curaSettings.FileType);
}
else
{
Expand All @@ -197,7 +218,7 @@ private void OnCommandClick(Commands_e spec)

if (bambuSettings.FileType != FileType._NONE)
{
FilePathBambu = SaveCurrentPart(exportSettings.ExportPath, bambuSettings.FileType);
FilePathBambu = SaveCurrentPart(addInSettings.ExportPath, bambuSettings.FileType);
}
else
{
Expand All @@ -219,7 +240,7 @@ private void OnCommandClick(Commands_e spec)

if (ankerMakeSettings.FileType != FileType._NONE)
{
FilePathAnker = SaveCurrentPart(exportSettings.ExportPath, ankerMakeSettings.FileType);
FilePathAnker = SaveCurrentPart(addInSettings.ExportPath, ankerMakeSettings.FileType);
}
else
{
Expand All @@ -241,7 +262,7 @@ private void OnCommandClick(Commands_e spec)

if (prusaSettings.FileType != FileType._NONE)
{
FilePathPrusa = SaveCurrentPart(exportSettings.ExportPath, prusaSettings.FileType);
FilePathPrusa = SaveCurrentPart(addInSettings.ExportPath, prusaSettings.FileType);
}
else
{
Expand All @@ -263,7 +284,7 @@ private void OnCommandClick(Commands_e spec)

if (slic3rSettings.FileType != FileType._NONE)
{
FilePathSlic3r = SaveCurrentPart(exportSettings.ExportPath, slic3rSettings.FileType);
FilePathSlic3r = SaveCurrentPart(addInSettings.ExportPath, slic3rSettings.FileType);
}
else
{
Expand All @@ -280,6 +301,35 @@ private void OnCommandClick(Commands_e spec)
}
break;

case Commands_e.OpenInOrca:
string FilePathOrca = null;

if (orcaSettings.FileType != FileType._NONE)
{
FilePathOrca = SaveCurrentPart(addInSettings.ExportPath, orcaSettings.FileType);
}
else
{
Application.ShowMessageBox("Select file format in settings.");
}

if (!string.IsNullOrEmpty(FilePathOrca) && !string.IsNullOrEmpty(orcaSettings.Path))
{
System.Diagnostics.Process.Start(orcaSettings.Path, $"\"{FilePathOrca}\"");
}
else
{
Application.ShowMessageBox("No Orca executable path entered in settings or file not saved sucessfully.");
}
break;

case Commands_e.QuickSave:
if (addInSettings.QuickSaveType != FileType._NONE)
{
FilePathSlic3r = SaveCurrentPart(addInSettings.ExportPath, addInSettings.QuickSaveType);
}
break;

case Commands_e.Github:
System.Diagnostics.Process.Start("https://github.com/SalamiSimon/Easy3DPrint");
break;
Expand Down
2 changes: 2 additions & 0 deletions Easy3DPrint_NetFW.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@
</ItemGroup>
<ItemGroup>
<Content Include="3DPrint_SW.sln" />
<None Include="img\orca.png" />
<None Include="img\quicksave.png" />
<None Include="img\github.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Expand Down
20 changes: 20 additions & 0 deletions Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,15 @@
<data name="github" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\img\github.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="orca" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\img\orca.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="prusa" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\img\prusa.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="quicksave" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\img\quicksave.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="settings" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\img\settings.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
Expand Down
Loading

0 comments on commit 399be5c

Please sign in to comment.