Merge pull request #5379 from larsbrubaker/main

main
This commit is contained in:
Lars Brubaker 2022-09-13 18:15:50 -07:00 committed by GitHub
commit f977e0b4a7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 61 additions and 22 deletions

View file

@ -34,22 +34,28 @@ using System.Linq;
using MatterHackers.Agg;
using MatterHackers.Agg.UI;
using MatterHackers.Localizations;
using MatterHackers.MatterControl.CustomWidgets;
namespace MatterHackers.MatterControl.PartPreviewWindow.PlusTab
{
public class ArticleSection : FlowLeftRightWithWrapping
public class ArticleSection : FlowLayoutWidget
{
private List<ArticleItem> allIconViews = new List<ArticleItem>();
private FeedSectionData content;
private ThemeConfig theme;
int maxStuff = 20;
private FlowLeftRightWithWrapping wrappingContent;
public ArticleSection(FeedSectionData content, ThemeConfig theme)
{
Proportional = true;
VAnchor = VAnchor.Fit | VAnchor.Top;
this.content = content;
public ArticleSection(FeedSectionData content, ThemeConfig theme)
: base(FlowDirection.TopToBottom)
{
this.HAnchor = HAnchor.Stretch;
this.VAnchor = VAnchor.Fit;
wrappingContent = new FlowLeftRightWithWrapping();
wrappingContent.Proportional = true;
wrappingContent.VAnchor = VAnchor.Fit;
wrappingContent.HAnchor = HAnchor.Stretch;
this.AddChild(wrappingContent);
this.content = content;
this.theme = theme;
var cultureInfo = new CultureInfo("en-US");
@ -74,12 +80,13 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.PlusTab
// Remove items and Children (this happens if the feed is different than the inital cach after being retrieved)
foreach (var iconView in allIconViews)
{
if (this.Children.Contains(iconView))
if (wrappingContent.Children.Contains(iconView))
{
this.RemoveChild(iconView);
wrappingContent.RemoveChild(iconView);
}
}
this.CloseChildren();
wrappingContent.CloseChildren();
int i = 0;
foreach (var iconView in allIconViews)
@ -88,7 +95,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.PlusTab
{
iconView.ClearRemovedFlag();
iconView.Margin = new BorderDouble(leftRightMargin, topBottomMargin);
this.AddChild(iconView);
wrappingContent.AddChild(iconView);
}
i++;
}
@ -99,6 +106,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.PlusTab
{
BackgroundColor = theme.MinimalShade,
Margin = new BorderDouble(right: leftRightMargin),
HAnchor = HAnchor.Left
};
moreButton.Click += (s, e1) =>
{
@ -119,7 +127,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.PlusTab
}
};
this.AddChild(moreButton);
this.AddChild(moreButton);
}
}
}

View file

@ -29,6 +29,7 @@ either expressed or implied, of the FreeBSD Project.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using MatterControl.Printing;
using MatterHackers.Agg;
@ -50,8 +51,10 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.PlusTab
private GuiWidget sectionSelectButtons;
private GuiWidget contentSection;
private bool loaded;
private int buttonPressedAlpha => 40;
private int buttonBackgroundAlpha => 5;
public ExplorePanel(ThemeConfig theme, string relativeUrl)
public ExplorePanel(ThemeConfig theme, string relativeUrl, bool addUnderline = false)
: base(FlowDirection.TopToBottom)
{
this.relativeUrl = relativeUrl;
@ -70,6 +73,12 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.PlusTab
Proportional = true,
Name = "Select Buttons"
});
if (addUnderline)
{
this.AddChild(new HorizontalLine());
}
contentSection = this.AddChild(new GuiWidget() { HAnchor = HAnchor.Stretch, VAnchor = VAnchor.Fit });
}
@ -121,8 +130,23 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.PlusTab
});
}
private void ButtonSelected(object s, EventArgs e)
{
foreach (var button in sectionSelectButtons.Descendants<ThemedButton>())
{
if (button == s)
{
button.BackgroundColor = button.HoverColor.WithAlpha(buttonPressedAlpha);
}
else
{
button.BackgroundColor = button.HoverColor.WithAlpha(buttonBackgroundAlpha);
}
}
}
private void AddContentItem(ThemeConfig theme, FeedSectionData content)
private void AddContentItem(ThemeConfig theme, FeedSectionData content)
{
switch (content.content_type)
{
@ -223,7 +247,9 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.PlusTab
// add the article group button to the button group
// add a content section connected to the button
var sectionButton = new ThemedTextButton(content.group_title, theme);
sectionSelectButtons.AddChild(sectionButton);
sectionButton.BackgroundColor = sectionButton.HoverColor.WithAlpha(buttonBackgroundAlpha);
sectionButton.Click += ButtonSelected;
sectionSelectButtons.AddChild(sectionButton);
var articleSection = new ArticleSection(content, theme)
{
Visible = false,
@ -244,7 +270,9 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.PlusTab
{
var sectionButton = new ThemedTextButton(content.group_title, theme);
sectionSelectButtons.AddChild(sectionButton);
var exploreSection = new ProductSection(content, theme)
sectionButton.BackgroundColor = sectionButton.HoverColor.WithAlpha(buttonPressedAlpha);
sectionButton.Click += ButtonSelected;
var exploreSection = new ProductSection(content, theme)
{
Name = content.group_title
};

View file

@ -57,10 +57,10 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.PlusTab
if (OemSettings.Instance.ShowShopButton)
{
topToBottom.AddChild(new ExplorePanel(theme, "banners?sk=ii2gffs6e89c2cdd9er21v"));
// actual feed
topToBottom.AddChild(new ExplorePanel(theme, "explore?sk=2lhddgi3q67xoqa53pchpeddl6w1uf"));
}
}
// actual feed
topToBottom.AddChild(new ExplorePanel(theme, "explore?sk=2lhddgi3q67xoqa53pchpeddl6w1uf", true));
}
}
public override void OnMouseWheel(MouseEventArgs mouseEvent)
{

View file

@ -288,7 +288,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
// Store tab
tabControl.AddTab(
tab = new ChromeTab("Store", "Resources".Localize(), tabControl, new StoreTabPage(theme), theme, hasClose: false)
tab = new ChromeTab("Store", "Store".Localize(), tabControl, new StoreTabPage(theme), theme, hasClose: false)
{
MinimumSize = new Vector2(0, theme.TabButtonHeight),
Name = "Store Tab",

View file

@ -4939,6 +4939,9 @@ Translated:Stop
English:Stop trying to connect to the printer.
Translated:Stop trying to connect to the printer.
English:Store
Translated:Store
English:Stretch X
Translated:Stretch X

@ -1 +1 @@
Subproject commit 7faf670dff04708f45a94d5e3288de3b71cc4dc4
Subproject commit 84b74049ebe5836f8570d498cb386299cb43ded8