Putting a shop button next to the select material drop down in temp widget

This commit is contained in:
Lars Brubaker 2019-02-05 17:39:11 -08:00
parent 26bdacd27d
commit 82d0b7c7e3
2 changed files with 34 additions and 13 deletions

View file

@ -53,7 +53,7 @@ namespace MatterHackers.MatterControl.ActionBar
this.printer = printer;
GuiWidget loadUnloadButtons = null;
// We do not yet support loading filament into extruders other than 0, fix it when time.
// We do not yet support loading filament into extruders other than 0 & 1, fix it when needed.
if (extruderIndex < 2)
{
// add in load and unload buttons
@ -343,7 +343,7 @@ namespace MatterHackers.MatterControl.ActionBar
if (hotendIndex == 0)
{
// put in the material selector
var presetsSelector = new PresetSelectorWidget(printer, "Material".Localize(), Color.Transparent, NamedSettingsLayers.Material, hotendIndex, menuTheme)
var presetsSelector = new PresetSelectorWidget(printer, "Material".Localize(), Color.Transparent, NamedSettingsLayers.Material, hotendIndex, menuTheme, true)
{
Margin = new BorderDouble(right: menuTheme.ToolbarPadding.Right),
Padding = 0,
@ -373,15 +373,34 @@ namespace MatterHackers.MatterControl.ActionBar
dropList.Margin = 0;
}
GuiWidget rowItem = null;
container.AddChild(
rowItem = new SettingsItem("Material".Localize(), presetsSelector, menuTheme, enforceGutter: false)
{
Border = new BorderDouble(0, 1)
});
var materialRowContainer = new FlowLayoutWidget()
{
HAnchor = HAnchor.Stretch
};
container.AddChild(materialRowContainer);
// material can be changed even when the printer is not connected
alwaysEnabled.Add(rowItem);
alwaysEnabled.Add(materialRowContainer);
// add in the material selector
GuiWidget materialSettingsRow = new SettingsItem("Material".Localize(), presetsSelector, menuTheme, enforceGutter: false)
{
Border = new BorderDouble(0, 1)
};
materialRowContainer.AddChild(materialSettingsRow);
// add in a shop button
var shopButton = theme.CreateDialogButton("Shop".Localize());
shopButton.Margin = new BorderDouble(3, 3, 6, 3);
shopButton.ToolTipText = "Shop Filament at MatterHackers".Localize();
shopButton.Click += (s, e) =>
{
UiThread.RunOnIdle(() =>
{
ApplicationController.Instance.LaunchBrowser("https://www.matterhackers.com/store/c/3d-printer-filament");
});
};
materialRowContainer.AddChild(shopButton);
presetsSelector.PerformLayout();
}
else // put in a temperature selector for the correct material

View file

@ -51,16 +51,18 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
private ThemeConfig theme;
private PrinterConfig printer;
private GuiWidget pullDownContainer;
private bool createAsFit;
public PresetSelectorWidget(PrinterConfig printer, string label, Color accentColor, NamedSettingsLayers layerType, int extruderIndex, ThemeConfig theme)
public PresetSelectorWidget(PrinterConfig printer, string label, Color accentColor, NamedSettingsLayers layerType, int extruderIndex, ThemeConfig theme, bool createAsFit = false)
: base(FlowDirection.TopToBottom)
{
this.createAsFit = createAsFit;
this.extruderIndex = extruderIndex;
this.layerType = layerType;
this.printer = printer;
this.Name = label;
this.theme = theme;
this.HAnchor = HAnchor.Stretch;
this.HAnchor = createAsFit ? HAnchor.Fit : HAnchor.Stretch;
this.VAnchor = VAnchor.Fit;
this.BackgroundColor = theme.MinimalShade;
this.Padding = theme.DefaultContainerPadding;
@ -74,7 +76,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
pullDownContainer = new GuiWidget()
{
HAnchor = HAnchor.Stretch,
HAnchor = createAsFit ? HAnchor.Fit : HAnchor.Stretch,
VAnchor = VAnchor.Fit,
Border = new BorderDouble(left: 3),
BorderColor = accentColor,
@ -95,7 +97,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
var container = new FlowLayoutWidget()
{
HAnchor = HAnchor.MaxFitOrStretch,
HAnchor = createAsFit ? HAnchor.Fit : HAnchor.MaxFitOrStretch,
Name = "Preset Pulldown Container"
};