diff --git a/MatterControlLib/DesignTools/Attributes/MarkdownStringAttribute.cs b/MatterControlLib/DesignTools/Attributes/MarkdownStringAttribute.cs deleted file mode 100644 index 38c429733..000000000 --- a/MatterControlLib/DesignTools/Attributes/MarkdownStringAttribute.cs +++ /dev/null @@ -1,38 +0,0 @@ -/* -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; - -namespace MatterHackers.MatterControl.DesignTools -{ - [AttributeUsage(AttributeTargets.Property)] - public class MarkdownStringAttribute : Attribute - { - } -} \ No newline at end of file diff --git a/MatterControlLib/DesignTools/Primitives/DescriptionObject3D.cs b/MatterControlLib/DesignTools/Primitives/DescriptionObject3D.cs index 7837ce634..b09620551 100644 --- a/MatterControlLib/DesignTools/Primitives/DescriptionObject3D.cs +++ b/MatterControlLib/DesignTools/Primitives/DescriptionObject3D.cs @@ -49,7 +49,6 @@ using MatterHackers.VectorMath; namespace MatterHackers.MatterControl.DesignTools { [HideChildrenFromTreeView] - [MarkDownDescription("Drag the sphere to the location you would like to position the description.")] [HideMeterialAndColor] public class DescriptionObject3D : Object3D, IObject3DControlsProvider, IAlwaysEditorDraw, IEditorButtonProvider { @@ -59,11 +58,6 @@ namespace MatterHackers.MatterControl.DesignTools public DescriptionObject3D() { Name = "Description".Localize(); - - using (Stream measureAmfStream = StaticData.Instance.OpenStream(Path.Combine("Stls", "description_tool.amf"))) - { - Children.Add(AmfDocument.Load(measureAmfStream, CancellationToken.None)); - } } public static async Task Create() @@ -79,7 +73,7 @@ namespace MatterHackers.MatterControl.DesignTools [HideFromEditor] public bool PositionHasBeenSet { get; set; } = false; - [MarkdownString] + [MultiLineEdit] public string Description { get; set; } = "Type a description in the properties panel"; public enum Placements @@ -116,10 +110,7 @@ namespace MatterHackers.MatterControl.DesignTools { tracedPositionControl = new TracedPositionObject3DControl(object3DControlsLayer, this, - () => - { - return PositionHasBeenSet ? Position : Position.Transform(Matrix); - }, + () => Position, (position) => { if (!PositionHasBeenSet) @@ -127,8 +118,11 @@ namespace MatterHackers.MatterControl.DesignTools PositionHasBeenSet = true; } - Position = position; - UiThread.RunOnIdle(() => Invalidate(InvalidateType.DisplayValues)); + if (Position != position) + { + Position = position; + UiThread.RunOnIdle(() => Invalidate(InvalidateType.DisplayValues)); + } }); } @@ -196,10 +190,26 @@ namespace MatterHackers.MatterControl.DesignTools public void DrawEditor(Object3DControlsLayer controlLayer, List transparentMeshes, DrawEventArgs e) { - var start = PositionHasBeenSet ? Position : Position.Transform(Matrix); + if (this.VisibleMeshes().Count() == 0) + { + // add the amf content + using (Stream measureAmfStream = StaticData.Instance.OpenStream(Path.Combine("Stls", "description_tool.amf"))) + { + Children.Add(AmfDocument.Load(measureAmfStream, CancellationToken.None)); + } + } var world = controlLayer.World; + if (!PositionHasBeenSet) + { + var aabb = this.GetAxisAlignedBoundingBox(); + Position = new Vector3(aabb.MinXYZ.X, aabb.MaxXYZ.Y, aabb.MaxXYZ.Z); + } + + + var start = Position; + var screenStart = world.GetScreenPosition(start); CreateWidgetIfRequired(controlLayer); @@ -237,13 +247,6 @@ namespace MatterHackers.MatterControl.DesignTools var transform = Matrix4X4.CreateScale(distBetweenPixelsWorldSpace) * world.RotationMatrix.Inverted * Matrix4X4.CreateTranslation(start); var theme = ApplicationController.Instance.MenuTheme; graphics2DOpenGL.RenderTransformedPath(transform, new Ellipse(0, 0, 5, 5), theme.PrimaryAccentColor, false); - - var hitPlane = tracedPositionControl?.HitPlane; - if (hitPlane != null) - { - world.RenderPlane(hitPlane.Plane, Color.Red, true, 30, 3); - //world.RenderPlane(initialHitPosition, hitPlane.Plane.Normal, Color.Red, true, 30, 3); - } } private void CreateWidgetIfRequired(Object3DControlsLayer controlLayer) @@ -309,7 +312,6 @@ namespace MatterHackers.MatterControl.DesignTools if (delta.LengthSquared > 0) { tracedPositionControl.MoveToScreenPosition(screenStart + delta); - // widgetDownPosition = ePosition; } } } diff --git a/MatterControlLib/DesignTools/PublicPropertyEditor.cs b/MatterControlLib/DesignTools/PublicPropertyEditor.cs index 774c86940..117c5c49c 100644 --- a/MatterControlLib/DesignTools/PublicPropertyEditor.cs +++ b/MatterControlLib/DesignTools/PublicPropertyEditor.cs @@ -690,18 +690,6 @@ namespace MatterHackers.MatterControl.DesignTools RegisterValueChanged(field, (valueString) => valueString); rowContainer = CreateSettingsColumn(property, field, fullWidth: true); } - else if (property.PropertyInfo.GetCustomAttributes(true).OfType().FirstOrDefault() != null) - { - // create a a multi-line string editor - var field = new MarkdownEditField(theme, "Description".Localize()); - field.Initialize(0); - field.SetValue(stringValue, false); - field.ClearUndoHistory(); - field.Content.HAnchor = HAnchor.Stretch; - // field.Content.MinimumSize = new Vector2(0, 200 * GuiWidget.DeviceScale); - RegisterValueChanged(field, (valueString) => valueString); - rowContainer = CreateSettingsColumn(property, field, fullWidth: true); - } else { // create a string editor diff --git a/MatterControlLib/Library/Providers/GitHub/GitHubContainer.cs b/MatterControlLib/Library/Providers/GitHub/GitHubContainer.cs index 64833ce0d..5e0cdbdc8 100644 --- a/MatterControlLib/Library/Providers/GitHub/GitHubContainer.cs +++ b/MatterControlLib/Library/Providers/GitHub/GitHubContainer.cs @@ -178,18 +178,21 @@ namespace MatterHackers.MatterControl.Library { lock (locker) { - FileInfo[] dirContents = JsonConvert.DeserializeObject(content); - - // read in data - foreach (FileInfo file in dirContents) + if (!string.IsNullOrEmpty(content) && !content.Contains("\"Not Found\"")) { - if (file.type == "file") - { - imageUrlCache.Add((file.name, file.download_url)); - } - } + FileInfo[] dirContents = JsonConvert.DeserializeObject(content); - imageUrlCaches[key] = imageUrlCache; + // read in data + foreach (FileInfo file in dirContents) + { + if (file.type == "file") + { + imageUrlCache.Add((file.name, file.download_url)); + } + } + + imageUrlCaches[key] = imageUrlCache; + } } }, false, diff --git a/MatterControlLib/Library/Providers/GitHub/GitHubLibraryItem.cs b/MatterControlLib/Library/Providers/GitHub/GitHubLibraryItem.cs index 2a882ab6f..104aa5a05 100644 --- a/MatterControlLib/Library/Providers/GitHub/GitHubLibraryItem.cs +++ b/MatterControlLib/Library/Providers/GitHub/GitHubLibraryItem.cs @@ -89,7 +89,7 @@ namespace MatterHackers.MatterControl.Library public string FileKey => Url.GetLongHashCode().ToString(); - public string FileExtension => Path.GetExtension(Name).Substring(1); + public string FileExtension => Path.GetExtension(FileName).Substring(1); public static string GetLibraryPath(string fileKey, string fileExtension) { diff --git a/MatterControlLib/PartPreviewWindow/MainViewWidget.cs b/MatterControlLib/PartPreviewWindow/MainViewWidget.cs index a67bb9acc..44ae81e34 100644 --- a/MatterControlLib/PartPreviewWindow/MainViewWidget.cs +++ b/MatterControlLib/PartPreviewWindow/MainViewWidget.cs @@ -749,28 +749,31 @@ namespace MatterHackers.MatterControl.PartPreviewWindow var menuTheme = ApplicationController.Instance.MenuTheme; var popupMenu = new PopupMenu(menuTheme); - var renameMenuItem = popupMenu.CreateMenuItem("Rename".Localize()); - renameMenuItem.Click += (s, e) => + if (printer != null) { - if (workspace != null) + var renameMenuItem = popupMenu.CreateMenuItem("Rename".Localize()); + renameMenuItem.Click += (s, e) => { - workspace.LibraryView.ActiveContainer.Rename(workspace.LibraryView.ActiveContainer.Items.FirstOrDefault()); - } - else if (printer != null) - { - DialogWindow.Show( - new InputBoxPage( - "Rename Item".Localize(), - "Name".Localize(), - printer.Settings.GetValue(SettingsKey.printer_name), - "Enter New Name Here".Localize(), - "Rename".Localize(), - (newName) => - { - printer.Settings.SetValue(SettingsKey.printer_name, newName); - })); - } - }; + if (workspace != null) + { + workspace.LibraryView.ActiveContainer.Rename(workspace.LibraryView.ActiveContainer.Items.FirstOrDefault()); + } + else if (printer != null) + { + DialogWindow.Show( + new InputBoxPage( + "Rename Item".Localize(), + "Name".Localize(), + printer.Settings.GetValue(SettingsKey.printer_name), + "Enter New Name Here".Localize(), + "Rename".Localize(), + (newName) => + { + printer.Settings.SetValue(SettingsKey.printer_name, newName); + })); + } + }; + } var moveButtons = new FlowLayoutWidget(); diff --git a/StaticData/Images/Thumbnails/11449967961953374403-256x256.png b/StaticData/Images/Thumbnails/11449967961953374403-256x256.png new file mode 100644 index 000000000..77d9665ca Binary files /dev/null and b/StaticData/Images/Thumbnails/11449967961953374403-256x256.png differ diff --git a/StaticData/Stls/description_tool.amf b/StaticData/Stls/description_tool.amf index b9e1336c3..c93b83e92 100644 Binary files a/StaticData/Stls/description_tool.amf and b/StaticData/Stls/description_tool.amf differ