Merge pull request #726 from jlewin/master
Migrate Macros to new profile format
This commit is contained in:
commit
bb5df2b411
9 changed files with 104 additions and 208 deletions
|
|
@ -98,6 +98,16 @@ namespace MatterHackers.MatterControl.DataStorage.ClassicDB
|
|||
layeredProfile.UserLayer["MatterControl.DeviceToken"] = printer.DeviceToken ?? "";
|
||||
layeredProfile.UserLayer["MatterControl.DeviceType"] = printer.DeviceType ?? "";
|
||||
|
||||
|
||||
// Import macros from the database
|
||||
var allMacros = Datastore.Instance.dbSQLite.Query<CustomCommands>("SELECT * FROM CustomCommands WHERE PrinterId = " + printer.Id);
|
||||
layeredProfile.Macros = allMacros.Select(macro => new GCodeMacro()
|
||||
{
|
||||
GCode = macro.Value.Trim(),
|
||||
Name = macro.Name,
|
||||
LastModified = macro.DateLastModified
|
||||
}).ToList();
|
||||
|
||||
string query = string.Format("SELECT * FROM PrinterSetting WHERE Name = 'PublishBedImage' and PrinterId = {0};", printer.Id);
|
||||
var publishBedImage = Datastore.Instance.dbSQLite.Query<PrinterSetting>(query).FirstOrDefault();
|
||||
|
||||
|
|
|
|||
|
|
@ -376,7 +376,6 @@
|
|||
<Compile Include="CustomWidgets\DynamicDropDownMenu.cs" />
|
||||
<Compile Include="ControlElements\DropDownMenuFactory.cs" />
|
||||
<Compile Include="ControlElements\SplitButtonFactory.cs" />
|
||||
<Compile Include="PrinterControls\PrinterConnections\PrinterSetupStatus.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
|
|
|
|||
|
|
@ -79,20 +79,9 @@ namespace MatterHackers.MatterControl.PrinterControls
|
|||
this.HAnchor = HAnchor.ParentLeftRight;
|
||||
}
|
||||
|
||||
public override RectangleDouble LocalBounds
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.LocalBounds;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.LocalBounds = value;
|
||||
}
|
||||
}
|
||||
|
||||
protected void ReloadMacros(object sender, EventArgs e)
|
||||
{
|
||||
ActiveSliceSettings.Instance.SaveChanges();
|
||||
ApplicationController.Instance.ReloadAdvancedControlsPanel();
|
||||
}
|
||||
|
||||
|
|
@ -141,16 +130,15 @@ namespace MatterHackers.MatterControl.PrinterControls
|
|||
macroButtonContainer.Padding = new BorderDouble(3);
|
||||
|
||||
int buttonCount = 0;
|
||||
foreach (CustomCommands macro in GetMacros())
|
||||
foreach (GCodeMacro macro in ActiveSliceSettings.Instance.Macros)
|
||||
{
|
||||
buttonCount++;
|
||||
|
||||
Button macroButton = textImageButtonFactory.Generate(macro.Name);
|
||||
macroButton.Text = macro.Value;
|
||||
macroButton.Text = macro.GCode;
|
||||
macroButton.Margin = new BorderDouble(right: 5);
|
||||
macroButton.Click += (sender, e) =>
|
||||
{
|
||||
SendCommandToPrinter(macroButton.Text);
|
||||
};
|
||||
macroButton.Click += (s, e) => SendCommandToPrinter(macroButton.Text);
|
||||
|
||||
macroButtonContainer.AddChild(macroButton);
|
||||
}
|
||||
|
||||
|
|
@ -164,21 +152,6 @@ namespace MatterHackers.MatterControl.PrinterControls
|
|||
return macroButtonContainer;
|
||||
}
|
||||
|
||||
internal static IEnumerable<CustomCommands> GetMacros()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(ActiveSliceSettings.Instance?.Id()))
|
||||
{
|
||||
// TODO: Hook macros into new settings system
|
||||
|
||||
// //Retrieve a list of macros from the database
|
||||
// string query = string.Format("SELECT * FROM CustomCommands WHERE PrinterId = {0};", ActiveSliceSettings.Instance.Id());
|
||||
//
|
||||
// return Datastore.Instance.dbSQLite.Query<CustomCommands>(query);
|
||||
}
|
||||
|
||||
return Enumerable.Empty<CustomCommands>();
|
||||
}
|
||||
|
||||
protected void SendCommandToPrinter(string command)
|
||||
{
|
||||
command = GCodeProcessing.ReplaceMacroValues(command);
|
||||
|
|
|
|||
|
|
@ -55,10 +55,6 @@ namespace MatterHackers.MatterControl
|
|||
public MacroDetailWidget(EditMacrosWindow windowController)
|
||||
{
|
||||
this.windowController = windowController;
|
||||
if (this.windowController.ActiveMacro == null)
|
||||
{
|
||||
initMacro();
|
||||
}
|
||||
|
||||
linkButtonFactory.fontSize = 10;
|
||||
|
||||
|
|
@ -167,7 +163,7 @@ namespace MatterHackers.MatterControl
|
|||
macroCommandLabel.HAnchor = HAnchor.ParentLeftRight;
|
||||
macroCommandLabel.Margin = new BorderDouble(0, 0, 0, 1);
|
||||
|
||||
macroCommandInput = new MHTextEditWidget(windowController.ActiveMacro.Value, pixelHeight: 120, multiLine: true);
|
||||
macroCommandInput = new MHTextEditWidget(windowController.ActiveMacro.GCode, pixelHeight: 120, multiLine: true);
|
||||
macroCommandInput.HAnchor = HAnchor.ParentLeftRight;
|
||||
macroCommandInput.VAnchor = VAnchor.ParentBottomTop;
|
||||
macroCommandInput.ActualTextEditWidget.VAnchor = VAnchor.ParentBottomTop;
|
||||
|
|
@ -211,25 +207,6 @@ namespace MatterHackers.MatterControl
|
|||
return formIsValid;
|
||||
}
|
||||
|
||||
private void initMacro()
|
||||
{
|
||||
if (ActiveSliceSettings.Instance != null)
|
||||
{
|
||||
// TODO: Review bindings to int printerID
|
||||
int printerID;
|
||||
int.TryParse(ActiveSliceSettings.Instance.Id(), out printerID);
|
||||
|
||||
windowController.ActiveMacro = new CustomCommands();
|
||||
windowController.ActiveMacro.PrinterId = printerID;
|
||||
windowController.ActiveMacro.Name = "Home All";
|
||||
windowController.ActiveMacro.Value = "G28 ; Home All Axes";
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Macros require a printer profile");
|
||||
}
|
||||
}
|
||||
|
||||
private void saveMacro_Click(object sender, EventArgs mouseEvent)
|
||||
{
|
||||
UiThread.RunOnIdle(() =>
|
||||
|
|
@ -246,8 +223,7 @@ namespace MatterHackers.MatterControl
|
|||
private void saveActiveMacro()
|
||||
{
|
||||
windowController.ActiveMacro.Name = macroNameInput.Text;
|
||||
windowController.ActiveMacro.Value = macroCommandInput.Text;
|
||||
windowController.ActiveMacro.Commit();
|
||||
windowController.ActiveMacro.GCode = macroCommandInput.Text;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -293,7 +269,7 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
topToBottom.AddChild(presetsFormContainer);
|
||||
|
||||
foreach (CustomCommands currentCommand in MacroControlsWidget.GetMacros())
|
||||
foreach (GCodeMacro macro in ActiveSliceSettings.Instance.Macros)
|
||||
{
|
||||
FlowLayoutWidget macroRow = new FlowLayoutWidget();
|
||||
macroRow.Margin = new BorderDouble(3, 0, 3, 3);
|
||||
|
|
@ -301,26 +277,27 @@ namespace MatterHackers.MatterControl
|
|||
macroRow.Padding = new BorderDouble(3);
|
||||
macroRow.BackgroundColor = RGBA_Bytes.White;
|
||||
|
||||
TextWidget buttonLabel = new TextWidget(currentCommand.Name);
|
||||
TextWidget buttonLabel = new TextWidget(macro.Name);
|
||||
macroRow.AddChild(buttonLabel);
|
||||
|
||||
macroRow.AddChild(new HorizontalSpacer());
|
||||
|
||||
Button editLink = linkButtonFactory.Generate(LocalizedString.Get("edit"));
|
||||
editLink.Margin = new BorderDouble(right: 5);
|
||||
// You can't pass a foreach variable into a link function or it wall always be the last item.
|
||||
// So we make a local variable copy of it and pass that. This will get the right one.
|
||||
CustomCommands currentCommandForLinkFunction = currentCommand;
|
||||
var localMacroReference = macro;
|
||||
|
||||
Button editLink = linkButtonFactory.Generate("edit".Localize());
|
||||
editLink.Margin = new BorderDouble(right: 5);
|
||||
editLink.Click += (sender, e) =>
|
||||
{
|
||||
windowController.ChangeToMacroDetail(currentCommandForLinkFunction);
|
||||
windowController.ChangeToMacroDetail(localMacroReference);
|
||||
};
|
||||
macroRow.AddChild(editLink);
|
||||
|
||||
Button removeLink = linkButtonFactory.Generate(LocalizedString.Get("remove"));
|
||||
Button removeLink = linkButtonFactory.Generate("remove".Localize());
|
||||
removeLink.Click += (sender, e) =>
|
||||
{
|
||||
currentCommandForLinkFunction.Delete();
|
||||
ActiveSliceSettings.Instance.Macros.Remove(localMacroReference);
|
||||
windowController.functionToCallOnSave(this, null);
|
||||
windowController.ChangeToMacroList();
|
||||
};
|
||||
|
|
@ -329,17 +306,21 @@ namespace MatterHackers.MatterControl
|
|||
presetsFormContainer.AddChild(macroRow);
|
||||
}
|
||||
|
||||
Button addMacroButton = textImageButtonFactory.Generate(LocalizedString.Get("Add"), "icon_circle_plus.png");
|
||||
Button addMacroButton = textImageButtonFactory.Generate("Add".Localize(), "icon_circle_plus.png");
|
||||
addMacroButton.ToolTipText = "Add a new Macro".Localize();
|
||||
addMacroButton.Click += new EventHandler(addMacro_Click);
|
||||
addMacroButton.Click += (s, e) =>
|
||||
{
|
||||
windowController.ChangeToMacroDetail(new GCodeMacro()
|
||||
{
|
||||
Name = "Home All",
|
||||
GCode = "G28 ; Home All Axes"
|
||||
});
|
||||
};
|
||||
|
||||
Button cancelPresetsButton = textImageButtonFactory.Generate(LocalizedString.Get("Close"));
|
||||
Button cancelPresetsButton = textImageButtonFactory.Generate("Close".Localize());
|
||||
cancelPresetsButton.Click += (sender, e) =>
|
||||
{
|
||||
UiThread.RunOnIdle(() =>
|
||||
{
|
||||
this.windowController.Close();
|
||||
});
|
||||
UiThread.RunOnIdle(() => this.windowController.Close());
|
||||
};
|
||||
|
||||
FlowLayoutWidget buttonRow = new FlowLayoutWidget();
|
||||
|
|
@ -357,18 +338,13 @@ namespace MatterHackers.MatterControl
|
|||
AddChild(topToBottom);
|
||||
this.AnchorAll();
|
||||
}
|
||||
|
||||
private void addMacro_Click(object sender, EventArgs mouseEvent)
|
||||
{
|
||||
windowController.ChangeToMacroDetail();
|
||||
}
|
||||
}
|
||||
|
||||
public class EditMacrosWindow : SystemWindow
|
||||
{
|
||||
public EventHandler functionToCallOnSave;
|
||||
|
||||
public CustomCommands ActiveMacro;
|
||||
public GCodeMacro ActiveMacro;
|
||||
|
||||
public EditMacrosWindow(EventHandler functionToCallOnSave)
|
||||
: base(360, 420)
|
||||
|
|
@ -396,18 +372,15 @@ namespace MatterHackers.MatterControl
|
|||
this.Invalidate();
|
||||
}
|
||||
|
||||
public void ChangeToMacroDetail(CustomCommands macro = null)
|
||||
public void ChangeToMacroDetail(GCodeMacro macro)
|
||||
{
|
||||
this.ActiveMacro = macro;
|
||||
UiThread.RunOnIdle(DoChangeToMacroDetail);
|
||||
}
|
||||
|
||||
private void DoChangeToMacroDetail()
|
||||
{
|
||||
GuiWidget macroDetailWidget = new MacroDetailWidget(this);
|
||||
this.RemoveAllChildren();
|
||||
this.AddChild(macroDetailWidget);
|
||||
this.Invalidate();
|
||||
UiThread.RunOnIdle(() =>
|
||||
{
|
||||
this.RemoveAllChildren();
|
||||
this.AddChild(new MacroDetailWidget(this));
|
||||
this.Invalidate();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,65 +0,0 @@
|
|||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.PlatformAbstract;
|
||||
using MatterHackers.MatterControl.ConfigurationPage.PrintLeveling;
|
||||
using MatterHackers.MatterControl.DataStorage;
|
||||
using MatterHackers.MatterControl.PrintLibrary;
|
||||
using MatterHackers.MatterControl.PrintLibrary.Provider;
|
||||
using MatterHackers.MatterControl.PrintQueue;
|
||||
using MatterHackers.MatterControl.SlicerConfiguration;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MatterHackers.MatterControl
|
||||
{
|
||||
//Wraps the printer record. Includes temporary information that we don't need in the DB.
|
||||
public class PrinterSetupStatus
|
||||
{
|
||||
public PrinterInfo ActivePrinter;
|
||||
|
||||
public Type PreviousSetupWidget;
|
||||
public Type NextSetupWidget;
|
||||
|
||||
private List<CustomCommands> printerCustomCommands;
|
||||
|
||||
public PrinterSetupStatus(PrinterInfo printer = null)
|
||||
{
|
||||
if (printer == null)
|
||||
{
|
||||
this.ActivePrinter = new PrinterInfo();
|
||||
this.ActivePrinter.Make = null;
|
||||
this.ActivePrinter.Model = null;
|
||||
this.ActivePrinter.Name = "Default Printer ({0})".FormatWith(ExistingPrinterCount() + 1);
|
||||
this.ActivePrinter.BaudRate = null;
|
||||
this.ActivePrinter.ComPort = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.ActivePrinter = printer;
|
||||
}
|
||||
}
|
||||
|
||||
public int ExistingPrinterCount()
|
||||
{
|
||||
return Datastore.Instance.RecordCount("Printer");
|
||||
}
|
||||
|
||||
public void Save()
|
||||
{
|
||||
//Ordering matters - need to get Id for printer prior to loading slice presets
|
||||
this.ActivePrinter.AutoConnect = true;
|
||||
|
||||
// TODO: Review printerID int requirement
|
||||
int printerID;
|
||||
int.TryParse(ActivePrinter.Id, out printerID);
|
||||
|
||||
foreach (CustomCommands customCommand in printerCustomCommands)
|
||||
{
|
||||
customCommand.PrinterId = printerID;
|
||||
customCommand.Commit();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -224,6 +224,34 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
layeredProfile.UserLayer["MatterControl.PrinterID"] = guid.ToString();
|
||||
layeredProfile.UserLayer["MatterControl.PrinterName"] = printerName;
|
||||
|
||||
// Import named macros as defined in the following printers: (Airwolf Axiom, HD, HD-R, HD2x, HDL, HDx, Me3D Me2, Robo R1[+])
|
||||
var classicDefaultMacros = layeredProfile.GetValue("default_macros");
|
||||
if (!string.IsNullOrEmpty(classicDefaultMacros))
|
||||
{
|
||||
var namedMacros = new Dictionary<string, string>();
|
||||
namedMacros["Lights On"] = "M42 P6 S255";
|
||||
namedMacros["Lights Off"] = "M42 P6 S0";
|
||||
namedMacros["Offset 0.8"] = "M565 Z0.8;\nM500";
|
||||
namedMacros["Offset 0.9"] = "M565 Z0.9;\nM500";
|
||||
namedMacros["Offset 1"] = "M565 Z1;\nM500";
|
||||
namedMacros["Offset 1.1"] = "M565 Z1.1;\nM500";
|
||||
namedMacros["Offset 1.2"] = "M565 Z1.2;\nM500";
|
||||
namedMacros["Z Offset"] = "G1 Z10;\nG28;\nG29;\nG1 Z10;\nG1 X5 Y5 F4000;\nM117;";
|
||||
|
||||
foreach (string namedMacro in classicDefaultMacros.Split(','))
|
||||
{
|
||||
string gcode;
|
||||
if (namedMacros.TryGetValue(namedMacro.Trim(), out gcode))
|
||||
{
|
||||
layeredProfile.Macros.Add(new GCodeMacro()
|
||||
{
|
||||
Name = namedMacro.Trim(),
|
||||
GCode = gcode
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
layeredProfile.Save();
|
||||
|
||||
ProfileData.Profiles.Add(new PrinterInfo
|
||||
|
|
|
|||
|
|
@ -36,6 +36,13 @@ using System.IO;
|
|||
|
||||
namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||
{
|
||||
public class GCodeMacro
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string GCode { get; set; }
|
||||
public DateTime LastModified { get; set; }
|
||||
}
|
||||
|
||||
public class LayeredProfile
|
||||
{
|
||||
[JsonIgnore]
|
||||
|
|
@ -50,6 +57,8 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
this.BaseLayer = baseConfig;
|
||||
}
|
||||
|
||||
public List<GCodeMacro> Macros { get; set; }
|
||||
|
||||
[OnDeserialized]
|
||||
internal void OnDeserializedMethod(StreamingContext context)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ClassDiagram MajorVersion="1" MinorVersion="1">
|
||||
<Class Name="MatterHackers.MatterControl.SlicerConfiguration.ActiveSliceSettings">
|
||||
<Position X="7.25" Y="0.5" Width="1.75" />
|
||||
<Position X="0.75" Y="0.5" Width="1.75" />
|
||||
<AssociationLine Name="Instance" Type="MatterHackers.MatterControl.SlicerConfiguration.SettingsProfile">
|
||||
<MemberNameLabel ManuallyPlaced="true" ManuallySized="true">
|
||||
<Position X="0.574" Y="-0.225" Height="0.182" Width="1.128" />
|
||||
</MemberNameLabel>
|
||||
</AssociationLine>
|
||||
<TypeIdentifier>
|
||||
<HashCode>IBAAAAEAAABAAAAAAAAAAAAAAIAAABAAQAgAAEAAAAA=</HashCode>
|
||||
<HashCode>ABAAgAAAAAAAACgAAGAAAAQAAAABAgAAQAgBAEAAhAA=</HashCode>
|
||||
<FileName>SlicerConfiguration\Settings\ActiveSliceSettings.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
<ShowAsAssociation>
|
||||
|
|
@ -24,23 +24,15 @@
|
|||
</TypeIdentifier>
|
||||
</Class>
|
||||
</NestedTypes>
|
||||
<AssociationLine Name="profileLayers" Type="MatterHackers.MatterControl.SlicerConfiguration.LayeredProfile">
|
||||
<MemberNameLabel ManuallyPlaced="true">
|
||||
<Position X="0.102" Y="0.256" />
|
||||
</MemberNameLabel>
|
||||
</AssociationLine>
|
||||
<TypeIdentifier>
|
||||
<HashCode>JCADAcoArLgkCEwJMG9CQD0AAEAjEMYASRgMAA5VAAQ=</HashCode>
|
||||
<HashCode>JCADYcoErLg2IEoJME0GCD0FFYAiEFagShgM0R4FAAU=</HashCode>
|
||||
<FileName>SlicerConfiguration\Settings\SettingsProfile.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
<ShowAsAssociation>
|
||||
<Field Name="profileLayers" />
|
||||
</ShowAsAssociation>
|
||||
</Class>
|
||||
<Class Name="MatterHackers.MatterControl.SlicerConfiguration.LayeredProfile">
|
||||
<Position X="7.25" Y="2" Width="1.75" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAACMQEKABAAAABEEAGAAQBAgABAAQEAAQIAAAQBAA=</HashCode>
|
||||
<HashCode>AAAACMQEKABAAAABEEAGAAQFAgABAAQEAAQIAAAQBAA=</HashCode>
|
||||
<FileName>SlicerConfiguration\Settings\LayeredProfile.cs</FileName>
|
||||
<NewMemberFileName>SlicerConfiguration\ActiveSliceSettings.cs</NewMemberFileName>
|
||||
</TypeIdentifier>
|
||||
|
|
@ -52,26 +44,27 @@
|
|||
</ShowAsAssociation>
|
||||
</Class>
|
||||
<Class Name="MatterHackers.MatterControl.SlicerConfiguration.SettingsLayer">
|
||||
<Position X="10.25" Y="2.25" Width="1.5" />
|
||||
<Position X="10.25" Y="2" Width="2.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAAAIAAAgAAAAAAEAAAAAQAAAAAAAAAAEAAAAAAAAA=</HashCode>
|
||||
<HashCode>AAAQAIAAAgAAAAAAEAAAAAQAAAAAAAAAAEAAAAAAAAA=</HashCode>
|
||||
<FileName>SlicerConfiguration\Settings\SettingsProfile.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="MatterHackers.MatterControl.SlicerConfiguration.OemProfile">
|
||||
<Position X="7.25" Y="7.75" Width="1.5" />
|
||||
<Position X="7.25" Y="7.75" Width="2" />
|
||||
<AssociationLine Name="OemLayer" Type="MatterHackers.MatterControl.SlicerConfiguration.SettingsLayer">
|
||||
<MemberNameLabel ManuallyPlaced="true">
|
||||
<Position X="0.464" Y="3.907" />
|
||||
</MemberNameLabel>
|
||||
</AssociationLine>
|
||||
<TypeIdentifier>
|
||||
<HashCode>AAAASAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAA=</HashCode>
|
||||
<FileName>SlicerConfiguration\Settings\LayeredProfile.cs</FileName>
|
||||
<NewMemberFileName>SlicerConfiguration\ActiveSliceSettings.cs</NewMemberFileName>
|
||||
</TypeIdentifier>
|
||||
</Class>
|
||||
<Class Name="MatterHackers.MatterControl.DataStorage.Printer" Collapsed="true">
|
||||
<Position X="0.75" Y="7.25" Width="1.5" />
|
||||
<TypeIdentifier>
|
||||
<HashCode>IAAAgQgCCCAAAAAAIAAAAgQAAAAAEAAAAAwAIBJEAAA=</HashCode>
|
||||
<FileName>DataStorage\Models.cs</FileName>
|
||||
</TypeIdentifier>
|
||||
<ShowAsAssociation>
|
||||
<Property Name="OemLayer" />
|
||||
</ShowAsAssociation>
|
||||
</Class>
|
||||
<Font Name="Segoe UI" Size="9" />
|
||||
</ClassDiagram>
|
||||
|
|
@ -139,6 +139,11 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
}
|
||||
}
|
||||
|
||||
internal void SaveChanges()
|
||||
{
|
||||
layeredProfile.Save();
|
||||
}
|
||||
|
||||
public string ExtruderTemperature(int extruderIndex)
|
||||
{
|
||||
if (extruderIndex >= layeredProfile.MaterialSettingsKeys.Count)
|
||||
|
|
@ -1027,36 +1032,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
return drivers;
|
||||
}
|
||||
|
||||
public void GetMacros(string make, string model)
|
||||
{
|
||||
Dictionary<string, string> macroDict = new Dictionary<string, string>();
|
||||
macroDict["Lights On"] = "M42 P6 S255";
|
||||
macroDict["Lights Off"] = "M42 P6 S0";
|
||||
macroDict["Offset 0.8"] = "M565 Z0.8;\nM500";
|
||||
macroDict["Offset 0.9"] = "M565 Z0.9;\nM500";
|
||||
macroDict["Offset 1"] = "M565 Z1;\nM500";
|
||||
macroDict["Offset 1.1"] = "M565 Z1.1;\nM500";
|
||||
macroDict["Offset 1.2"] = "M565 Z1.2;\nM500";
|
||||
macroDict["Z Offset"] = "G1 Z10;\nG28;\nG29;\nG1 Z10;\nG1 X5 Y5 F4000;\nM117;";
|
||||
|
||||
string defaultMacros = ActiveValue("default_macros");
|
||||
var printerCustomCommands = new List<CustomCommands>();
|
||||
if (!string.IsNullOrEmpty(defaultMacros))
|
||||
{
|
||||
foreach (string macroName in defaultMacros.Split(','))
|
||||
{
|
||||
string macroValue;
|
||||
if (macroDict.TryGetValue(macroName.Trim(), out macroValue))
|
||||
{
|
||||
CustomCommands customMacro = new CustomCommands();
|
||||
customMacro.Name = macroName.Trim();
|
||||
customMacro.Value = macroValue;
|
||||
|
||||
printerCustomCommands.Add(customMacro);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public List<GCodeMacro> Macros => layeredProfile.Macros;
|
||||
}
|
||||
|
||||
public class SettingsLayer : SettingsDictionary
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue