diff --git a/MatterControl.MeshOperations/OperationSourceContainerObject3D.cs b/MatterControl.MeshOperations/OperationSourceContainerObject3D.cs index 779cf8731..14783a8d5 100644 --- a/MatterControl.MeshOperations/OperationSourceContainerObject3D.cs +++ b/MatterControl.MeshOperations/OperationSourceContainerObject3D.cs @@ -282,7 +282,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations } // and select this - var rootItem = this.Ancestors().Where(i => scene.Children.Contains(i)).FirstOrDefault(); + var rootItem = this.Parents().Where(i => scene.Children.Contains(i)).FirstOrDefault(); if (rootItem != null) { scene.SelectedItem = rootItem; diff --git a/MatterControlLib/DesignTools/EditorTools/LithophanePlugin.cs b/MatterControlLib/DesignTools/EditorTools/LithophanePlugin.cs index e2f0f7fe2..27c99addb 100644 --- a/MatterControlLib/DesignTools/EditorTools/LithophanePlugin.cs +++ b/MatterControlLib/DesignTools/EditorTools/LithophanePlugin.cs @@ -59,7 +59,7 @@ namespace MatterHackers.MatterControl.Plugins.Lithophane if (scene != null) { - var topParent = wrapper.Ancestors().LastOrDefault(i => i.Parent != null); + var topParent = wrapper.Parents().LastOrDefault(i => i.Parent != null); UiThread.RunOnIdle(() => { scene.SelectedItem = topParent ?? wrapper; diff --git a/MatterControlLib/DesignTools/Operations/RotateObject3D_2.cs b/MatterControlLib/DesignTools/Operations/RotateObject3D_2.cs index c39330b3d..298b764ec 100644 --- a/MatterControlLib/DesignTools/Operations/RotateObject3D_2.cs +++ b/MatterControlLib/DesignTools/Operations/RotateObject3D_2.cs @@ -140,6 +140,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations public override Task Rebuild() { + this.DebugDepth("Rebuild"); using (RebuildLock()) { // set the matrix for the inner object diff --git a/MatterControlLib/DesignTools/Operations/TransformWrapperObject3D.cs b/MatterControlLib/DesignTools/Operations/TransformWrapperObject3D.cs index cd0fd9b75..fc149fa08 100644 --- a/MatterControlLib/DesignTools/Operations/TransformWrapperObject3D.cs +++ b/MatterControlLib/DesignTools/Operations/TransformWrapperObject3D.cs @@ -173,7 +173,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations parentLock?.Dispose(); // and select this - var rootItem = this.Ancestors().Where(i => scene.Children.Contains(i)).FirstOrDefault(); + var rootItem = this.Parents().Where(i => scene.Children.Contains(i)).FirstOrDefault(); if (rootItem != null) { scene.SelectedItem = rootItem; diff --git a/MatterControlLib/Library/Providers/GitHub/GitHubContainer.cs b/MatterControlLib/Library/Providers/GitHub/GitHubContainer.cs index 723b6d2c9..811f7faac 100644 --- a/MatterControlLib/Library/Providers/GitHub/GitHubContainer.cs +++ b/MatterControlLib/Library/Providers/GitHub/GitHubContainer.cs @@ -1,5 +1,6 @@ /* Copyright (c) 2019, John Lewin +Copyright (c) 2021, Lars Brubaker All rights reserved. Redistribution and use in source and binary forms, with or without @@ -86,6 +87,11 @@ namespace MatterHackers.MatterControl.Library { lock (locker) { + if (content.Contains("rate limit exceeded")) + { + StatusMessage = content; + return; + } ParseJson(content); } }, @@ -167,9 +173,10 @@ namespace MatterHackers.MatterControl.Library } // check the global cache if any - var repositoryImage = CheckForImage(item.ID, LoadRepositoryImageUrlCache()); + var repositoryImage = CheckRepositoryForImage(item.ID, LoadRepositoryImageUrlCache()); if (repositoryImage != null) { + repositoryImage.SetRecieveBlender(new BlenderPreMultBGRA()); return Task.FromResult(repositoryImage); } } @@ -194,6 +201,23 @@ namespace MatterHackers.MatterControl.Library return null; } + private ImageBuffer CheckRepositoryForImage(string id, List<(string name, string url)> cache) + { + foreach (var imageUrl in cache) + { + if (imageUrl.name.Contains(Path.GetFileNameWithoutExtension(id))) + { + // download the image and cache it + var image = new ImageBuffer(LibraryConfig.DefaultItemIcon); + image.SetRecieveBlender(new BlenderPreMultBGRA()); + WebCache.RetrieveImageAsync(image, imageUrl.url, false); + return image; + } + } + + return null; + } + private async Task LoadFolderImageUrlCache() { if (folderImageUrlCache.Count == 0) @@ -279,6 +303,11 @@ namespace MatterHackers.MatterControl.Library request.Headers.Add("Upgrade-Insecure-Requests", "1"); request.Headers.Add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36"); request.Headers.Add("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9"); + var token = UserSettings.Instance.get("GitHubPat"); + if (string.IsNullOrEmpty(token)) + { + request.Headers.Add("Authorization", $"token {token}"); + } request.Headers.Add("Sec-Fetch-Site", "none"); request.Headers.Add("Sec-Fetch-Mode", "navigate"); request.Headers.Add("Sec-Fetch-User", "?1"); diff --git a/MatterControlLib/PartPreviewWindow/View3D/Object3DControlsLayer.cs b/MatterControlLib/PartPreviewWindow/View3D/Object3DControlsLayer.cs index 1814ad7b5..b8425fcc9 100644 --- a/MatterControlLib/PartPreviewWindow/View3D/Object3DControlsLayer.cs +++ b/MatterControlLib/PartPreviewWindow/View3D/Object3DControlsLayer.cs @@ -760,7 +760,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow bool isSelected = selectedItem != null && (item == selectedItem - || item.Ancestors().Any(p => p == selectedItem)); + || item.Parents().Any(p => p == selectedItem)); // Invoke all item Drawables foreach (var drawable in itemDrawables.Where(d => d.DrawStage != DrawStage.Last && d.Enabled)) diff --git a/MatterControlLib/SettingsManagement/ApplicationSettingsPage.cs b/MatterControlLib/SettingsManagement/ApplicationSettingsPage.cs index 2ed7dac05..cde67737b 100644 --- a/MatterControlLib/SettingsManagement/ApplicationSettingsPage.cs +++ b/MatterControlLib/SettingsManagement/ApplicationSettingsPage.cs @@ -447,6 +447,28 @@ namespace MatterHackers.MatterControl advancedPanel); #endif + var gitHubPat = UserSettings.Instance.get("GitHubPat"); + if (gitHubPat == null) + { + gitHubPat = ""; + } + var accessToken = new MHTextEditWidget(gitHubPat, theme, pixelWidth: 300, messageWhenEmptyAndNotSelected: "Enter a GitHub Person Access Token".Localize()) + { + HAnchor = HAnchor.Stretch, + Margin = new BorderDouble(5), + Name = "GitHubPat Edit Field" + }; + accessToken.ActualTextEditWidget.EnterPressed += (s, e) => + { + UserSettings.Instance.set("GitHubPat", accessToken.ActualTextEditWidget.Text); + }; + this.AddSettingsRow( + new SettingsItem( + "GitHub Personal Access Token".Localize(), + accessToken, + theme), + advancedPanel); + advancedPanel.Children().First().Border = new BorderDouble(0, 1); } diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index 6f9957b67..0f47e2dc3 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit 6f9957b6744efcc732700d092674572040a15809 +Subproject commit 0f47e2dc3853ad5b2bf4775d37a3e4e1ed44a7c6