From 1da9d0dfb5a51ef734b27a1eedbe902b87074bdb Mon Sep 17 00:00:00 2001 From: John Lewin Date: Tue, 23 Jan 2018 14:39:53 -0800 Subject: [PATCH] Consolidate file extension definitions - Issue MatterHackers/MCCentral#2527 Too many authorities on valid files types --- ApplicationView/WindowsPlatformsFeatures.cs | 15 --------------- Library/Export/GCodeExport.cs | 2 +- .../MatterControl/SqliteLibraryContainer.cs | 2 +- PartPreviewWindow/ViewControls3D.cs | 2 +- Queue/OptionsMenu/ExportToFolderProcess.cs | 2 +- RootSystemWindow.cs | 2 +- SettingsManagement/ApplicationSettings.cs | 1 + Submodules/agg-sharp | 2 +- Utilities/ProjectFileHandler.cs | 2 +- 9 files changed, 8 insertions(+), 22 deletions(-) diff --git a/ApplicationView/WindowsPlatformsFeatures.cs b/ApplicationView/WindowsPlatformsFeatures.cs index bb8ea3382..048273c36 100644 --- a/ApplicationView/WindowsPlatformsFeatures.cs +++ b/ApplicationView/WindowsPlatformsFeatures.cs @@ -37,10 +37,7 @@ namespace MatterHackers.MatterControl { using Agg.Image; using MatterHackers.Agg.Platform; - using MatterHackers.DataConverters3D; - using MatterHackers.MatterControl.DataStorage; using MatterHackers.MatterControl.PluginSystem; - using MatterHackers.MatterControl.PrintQueue; using MatterHackers.RenderOpenGl.OpenGl; public class WindowsPlatformsFeatures : INativePlatformFeatures @@ -139,18 +136,6 @@ namespace MatterHackers.MatterControl break; } } - - // TODO: Do we still want to support command line arguments for adding to the queue? - foreach (string arg in commandLineArgs) - { - string argExtension = Path.GetExtension(arg).ToUpper(); - if (argExtension.Length > 1 - && MeshFileIo.ValidFileExtensions().Contains(argExtension)) - { - QueueData.Instance.AddItem(new PrintItemWrapper(new PrintItem(Path.GetFileName(arg), Path.GetFullPath(arg)))); - } - } - } public void ReportException(Exception e, string key = "", string value = "", ReportSeverity2 warningLevel = ReportSeverity2.Warning) diff --git a/Library/Export/GCodeExport.cs b/Library/Export/GCodeExport.cs index 2b326bd69..4eee5c959 100644 --- a/Library/Export/GCodeExport.cs +++ b/Library/Export/GCodeExport.cs @@ -121,7 +121,7 @@ namespace MatterHackers.MatterControl.Library.Export string fileToProcess = ""; string sourceExtension = Path.GetExtension(libraryContent.FileName).ToUpper(); - if (MeshFileIo.ValidFileExtensions().Contains(sourceExtension) + if (ApplicationSettings.ValidFileExtensions.Contains(sourceExtension) || sourceExtension == ".MCX") { // Conceptually we need to: diff --git a/Library/Providers/MatterControl/SqliteLibraryContainer.cs b/Library/Providers/MatterControl/SqliteLibraryContainer.cs index 57c63edd0..eadc9a0e0 100644 --- a/Library/Providers/MatterControl/SqliteLibraryContainer.cs +++ b/Library/Providers/MatterControl/SqliteLibraryContainer.cs @@ -273,7 +273,7 @@ namespace MatterHackers.MatterControl.Library // Special load processing for mesh data, simple copy below for non-mesh if (forceAMF - && (extension != "" && MeshFileIo.ValidFileExtensions().Contains(extension.ToUpper()))) + && (extension != "" && ApplicationSettings.ValidFileExtensions.Contains(extension.ToUpper()))) { try { diff --git a/PartPreviewWindow/ViewControls3D.cs b/PartPreviewWindow/ViewControls3D.cs index 7f33053be..1b3bab101 100644 --- a/PartPreviewWindow/ViewControls3D.cs +++ b/PartPreviewWindow/ViewControls3D.cs @@ -513,7 +513,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow foreach (string loadedFileName in filesToLoadIncludingZips) { string extension = Path.GetExtension(loadedFileName).ToUpper(); - if ((extension != "" && MeshFileIo.ValidFileExtensions().Contains(extension))) + if ((extension != "" && ApplicationSettings.ValidFileExtensions.Contains(extension))) { filesToLoad.Add(loadedFileName); } diff --git a/Queue/OptionsMenu/ExportToFolderProcess.cs b/Queue/OptionsMenu/ExportToFolderProcess.cs index 59d399dfe..f07722229 100644 --- a/Queue/OptionsMenu/ExportToFolderProcess.cs +++ b/Queue/OptionsMenu/ExportToFolderProcess.cs @@ -105,7 +105,7 @@ namespace MatterHackers.MatterControl.PrintQueue { var printItemWrapper = new PrintItemWrapper(part); string extension = Path.GetExtension(printItemWrapper.FileLocation).ToUpper(); - if (extension != "" && MeshFileIo.ValidFileExtensions().Contains(extension)) + if (extension != "" && ApplicationSettings.ValidFileExtensions.Contains(extension)) { await ApplicationController.Instance.Tasks.Execute((reporter, cancellationToken) => { diff --git a/RootSystemWindow.cs b/RootSystemWindow.cs index 2af1df47d..42749f7cc 100644 --- a/RootSystemWindow.cs +++ b/RootSystemWindow.cs @@ -353,7 +353,7 @@ namespace MatterHackers.MatterControl foreach (string file in mouseEvent.DragFiles) { string extension = Path.GetExtension(file).ToUpper(); - if ((extension != "" && MeshFileIo.ValidFileExtensions().Contains(extension)) + if ((extension != "" && ApplicationSettings.ValidFileExtensions.Contains(extension)) || extension == ".GCODE" || extension == ".ZIP") { diff --git a/SettingsManagement/ApplicationSettings.cs b/SettingsManagement/ApplicationSettings.cs index 508bf470f..acd26ec12 100644 --- a/SettingsManagement/ApplicationSettings.cs +++ b/SettingsManagement/ApplicationSettings.cs @@ -20,6 +20,7 @@ namespace MatterHackers.MatterControl public class ApplicationSettings { + public static string ValidFileExtensions { get; } = ".STL;.AMF;.OBJ"; public static string LibraryMeshFileExtensions { get; } = ".stl,.obj,.amf,.mcx"; public static string LibraryFilterFileExtensions { get; } = LibraryMeshFileExtensions + ",.gcode"; public static string OpenPrintableFileParams { get; } = "STL, AMF, OBJ, GCODE, MCX|*.stl;*.amf;*.obj;*.gcode;*.mcx"; diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index 7c227e848..006fcf790 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit 7c227e8487d6432dd0b0db7b380f93d946e5faa4 +Subproject commit 006fcf790727fbfffb6de131764f3481b8e65a88 diff --git a/Utilities/ProjectFileHandler.cs b/Utilities/ProjectFileHandler.cs index b14efb11d..4e6685632 100644 --- a/Utilities/ProjectFileHandler.cs +++ b/Utilities/ProjectFileHandler.cs @@ -251,7 +251,7 @@ namespace MatterHackers.MatterControl // - are named manifest.json if (!string.IsNullOrWhiteSpace(zipEntry.Name) && (zipEntry.Name == "manifest.json" - || MeshFileIo.ValidFileExtensions().Contains(sourceExtension) + || ApplicationSettings.ValidFileExtensions.Contains(sourceExtension) || sourceExtension == ".GCODE")) { string extractedFileName = Path.Combine(stagingFolder, zipEntry.Name);