Made it so that you can add fonts and (open with 'system file')

Fixed BaseObject
This commit is contained in:
MatterHackers 2023-12-03 21:00:59 -08:00
parent 74db968eee
commit c2bf2ad5a5
8 changed files with 43 additions and 14 deletions

View file

@ -130,7 +130,7 @@ namespace MatterHackers.MatterControl
public event EventHandler AnyPrintComplete;
public static string[] ShellFileExtensions => new string[] { ".stl", ".amf", ".3mf", ".obj", ".mcx", ".png", ".jpg", ".jpeg" };
public static string[] ShellFileExtensions => new string[] { ".stl", ".amf", ".3mf", ".obj", ".mcx", ".png", ".jpg", ".jpeg", ".ttf", ".otf" };
public bool IsMatterControlPro()
{
@ -1380,10 +1380,9 @@ namespace MatterHackers.MatterControl
{
addedWindowsFonts = true;
// add all the windows fonts
// get all the files with the extension .ttf in the windows/fonts directory
var ttfs = Directory.GetFiles(Environment.GetFolderPath(Environment.SpecialFolder.Fonts), "*.ttf");
var otf = Directory.GetFiles(Environment.GetFolderPath(Environment.SpecialFolder.Fonts), "*.otf");
// add all the fonts from user data "Fonts" folder
var ttfs = Directory.GetFiles(ApplicationDataStorage.Instance.ApplicationFontsDataPath, "*.ttf");
var otf = Directory.GetFiles(ApplicationDataStorage.Instance.ApplicationFontsDataPath, "*.otf");
var fonts = ttfs.Concat(otf);
// add all the fonts to the cache
foreach (var font in fonts)

View file

@ -76,7 +76,9 @@ namespace MatterHackers.MatterControl.DataStorage
private static string _applicationUserDataPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), ApplicationDataFolderName);
private static string _applicationLibraryDataPath => Path.Combine(_applicationUserDataPath, "Library");
private static string _applicationLibraryDataPath => Path.Combine(_applicationUserDataPath, "Library");
private static string _applicationFontsDataPath => Path.Combine(_applicationUserDataPath, "Fonts");
private static string _libraryAssetPath => Path.Combine(_applicationLibraryDataPath, "Assets");
@ -96,6 +98,8 @@ namespace MatterHackers.MatterControl.DataStorage
public string ApplicationLibraryDataPath => EnsurePath(_applicationLibraryDataPath);
public string ApplicationFontsDataPath => EnsurePath(_applicationFontsDataPath);
public string CloudLibraryPath => EnsurePath(_cloudLibraryPath);
public string LibraryAssetsPath => EnsurePath(_libraryAssetPath);

View file

@ -34,6 +34,7 @@ using System.Threading;
using System.Threading.Tasks;
using MatterControlLib.DesignTools.Operations.Path;
using MatterHackers.Agg.UI;
using MatterHackers.Agg.VertexSource;
using MatterHackers.DataConverters3D;
using MatterHackers.DataConverters3D.UndoCommands;
using MatterHackers.Localizations;
@ -44,7 +45,7 @@ using MatterHackers.VectorMath;
namespace MatterHackers.MatterControl.DesignTools.Operations
{
public class LinearExtrudeObject3D : PathObject3DAbstract, IPrimaryOperationsSpecifier, IPropertyGridModifier
public class LinearExtrudeObject3D : Object3D, IPrimaryOperationsSpecifier, IPropertyGridModifier, IPathProvider
{
[Description("The height of the extrusion")]
[Slider(.1, 50, Easing.EaseType.Quadratic, useSnappingGrid: true)]
@ -65,7 +66,7 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
public override bool CanApply => true;
public override bool MeshIsSolidObject => true;
public bool MeshIsSolidObject => true;
public override void Apply(UndoBuffer undoBuffer)
{
@ -195,5 +196,10 @@ namespace MatterHackers.MatterControl.DesignTools.Operations
{
yield return SceneOperations.ById("AddBase");
}
public IVertexSource GetRawPath()
{
return this.CombinedVisibleChildrenPaths();
}
}
}

View file

@ -231,10 +231,10 @@ namespace MatterHackers.MatterControl.DesignTools
});
// and create the base
var vertexSource = GetRawPath();
var vertexSource = this.CombinedVisibleChildrenPaths();
// Convert VertexSource into expected Polygons
Polygons polygonShape = (vertexSource == null) ? null : vertexSource.CreatePolygons();
// Convert VertexSource into expected Polygons
Polygons polygonShape = (vertexSource == null) ? null : vertexSource.CreatePolygons();
GenerateBase(polygonShape, firstChild.GetAxisAlignedBoundingBox().MinXYZ.Z);
}

View file

@ -42,6 +42,7 @@ using MatterHackers.DataConverters3D;
using MatterHackers.ImageProcessing;
using MatterHackers.Localizations;
using MatterHackers.MatterControl.CustomWidgets;
using MatterHackers.MatterControl.DataStorage;
using MatterHackers.MatterControl.Library;
using MatterHackers.MatterControl.Library.Widgets;
using MatterHackers.MatterControl.PartPreviewWindow.PlusTab;
@ -510,7 +511,23 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
}
break;
default:
case ".ttf":
case ".otf":
{
// check if the file is already in the fonts directory
if (!File.Exists(Path.Combine(ApplicationDataStorage.Instance.ApplicationFontsDataPath, Path.GetFileName(filePath))))
{
// make sure the directory exists
Directory.CreateDirectory(ApplicationDataStorage.Instance.ApplicationFontsDataPath);
// copy the file to the fonts directory
var newFilePath = Path.Combine(ApplicationDataStorage.Instance.ApplicationFontsDataPath, Path.GetFileName(filePath));
File.Copy(filePath, newFilePath, true);
}
}
break;
default:
{
var workspace = await CreateNewDesignTab(false);
workspace.SceneContext.AddToPlate(new string[] { filePath }, false);

View file

@ -52,7 +52,7 @@ namespace MatterHackers.MatterControl
public static string LibraryFilterFileExtensions { get; } = ValidFileExtensions + ",.gcode";
public static string OpenDesignFileParams { get; } = "STL, AMF, OBJ, 3MF, GCODE, MCX|*.stl;*.amf;*.obj;*.gcode;*.mcx";
public static string OpenDesignFileParams { get; } = "STL, AMF, OBJ, 3MF, MCX, TTF, OTF|*.stl;*.amf;*.obj;*.mcx;*.ttf;*.otf";
private static ApplicationSettings globalInstance = null;

View file

@ -2434,6 +2434,9 @@ Translated:Image Converter
English:Image Missing
Translated:Image Missing
English:Image Search
Translated:Image Search
English:Image to Path
Translated:Image to Path

@ -1 +1 @@
Subproject commit 4a3185d8d49855cf6ade9d2bf2ada19e101d731f
Subproject commit 2f0d725538c880d740ed516d6eb9d3d261f68c58