Merge pull request #3402 from larsbrubaker/design_tools
Change start page to have panels
This commit is contained in:
commit
4270ec5520
11 changed files with 310 additions and 275 deletions
|
|
@ -112,6 +112,10 @@
|
|||
<Compile Include="PartPreviewWindow\GCodeDetails\IToggleOption.cs" />
|
||||
<Compile Include="PartPreviewWindow\LeftClipFlowLayoutWidget.cs" />
|
||||
<Compile Include="PartPreviewWindow\Object3DTreeBuilder.cs" />
|
||||
<Compile Include="PartPreviewWindow\StartPage\FeedData.cs" />
|
||||
<Compile Include="PartPreviewWindow\StartPage\FeedItemData.cs" />
|
||||
<Compile Include="PartPreviewWindow\StartPage\FeedSectionData.cs" />
|
||||
<Compile Include="PartPreviewWindow\StartPage\StartTabPage.cs" />
|
||||
<Compile Include="PartPreviewWindow\View3D\Actions\CombineObject3D.cs" />
|
||||
<Compile Include="PartPreviewWindow\View3D\Actions\IntersectionObject3D.cs" />
|
||||
<Compile Include="PartPreviewWindow\View3D\Actions\SubtractAndReplaceObject3D.cs" />
|
||||
|
|
@ -179,7 +183,7 @@
|
|||
<Compile Include="PartPreviewWindow\MaterialControls.cs" />
|
||||
<Compile Include="PartPreviewWindow\ModelOptionsPanel.cs" />
|
||||
<Compile Include="PartPreviewWindow\MoveItemPage.cs" />
|
||||
<Compile Include="PartPreviewWindow\PlusTab\ExplorerBar.cs" />
|
||||
<Compile Include="PartPreviewWindow\StartPage\ExplorerBar.cs" />
|
||||
<Compile Include="PartPreviewWindow\RoundedToggleSwitch.cs" />
|
||||
<Compile Include="PartPreviewWindow\View3D\Actions\ImageEditor.cs" />
|
||||
<Compile Include="PartPreviewWindow\View3D\Actions\MeshWrapperObject3D.cs" />
|
||||
|
|
@ -220,9 +224,9 @@
|
|||
<Compile Include="Library\Widgets\InsertionGroup.cs" />
|
||||
<Compile Include="PartPreviewWindow\NewTabButton.cs" />
|
||||
<Compile Include="PartPreviewWindow\PartTabPage.cs" />
|
||||
<Compile Include="PartPreviewWindow\PlusTab\ExploreItem.cs" />
|
||||
<Compile Include="PartPreviewWindow\PlusTab\ExplorePanel.cs" />
|
||||
<Compile Include="PartPreviewWindow\PlusTab\ExploreSection.cs" />
|
||||
<Compile Include="PartPreviewWindow\StartPage\ExploreItem.cs" />
|
||||
<Compile Include="PartPreviewWindow\StartPage\ExplorePanel.cs" />
|
||||
<Compile Include="PartPreviewWindow\StartPage\ExploreSection.cs" />
|
||||
<Compile Include="PartPreviewWindow\PopupMenu.cs" />
|
||||
<Compile Include="PartPreviewWindow\PopupMenuButton.cs" />
|
||||
<Compile Include="PartPreviewWindow\PopupButton.cs" />
|
||||
|
|
@ -319,7 +323,6 @@
|
|||
<Compile Include="Library\Providers\Zip\ZipMemoryContainer.cs" />
|
||||
<Compile Include="PartPreviewWindow\GCodeDetails\GCodeDetails.cs" />
|
||||
<Compile Include="PartPreviewWindow\GCodeDetails\GCodeDetailsView.cs" />
|
||||
<Compile Include="PartPreviewWindow\PlusTab\PlusTabPage.cs" />
|
||||
<Compile Include="PartPreviewWindow\Tabs.cs" />
|
||||
<Compile Include="PartPreviewWindow\PrinterTabPage.cs" />
|
||||
<Compile Include="PartPreviewWindow\View3D\BedMeshGenerator.cs" />
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
Border = new BorderDouble(left: 1),
|
||||
NewTabPage = () =>
|
||||
{
|
||||
return new PlusTabPage(this, theme);
|
||||
return new StartTabPage(this, theme);
|
||||
}
|
||||
};
|
||||
tabControl.ActiveTabChanged += (s, e) =>
|
||||
|
|
|
|||
|
|
@ -1,216 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2017, Lars Brubaker, John Lewin
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
The views and conclusions contained in the software and documentation are those
|
||||
of the authors and should not be interpreted as representing official policies,
|
||||
either expressed or implied, of the FreeBSD Project.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.Localizations;
|
||||
using MatterHackers.MatterControl.CustomWidgets;
|
||||
using MatterHackers.VectorMath;
|
||||
|
||||
namespace MatterHackers.MatterControl.PartPreviewWindow.PlusTab
|
||||
{
|
||||
public class ExploreSection : FlowLayoutWidget
|
||||
{
|
||||
private List<ExploreItem> allIconViews = new List<ExploreItem>();
|
||||
private int cellIndex = 0;
|
||||
private int columnCount = 1;
|
||||
private ExploreFeedContent content;
|
||||
private int lastReflowWidth = -1;
|
||||
private int leftRightMargin;
|
||||
private FlowLayoutWidget rowButtonContainer = null;
|
||||
private TextWidget heading;
|
||||
private ThemeConfig theme;
|
||||
private TextButton moreButton;
|
||||
int maxStuff = 10;
|
||||
|
||||
public ExploreSection(ExploreFeedContent content, ThemeConfig theme)
|
||||
: base(FlowDirection.TopToBottom)
|
||||
{
|
||||
this.content = content;
|
||||
this.HAnchor = HAnchor.Stretch;
|
||||
this.theme = theme;
|
||||
|
||||
foreach (var item in content.group_items)
|
||||
{
|
||||
allIconViews.Add(new ExploreItem(item, theme)
|
||||
{
|
||||
BackgroundColor = theme.MinimalShade,
|
||||
VAnchor = VAnchor.Top | VAnchor.Fit,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnBoundsChanged(EventArgs e)
|
||||
{
|
||||
int topBottomMargin = 5;
|
||||
|
||||
int currentWidth = (int)this.Size.X;
|
||||
if (lastReflowWidth != currentWidth)
|
||||
{
|
||||
lastReflowWidth = currentWidth;
|
||||
|
||||
int newColumnCount = RecomputeFlowValues();
|
||||
if (newColumnCount != columnCount)
|
||||
{
|
||||
columnCount = newColumnCount;
|
||||
|
||||
// Reflow Children
|
||||
foreach (var iconView in allIconViews)
|
||||
{
|
||||
iconView.Parent?.RemoveChild(iconView);
|
||||
}
|
||||
this.CloseAllChildren();
|
||||
|
||||
if (content.group_title != null)
|
||||
{
|
||||
this.AddChild(heading = new TextWidget(content.group_title, pointSize: theme.H1PointSize, textColor: ActiveTheme.Instance.PrimaryTextColor, bold: true)
|
||||
{
|
||||
HAnchor = HAnchor.Left,
|
||||
Margin = new BorderDouble(leftRightMargin, 5)
|
||||
});
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
foreach (var iconView in allIconViews)
|
||||
{
|
||||
if (i < maxStuff)
|
||||
{
|
||||
iconView.ClearRemovedFlag();
|
||||
iconView.Margin = new BorderDouble(leftRightMargin, topBottomMargin);
|
||||
AddColumnAndChild(iconView);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
if (content.group_items.Count > maxStuff)
|
||||
{
|
||||
moreButton = new TextButton("More".Localize() + "...", theme)
|
||||
{
|
||||
VAnchor = VAnchor.Absolute,
|
||||
HAnchor = HAnchor.Right,
|
||||
BackgroundColor = theme.MinimalShade,
|
||||
Margin = new BorderDouble(right: leftRightMargin)
|
||||
};
|
||||
moreButton.Click += (s, e1) =>
|
||||
{
|
||||
maxStuff += 25;
|
||||
lastReflowWidth = -1;
|
||||
columnCount = 0;
|
||||
|
||||
var scroll = this.Parents<ScrollableWidget>().FirstOrDefault();
|
||||
var position = scroll.ScrollPositionFromTop;
|
||||
OnBoundsChanged(null);
|
||||
scroll.ScrollPositionFromTop = position;
|
||||
};
|
||||
this.AddChild(moreButton);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (moreButton != null)
|
||||
{
|
||||
moreButton.Margin = new BorderDouble(right: leftRightMargin);
|
||||
}
|
||||
|
||||
if (heading != null)
|
||||
{
|
||||
heading.Margin = new BorderDouble(leftRightMargin, 5);
|
||||
}
|
||||
|
||||
foreach (var iconView in allIconViews)
|
||||
{
|
||||
iconView.Margin = new BorderDouble(leftRightMargin, topBottomMargin);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
base.OnBoundsChanged(e);
|
||||
}
|
||||
|
||||
private void AddColumnAndChild(ExploreItem iconView)
|
||||
{
|
||||
if (rowButtonContainer == null)
|
||||
{
|
||||
rowButtonContainer = new FlowLayoutWidget(FlowDirection.LeftToRight)
|
||||
{
|
||||
HAnchor = HAnchor.Stretch,
|
||||
Padding = 0
|
||||
};
|
||||
this.AddChild(rowButtonContainer);
|
||||
}
|
||||
|
||||
rowButtonContainer.AddChild(iconView);
|
||||
|
||||
if (cellIndex++ >= columnCount - 1)
|
||||
{
|
||||
rowButtonContainer = null;
|
||||
cellIndex = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private int RecomputeFlowValues()
|
||||
{
|
||||
int MinimumMargin = 8;
|
||||
int itemWidth = (int)allIconViews[0].Width + MinimumMargin * 2;
|
||||
|
||||
int newColumnCount = (int)Math.Round(this.LocalBounds.Width / itemWidth);
|
||||
int remainingSpace = (int)this.LocalBounds.Width - newColumnCount * itemWidth;
|
||||
|
||||
// Reset position before reflow
|
||||
cellIndex = 0;
|
||||
rowButtonContainer = null;
|
||||
|
||||
// There should always be at least one visible column
|
||||
if (newColumnCount < 1)
|
||||
{
|
||||
newColumnCount = 1;
|
||||
remainingSpace = 0;
|
||||
}
|
||||
|
||||
// Only center items if extra space exists
|
||||
|
||||
// we find the space we want between each column and the sides
|
||||
double spacePerColumn = (remainingSpace > 0) ? remainingSpace / (newColumnCount + 1) : 0;
|
||||
|
||||
// set the margin to be 1/2 the space (it will happen on each side of each icon)
|
||||
//
|
||||
// TODO: Replace short term hack with new solution
|
||||
//leftRightMargin = (int)(remainingSpace > 0 ? spacePerColumn / 2 : 0);
|
||||
leftRightMargin = Math.Max(MinimumMargin, (int)(remainingSpace > 0 ? spacePerColumn / 2 + 8 : 0));
|
||||
|
||||
// put in padding to get the "other" side of the outside icons
|
||||
this.Padding = new BorderDouble(leftRightMargin - MinimumMargin, 0);
|
||||
|
||||
return newColumnCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -35,12 +35,12 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.PlusTab
|
|||
{
|
||||
public class ExploreItem : FlowLayoutWidget
|
||||
{
|
||||
private ExplorerFeedItem item;
|
||||
private FeedItemData item;
|
||||
|
||||
public static int IconSize => (int)(40 * GuiWidget.DeviceScale);
|
||||
public static int ItemSpacing { get; } = 10;
|
||||
|
||||
public ExploreItem(ExplorerFeedItem item, ThemeConfig theme)
|
||||
public ExploreItem(FeedItemData item, ThemeConfig theme)
|
||||
{
|
||||
|
||||
this.HAnchor = HAnchor.Absolute;
|
||||
|
|
@ -63,6 +63,27 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.PlusTab
|
|||
imageWidget.Load += (s, e) => ApplicationController.Instance.DownloadToImageAsync(image, item.icon, true, new BlenderPreMultBGRA());
|
||||
this.AddChild(imageWidget);
|
||||
}
|
||||
else if(item.widget_url != null)
|
||||
{
|
||||
ImageBuffer image = new ImageBuffer(IconSize, IconSize);
|
||||
|
||||
var whiteBackground = new GuiWidget(IconSize, IconSize)
|
||||
{
|
||||
// these images expect to be on white so change the background to white
|
||||
BackgroundColor = Color.White,
|
||||
};
|
||||
this.AddChild(whiteBackground);
|
||||
|
||||
var imageWidget = new ImageWidget(image)
|
||||
{
|
||||
Selectable = false,
|
||||
VAnchor = VAnchor.Center,
|
||||
Margin = new BorderDouble(right: ItemSpacing)
|
||||
};
|
||||
|
||||
imageWidget.Load += (s, e) => ApplicationController.Instance.DownloadToImageAsync(image, item.widget_url, true, new BlenderPreMultBGRA());
|
||||
whiteBackground.AddChild(imageWidget);
|
||||
}
|
||||
|
||||
var wrappedText = new WrappedTextWidget(item.title, textColor: ActiveTheme.Instance.PrimaryTextColor, pointSize: theme.DefaultFontSize)
|
||||
{
|
||||
|
|
@ -48,6 +48,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.PlusTab
|
|||
string relativeUrl;
|
||||
string staticFile;
|
||||
private ThemeConfig theme;
|
||||
FlowLeftRightWithWrapping currentContentContainer;
|
||||
|
||||
public ExplorePanel(ThemeConfig theme, string relativeUrl, string staticFile)
|
||||
: base(FlowDirection.TopToBottom)
|
||||
|
|
@ -67,13 +68,13 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.PlusTab
|
|||
|
||||
try
|
||||
{
|
||||
ExplorerFeed explorerFeed = null;
|
||||
FeedData explorerFeed = null;
|
||||
|
||||
var json = ApplicationController.LoadCachedFile(staticFile, "MatterHackers");
|
||||
if (json != null)
|
||||
{
|
||||
// Construct directly from cache
|
||||
explorerFeed = JsonConvert.DeserializeObject<ExplorerFeed>(json);
|
||||
explorerFeed = JsonConvert.DeserializeObject<FeedData>(json);
|
||||
// Add controls for content
|
||||
AddControlsForContent(explorerFeed);
|
||||
|
||||
|
|
@ -111,14 +112,14 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.PlusTab
|
|||
}
|
||||
}
|
||||
|
||||
public async Task<ExplorerFeed> LoadExploreFeed(int loadedID, string cachePath)
|
||||
public async Task<FeedData> LoadExploreFeed(int loadedID, string cachePath)
|
||||
{
|
||||
try
|
||||
{
|
||||
var client = new HttpClient();
|
||||
string json = await client.GetStringAsync($"http://www.matterhackers.com/feeds/{relativeUrl}");
|
||||
|
||||
var explorerFeed = JsonConvert.DeserializeObject<ExplorerFeed>(json);
|
||||
var explorerFeed = JsonConvert.DeserializeObject<FeedData>(json);
|
||||
|
||||
var sanitizedJsonID = JsonConvert.SerializeObject(explorerFeed, Formatting.Indented).GetHashCode();
|
||||
if (loadedID == sanitizedJsonID)
|
||||
|
|
@ -140,7 +141,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.PlusTab
|
|||
return null;
|
||||
}
|
||||
|
||||
private void AddControlsForContent(ExplorerFeed contentList)
|
||||
private void AddControlsForContent(FeedData contentList)
|
||||
{
|
||||
foreach (var content in contentList.Content)
|
||||
{
|
||||
|
|
@ -148,12 +149,14 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.PlusTab
|
|||
}
|
||||
}
|
||||
|
||||
private void AddContentItem(ExploreFeedContent content)
|
||||
private void AddContentItem(FeedSectionData content)
|
||||
{
|
||||
switch (content.content_type)
|
||||
{
|
||||
case "headline":
|
||||
{
|
||||
break;
|
||||
|
||||
// use the Golden Ratio to calculate an atractive size relative to the banner
|
||||
var image = new ImageBuffer(1520, (int)(170 / 1.618));
|
||||
var imageWidget = new ResponsiveImageWidget(image)
|
||||
|
|
@ -237,47 +240,14 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.PlusTab
|
|||
|
||||
case "article_group":
|
||||
case "product_group":
|
||||
this.AddChild(new ExploreSection(content, theme));
|
||||
if(currentContentContainer == null)
|
||||
{
|
||||
currentContentContainer = new FlowLeftRightWithWrapping();
|
||||
this.AddChild(currentContentContainer);
|
||||
}
|
||||
currentContentContainer.AddChild(new ExploreSection(content, theme));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region json expand classes
|
||||
|
||||
public class ExploreFeedContent
|
||||
{
|
||||
public string content_type;
|
||||
public List<ExplorerFeedItem> group_items;
|
||||
public List<ExploreFeedContent> banner_list;
|
||||
public string group_link;
|
||||
public string group_subtitle;
|
||||
public string group_title;
|
||||
public string icon_url;
|
||||
public string image_url;
|
||||
public string link;
|
||||
public string text;
|
||||
public string theme_filter;
|
||||
}
|
||||
|
||||
public class ExplorerFeed
|
||||
{
|
||||
public List<ExploreFeedContent> Content;
|
||||
public string Status;
|
||||
}
|
||||
|
||||
public class ExplorerFeedItem
|
||||
{
|
||||
public string author;
|
||||
public string category;
|
||||
public string date_published;
|
||||
public string description;
|
||||
public string hero;
|
||||
public string icon;
|
||||
public string link;
|
||||
public string title;
|
||||
public string url;
|
||||
}
|
||||
|
||||
#endregion json expand classes
|
||||
}
|
||||
127
PartPreviewWindow/StartPage/ExploreSection.cs
Normal file
127
PartPreviewWindow/StartPage/ExploreSection.cs
Normal file
|
|
@ -0,0 +1,127 @@
|
|||
/*
|
||||
Copyright (c) 2017, Lars Brubaker, John Lewin
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
The views and conclusions contained in the software and documentation are those
|
||||
of the authors and should not be interpreted as representing official policies,
|
||||
either expressed or implied, of the FreeBSD Project.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.Localizations;
|
||||
using MatterHackers.MatterControl.CustomWidgets;
|
||||
using MatterHackers.VectorMath;
|
||||
|
||||
namespace MatterHackers.MatterControl.PartPreviewWindow.PlusTab
|
||||
{
|
||||
public class ExploreSection : FlowLayoutWidget
|
||||
{
|
||||
private List<ExploreItem> allIconViews = new List<ExploreItem>();
|
||||
private FeedSectionData content;
|
||||
private ThemeConfig theme;
|
||||
private TextButton moreButton;
|
||||
int maxStuff = 7;
|
||||
|
||||
public ExploreSection(FeedSectionData content, ThemeConfig theme)
|
||||
: base(FlowDirection.TopToBottom)
|
||||
{
|
||||
VAnchor = VAnchor.Fit | VAnchor.Top;
|
||||
this.content = content;
|
||||
this.theme = theme;
|
||||
|
||||
foreach (var item in content.group_items)
|
||||
{
|
||||
allIconViews.Add(new ExploreItem(item, theme)
|
||||
{
|
||||
BackgroundColor = theme.MinimalShade,
|
||||
VAnchor = VAnchor.Fit,
|
||||
});
|
||||
}
|
||||
|
||||
AddContent();
|
||||
}
|
||||
|
||||
public void AddContent()
|
||||
{
|
||||
int leftRightMargin = 5;
|
||||
int topBottomMargin = 5;
|
||||
|
||||
// Reflow Children
|
||||
foreach (var iconView in allIconViews)
|
||||
{
|
||||
if (this.Children.Contains(iconView))
|
||||
{
|
||||
this.RemoveChild(iconView);
|
||||
}
|
||||
}
|
||||
this.CloseAllChildren();
|
||||
|
||||
if (content.group_title != null)
|
||||
{
|
||||
this.AddChild(new TextWidget(content.group_title, pointSize: theme.H1PointSize, textColor: ActiveTheme.Instance.PrimaryTextColor, bold: true)
|
||||
{
|
||||
HAnchor = HAnchor.Left,
|
||||
Margin = new BorderDouble(leftRightMargin, 5)
|
||||
});
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
foreach (var iconView in allIconViews)
|
||||
{
|
||||
if (i < maxStuff)
|
||||
{
|
||||
iconView.ClearRemovedFlag();
|
||||
iconView.Margin = new BorderDouble(leftRightMargin, topBottomMargin);
|
||||
this.AddChild(iconView);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
if (content.group_items.Count > maxStuff)
|
||||
{
|
||||
moreButton = new TextButton("More".Localize() + "...", theme)
|
||||
{
|
||||
VAnchor = VAnchor.Absolute,
|
||||
HAnchor = HAnchor.Right,
|
||||
BackgroundColor = theme.MinimalShade,
|
||||
Margin = new BorderDouble(right: leftRightMargin)
|
||||
};
|
||||
moreButton.Click += (s, e1) =>
|
||||
{
|
||||
var scroll = this.Parents<ScrollableWidget>().FirstOrDefault();
|
||||
var position = scroll.ScrollPositionFromTop;
|
||||
|
||||
maxStuff += 6;
|
||||
AddContent();
|
||||
|
||||
scroll.ScrollPositionFromTop = position;
|
||||
};
|
||||
this.AddChild(moreButton);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
39
PartPreviewWindow/StartPage/FeedData.cs
Normal file
39
PartPreviewWindow/StartPage/FeedData.cs
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
Copyright (c) 2018, Lars Brubaker, John Lewin
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
The views and conclusions contained in the software and documentation are those
|
||||
of the authors and should not be interpreted as representing official policies,
|
||||
either expressed or implied, of the FreeBSD Project.
|
||||
*/
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MatterHackers.MatterControl.PartPreviewWindow.PlusTab
|
||||
{
|
||||
public class FeedData
|
||||
{
|
||||
public List<FeedSectionData> Content;
|
||||
public string Status;
|
||||
}
|
||||
}
|
||||
46
PartPreviewWindow/StartPage/FeedItemData.cs
Normal file
46
PartPreviewWindow/StartPage/FeedItemData.cs
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
Copyright (c) 2018, Lars Brubaker, John Lewin
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
The views and conclusions contained in the software and documentation are those
|
||||
of the authors and should not be interpreted as representing official policies,
|
||||
either expressed or implied, of the FreeBSD Project.
|
||||
*/
|
||||
|
||||
|
||||
namespace MatterHackers.MatterControl.PartPreviewWindow.PlusTab
|
||||
{
|
||||
public class FeedItemData
|
||||
{
|
||||
public string author;
|
||||
public string category;
|
||||
public string date_published;
|
||||
public string description;
|
||||
public string hero;
|
||||
public string icon;
|
||||
public string link;
|
||||
public string title;
|
||||
public string url;
|
||||
public string widget_url;
|
||||
}
|
||||
}
|
||||
49
PartPreviewWindow/StartPage/FeedSectionData.cs
Normal file
49
PartPreviewWindow/StartPage/FeedSectionData.cs
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
Copyright (c) 2018, Lars Brubaker, John Lewin
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
The views and conclusions contained in the software and documentation are those
|
||||
of the authors and should not be interpreted as representing official policies,
|
||||
either expressed or implied, of the FreeBSD Project.
|
||||
*/
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MatterHackers.MatterControl.PartPreviewWindow.PlusTab
|
||||
{
|
||||
public class FeedSectionData
|
||||
{
|
||||
public string content_type;
|
||||
public List<FeedItemData> group_items;
|
||||
public List<FeedSectionData> banner_list;
|
||||
public string group_link;
|
||||
public string group_subtitle;
|
||||
public string group_title;
|
||||
public string icon_url;
|
||||
public string image_url;
|
||||
public string link;
|
||||
public string text;
|
||||
public string theme_filter;
|
||||
public string banner_url;
|
||||
}
|
||||
}
|
||||
|
|
@ -27,21 +27,17 @@ of the authors and should not be interpreted as representing official policies,
|
|||
either expressed or implied, of the FreeBSD Project.
|
||||
*/
|
||||
|
||||
using System.IO;
|
||||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.Platform;
|
||||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.Localizations;
|
||||
using MatterHackers.MatterControl.PrinterControls.PrinterConnections;
|
||||
using MatterHackers.MatterControl.SettingsManagement;
|
||||
using MatterHackers.MatterControl.SlicerConfiguration;
|
||||
using MatterHackers.VectorMath;
|
||||
|
||||
namespace MatterHackers.MatterControl.PartPreviewWindow.PlusTab
|
||||
{
|
||||
public class PlusTabPage : ScrollableWidget
|
||||
public class StartTabPage : ScrollableWidget
|
||||
{
|
||||
public PlusTabPage(PartPreviewContent partPreviewContent, ThemeConfig theme)
|
||||
public StartTabPage(PartPreviewContent partPreviewContent, ThemeConfig theme)
|
||||
{
|
||||
this.AutoScroll = true;
|
||||
this.ScrollArea.Padding = new BorderDouble(3);
|
||||
Loading…
Add table
Add a link
Reference in a new issue