description working with icon

improving github container
This commit is contained in:
Lars Brubaker 2021-04-22 12:31:42 -07:00
parent 02db4f7052
commit d0d5b992d7
8 changed files with 61 additions and 103 deletions

View file

@ -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
{
}
}

View file

@ -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<DescriptionObject3D> 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<Object3DView> 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;
}
}
}

View file

@ -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<MarkdownStringAttribute>().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

View file

@ -178,18 +178,21 @@ namespace MatterHackers.MatterControl.Library
{
lock (locker)
{
FileInfo[] dirContents = JsonConvert.DeserializeObject<FileInfo[]>(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<FileInfo[]>(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,

View file

@ -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)
{

View file

@ -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();

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.