Use existing button factory
This commit is contained in:
parent
0613f8c8b9
commit
1efe8dec4f
1 changed files with 15 additions and 39 deletions
|
|
@ -60,25 +60,10 @@ namespace MatterHackers.MatterControl.PrinterControls
|
|||
|
||||
public class ActionControlsWidget : FlowLayoutWidget
|
||||
{
|
||||
protected string editWindowLabel;
|
||||
protected string label;
|
||||
protected FlowLayoutWidget presetButtonsContainer;
|
||||
protected TextImageButtonFactory textImageButtonFactory = new TextImageButtonFactory();
|
||||
|
||||
public ActionControlsWidget()
|
||||
: base(FlowDirection.TopToBottom)
|
||||
{
|
||||
this.textImageButtonFactory.Options.Normal.FillColor = RGBA_Bytes.White;
|
||||
this.textImageButtonFactory.Options.FixedHeight = 24 * GuiWidget.DeviceScale;
|
||||
this.textImageButtonFactory.Options.FontSize = 12;
|
||||
this.textImageButtonFactory.Options.BorderWidth = 1;
|
||||
this.textImageButtonFactory.Options.Normal.BorderColor = new RGBA_Bytes(ActiveTheme.Instance.PrimaryTextColor, 200);
|
||||
this.textImageButtonFactory.Options.Hover.BorderColor = new RGBA_Bytes(ActiveTheme.Instance.PrimaryTextColor, 200);
|
||||
|
||||
this.textImageButtonFactory.Options.Disabled.TextColor = RGBA_Bytes.Gray;
|
||||
this.textImageButtonFactory.Options.Hover.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||
this.textImageButtonFactory.Options.Normal.TextColor = RGBA_Bytes.Black;
|
||||
this.textImageButtonFactory.Options.Pressed.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||
var buttonFactory = ApplicationController.Instance.Theme.HomingButtons;
|
||||
|
||||
this.HAnchor = HAnchor.ParentLeftRight;
|
||||
|
||||
|
|
@ -97,36 +82,27 @@ namespace MatterHackers.MatterControl.PrinterControls
|
|||
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();
|
||||
|
||||
var macroButtonContainer = new FlowLayoutWidget();
|
||||
macroButtonContainer.Margin = new BorderDouble(0, 0, 3, 0);
|
||||
macroButtonContainer.Padding = new BorderDouble(0, 3, 3, 3);
|
||||
|
||||
if (ActiveSliceSettings.Instance?.ActionMacros().Any() != true)
|
||||
if (ActiveSliceSettings.Instance?.ActionMacros().Any() == true)
|
||||
{
|
||||
return macroButtonContainer;
|
||||
foreach (GCodeMacro macro in ActiveSliceSettings.Instance.ActionMacros())
|
||||
{
|
||||
Button macroButton = buttonFactory.Generate(GCodeMacro.FixMacroName(macro.Name));
|
||||
macroButton.Margin = new BorderDouble(right: 5);
|
||||
macroButton.Click += (s, e) => macro.Run();
|
||||
|
||||
macroButtonContainer.AddChild(macroButton);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (GCodeMacro macro in ActiveSliceSettings.Instance.ActionMacros())
|
||||
{
|
||||
Button macroButton = textImageButtonFactory.Generate(GCodeMacro.FixMacroName(macro.Name));
|
||||
macroButton.Margin = new BorderDouble(right: 5);
|
||||
macroButton.Click += (s, e) => macro.Run();
|
||||
controlRow.AddChild(macroButtonContainer);
|
||||
|
||||
macroButtonContainer.AddChild(macroButton);
|
||||
}
|
||||
|
||||
return macroButtonContainer;
|
||||
groupBox.AddChild(controlRow);
|
||||
this.AddChild(groupBox);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue