Merge pull request #3192 from jlewin/design_tools
Move redeem operations into user menu
This commit is contained in:
commit
7257ac5494
13 changed files with 167 additions and 316 deletions
|
|
@ -39,6 +39,7 @@ namespace MatterHackers.MatterControl
|
|||
using MatterHackers.Agg.Platform;
|
||||
using MatterHackers.Localizations;
|
||||
using MatterHackers.MatterControl.PartPreviewWindow;
|
||||
using MatterHackers.MatterControl.PrinterCommunication;
|
||||
using MatterHackers.VectorMath;
|
||||
|
||||
public class ThemeConfig
|
||||
|
|
@ -199,6 +200,38 @@ namespace MatterHackers.MatterControl
|
|||
};
|
||||
}
|
||||
|
||||
public JogControls.MoveButton CreateMoveButton(PrinterConfig printer, string label, PrinterConnection.Axis axis, double movementFeedRate, bool levelingButtons = false)
|
||||
{
|
||||
return new JogControls.MoveButton(label, printer, axis, movementFeedRate, this)
|
||||
{
|
||||
BackgroundColor = this.MinimalShade,
|
||||
Border = 1,
|
||||
BorderColor = this.GetBorderColor(40),
|
||||
VAnchor = VAnchor.Absolute,
|
||||
HAnchor = HAnchor.Absolute,
|
||||
Margin = 0,
|
||||
Padding = 0,
|
||||
Height = (levelingButtons ? 45 : 40) * GuiWidget.DeviceScale,
|
||||
Width = (levelingButtons ? 90 : 40) * GuiWidget.DeviceScale,
|
||||
};
|
||||
}
|
||||
|
||||
public JogControls.ExtrudeButton CreateExtrudeButton(PrinterConfig printer, string label, double movementFeedRate, int extruderNumber, bool levelingButtons = false)
|
||||
{
|
||||
return new JogControls.ExtrudeButton(printer, label, movementFeedRate, extruderNumber, this)
|
||||
{
|
||||
BackgroundColor = this.MinimalShade,
|
||||
Border = 1,
|
||||
BorderColor = this.GetBorderColor(40),
|
||||
VAnchor = VAnchor.Absolute,
|
||||
HAnchor = HAnchor.Absolute,
|
||||
Margin = 0,
|
||||
Padding = 0,
|
||||
Height = (levelingButtons ? 45 : 40) * GuiWidget.DeviceScale,
|
||||
Width = (levelingButtons ? 90 : 40) * GuiWidget.DeviceScale,
|
||||
};
|
||||
}
|
||||
|
||||
public RadioTextButton CreateMicroRadioButton(string text, IList<GuiWidget> siblingRadioButtonList = null)
|
||||
{
|
||||
var radioButton = new RadioTextButton(text, this, this.FontSize8)
|
||||
|
|
|
|||
|
|
@ -48,12 +48,14 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
|
||||
protected JogControls.MoveButton zPlusControl;
|
||||
protected JogControls.MoveButton zMinusControl;
|
||||
private ThemeConfig theme;
|
||||
protected WizardControl container;
|
||||
|
||||
public FindBedHeight(PrinterConfig printer, WizardControl container, string pageDescription, string setZHeightCoarseInstruction1, string setZHeightCoarseInstruction2, double moveDistance,
|
||||
List<ProbePosition> probePositions, int probePositionsBeingEditedIndex, ThemeConfig theme)
|
||||
: base(printer, pageDescription, setZHeightCoarseInstruction1, theme)
|
||||
{
|
||||
this.theme = theme;
|
||||
this.container = container;
|
||||
this.probePositions = probePositions;
|
||||
this.moveAmount = moveDistance;
|
||||
|
|
@ -114,7 +116,8 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
|
||||
private FlowLayoutWidget CreateZButtons()
|
||||
{
|
||||
FlowLayoutWidget zButtons = JogControls.CreateZButtons(printer, Color.White, 4, out zPlusControl, out zMinusControl, true);
|
||||
FlowLayoutWidget zButtons = JogControls.CreateZButtons(printer, 4, out zPlusControl, out zMinusControl, new PrinterControls.XYZColors(theme), theme, true);
|
||||
|
||||
// set these to 0 so the button does not do any movements by default (we will handle the movement on our click callback)
|
||||
zPlusControl.MoveAmount = 0;
|
||||
zPlusControl.ToolTipText += " [Up Arrow]".Localize();
|
||||
|
|
|
|||
|
|
@ -39,21 +39,9 @@ namespace MatterHackers.MatterControl.CustomWidgets
|
|||
{
|
||||
public class ZAxisControls : FlowLayoutWidget
|
||||
{
|
||||
private MoveButtonFactory buttonFactory;
|
||||
|
||||
public ZAxisControls(PrinterConfig printer, ThemeConfig theme, bool smallScreen) :
|
||||
base(FlowDirection.TopToBottom)
|
||||
{
|
||||
buttonFactory = new MoveButtonFactory()
|
||||
{
|
||||
FontSize = theme.DefaultFontSize,
|
||||
BorderWidth = 0
|
||||
};
|
||||
|
||||
buttonFactory.Colors.Fill.Normal = theme.Colors.PrimaryAccentColor;
|
||||
buttonFactory.Colors.Fill.Hover = theme.Colors.PrimaryAccentColor;
|
||||
buttonFactory.Colors.Text.Normal = Color.White;
|
||||
|
||||
this.AddChild(new TextWidget("Z+", pointSize: smallScreen ? 12 : 15, textColor: theme.Colors.PrimaryTextColor)
|
||||
{
|
||||
AutoExpandBoundsToText = true,
|
||||
|
|
@ -90,9 +78,9 @@ namespace MatterHackers.MatterControl.CustomWidgets
|
|||
this.VAnchor = VAnchor.Fit | VAnchor.Top;
|
||||
}
|
||||
|
||||
private Button CreateZMoveButton(PrinterConfig printer, double moveAmount, bool smallScreen, ThemeConfig theme)
|
||||
private MoveButton CreateZMoveButton(PrinterConfig printer, double moveAmount, bool smallScreen, ThemeConfig theme)
|
||||
{
|
||||
var button = buttonFactory.GenerateMoveButton(printer, $"{Math.Abs(moveAmount):0.00} mm", PrinterConnection.Axis.Z, printer.Settings.ZSpeed());
|
||||
var button = theme.CreateMoveButton(printer, $"{Math.Abs(moveAmount):0.00} mm", PrinterConnection.Axis.Z, printer.Settings.ZSpeed());
|
||||
button.MoveAmount = moveAmount;
|
||||
button.HAnchor = HAnchor.MaxFitOrStretch;
|
||||
button.VAnchor = VAnchor.Fit;
|
||||
|
|
|
|||
|
|
@ -98,9 +98,11 @@ namespace MatterHackers.MatterControl
|
|||
return totalBounds;
|
||||
}
|
||||
|
||||
public double TrackRadius { get; set; } = 0;
|
||||
|
||||
public void DrawTrackAndThumb(Graphics2D graphics2D)
|
||||
{
|
||||
RoundedRect track = new RoundedRect(GetTrackBounds(), 0);
|
||||
RoundedRect track = new RoundedRect(GetTrackBounds(), this.TrackRadius);
|
||||
Vector2 ValuePrintPosition;
|
||||
if (sliderAttachedTo.Orientation == Orientation.Horizontal)
|
||||
{
|
||||
|
|
@ -117,7 +119,7 @@ namespace MatterHackers.MatterControl
|
|||
// now do the thumb
|
||||
RectangleDouble thumbBounds = sliderAttachedTo.GetThumbHitBounds();
|
||||
RoundedRect thumbOutside = new RoundedRect(thumbBounds, 0);
|
||||
graphics2D.Render(thumbOutside, ColorF.GetTweenColor(ThumbColor.ToColorF(), ColorF.Black.ToColorF(), .2).ToColor());
|
||||
graphics2D.Render(thumbOutside, this.ThumbColor); // ColorF.GetTweenColor(ThumbColor.ToColorF(), ColorF.Black.ToColorF(), .2).ToColor());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -186,41 +186,6 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.PlusTab
|
|||
Margin = new BorderDouble(left: 15)
|
||||
};
|
||||
toolBarA.AddChild(printerSelector);
|
||||
|
||||
toolBarA.AddChild(new VerticalLine(50) { Margin = new BorderDouble(12, 0) });
|
||||
|
||||
var redeemDesignCode = new TextButton("Redeem Design Code".Localize(), theme)
|
||||
{
|
||||
Name = "Redeem Design Code Button",
|
||||
Margin = theme.ButtonSpacing
|
||||
};
|
||||
redeemDesignCode.Click += (s, e) =>
|
||||
{
|
||||
UiThread.RunOnIdle(() =>
|
||||
{
|
||||
simpleTabs.RemoveTab(simpleTabs.ActiveTab);
|
||||
// Implementation already does RunOnIdle
|
||||
ApplicationController.Instance.RedeemDesignCode?.Invoke();
|
||||
});
|
||||
};
|
||||
toolBarA.AddChild(redeemDesignCode);
|
||||
|
||||
var redeemShareCode = new TextButton("Enter Share Code".Localize(), theme)
|
||||
{
|
||||
Name = "Enter Share Code Button",
|
||||
Margin = theme.ButtonSpacing
|
||||
};
|
||||
redeemShareCode.Click += (s, e) =>
|
||||
{
|
||||
UiThread.RunOnIdle(() =>
|
||||
{
|
||||
simpleTabs.RemoveTab(simpleTabs.ActiveTab);
|
||||
|
||||
// Implementation already does RunOnIdle
|
||||
ApplicationController.Instance.EnterShareCode?.Invoke();
|
||||
});
|
||||
};
|
||||
toolBarA.AddChild(redeemShareCode);
|
||||
}
|
||||
|
||||
public async override void OnLoad(EventArgs args)
|
||||
|
|
@ -281,7 +246,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.PlusTab
|
|||
{
|
||||
foreach (var content in contentList.Content)
|
||||
{
|
||||
switch (content.content_type)
|
||||
switch (content.content_type)
|
||||
{
|
||||
case "banner_image":
|
||||
{
|
||||
|
|
|
|||
|
|
@ -246,6 +246,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
{
|
||||
sectionWidget.ContentPanel.Padding = new BorderDouble(10, 10, 10, 0);
|
||||
sectionWidget.ExpandableWhenDisabled = true;
|
||||
sectionWidget.Enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ using System.Collections.Generic;
|
|||
using System.IO;
|
||||
using System.Linq;
|
||||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.ImageProcessing;
|
||||
using MatterHackers.Agg.Platform;
|
||||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.MatterControl.CustomWidgets;
|
||||
|
|
@ -123,9 +124,18 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
|
||||
var iconButton = widget as IconButton;
|
||||
|
||||
var iconImage = iconButton?.IconImage;
|
||||
|
||||
// Invert the menu icon if the application theme is dark
|
||||
if (iconImage != null
|
||||
&& theme.InvertIcons)
|
||||
{
|
||||
iconImage = iconImage.InvertLightness();
|
||||
}
|
||||
|
||||
menuItem = popupMenu.CreateMenuItem(
|
||||
widget.ToolTipText ?? widget.Text,
|
||||
iconButton?.IconImage);
|
||||
iconImage);
|
||||
|
||||
menuItem.Enabled = widget.Enabled;
|
||||
|
||||
|
|
|
|||
|
|
@ -60,6 +60,8 @@ namespace MatterHackers.MatterControl.PrinterControls
|
|||
double sliderWidth = 300 * GuiWidget.DeviceScale;
|
||||
double sliderThumbWidth = 10 * GuiWidget.DeviceScale;
|
||||
|
||||
Color sliderTrackColor = theme.Colors.IsDarkTheme ? new Color(theme.Shade, 65) : theme.SlightShade;
|
||||
|
||||
SettingsRow settingsRow;
|
||||
|
||||
{
|
||||
|
|
@ -80,6 +82,8 @@ namespace MatterHackers.MatterControl.PrinterControls
|
|||
VAnchor = VAnchor.Center,
|
||||
TotalWidthInPixels = sliderWidth,
|
||||
};
|
||||
feedRateRatioSlider.View.TrackColor = sliderTrackColor;
|
||||
feedRateRatioSlider.View.TrackRadius = 4;
|
||||
feedRateRatioSlider.ValueChanged += (sender, e) =>
|
||||
{
|
||||
feedRateValue.ActuallNumberEdit.Value = Math.Round(feedRateRatioSlider.Value, 2);
|
||||
|
|
@ -137,7 +141,8 @@ namespace MatterHackers.MatterControl.PrinterControls
|
|||
Margin = new BorderDouble(5, 0),
|
||||
Value = ExtrusionMultiplyerStream.ExtrusionRatio
|
||||
};
|
||||
extrusionRatioSlider.BackgroundColor = new Color();
|
||||
extrusionRatioSlider.View.TrackColor = sliderTrackColor;
|
||||
extrusionRatioSlider.View.TrackRadius = 4;
|
||||
extrusionRatioSlider.ValueChanged += (sender, e) =>
|
||||
{
|
||||
extrusionValue.ActuallNumberEdit.Value = Math.Round(extrusionRatioSlider.Value, 2);
|
||||
|
|
|
|||
|
|
@ -56,13 +56,13 @@ namespace MatterHackers.MatterControl.PrinterControls
|
|||
|
||||
private EventHandler unregisterEvents;
|
||||
|
||||
private MovementControls(PrinterConfig printer, ThemeConfig theme)
|
||||
private MovementControls(PrinterConfig printer, XYZColors xyzColors, ThemeConfig theme)
|
||||
: base (FlowDirection.TopToBottom)
|
||||
{
|
||||
this.printer = printer;
|
||||
this.theme = theme;
|
||||
|
||||
jogControls = new JogControls(printer, new XYZColors(), theme)
|
||||
jogControls = new JogControls(printer, xyzColors, theme)
|
||||
{
|
||||
HAnchor = HAnchor.Left | HAnchor.Stretch,
|
||||
Margin = 0
|
||||
|
|
@ -77,7 +77,7 @@ namespace MatterHackers.MatterControl.PrinterControls
|
|||
|
||||
public static SectionWidget CreateSection(PrinterConfig printer, ThemeConfig theme)
|
||||
{
|
||||
var widget = new MovementControls(printer, theme);
|
||||
var widget = new MovementControls(printer, new XYZColors(theme), theme);
|
||||
|
||||
var editButton = new IconButton(AggContext.StaticData.LoadIcon("icon_edit.png", 16, 16, theme.InvertIcons), theme);
|
||||
editButton.Click += (s, e) => widget.EditOptions();
|
||||
|
|
@ -256,13 +256,17 @@ namespace MatterHackers.MatterControl.PrinterControls
|
|||
|
||||
public class XYZColors
|
||||
{
|
||||
public static Color eColor = new Color(180, 180, 180);
|
||||
public static Color xColor = new Color(180, 180, 180);
|
||||
public static Color yColor = new Color(255, 255, 255);
|
||||
public static Color zColor = new Color(255, 255, 255);
|
||||
public Color EColor { get; }
|
||||
public Color XColor { get; }
|
||||
public Color YColor { get; }
|
||||
public Color ZColor { get; }
|
||||
|
||||
public XYZColors()
|
||||
public XYZColors(ThemeConfig theme)
|
||||
{
|
||||
this.EColor = theme.GetBorderColor(40); // new Color(180, 180, 180);
|
||||
this.XColor = theme.GetBorderColor(40); // new Color(180, 180, 180);
|
||||
this.YColor = theme.GetBorderColor(40); //new Color(255, 255, 255);
|
||||
this.ZColor = theme.GetBorderColor(40); //new Color(255, 255, 255);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -128,6 +128,12 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
column.AddChild(sectionWidget);
|
||||
|
||||
// Disable borders on all SettingsRow children in control panels
|
||||
foreach(var settingsRow in sectionWidget.ContentPanel.Descendants<SettingsRow>())
|
||||
{
|
||||
settingsRow.BorderColor = Color.Transparent;
|
||||
}
|
||||
|
||||
// Return the panel widget rather than the source sectionWidget
|
||||
return sectionWidget.ContentPanel;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,10 +58,6 @@ namespace MatterHackers.MatterControl
|
|||
private MoveButton zPlusControl;
|
||||
private MoveButton zMinusControl;
|
||||
|
||||
private MoveButtonFactory moveButtonFactory = new MoveButtonFactory()
|
||||
{
|
||||
FontSize = ApplicationController.Instance.Theme.DefaultFontSize
|
||||
};
|
||||
private ThemeConfig theme;
|
||||
private PrinterConfig printer;
|
||||
|
||||
|
|
@ -69,7 +65,6 @@ namespace MatterHackers.MatterControl
|
|||
{
|
||||
this.theme = theme;
|
||||
this.printer = printer;
|
||||
moveButtonFactory.Colors.Text.Normal = Color.Black;
|
||||
|
||||
double distanceBetweenControls = 12;
|
||||
double buttonSeparationDistance = 10;
|
||||
|
|
@ -88,7 +83,7 @@ namespace MatterHackers.MatterControl
|
|||
GuiWidget xyGrid = CreateXYGridControl(colors, distanceBetweenControls, buttonSeparationDistance);
|
||||
xYZControls.AddChild(xyGrid);
|
||||
|
||||
FlowLayoutWidget zButtons = CreateZButtons(printer, XYZColors.zColor, buttonSeparationDistance, out zPlusControl, out zMinusControl);
|
||||
FlowLayoutWidget zButtons = JogControls.CreateZButtons(printer, buttonSeparationDistance, out zPlusControl, out zMinusControl, colors, theme);
|
||||
zButtons.VAnchor = VAnchor.Bottom;
|
||||
xYZControls.AddChild(zButtons);
|
||||
xYZWithDistance.AddChild(xYZControls);
|
||||
|
|
@ -186,13 +181,15 @@ namespace MatterHackers.MatterControl
|
|||
#if !__ANDROID__
|
||||
allControlsLeftToRight.AddChild(GetHotkeyControlContainer());
|
||||
#endif
|
||||
GuiWidget barBetweenZAndE = new GuiWidget(2, 2);
|
||||
barBetweenZAndE.VAnchor = VAnchor.Stretch;
|
||||
barBetweenZAndE.BackgroundColor = Color.White;
|
||||
barBetweenZAndE.Margin = new BorderDouble(distanceBetweenControls, 5);
|
||||
var barBetweenZAndE = new GuiWidget(1, 1)
|
||||
{
|
||||
VAnchor = VAnchor.Stretch,
|
||||
BackgroundColor = colors.ZColor,
|
||||
Margin = new BorderDouble(distanceBetweenControls, 5)
|
||||
};
|
||||
allControlsLeftToRight.AddChild(barBetweenZAndE);
|
||||
|
||||
FlowLayoutWidget eButtons = CreateEButtons(buttonSeparationDistance);
|
||||
FlowLayoutWidget eButtons = CreateEButtons(buttonSeparationDistance, colors);
|
||||
disableableEButtons = new DisableableWidget()
|
||||
{
|
||||
Name = "disableableEButtons",
|
||||
|
|
@ -276,7 +273,7 @@ namespace MatterHackers.MatterControl
|
|||
private DisableableWidget disableableEButtons;
|
||||
private DisableableWidget tooBigForBabyStepping;
|
||||
private GuiWidget keyboardFocusBorder;
|
||||
private ImageWidget keyboardImage;
|
||||
private GuiWidget keyboardImage;
|
||||
private EventHandler unregisterEvents;
|
||||
|
||||
public override void OnClosed(ClosedEventArgs e)
|
||||
|
|
@ -291,17 +288,17 @@ namespace MatterHackers.MatterControl
|
|||
{
|
||||
HAnchor = HAnchor.Fit,
|
||||
VAnchor = VAnchor.Stretch,
|
||||
ToolTipText = "Enable cursor keys for movement".Localize(),
|
||||
ToolTipText = "Use cursor keys for axis movements".Localize(),
|
||||
Margin = new BorderDouble(left: 10)
|
||||
};
|
||||
|
||||
keyboardImage = new ImageWidget(AggContext.StaticData.LoadIcon("hot_key_small_white.png", 19, 12, theme.InvertIcons))
|
||||
keyboardImage = new IconButton(AggContext.StaticData.LoadIcon("hot_key_small_white.png", 19, 12, theme.InvertIcons), theme)
|
||||
{
|
||||
BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor,
|
||||
VAnchor = VAnchor.Center,
|
||||
HAnchor = HAnchor.Center,
|
||||
Margin = new BorderDouble(5),
|
||||
Visible = false,
|
||||
Visible = !UserSettings.Instance.IsTouchScreen,
|
||||
Enabled = false,
|
||||
Selectable = false
|
||||
};
|
||||
|
||||
keyboardFocusBorder = new GuiWidget(1, 1)
|
||||
|
|
@ -320,20 +317,17 @@ namespace MatterHackers.MatterControl
|
|||
#if !__ANDROID__
|
||||
public override void OnLoad(EventArgs args)
|
||||
{
|
||||
var parents = keyboardFocusBorder.Parents<SectionWidget>();
|
||||
var parent = keyboardFocusBorder.Parents<SectionWidget>().First();
|
||||
|
||||
parents.First().KeyDown += JogControls_KeyDown;
|
||||
parent.KeyDown += JogControls_KeyDown;
|
||||
|
||||
parents.First().ContainsFocusChanged += (sender, e) =>
|
||||
parent.ContainsFocusChanged += (sender, e) =>
|
||||
{
|
||||
if ((sender as GuiWidget).ContainsFocus
|
||||
&& !UserSettings.Instance.IsTouchScreen)
|
||||
bool hasFocus = (sender as GuiWidget).ContainsFocus;
|
||||
if (keyboardImage.Enabled != hasFocus)
|
||||
{
|
||||
keyboardImage.Visible = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
keyboardImage.Visible = false;
|
||||
keyboardImage.Enabled = hasFocus;
|
||||
//keyboardImage.BackgroundColor = (hasFocus) ? theme.SlightShade : Color.Transparent;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -427,7 +421,7 @@ namespace MatterHackers.MatterControl
|
|||
}
|
||||
}
|
||||
|
||||
private FlowLayoutWidget CreateEButtons(double buttonSeparationDistance)
|
||||
private FlowLayoutWidget CreateEButtons(double buttonSeparationDistance, XYZColors colors)
|
||||
{
|
||||
int extruderCount = printer.Settings.GetValue<int>(SettingsKey.extruder_count);
|
||||
|
||||
|
|
@ -438,7 +432,7 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
if (extruderCount == 1)
|
||||
{
|
||||
ExtrudeButton eMinusControl = CreateExtrudeButton(printer, "E-", printer.Settings.EFeedRate(0), 0, moveButtonFactory);
|
||||
ExtrudeButton eMinusControl = theme.CreateExtrudeButton(printer, "E-", printer.Settings.EFeedRate(0), 0);
|
||||
eMinusControl.Margin = extrusionMargin;
|
||||
eMinusControl.ToolTipText = "Retract filament".Localize();
|
||||
eMinusButtonAndText.AddChild(eMinusControl);
|
||||
|
|
@ -448,7 +442,7 @@ namespace MatterHackers.MatterControl
|
|||
{
|
||||
for (int i = 0; i < extruderCount; i++)
|
||||
{
|
||||
ExtrudeButton eMinusControl = CreateExtrudeButton(printer, $"E{i + 1}-", printer.Settings.EFeedRate(0), i, moveButtonFactory);
|
||||
ExtrudeButton eMinusControl = theme.CreateExtrudeButton(printer, $"E{i + 1}-", printer.Settings.EFeedRate(0), i);
|
||||
eMinusControl.ToolTipText = "Retract filament".Localize();
|
||||
eMinusControl.Margin = extrusionMargin;
|
||||
eMinusButtonAndText.AddChild(eMinusControl);
|
||||
|
|
@ -468,11 +462,13 @@ namespace MatterHackers.MatterControl
|
|||
FlowLayoutWidget buttonSpacerContainer = new FlowLayoutWidget();
|
||||
for (int i = 0; i < extruderCount; i++)
|
||||
{
|
||||
GuiWidget eSpacer = new GuiWidget(2, buttonSeparationDistance);
|
||||
double buttonWidth = eMinusButtons[i].Width + 6;
|
||||
|
||||
eSpacer.Margin = new BorderDouble((buttonWidth / 2), 0, ((buttonWidth) / 2), 0);
|
||||
eSpacer.BackgroundColor = XYZColors.eColor;
|
||||
var eSpacer = new GuiWidget(1, buttonSeparationDistance)
|
||||
{
|
||||
Margin = new BorderDouble((buttonWidth / 2), 0, ((buttonWidth) / 2), 0),
|
||||
BackgroundColor = colors.EColor
|
||||
};
|
||||
buttonSpacerContainer.AddChild(eSpacer);
|
||||
}
|
||||
|
||||
|
|
@ -484,7 +480,7 @@ namespace MatterHackers.MatterControl
|
|||
FlowLayoutWidget ePlusButtonAndText = new FlowLayoutWidget();
|
||||
if (extruderCount == 1)
|
||||
{
|
||||
ExtrudeButton ePlusControl = CreateExtrudeButton(printer, "E+", printer.Settings.EFeedRate(0), 0, moveButtonFactory);
|
||||
ExtrudeButton ePlusControl = theme.CreateExtrudeButton(printer, "E+", printer.Settings.EFeedRate(0), 0);
|
||||
ePlusControl.Margin = extrusionMargin;
|
||||
ePlusControl.ToolTipText = "Extrude filament".Localize();
|
||||
ePlusButtonAndText.AddChild(ePlusControl);
|
||||
|
|
@ -494,7 +490,7 @@ namespace MatterHackers.MatterControl
|
|||
{
|
||||
for (int i = 0; i < extruderCount; i++)
|
||||
{
|
||||
ExtrudeButton ePlusControl = CreateExtrudeButton(printer, $"E{i + 1}+", printer.Settings.EFeedRate(0), i, moveButtonFactory);
|
||||
ExtrudeButton ePlusControl = theme.CreateExtrudeButton(printer, $"E{i + 1}+", printer.Settings.EFeedRate(0), i);
|
||||
ePlusControl.Margin = extrusionMargin;
|
||||
ePlusControl.ToolTipText = "Extrude filament".Localize();
|
||||
ePlusButtonAndText.AddChild(ePlusControl);
|
||||
|
|
@ -574,54 +570,29 @@ namespace MatterHackers.MatterControl
|
|||
return eButtons;
|
||||
}
|
||||
|
||||
private static MoveButton CreateMoveButton(PrinterConfig printer, string label, PrinterConnection.Axis axis, double moveSpeed, bool levelingButtons, MoveButtonFactory buttonFactory)
|
||||
public static FlowLayoutWidget CreateZButtons(PrinterConfig printer, double buttonSeparationDistance, out MoveButton zPlusControl, out MoveButton zMinusControl, XYZColors colors, ThemeConfig theme, bool levelingButtons = false)
|
||||
{
|
||||
var button = buttonFactory.GenerateMoveButton(printer, label, axis, moveSpeed);
|
||||
button.VAnchor = VAnchor.Absolute;
|
||||
button.HAnchor = HAnchor.Absolute;
|
||||
button.Height = (levelingButtons ? 45 : 40) * GuiWidget.DeviceScale;
|
||||
button.Width = (levelingButtons ? 90 : 40) * GuiWidget.DeviceScale;
|
||||
|
||||
return button;
|
||||
}
|
||||
|
||||
private static ExtrudeButton CreateExtrudeButton(PrinterConfig printer, string label, double moveSpeed, int extruderNumber, MoveButtonFactory buttonFactory = null)
|
||||
{
|
||||
var button = buttonFactory.GenerateExtrudeButton(printer, label, moveSpeed, extruderNumber);
|
||||
button.Height = 40 * GuiWidget.DeviceScale;
|
||||
button.Width = 40 * GuiWidget.DeviceScale;
|
||||
|
||||
return button;
|
||||
}
|
||||
|
||||
public static FlowLayoutWidget CreateZButtons(PrinterConfig printer, Color color, double buttonSeparationDistance,
|
||||
out MoveButton zPlusControl, out MoveButton zMinusControl, bool levelingButtons = false)
|
||||
{
|
||||
FlowLayoutWidget zButtons = new FlowLayoutWidget(FlowDirection.TopToBottom);
|
||||
var zButtons = new FlowLayoutWidget(FlowDirection.TopToBottom)
|
||||
{
|
||||
var moveButtonFactory = new MoveButtonFactory()
|
||||
{
|
||||
FontSize = ApplicationController.Instance.Theme.DefaultFontSize
|
||||
};
|
||||
moveButtonFactory.Colors.Fill.Normal = color;
|
||||
Margin = new BorderDouble(0, 5),
|
||||
};
|
||||
|
||||
zPlusControl = CreateMoveButton(printer, "Z+", PrinterConnection.Axis.Z, printer.Settings.ZSpeed(), levelingButtons, moveButtonFactory);
|
||||
zPlusControl.Name = "Move Z positive".Localize();
|
||||
zPlusControl.ToolTipText = "Move Z positive".Localize();
|
||||
zButtons.AddChild(zPlusControl);
|
||||
zPlusControl = theme.CreateMoveButton(printer, "Z+", PrinterConnection.Axis.Z, printer.Settings.ZSpeed(), levelingButtons);
|
||||
zPlusControl.Name = "Move Z positive".Localize();
|
||||
zPlusControl.ToolTipText = "Move Z positive".Localize();
|
||||
zButtons.AddChild(zPlusControl);
|
||||
|
||||
// spacer
|
||||
zButtons.AddChild(new GuiWidget(2, buttonSeparationDistance)
|
||||
{
|
||||
HAnchor = HAnchor.Center,
|
||||
BackgroundColor = XYZColors.zColor
|
||||
});
|
||||
// spacer
|
||||
zButtons.AddChild(new GuiWidget(1, buttonSeparationDistance)
|
||||
{
|
||||
HAnchor = HAnchor.Center,
|
||||
BackgroundColor = colors.ZColor
|
||||
});
|
||||
|
||||
zMinusControl = theme.CreateMoveButton(printer, "Z-", PrinterConnection.Axis.Z, printer.Settings.ZSpeed(), levelingButtons);
|
||||
zMinusControl.ToolTipText = "Move Z negative".Localize();
|
||||
zButtons.AddChild(zMinusControl);
|
||||
|
||||
zMinusControl = CreateMoveButton(printer, "Z-", PrinterConnection.Axis.Z, printer.Settings.ZSpeed(), levelingButtons, moveButtonFactory);
|
||||
zMinusControl.ToolTipText = "Move Z negative".Localize();
|
||||
zButtons.AddChild(zMinusControl);
|
||||
}
|
||||
zButtons.Margin = new BorderDouble(0, 5);
|
||||
return zButtons;
|
||||
}
|
||||
|
||||
|
|
@ -660,22 +631,21 @@ namespace MatterHackers.MatterControl
|
|||
{
|
||||
FlowLayoutWidget xButtons = new FlowLayoutWidget();
|
||||
{
|
||||
moveButtonFactory.Colors.Fill.Normal = XYZColors.xColor;
|
||||
xButtons.HAnchor |= HAnchor.Center;
|
||||
xButtons.VAnchor |= VAnchor.Center;
|
||||
|
||||
xMinusControl = CreateMoveButton(printer, "X-", PrinterConnection.Axis.X, printer.Settings.XSpeed(), false, moveButtonFactory);
|
||||
xMinusControl = theme.CreateMoveButton(printer, "X-", PrinterConnection.Axis.X, printer.Settings.XSpeed());
|
||||
xMinusControl.ToolTipText = "Move X negative".Localize();
|
||||
xButtons.AddChild(xMinusControl);
|
||||
|
||||
// spacer
|
||||
xButtons.AddChild(new GuiWidget(xMinusControl.Width + buttonSeparationDistance * 2, 2)
|
||||
xButtons.AddChild(new GuiWidget(xMinusControl.Width + buttonSeparationDistance * 2, 1)
|
||||
{
|
||||
VAnchor = VAnchor.Center,
|
||||
BackgroundColor = XYZColors.xColor
|
||||
BackgroundColor = colors.XColor
|
||||
});
|
||||
|
||||
xPlusControl = CreateMoveButton(printer, "X+", PrinterConnection.Axis.X, printer.Settings.XSpeed(), false, moveButtonFactory);
|
||||
xPlusControl = theme.CreateMoveButton(printer, "X+", PrinterConnection.Axis.X, printer.Settings.XSpeed());
|
||||
xPlusControl.ToolTipText = "Move X positive".Localize();
|
||||
xButtons.AddChild(xPlusControl);
|
||||
}
|
||||
|
|
@ -683,21 +653,20 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
FlowLayoutWidget yButtons = new FlowLayoutWidget(FlowDirection.TopToBottom);
|
||||
{
|
||||
moveButtonFactory.Colors.Fill.Normal = XYZColors.yColor;
|
||||
yButtons.HAnchor |= HAnchor.Center;
|
||||
yButtons.VAnchor |= VAnchor.Center;
|
||||
yPlusControl = CreateMoveButton(printer, "Y+", PrinterConnection.Axis.Y, printer.Settings.YSpeed(), false, moveButtonFactory);
|
||||
yPlusControl = theme.CreateMoveButton(printer, "Y+", PrinterConnection.Axis.Y, printer.Settings.YSpeed());
|
||||
yPlusControl.ToolTipText = "Move Y positive".Localize();
|
||||
yButtons.AddChild(yPlusControl);
|
||||
|
||||
// spacer
|
||||
yButtons.AddChild(new GuiWidget(2, buttonSeparationDistance)
|
||||
yButtons.AddChild(new GuiWidget(1, buttonSeparationDistance)
|
||||
{
|
||||
HAnchor = HAnchor.Center,
|
||||
BackgroundColor = XYZColors.yColor
|
||||
BackgroundColor = colors.YColor
|
||||
});
|
||||
|
||||
yMinusControl = CreateMoveButton(printer, "Y-", PrinterConnection.Axis.Y, printer.Settings.YSpeed(), false, moveButtonFactory);
|
||||
yMinusControl = theme.CreateMoveButton(printer, "Y-", PrinterConnection.Axis.Y, printer.Settings.YSpeed());
|
||||
yMinusControl.ToolTipText = "Move Y negative".Localize();
|
||||
yButtons.AddChild(yMinusControl);
|
||||
}
|
||||
|
|
@ -707,46 +676,48 @@ namespace MatterHackers.MatterControl
|
|||
xyGrid.VAnchor = VAnchor.Fit;
|
||||
xyGrid.VAnchor = VAnchor.Bottom;
|
||||
xyGrid.Margin = new BorderDouble(0, 5, distanceBetweenControls, 5);
|
||||
|
||||
return xyGrid;
|
||||
}
|
||||
|
||||
public class MoveButton : Button
|
||||
public class MoveButton : TextButton
|
||||
{
|
||||
private PrinterConnection.Axis moveAxis;
|
||||
|
||||
//Amounts in millimeters
|
||||
public double MoveAmount = 10;
|
||||
public double MoveAmount { get; set; } = 10;
|
||||
|
||||
public double MovementFeedRate { get; set; }
|
||||
private PrinterConfig printer;
|
||||
|
||||
public MoveButton(PrinterConfig printer, double x, double y, GuiWidget buttonView, PrinterConnection.Axis axis, double movementFeedRate)
|
||||
: base(x, y, buttonView)
|
||||
private PrinterConnection.Axis moveAxis;
|
||||
public MoveButton(string text, PrinterConfig printer, PrinterConnection.Axis axis, double movementFeedRate, ThemeConfig theme)
|
||||
: base(text, theme)
|
||||
{
|
||||
this.printer = printer;
|
||||
this.moveAxis = axis;
|
||||
this.MovementFeedRate = movementFeedRate;
|
||||
}
|
||||
|
||||
this.Click += (s, e) =>
|
||||
public override void OnClick(MouseEventArgs mouseEvent)
|
||||
{
|
||||
base.OnClick(mouseEvent);
|
||||
|
||||
if (printer.Connection.CommunicationState == CommunicationStates.Printing)
|
||||
{
|
||||
if (printer.Connection.CommunicationState == CommunicationStates.Printing)
|
||||
if (moveAxis == PrinterConnection.Axis.Z) // only works on z
|
||||
{
|
||||
if (moveAxis == PrinterConnection.Axis.Z) // only works on z
|
||||
{
|
||||
var currentZ = printer.Settings.GetValue<double>(SettingsKey.baby_step_z_offset);
|
||||
currentZ += this.MoveAmount;
|
||||
printer.Settings.SetValue(SettingsKey.baby_step_z_offset, currentZ.ToString("0.##"));
|
||||
}
|
||||
var currentZ = printer.Settings.GetValue<double>(SettingsKey.baby_step_z_offset);
|
||||
currentZ += this.MoveAmount;
|
||||
printer.Settings.SetValue(SettingsKey.baby_step_z_offset, currentZ.ToString("0.##"));
|
||||
}
|
||||
else
|
||||
{
|
||||
printer.Connection.MoveRelative(this.moveAxis, this.MoveAmount, MovementFeedRate);
|
||||
}
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
printer.Connection.MoveRelative(this.moveAxis, this.MoveAmount, MovementFeedRate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class ExtrudeButton : Button
|
||||
public class ExtrudeButton : TextButton
|
||||
{
|
||||
//Amounts in millimeters
|
||||
public double MoveAmount = 10;
|
||||
|
|
@ -756,8 +727,8 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
private PrinterConfig printer;
|
||||
|
||||
public ExtrudeButton(PrinterConfig printer, double x, double y, GuiWidget buttonView, double movementFeedRate, int extruderNumber)
|
||||
: base(x, y, buttonView)
|
||||
public ExtrudeButton(PrinterConfig printer, string text, double movementFeedRate, int extruderNumber, ThemeConfig theme)
|
||||
: base(text, theme)
|
||||
{
|
||||
this.printer = printer;
|
||||
this.ExtruderNumber = extruderNumber;
|
||||
|
|
@ -772,147 +743,5 @@ namespace MatterHackers.MatterControl
|
|||
printer.Connection.MoveExtruderRelative(MoveAmount, MovementFeedRate, ExtruderNumber);
|
||||
}
|
||||
}
|
||||
|
||||
public class MoveButtonWidget : GuiWidget
|
||||
{
|
||||
public double BorderWidth { get; set; } = 1;
|
||||
|
||||
private Color borderColor;
|
||||
private Stroke borderStroke = null;
|
||||
|
||||
public MoveButtonWidget(string label, Color textColor, double fontSize = 12)
|
||||
{
|
||||
this.Margin = 0;
|
||||
this.Padding = 0;
|
||||
this.borderColor = new Color(ActiveTheme.Instance.PrimaryTextColor, 200);
|
||||
|
||||
this.AnchorAll();
|
||||
|
||||
if (label != "")
|
||||
{
|
||||
TextWidget textWidget = new TextWidget(label, pointSize: fontSize)
|
||||
{
|
||||
VAnchor = VAnchor.Center,
|
||||
HAnchor = HAnchor.Center,
|
||||
TextColor = textColor,
|
||||
Padding = new BorderDouble(3, 0)
|
||||
};
|
||||
this.AddChild(textWidget);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnBoundsChanged(EventArgs e)
|
||||
{
|
||||
borderStroke = new Stroke(
|
||||
new RoundedRect(LocalBounds, 0),
|
||||
BorderWidth);
|
||||
|
||||
base.OnBoundsChanged(e);
|
||||
}
|
||||
|
||||
public override void OnDraw(Graphics2D graphics2D)
|
||||
{
|
||||
base.OnDraw(graphics2D);
|
||||
|
||||
if (this.BorderWidth > 0 && borderStroke != null)
|
||||
{
|
||||
graphics2D.Render(borderStroke, borderColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class WidgetStateColors
|
||||
{
|
||||
public Color Normal { get; set; }
|
||||
public Color Hover { get; set; }
|
||||
public Color Pressed { get; set; }
|
||||
public Color Disabled { get; set; }
|
||||
}
|
||||
|
||||
public class WidgetColors
|
||||
{
|
||||
public WidgetStateColors Fill { get; set; }
|
||||
public WidgetStateColors Text { get; set; }
|
||||
}
|
||||
|
||||
public class MoveButtonFactory
|
||||
{
|
||||
public BorderDouble Padding;
|
||||
public BorderDouble Margin;
|
||||
|
||||
public WidgetColors Colors { get; set; } = new WidgetColors()
|
||||
{
|
||||
Text = new WidgetStateColors()
|
||||
{
|
||||
Normal = Color.Black,
|
||||
Hover = Color.White,
|
||||
Pressed = Color.White,
|
||||
Disabled = Color.White
|
||||
},
|
||||
Fill = new WidgetStateColors()
|
||||
{
|
||||
Normal = Color.White,
|
||||
Hover = new Color(0, 0, 0, 50),
|
||||
Pressed = Color.Transparent,
|
||||
Disabled = new Color(255, 255, 255, 50)
|
||||
}
|
||||
};
|
||||
|
||||
public double FontSize { get; set; } = 12;
|
||||
|
||||
public double BorderWidth { get; set; } = 1;
|
||||
|
||||
public MoveButton GenerateMoveButton(PrinterConfig printer, string label, PrinterConnection.Axis axis, double movementFeedRate)
|
||||
{
|
||||
//Create button based on view container widget
|
||||
return new MoveButton(printer, 0, 0, GetButtonView(label), axis, movementFeedRate)
|
||||
{
|
||||
Margin = 0,
|
||||
Padding = 0
|
||||
};
|
||||
}
|
||||
|
||||
public ExtrudeButton GenerateExtrudeButton(PrinterConfig printer, string label, double movementFeedRate, int extruderNumber)
|
||||
{
|
||||
//Create button based on view container widget
|
||||
return new ExtrudeButton(printer, 0, 0, GetButtonView(label), movementFeedRate, extruderNumber)
|
||||
{
|
||||
Margin = 0,
|
||||
Padding = 0
|
||||
};
|
||||
}
|
||||
|
||||
private ButtonViewStates GetButtonView(string label)
|
||||
{
|
||||
//Create the multi-state button view
|
||||
var buttonViewStates = new ButtonViewStates(
|
||||
new MoveButtonWidget(label, Colors.Text.Normal, this.FontSize)
|
||||
{
|
||||
BackgroundColor = Colors.Fill.Normal,
|
||||
BorderWidth = this.BorderWidth
|
||||
},
|
||||
new MoveButtonWidget(label, Colors.Text.Hover, this.FontSize)
|
||||
{
|
||||
BackgroundColor = Colors.Fill.Hover,
|
||||
BorderWidth = this.BorderWidth
|
||||
},
|
||||
new MoveButtonWidget(label, Colors.Text.Pressed, this.FontSize)
|
||||
{
|
||||
BackgroundColor = Colors.Fill.Pressed,
|
||||
BorderWidth = this.BorderWidth
|
||||
},
|
||||
new MoveButtonWidget(label, Colors.Text.Disabled, this.FontSize)
|
||||
{
|
||||
BackgroundColor = Colors.Fill.Disabled,
|
||||
BorderWidth = this.BorderWidth
|
||||
}
|
||||
);
|
||||
|
||||
buttonViewStates.HAnchor = HAnchor.Stretch;
|
||||
buttonViewStates.VAnchor = VAnchor.Stretch;
|
||||
|
||||
return buttonViewStates;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1 +1 @@
|
|||
Subproject commit f84b00b5a5e042e99fdeb0fcc7370dd62e070f51
|
||||
Subproject commit fd72d11704dbac9019a5cc106461fbb8ac3b4b26
|
||||
|
|
@ -436,6 +436,11 @@ namespace MatterHackers.MatterControl.Tests.Automation
|
|||
Assert.IsTrue(queueItemData != null && queueItemData.ProjectFiles.Count > 0);
|
||||
}
|
||||
|
||||
public static void OpenUserPopupMenu(this AutomationRunner testRunner)
|
||||
{
|
||||
testRunner.ClickByName("User Options Menu");
|
||||
}
|
||||
|
||||
public static void NavigateToFolder(this AutomationRunner testRunner, string libraryRowItemName)
|
||||
{
|
||||
EnsureFoldersVisible(testRunner);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue