Merge pull request #2783 from jlewin/design_tools
Conditionally set MeshPath on dragdrop operations from the shell
This commit is contained in:
commit
8b523cba2c
6 changed files with 31 additions and 7 deletions
|
|
@ -53,5 +53,11 @@ namespace MatterHackers.MatterControl.Library
|
|||
|| (item is ILibraryContentStream contentStream
|
||||
&& ApplicationController.Instance.Library.IsContentFileType(contentStream.FileName));
|
||||
}
|
||||
|
||||
public static bool IsMeshFileType(this ILibraryItem item)
|
||||
{
|
||||
return item is ILibraryContentStream contentStream
|
||||
&& ApplicationController.Instance.Library.IsMeshFileType(contentStream.FileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -187,6 +187,13 @@ namespace MatterHackers.MatterControl.Library
|
|||
|| ApplicationController.Instance.Library.ContentProviders.Keys.Contains(fileExtensionLower));
|
||||
}
|
||||
|
||||
public bool IsMeshFileType(string fileName)
|
||||
{
|
||||
string fileExtensionLower = Path.GetExtension(fileName).ToLower().Trim('.');
|
||||
return !string.IsNullOrEmpty(fileExtensionLower)
|
||||
&& ApplicationSettings.LibraryMeshFileExtensions.Contains(fileExtensionLower);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Notifies listeners that the ActiveContainer Changed
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ namespace MatterHackers.MatterControl.PrintLibrary
|
|||
}
|
||||
|
||||
// TODO: Figure out how best to collapse the InsertionGroup after the load task completes
|
||||
public InsertionGroup(IEnumerable<ILibraryItem> items, View3DWidget view3DWidget, InteractiveScene scene, Vector2 bedCenter, Func<bool> dragOperationActive)
|
||||
public InsertionGroup(IEnumerable<ILibraryItem> items, View3DWidget view3DWidget, InteractiveScene scene, Vector2 bedCenter, Func<bool> dragOperationActive, bool trackSourceFiles = false)
|
||||
{
|
||||
// Add a temporary placeholder to give us some bounds
|
||||
this.Mesh = InsertionGroup.placeHolderMesh;
|
||||
|
|
@ -116,6 +116,14 @@ namespace MatterHackers.MatterControl.PrintLibrary
|
|||
loadedItem.Matrix = loadedItem.Matrix * Matrix4X4.CreateTranslation((double)-aabb.Center.X, (double)-aabb.Center.Y, (double)-aabb.minXYZ.Z) * placeholderItem.Matrix;
|
||||
loadedItem.Color = loadedItem.Color;
|
||||
|
||||
// Set mesh path if tracking requested
|
||||
if (trackSourceFiles
|
||||
&& item is FileSystemFileItem fileItem
|
||||
&& item.IsMeshFileType())
|
||||
{
|
||||
loadedItem.MeshPath = fileItem.Path;
|
||||
}
|
||||
|
||||
// Notification should force invalidate and redraw
|
||||
//progressReporter?.Invoke(1, "");
|
||||
|
||||
|
|
|
|||
|
|
@ -877,7 +877,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
}
|
||||
}
|
||||
|
||||
private void StartDragDrop(IEnumerable<ILibraryItem> items, Vector2 screenSpaceMousePosition)
|
||||
private void StartDragDrop(IEnumerable<ILibraryItem> items, Vector2 screenSpaceMousePosition, bool trackSourceFiles = false)
|
||||
{
|
||||
this.DragOperationActive = true;
|
||||
|
||||
|
|
@ -904,7 +904,8 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
this,
|
||||
this.Scene,
|
||||
sceneContext.BedCenter,
|
||||
() => this.DragOperationActive);
|
||||
() => this.DragOperationActive,
|
||||
trackSourceFiles);
|
||||
|
||||
// Find intersection position of the mouse with the bed plane
|
||||
var intersectInfo = GetIntersectPosition(screenSpaceMousePosition);
|
||||
|
|
@ -1417,8 +1418,9 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
{
|
||||
// Project DragFiles to IEnumerable<FileSystemFileItem>
|
||||
this.StartDragDrop(
|
||||
mouseEvent.DragFiles.Select(path => new FileSystemFileItem(path)),
|
||||
screenSpaceMousePosition: this.TransformToScreenSpace(mouseEvent.Position));
|
||||
mouseEvent.DragFiles.Select(path => new FileSystemFileItem(path)),
|
||||
screenSpaceMousePosition: this.TransformToScreenSpace(mouseEvent.Position),
|
||||
trackSourceFiles: true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,8 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
public class ApplicationSettings
|
||||
{
|
||||
public static string LibraryFilterFileExtensions { get; } = ".stl,.obj,.amf,.gcode,.mcx";
|
||||
public static string LibraryMeshFileExtensions { get; } = ".stl,.obj,.amf,.mcx";
|
||||
public static string LibraryFilterFileExtensions { get; } = LibraryMeshFileExtensions + ",.gcode";
|
||||
public static string OpenPrintableFileParams { get; } = "STL, AMF, OBJ, ZIP, GCODE, MCX|*.stl;*.amf;*.obj;*.zip;*.gcode;*.mcx";
|
||||
public static string OpenDesignFileParams { get; } = "STL, AMF, OBJ, ZIP, GCODE, MCX|*.stl;*.amf;*.obj;*.zip;*.gcode;*.mcx";
|
||||
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 37dcb2f6fed1868eb9e557d82ef7be1b893ff332
|
||||
Subproject commit 0e12283490c83827df27ee0caaa10d510b3814c1
|
||||
Loading…
Add table
Add a link
Reference in a new issue