Merge pull request #1714 from larsbrubaker/master
Put in the action menus and controls.
This commit is contained in:
commit
9bb75473ae
11 changed files with 203 additions and 86 deletions
|
|
@ -33,6 +33,8 @@ using MatterHackers.MatterControl.CustomWidgets;
|
|||
using MatterHackers.MatterControl.AboutPage;
|
||||
using System;
|
||||
using MatterHackers.Localizations;
|
||||
using MatterHackers.MatterControl.SlicerConfiguration;
|
||||
using System.Linq;
|
||||
|
||||
namespace MatterHackers.MatterControl
|
||||
{
|
||||
|
|
@ -67,7 +69,10 @@ namespace MatterHackers.MatterControl
|
|||
this.AddChild(new MenuOptionSettings());
|
||||
|
||||
// put in the help menu
|
||||
this.AddChild(new MenuOptionMacros());
|
||||
if (ActiveSliceSettings.Instance.ActionMacros().Any())
|
||||
{
|
||||
this.AddChild(new MenuOptionAction());
|
||||
}
|
||||
|
||||
// put in the help menu
|
||||
this.AddChild(new MenuOptionHelp());
|
||||
|
|
|
|||
|
|
@ -9,15 +9,16 @@ using System.Collections.Generic;
|
|||
using MatterHackers.MatterControl.SlicerConfiguration;
|
||||
using MatterHackers.MatterControl.PrinterControls;
|
||||
using MatterHackers.MatterControl.PrinterCommunication;
|
||||
using System.Linq;
|
||||
|
||||
namespace MatterHackers.MatterControl
|
||||
{
|
||||
public class MenuOptionMacros : MenuBase
|
||||
public class MenuOptionAction : MenuBase
|
||||
{
|
||||
private event EventHandler unregisterEvents;
|
||||
public MenuOptionMacros() : base("Macros".Localize())
|
||||
public MenuOptionAction() : base("Actions".Localize())
|
||||
{
|
||||
Name = "Macro Menu";
|
||||
Name = "Actions Menu";
|
||||
|
||||
ActiveSliceSettings.ActivePrinterChanged.RegisterEvent((s, e) => SetEnabledState(), ref unregisterEvents);
|
||||
PrinterConnectionAndCommunication.Instance.CommunicationStateChanged.RegisterEvent((s,e) => SetEnabledState(), ref unregisterEvents);
|
||||
|
|
@ -37,48 +38,26 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
private void SetEnabledState()
|
||||
{
|
||||
for(int i=0; i<MenuDropList.MenuItems.Count-1; i++)
|
||||
for(int i=0; i<MenuDropList.MenuItems.Count; i++)
|
||||
{
|
||||
MenuDropList.MenuItems[i].Enabled = ActiveSliceSettings.Instance.PrinterSelected
|
||||
&& PrinterConnectionAndCommunication.Instance.PrinterIsConnected
|
||||
&& !PrinterConnectionAndCommunication.Instance.PrinterIsPrinting;
|
||||
}
|
||||
|
||||
// and set the edit menu item
|
||||
MenuDropList.MenuItems[MenuDropList.MenuItems.Count-1].Enabled = ActiveSliceSettings.Instance.PrinterSelected;
|
||||
}
|
||||
|
||||
protected override IEnumerable<MenuItemAction> GetMenuActions()
|
||||
{
|
||||
var list = new List<MenuItemAction>();
|
||||
|
||||
if (ActiveSliceSettings.Instance.Macros.Count > 0)
|
||||
if (ActiveSliceSettings.Instance.ActionMacros().Any())
|
||||
{
|
||||
foreach (GCodeMacro macro in ActiveSliceSettings.Instance.Macros)
|
||||
foreach (GCodeMacro macro in ActiveSliceSettings.Instance.ActionMacros())
|
||||
{
|
||||
list.Add(new MenuItemAction(MacroControls.FixMacroName(macro.Name), macro.Run));
|
||||
list.Add(new MenuItemAction(GCodeMacro.FixMacroName(macro.Name), macro.Run));
|
||||
}
|
||||
}
|
||||
|
||||
list.Add(new MenuItemAction(
|
||||
//StaticData.Instance.LoadIcon("icon_plus.png", 32, 32),
|
||||
"Edit Macros...",
|
||||
() =>
|
||||
{
|
||||
if (PrinterConnectionAndCommunication.Instance.PrinterIsPrinting)
|
||||
{
|
||||
UiThread.RunOnIdle(() =>
|
||||
StyledMessageBox.ShowMessageBox(null, "Please wait until the print has finished and try again.".Localize(), "Can't edit macros while printing".Localize())
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
UiThread.RunOnIdle(() => EditMacrosWindow.Show());
|
||||
}
|
||||
|
||||
}));
|
||||
|
||||
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
|
@ -236,7 +236,7 @@ namespace MatterHackers.MatterControl.PrintLibrary
|
|||
|
||||
private GuiWidget CreateActionsMenu()
|
||||
{
|
||||
var actionMenu = new DropDownMenu("Action".Localize() + "... ");
|
||||
var actionMenu = new DropDownMenu("Actions".Localize() + "... ");
|
||||
actionMenu.AlignToRightEdge = true;
|
||||
actionMenu.NormalColor = new RGBA_Bytes();
|
||||
actionMenu.BorderWidth = 1;
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@
|
|||
<Compile Include="ActionBar\PrintStatusRow.cs" />
|
||||
<Compile Include="ActionBar\TemperatureWidgetBase.cs" />
|
||||
<Compile Include="ActionBar\TemperatureWidgetExtruder.cs" />
|
||||
<Compile Include="ApplicationView\MenuRow\MenuOptionMacros.cs" />
|
||||
<Compile Include="ApplicationView\MenuRow\MenuOptionAction.cs" />
|
||||
<Compile Include="ApplicationView\MenuRow\MenuOptionHelp.cs" />
|
||||
<Compile Include="ApplicationView\MenuRow\MenuOptionSettings.cs" />
|
||||
<Compile Include="ApplicationView\MenuRow\MenuOptionFile.cs" />
|
||||
|
|
|
|||
|
|
@ -43,21 +43,6 @@ namespace MatterHackers.MatterControl.PrinterControls
|
|||
{
|
||||
public class MacroControls : ControlWidgetBase
|
||||
{
|
||||
static internal string FixMacroName(string input)
|
||||
{
|
||||
int lengthLimit = 24;
|
||||
|
||||
string result = Regex.Replace(input, @"\r\n?|\n", " ");
|
||||
|
||||
if (result.Length > lengthLimit)
|
||||
{
|
||||
result = result.Substring(0, lengthLimit) + "...";
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
public MacroControls()
|
||||
{
|
||||
this.AddChild(new MacroControlsWidget());
|
||||
|
|
@ -120,17 +105,114 @@ namespace MatterHackers.MatterControl.PrinterControls
|
|||
macroButtonContainer.Margin = new BorderDouble(3, 0);
|
||||
macroButtonContainer.Padding = new BorderDouble(3);
|
||||
|
||||
if (ActiveSliceSettings.Instance?.Macros == null)
|
||||
if (ActiveSliceSettings.Instance?.UserMacros().Any() == false)
|
||||
{
|
||||
return macroButtonContainer;
|
||||
}
|
||||
|
||||
int buttonCount = 0;
|
||||
foreach (GCodeMacro macro in ActiveSliceSettings.Instance.Macros)
|
||||
foreach (GCodeMacro macro in ActiveSliceSettings.Instance.UserMacros())
|
||||
{
|
||||
buttonCount++;
|
||||
|
||||
Button macroButton = textImageButtonFactory.Generate(MacroControls.FixMacroName(macro.Name));
|
||||
Button macroButton = textImageButtonFactory.Generate(GCodeMacro.FixMacroName(macro.Name));
|
||||
macroButton.Margin = new BorderDouble(right: 5);
|
||||
macroButton.Click += (s, e) => macro.Run();
|
||||
|
||||
macroButtonContainer.AddChild(macroButton);
|
||||
}
|
||||
|
||||
if (buttonCount == 0)
|
||||
{
|
||||
TextWidget noMacrosFound = new TextWidget(LocalizedString.Get("No macros are currently set up for this printer."), pointSize: 10);
|
||||
noMacrosFound.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||
macroButtonContainer.AddChild(noMacrosFound);
|
||||
}
|
||||
|
||||
return macroButtonContainer;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class ActionControls : ControlWidgetBase
|
||||
{
|
||||
public ActionControls()
|
||||
{
|
||||
if (!ActiveSliceSettings.Instance.ActionMacros().Any())
|
||||
{
|
||||
Margin = new BorderDouble();
|
||||
return;
|
||||
}
|
||||
this.AddChild(new ActionControlsWidget());
|
||||
}
|
||||
}
|
||||
|
||||
public class ActionControlsWidget : FlowLayoutWidget
|
||||
{
|
||||
protected TextImageButtonFactory textImageButtonFactory = new TextImageButtonFactory();
|
||||
protected FlowLayoutWidget presetButtonsContainer;
|
||||
|
||||
protected string label;
|
||||
protected string editWindowLabel;
|
||||
|
||||
public ActionControlsWidget()
|
||||
: base(FlowDirection.TopToBottom)
|
||||
{
|
||||
this.textImageButtonFactory.normalFillColor = RGBA_Bytes.White;
|
||||
this.textImageButtonFactory.FixedHeight = 24 * GuiWidget.DeviceScale;
|
||||
this.textImageButtonFactory.fontSize = 12;
|
||||
this.textImageButtonFactory.borderWidth = 1;
|
||||
this.textImageButtonFactory.normalBorderColor = new RGBA_Bytes(ActiveTheme.Instance.PrimaryTextColor, 200);
|
||||
this.textImageButtonFactory.hoverBorderColor = new RGBA_Bytes(ActiveTheme.Instance.PrimaryTextColor, 200);
|
||||
|
||||
this.textImageButtonFactory.disabledTextColor = RGBA_Bytes.Gray;
|
||||
this.textImageButtonFactory.hoverTextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||
this.textImageButtonFactory.normalTextColor = RGBA_Bytes.Black;
|
||||
this.textImageButtonFactory.pressedTextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||
|
||||
this.HAnchor = HAnchor.ParentLeftRight;
|
||||
|
||||
// add the widgets to this window
|
||||
FlowLayoutWidget groupBox = new FlowLayoutWidget()
|
||||
{
|
||||
Padding = new BorderDouble(5),
|
||||
HAnchor = HAnchor.ParentLeftRight,
|
||||
BackgroundColor = ActiveTheme.Instance.TertiaryBackgroundColor,
|
||||
};
|
||||
|
||||
groupBox.HAnchor |= Agg.UI.HAnchor.ParentLeftRight;
|
||||
// make sure the client area will get smaller when the contents get smaller
|
||||
groupBox.VAnchor = Agg.UI.VAnchor.FitToChildren;
|
||||
|
||||
FlowLayoutWidget controlRow = new FlowLayoutWidget(Agg.UI.FlowDirection.TopToBottom);
|
||||
controlRow.Margin = new BorderDouble(top: 5);
|
||||
controlRow.HAnchor |= HAnchor.ParentLeftRight;
|
||||
{
|
||||
this.presetButtonsContainer = GetMacroButtonContainer();
|
||||
controlRow.AddChild(this.presetButtonsContainer);
|
||||
}
|
||||
|
||||
groupBox.AddChild(controlRow);
|
||||
this.AddChild(groupBox);
|
||||
}
|
||||
|
||||
private FlowLayoutWidget GetMacroButtonContainer()
|
||||
{
|
||||
FlowLayoutWidget macroButtonContainer = new FlowLayoutWidget();
|
||||
macroButtonContainer.Margin = new BorderDouble(0,0,3, 0);
|
||||
macroButtonContainer.Padding = new BorderDouble(0,3,3,3);
|
||||
|
||||
if (ActiveSliceSettings.Instance?.ActionMacros().Any() == false)
|
||||
{
|
||||
return macroButtonContainer;
|
||||
}
|
||||
|
||||
int buttonCount = 0;
|
||||
foreach (GCodeMacro macro in ActiveSliceSettings.Instance.ActionMacros())
|
||||
{
|
||||
buttonCount++;
|
||||
|
||||
Button macroButton = textImageButtonFactory.Generate(GCodeMacro.FixMacroName(macro.Name));
|
||||
macroButton.Margin = new BorderDouble(right: 5);
|
||||
macroButton.Click += (s, e) => macro.Run();
|
||||
|
||||
|
|
|
|||
|
|
@ -110,6 +110,7 @@ namespace MatterHackers.MatterControl
|
|||
private MHTextEditWidget macroCommandInput;
|
||||
private TextWidget macroNameError;
|
||||
private MHTextEditWidget macroNameInput;
|
||||
private CheckBox showInActionMenu;
|
||||
private TextImageButtonFactory textImageButtonFactory = new TextImageButtonFactory();
|
||||
private EditMacrosWindow windowController;
|
||||
|
||||
|
|
@ -150,8 +151,9 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
topToBottom.AddChild(presetsFormContainer);
|
||||
|
||||
presetsFormContainer.AddChild(createMacroNameContainer());
|
||||
presetsFormContainer.AddChild(CreateMacroNameContainer());
|
||||
presetsFormContainer.AddChild(CreateMacroCommandContainer());
|
||||
presetsFormContainer.AddChild(CreateMacroActionEdit());
|
||||
|
||||
Button addMacroButton = textImageButtonFactory.Generate(LocalizedString.Get("Save"));
|
||||
addMacroButton.Click += new EventHandler(SaveMacro_Click);
|
||||
|
|
@ -215,20 +217,19 @@ namespace MatterHackers.MatterControl
|
|||
return container;
|
||||
}
|
||||
|
||||
private FlowLayoutWidget createMacroNameContainer()
|
||||
private FlowLayoutWidget CreateMacroNameContainer()
|
||||
{
|
||||
FlowLayoutWidget container = new FlowLayoutWidget(FlowDirection.TopToBottom);
|
||||
container.Margin = new BorderDouble(0, 5);
|
||||
BorderDouble elementMargin = new BorderDouble(top: 3);
|
||||
|
||||
string macroNameLabelTxt = LocalizedString.Get("Macro Name");
|
||||
string macroNameLabelTxtFull = string.Format("{0}:", macroNameLabelTxt);
|
||||
string macroNameLabelTxtFull = string.Format("{0}:", "Macro Name".Localize());
|
||||
TextWidget macroNameLabel = new TextWidget(macroNameLabelTxtFull, 0, 0, 12);
|
||||
macroNameLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||
macroNameLabel.HAnchor = HAnchor.ParentLeftRight;
|
||||
macroNameLabel.Margin = new BorderDouble(0, 0, 0, 1);
|
||||
|
||||
macroNameInput = new MHTextEditWidget(MacroControls.FixMacroName(windowController.ActiveMacro.Name));
|
||||
macroNameInput = new MHTextEditWidget(GCodeMacro.FixMacroName(windowController.ActiveMacro.Name));
|
||||
macroNameInput.HAnchor = HAnchor.ParentLeftRight;
|
||||
|
||||
string giveMacroANameLabel = LocalizedString.Get("Give the macro a name");
|
||||
|
|
@ -245,10 +246,30 @@ namespace MatterHackers.MatterControl
|
|||
return container;
|
||||
}
|
||||
|
||||
FlowLayoutWidget CreateMacroActionEdit()
|
||||
{
|
||||
FlowLayoutWidget container = new FlowLayoutWidget(FlowDirection.TopToBottom);
|
||||
container.Margin = new BorderDouble(0, 5);
|
||||
BorderDouble elementMargin = new BorderDouble(top: 3);
|
||||
|
||||
showInActionMenu = new CheckBox("Show In Action Menu".Localize())
|
||||
{
|
||||
TextColor = ActiveTheme.Instance.PrimaryTextColor,
|
||||
HAnchor = HAnchor.ParentLeftRight,
|
||||
Margin = new BorderDouble(0, 0, 0, 1),
|
||||
Checked = windowController.ActiveMacro.ActionGroup,
|
||||
};
|
||||
|
||||
container.AddChild(showInActionMenu);
|
||||
container.HAnchor = HAnchor.ParentLeftRight;
|
||||
return container;
|
||||
}
|
||||
|
||||
private void SaveActiveMacro()
|
||||
{
|
||||
windowController.ActiveMacro.Name = macroNameInput.Text;
|
||||
windowController.ActiveMacro.GCode = macroCommandInput.Text;
|
||||
windowController.ActiveMacro.ActionGroup = showInActionMenu.Checked;
|
||||
|
||||
if (!ActiveSliceSettings.Instance.Macros.Contains(windowController.ActiveMacro))
|
||||
{
|
||||
|
|
@ -346,7 +367,7 @@ namespace MatterHackers.MatterControl
|
|||
macroRow.Padding = new BorderDouble(3);
|
||||
macroRow.BackgroundColor = RGBA_Bytes.White;
|
||||
|
||||
TextWidget buttonLabel = new TextWidget(MacroControls.FixMacroName(macro.Name));
|
||||
TextWidget buttonLabel = new TextWidget(GCodeMacro.FixMacroName(macro.Name));
|
||||
macroRow.AddChild(buttonLabel);
|
||||
|
||||
macroRow.AddChild(new HorizontalSpacer());
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ using MatterHackers.MatterControl.PrinterCommunication;
|
|||
using MatterHackers.MatterControl.PrinterControls;
|
||||
using MatterHackers.MatterControl.SlicerConfiguration;
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace MatterHackers.MatterControl
|
||||
{
|
||||
|
|
@ -46,6 +47,7 @@ namespace MatterHackers.MatterControl
|
|||
private DisableableWidget fanControlsContainer;
|
||||
|
||||
private DisableableWidget macroControlsContainer;
|
||||
private DisableableWidget actionControlsContainer;
|
||||
|
||||
private MovementControls movementControlsContainer;
|
||||
|
||||
|
|
@ -69,11 +71,13 @@ namespace MatterHackers.MatterControl
|
|||
controlsTopToBottomLayout.Name = "ManualPrinterControls.ControlsContainer";
|
||||
controlsTopToBottomLayout.Margin = new BorderDouble(0);
|
||||
|
||||
AddMacroControls(controlsTopToBottomLayout);
|
||||
AddActionControls(controlsTopToBottomLayout);
|
||||
|
||||
AddTemperatureControls(controlsTopToBottomLayout);
|
||||
AddMovementControls(controlsTopToBottomLayout);
|
||||
|
||||
AddMacroControls(controlsTopToBottomLayout);
|
||||
|
||||
FlowLayoutWidget linearPanel = new FlowLayoutWidget();
|
||||
linearPanel.HAnchor = Agg.UI.HAnchor.ParentLeftRight;
|
||||
controlsTopToBottomLayout.AddChild(linearPanel);
|
||||
|
|
@ -133,6 +137,12 @@ namespace MatterHackers.MatterControl
|
|||
PrinterConnectionAndCommunication.Instance.EnableChanged.RegisterEvent(onPrinterStatusChanged, ref unregisterEvents);
|
||||
}
|
||||
|
||||
private void AddActionControls(FlowLayoutWidget controlsTopToBottomLayout)
|
||||
{
|
||||
actionControlsContainer = new ActionControls();
|
||||
controlsTopToBottomLayout.AddChild(actionControlsContainer);
|
||||
}
|
||||
|
||||
private void AddMacroControls(FlowLayoutWidget controlsTopToBottomLayout)
|
||||
{
|
||||
macroControlsContainer = new MacroControls();
|
||||
|
|
@ -180,6 +190,7 @@ namespace MatterHackers.MatterControl
|
|||
movementControlsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Disabled);
|
||||
fanControlsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Disabled);
|
||||
macroControlsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Disabled);
|
||||
actionControlsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Disabled);
|
||||
tuningAdjustmentControlsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Disabled);
|
||||
}
|
||||
else // we at least have a printer selected
|
||||
|
|
@ -199,6 +210,7 @@ namespace MatterHackers.MatterControl
|
|||
movementControlsContainer.SetEnableLevel(DisableableWidget.EnableLevel.ConfigOnly);
|
||||
fanControlsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Disabled);
|
||||
macroControlsContainer.SetEnableLevel(DisableableWidget.EnableLevel.ConfigOnly);
|
||||
actionControlsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Disabled);
|
||||
tuningAdjustmentControlsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Disabled);
|
||||
|
||||
foreach (var widget in movementControlsContainer.DisableableWidgets)
|
||||
|
|
@ -220,6 +232,7 @@ namespace MatterHackers.MatterControl
|
|||
movementControlsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Enabled);
|
||||
fanControlsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Enabled);
|
||||
macroControlsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Enabled);
|
||||
actionControlsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Enabled);
|
||||
tuningAdjustmentControlsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Disabled);
|
||||
|
||||
foreach (var widget in movementControlsContainer.DisableableWidgets)
|
||||
|
|
@ -239,6 +252,7 @@ namespace MatterHackers.MatterControl
|
|||
movementControlsContainer.SetEnableLevel(DisableableWidget.EnableLevel.ConfigOnly);
|
||||
fanControlsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Enabled);
|
||||
macroControlsContainer.SetEnableLevel(DisableableWidget.EnableLevel.ConfigOnly);
|
||||
actionControlsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Disabled);
|
||||
tuningAdjustmentControlsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Disabled);
|
||||
break;
|
||||
|
||||
|
|
@ -258,6 +272,7 @@ namespace MatterHackers.MatterControl
|
|||
//movementControlsContainer.SetEnableLevel(DisableableWidget.EnableLevel.ConfigOnly);
|
||||
fanControlsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Enabled);
|
||||
macroControlsContainer.SetEnableLevel(DisableableWidget.EnableLevel.ConfigOnly);
|
||||
actionControlsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Disabled);
|
||||
tuningAdjustmentControlsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Enabled);
|
||||
|
||||
foreach(var widget in movementControlsContainer.DisableableWidgets)
|
||||
|
|
@ -283,6 +298,7 @@ namespace MatterHackers.MatterControl
|
|||
movementControlsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Enabled);
|
||||
fanControlsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Enabled);
|
||||
macroControlsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Enabled);
|
||||
actionControlsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Enabled);
|
||||
tuningAdjustmentControlsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Enabled);
|
||||
|
||||
foreach (var widget in movementControlsContainer.DisableableWidgets)
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ using Newtonsoft.Json.Linq;
|
|||
using System.Text;
|
||||
using MatterHackers.MatterControl.PrinterCommunication;
|
||||
using MatterHackers.MatterControl.PrinterCommunication.Io;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace MatterHackers.MatterControl.SlicerConfiguration
|
||||
{
|
||||
|
|
@ -44,8 +45,23 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
{
|
||||
public string Name { get; set; }
|
||||
public string GCode { get; set; }
|
||||
public bool ActionGroup { get; set; }
|
||||
public DateTime LastModified { get; set; }
|
||||
|
||||
public static string FixMacroName(string input)
|
||||
{
|
||||
int lengthLimit = 24;
|
||||
|
||||
string result = Regex.Replace(input, @"\r\n?|\n", " ");
|
||||
|
||||
if (result.Length > lengthLimit)
|
||||
{
|
||||
result = result.Substring(0, lengthLimit) + "...";
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public void Run()
|
||||
{
|
||||
if (PrinterConnectionAndCommunication.Instance.PrinterIsConnected)
|
||||
|
|
|
|||
|
|
@ -81,7 +81,27 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
}
|
||||
|
||||
public List<GCodeMacro> Macros { get; set; } = new List<GCodeMacro>();
|
||||
|
||||
public IEnumerable<GCodeMacro> UserMacros()
|
||||
{
|
||||
foreach (var macro in Macros)
|
||||
{
|
||||
if (!macro.ActionGroup)
|
||||
{
|
||||
yield return macro;
|
||||
}
|
||||
}
|
||||
}
|
||||
public IEnumerable<GCodeMacro> ActionMacros()
|
||||
{
|
||||
foreach (var macro in Macros)
|
||||
{
|
||||
if (macro.ActionGroup)
|
||||
{
|
||||
yield return macro;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[OnDeserialized]
|
||||
internal void OnDeserializedMethod(StreamingContext context)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -440,34 +440,6 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
//If the active printer has no theme we set it to the current theme color
|
||||
printerSettings.UserLayer[SettingsKey.active_theme_name] = ActiveTheme.Instance.Name;
|
||||
|
||||
// Import named macros as defined in the following printers: (Airwolf Axiom, HD, HD-R, HD2x, HDL, HDx, Me3D Me2, Robo R1[+])
|
||||
var classicDefaultMacros = printerSettings.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))
|
||||
{
|
||||
printerSettings.Macros.Add(new GCodeMacro()
|
||||
{
|
||||
Name = namedMacro.Trim(),
|
||||
GCode = gcode
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Add to Profiles - fires ProfileManager.Save due to ObservableCollection event listener
|
||||
Instance.Profiles.Add(new PrinterInfo
|
||||
{
|
||||
|
|
|
|||
|
|
@ -5644,3 +5644,9 @@ Translated:Note: Be sure the tip of the extruder is clean.
|
|||
English:- none -
|
||||
Translated:- none -
|
||||
|
||||
English:Actions
|
||||
Translated:Actions
|
||||
|
||||
English:Show In Action Menu
|
||||
Translated:Show In Action Menu
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue