improving store page
This commit is contained in:
parent
569cc386f4
commit
ad91859c3a
6 changed files with 61 additions and 22 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue