Merge pull request #5170 from larsbrubaker/main

main
This commit is contained in:
Lars Brubaker 2021-11-26 10:28:19 -08:00 committed by GitHub
commit d5ac8376aa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 61 additions and 28 deletions

View file

@ -998,7 +998,24 @@ namespace MatterHackers.MatterControl
this.InitializeLibrary();
}
public void Connection_ErrorReported(object sender, string line)
/// <summary>
/// Show a notification on screen. This is usually due to a system error of some kind
/// like a bad save or load.
/// </summary>
/// <param name="message">The message to show</param>
public void ShowNotification(string message)
{
foreach(var printer in ActivePrinters)
{
var terminal = printer?.Connection?.TerminalLog;
if (terminal != null)
{
terminal.WriteLine(message);
}
}
}
public void Connection_ErrorReported(object sender, string line)
{
if (line != null)
{

View file

@ -186,18 +186,22 @@ namespace MatterHackers.MatterControl.DesignTools
var doStartPosition = worldStartPosition;
var doEndPosition = worldEndPosition;
controlLayer.Scene.UndoBuffer.Add(new UndoRedoActions(() =>
var undoBuffer = controlLayer?.Scene?.UndoBuffer;
if (undoBuffer != null)
{
worldStartPosition = undoStartPosition;
worldEndPosition = undoEndPosition;
this.Invalidate(InvalidateType.Matrix);
},
() =>
{
worldStartPosition = doStartPosition;
worldEndPosition = doEndPosition;
this.Invalidate(InvalidateType.Matrix);
}));
undoBuffer.Add(new UndoRedoActions(() =>
{
worldStartPosition = undoStartPosition;
worldEndPosition = undoEndPosition;
this.Invalidate(InvalidateType.Matrix);
},
() =>
{
worldStartPosition = doStartPosition;
worldEndPosition = doEndPosition;
this.Invalidate(InvalidateType.Matrix);
}));
}
}
public override async void OnInvalidate(InvalidateArgs invalidateType)

View file

@ -61,7 +61,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.PlusTab
Margin = new BorderDouble(right: ItemSpacing)
};
Load += (s, e) => WebCache.RetrieveImageAsync(image, item.icon, true, new BlenderPreMultBGRA());
Load += (s, e) => WebCache.RetrieveImageAsync(image, item.icon, true);
this.AddChild(imageWidget);
}
else if (item.widget_url != null)
@ -80,7 +80,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.PlusTab
VAnchor = VAnchor.Center,
};
Load += (s, e) => WebCache.RetrieveImageAsync(image, item.widget_url, true, new BlenderPreMultBGRA());
Load += (s, e) => WebCache.RetrieveImageAsync(image, item.widget_url, true);
whiteBackground.AddChild(imageWidget);
}

View file

@ -27,7 +27,9 @@ 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.Globalization;
using System.Linq;
using MatterHackers.Agg;
using MatterHackers.Agg.UI;
@ -50,7 +52,9 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.PlusTab
this.content = content;
this.theme = theme;
foreach (var item in content.group_items)
var cultureInfo = new CultureInfo("en-US");
foreach (var item in content.group_items.OrderByDescending(i => DateTime.Parse(i.date_published, cultureInfo)))
{
allIconViews.Add(new ArticleItem(item, theme)
{
@ -67,7 +71,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.PlusTab
int leftRightMargin = 5;
int topBottomMargin = 5;
// Reflow Children
// 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))

View file

@ -210,7 +210,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.PlusTab
if (!loaded)
{
loaded = true;
WebCache.RetrieveImageAsync(image, content.image_url, false, new BlenderPreMultBGRA());
WebCache.RetrieveImageAsync(image, content.image_url, false);
}
};
topBanner.AddChild(imageWidget);
@ -224,17 +224,17 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.PlusTab
// add a content section connected to the button
var sectionButton = new TextButton(content.group_title, theme);
sectionSelectButtons.AddChild(sectionButton);
var exploreSection = new ArticleSection(content, theme)
var articleSection = new ArticleSection(content, theme)
{
Visible = false,
Name = content.group_title
};
contentSection.AddChild(exploreSection);
contentSection.AddChild(articleSection);
sectionButton.Click += (s, e) =>
{
foreach (var contentWidget in contentSection.Children)
{
contentWidget.Visible = contentWidget == exploreSection;
contentWidget.Visible = contentWidget == articleSection;
}
};
}

View file

@ -49,6 +49,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.PlusTab
this.theme = theme;
var image = new ImageBuffer(IconSize, IconSize);
image.SetRecieveBlender(new BlenderPreMultBGRA());
BackgroundRadius = 5 * GuiWidget.DeviceScale;
if (item.widget_url != null)
@ -69,7 +70,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow.PlusTab
VAnchor = VAnchor.Center,
};
Load += (s, e) => WebCache.RetrieveImageAsync(image, item.widget_url, true, new BlenderPreMultBGRA());
Load += (s, e) => WebCache.RetrieveImageAsync(image, item.widget_url, true);
whiteBackground.AddChild(imageWidget);
}

View file

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

View file

@ -948,7 +948,14 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
{
lock (writeLock)
{
File.WriteAllText(ProfilesDocPath, JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented));
try
{
File.WriteAllText(ProfilesDocPath, JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented));
}
catch (Exception ex)
{
ApplicationController.Instance.ShowNotification($"Profile Save Error: {ex.Message}");
}
}
}

View file

@ -48,7 +48,7 @@ namespace MatterHackers.MatterControl
private static object locker = new object();
// Download an image from the web into the specified ImageBuffer
public static void RetrieveImageAsync(ImageBuffer imageToLoadInto, string uriToLoad, bool scaleToImageX, IRecieveBlenderByte scalingBlender = null)
public static void RetrieveImageAsync(ImageBuffer imageToLoadInto, string uriToLoad, bool scaleToImageX)
{
var longHash = uriToLoad.GetLongHashCode();
if (scaleToImageX)
@ -61,7 +61,7 @@ namespace MatterHackers.MatterControl
{
try
{
LoadImageInto(imageToLoadInto, scaleToImageX, scalingBlender, new StreamReader(imageFileName).BaseStream);
LoadImageInto(imageToLoadInto, scaleToImageX, null, new StreamReader(imageFileName).BaseStream);
return;
}
catch
@ -76,7 +76,7 @@ namespace MatterHackers.MatterControl
{
Stream stream = new MemoryStream(e.Result);
LoadImageInto(imageToLoadInto, scaleToImageX, scalingBlender, stream);
LoadImageInto(imageToLoadInto, scaleToImageX, new BlenderPreMultBGRA(), stream);
if (imageToLoadInto.Width > 0
&& imageToLoadInto.Height > 0

@ -1 +1 @@
Subproject commit 18bb089dfbd5474e518ce578826001f8b9e7f911
Subproject commit 124112de436431fcbe701a13919b207eab0eb1ad

@ -1 +1 @@
Subproject commit 4142bb3dcb97fb921fb5afb922aba575bf231515
Subproject commit f98d2331a1f7e2443bb8423c666229544e75b32b