From 0b1e3732c44f9921a7ba817366b5d6762179dacc Mon Sep 17 00:00:00 2001 From: John Lewin Date: Mon, 4 Feb 2019 08:41:08 -0800 Subject: [PATCH] Revise plugins --- KnownPlugins.json | 22 +++ .../Extensibility/IApplicationPlugin.cs | 37 +++++ .../Extensibility/PluginInfo.cs | 40 +++++ .../Extensibility/PluginManager.cs | 143 ++++++++++++++++++ .../INativePlatformFeatures.cs | 3 +- .../MatterControl.Common.csproj | 3 +- .../FrostedSerial/FrostedSerialPortFactory.cs | 1 + .../FrostedSerial/IFrostedSerialPort.cs | 2 +- .../IFrostedSerialPortFactory.cs | 12 ++ .../MatterControl.Printing.csproj | 4 + .../MatterControl.Winforms.csproj | 8 +- .../WindowsPlatformsFeatures.cs | 9 -- MatterControl.csproj | 5 + MatterControl.sln | 26 ++-- .../ApplicationView/ApplicationController.cs | 71 +++------ .../ApplicationView/ExtensionsConfig.cs | 116 ++++++++++++++ .../ApplicationSettings/PluginsPage.cs | 96 ++++++++++++ .../Braille/BrailleGrade2Mapping.cs | 7 - .../DesignTools/PublicPropertyEditor.cs | 2 +- MatterControlLib/MatterControlApplication.cs | 1 - MatterControlLib/MatterControlLib.csproj | 2 +- .../PartPreviewWindow/SelectedObjectPanel.cs | 6 +- .../View3D/Actions/ImageEditor.cs | 1 - .../View3D/InteractionVolume.cs | 8 +- .../PartPreviewWindow/View3D/View3DWidget.cs | 7 +- .../ApplicationSettingsPage.cs | 26 +++- PluginSystem/MatterControlPluginBase.cs | 59 -------- .../MatterControl.AutomationTests.csproj | 8 +- .../MatterControl.Tests.csproj | 8 +- 29 files changed, 566 insertions(+), 167 deletions(-) create mode 100644 KnownPlugins.json create mode 100644 MatterControl.Common/Extensibility/IApplicationPlugin.cs create mode 100644 MatterControl.Common/Extensibility/PluginInfo.cs create mode 100644 MatterControl.Common/Extensibility/PluginManager.cs rename {PluginSystem => MatterControl.Common}/INativePlatformFeatures.cs (95%) rename PluginSystem/MatterControlPluginSystem.csproj => MatterControl.Common/MatterControl.Common.csproj (85%) create mode 100644 MatterControl.Printing/Communication/FrostedSerial/IFrostedSerialPortFactory.cs create mode 100644 MatterControlLib/ApplicationView/ExtensionsConfig.cs create mode 100644 MatterControlLib/ConfigurationPage/ApplicationSettings/PluginsPage.cs delete mode 100644 PluginSystem/MatterControlPluginBase.cs diff --git a/KnownPlugins.json b/KnownPlugins.json new file mode 100644 index 000000000..66065dc76 --- /dev/null +++ b/KnownPlugins.json @@ -0,0 +1,22 @@ +[ + { + "Name": "MatterControl Cloud Services", + "TypeName": "MatterHackers.MatterControl.Plugins.CloudServices.CloudServicesPlugin" + }, + { + "Name": "MatterControl Authentication", + "TypeName": "MatterHackers.MatterControl.Plugins.AuthenticationPlugin.AuthenticationPlugin" + }, + { + "Name": "Editor Tools", + "TypeName": "MatterHackers.Plugins.EditorTools.EditorToolsPlugin" + }, + { + "Name": "Firmware Updater", + "TypeName": "MatterHackers.MatterControl.Plugins.MarlinFirmwareUpdatePlugin.MarlinFirmwareUpdatePlugin" + }, + { + "Name": "Print Notifications", + "TypeName": "MatterHackers.MatterControl.Plugins.PrintNotifications.PrintNotificationPlugin" + }, +] \ No newline at end of file diff --git a/MatterControl.Common/Extensibility/IApplicationPlugin.cs b/MatterControl.Common/Extensibility/IApplicationPlugin.cs new file mode 100644 index 000000000..658e6e806 --- /dev/null +++ b/MatterControl.Common/Extensibility/IApplicationPlugin.cs @@ -0,0 +1,37 @@ +/* +Copyright (c) 2019, 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. +*/ + +namespace MatterHackers.MatterControl.Extensibility +{ + public interface IApplicationPlugin + { + PluginInfo MetaData { get; } + void Initialize(); + } +} \ No newline at end of file diff --git a/MatterControl.Common/Extensibility/PluginInfo.cs b/MatterControl.Common/Extensibility/PluginInfo.cs new file mode 100644 index 000000000..9f987488c --- /dev/null +++ b/MatterControl.Common/Extensibility/PluginInfo.cs @@ -0,0 +1,40 @@ +/* +Copyright (c) 2019, 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. +*/ + +namespace MatterHackers.MatterControl.Extensibility +{ + public class PluginInfo + { + public string Name { get; set; } + public string UUID { get; set; } + public string About { get; set; } + public string Developer { get; set; } + public string Url { get; set; } + } +} \ No newline at end of file diff --git a/MatterControl.Common/Extensibility/PluginManager.cs b/MatterControl.Common/Extensibility/PluginManager.cs new file mode 100644 index 000000000..f68905c4e --- /dev/null +++ b/MatterControl.Common/Extensibility/PluginManager.cs @@ -0,0 +1,143 @@ +/* +Copyright (c) 2019, 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; +using System.Collections.Generic; +using System.Collections.Specialized; +using System.IO; +using System.Linq; +using System.Net; +using MatterHackers.Agg; +using MatterHackers.Agg.UI; +using Newtonsoft.Json; + +namespace MatterHackers.MatterControl.Extensibility +{ + public class PluginManager + { + private string pluginStateFile = "DisabledPlugins.json"; + private string knownPluginsFile = "KnownPlugins.json"; + + public PluginManager() + { + if (File.Exists(pluginStateFile)) + { + try + { + this.Disabled = JsonConvert.DeserializeObject>(File.ReadAllText(pluginStateFile)); + } + catch + { + this.Disabled = new HashSet(); + } + } + else + { + this.Disabled = new HashSet(); + } + + if (File.Exists(knownPluginsFile)) + { + try + { + this.KnownPlugins = JsonConvert.DeserializeObject>(File.ReadAllText(knownPluginsFile)); + } + catch + { + } + } + + var plugins = new List(); + + foreach (var containerType in PluginFinder.FindTypes().Where(type => Disabled.Contains(type.FullName) == false)) + { + try + { + plugins.Add(Activator.CreateInstance(containerType) as IApplicationPlugin); + } + catch(Exception ex) + { + Console.WriteLine("Error constructing plugin: " + ex.Message); + } + } + + this.Plugins = plugins; + + /* + // Uncomment to generate new KnownPlugins.json file + KnownPlugins = plugins.Where(p => p.MetaData != null).Select(p => new PluginState { TypeName = p.GetType().FullName, Name = p.MetaData.Name }).ToList(); + + File.WriteAllText( + Path.Combine("..", "..", "knownPlugins.json"), + JsonConvert.SerializeObject(KnownPlugins, Formatting.Indented)); */ + + } + + public List Plugins { get; } + + public List KnownPlugins { get; } + + public class PluginState + { + public string Name { get; set; } + public string TypeName { get; set; } + //public bool Enabled { get; set; } + //public bool UpdateAvailable { get; set; } + } + + public HashSet Disabled { get; } + + public void Disable(string typeName) => Disabled.Add(typeName); + + public void Enable(string typeName) => Disabled.Remove(typeName); + + public void Save() + { + File.WriteAllText( + pluginStateFile, + JsonConvert.SerializeObject(Disabled, Formatting.Indented)); + } + + public void InitializePlugins(SystemWindow systemWindow) + { + foreach (var plugin in this.Plugins) + { + plugin.Initialize(); + } + } + + public class MatterControlPluginItem + { + public string Name { get; set; } + public string Url { get; set; } + public string Version { get; set; } + public DateTime ReleaseDate { get; set; } + } + } +} diff --git a/PluginSystem/INativePlatformFeatures.cs b/MatterControl.Common/INativePlatformFeatures.cs similarity index 95% rename from PluginSystem/INativePlatformFeatures.cs rename to MatterControl.Common/INativePlatformFeatures.cs index 69eb93c01..648ebdb9c 100644 --- a/PluginSystem/INativePlatformFeatures.cs +++ b/MatterControl.Common/INativePlatformFeatures.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018, Lars Brubaker, John Lewin +Copyright (c) 2019, Lars Brubaker, John Lewin All rights reserved. Redistribution and use in source and binary forms, with or without @@ -43,7 +43,6 @@ namespace MatterHackers.MatterControl bool IsNetworkConnected(); void InitPluginFinder(); GuiWidget GetConnectDevicePage(object printer); - void FindAndInstantiatePlugins(SystemWindow systemWindow); void ProcessCommandline(); void PlatformInit(Action reporter); void GenerateLocalizationValidationFile(); diff --git a/PluginSystem/MatterControlPluginSystem.csproj b/MatterControl.Common/MatterControl.Common.csproj similarity index 85% rename from PluginSystem/MatterControlPluginSystem.csproj rename to MatterControl.Common/MatterControl.Common.csproj index 0f876713d..ae326c451 100644 --- a/PluginSystem/MatterControlPluginSystem.csproj +++ b/MatterControl.Common/MatterControl.Common.csproj @@ -3,6 +3,7 @@ netstandard2.0 MatterHackers Inc. + true @@ -10,4 +11,4 @@ - + \ No newline at end of file diff --git a/MatterControl.Printing/Communication/FrostedSerial/FrostedSerialPortFactory.cs b/MatterControl.Printing/Communication/FrostedSerial/FrostedSerialPortFactory.cs index 3383a8145..0e58e5f6a 100644 --- a/MatterControl.Printing/Communication/FrostedSerial/FrostedSerialPortFactory.cs +++ b/MatterControl.Printing/Communication/FrostedSerial/FrostedSerialPortFactory.cs @@ -35,6 +35,7 @@ using System.Runtime.InteropServices; using MatterHackers.Agg; using MatterHackers.Agg.Platform; using MatterHackers.MatterControl.SlicerConfiguration; +using MatterHackers.MatterControl.Extensibility; using Microsoft.Win32.SafeHandles; namespace MatterHackers.SerialPortCommunication.FrostedSerial diff --git a/MatterControl.Printing/Communication/FrostedSerial/IFrostedSerialPort.cs b/MatterControl.Printing/Communication/FrostedSerial/IFrostedSerialPort.cs index 620fd8e7b..8acb7cf76 100644 --- a/MatterControl.Printing/Communication/FrostedSerial/IFrostedSerialPort.cs +++ b/MatterControl.Printing/Communication/FrostedSerial/IFrostedSerialPort.cs @@ -68,7 +68,7 @@ namespace MatterHackers.SerialPortCommunication.FrostedSerial void Dispose(); } - internal enum SerialSignal + public enum SerialSignal { None = 0, Cd = 1, // Carrier detect diff --git a/MatterControl.Printing/Communication/FrostedSerial/IFrostedSerialPortFactory.cs b/MatterControl.Printing/Communication/FrostedSerial/IFrostedSerialPortFactory.cs new file mode 100644 index 000000000..b3b69831c --- /dev/null +++ b/MatterControl.Printing/Communication/FrostedSerial/IFrostedSerialPortFactory.cs @@ -0,0 +1,12 @@ +namespace MatterHackers.SerialPortCommunication.FrostedSerial +{ + public interface IFrostedSerialPortFactory + { + bool IsWindows { get; } + + bool SerialPortAlreadyOpen(string portName); + + IFrostedSerialPort Create(string serialPortName); + IFrostedSerialPort CreateAndOpen(string serialPortName, int baudRate, bool DtrEnableOnConnect); + } +} diff --git a/MatterControl.Printing/MatterControl.Printing.csproj b/MatterControl.Printing/MatterControl.Printing.csproj index c5670ca4e..4ebe771d2 100644 --- a/MatterControl.Printing/MatterControl.Printing.csproj +++ b/MatterControl.Printing/MatterControl.Printing.csproj @@ -11,6 +11,10 @@ + + {2af30557-fc50-4de3-ad1c-7eb57131a9c5} + MatterControl.Common + diff --git a/MatterControl.Winforms/MatterControl.Winforms.csproj b/MatterControl.Winforms/MatterControl.Winforms.csproj index 7e53c0caf..17caba40c 100644 --- a/MatterControl.Winforms/MatterControl.Winforms.csproj +++ b/MatterControl.Winforms/MatterControl.Winforms.csproj @@ -62,14 +62,14 @@ {f1653f20-d47d-4f29-8c55-3c835542af5f} Community.CsharpSqlite + + {2af30557-fc50-4de3-ad1c-7eb57131a9c5} + MatterControl.Common + {D557B079-612F-467F-AE0D-3F77BCD627F7} MatterControlLib - - {865172a0-a1a9-49c2-9386-f2fdb4e141b7} - MatterControlPluginSystem - {657dbc6d-c3ea-4398-a3fa-ddb73c14f71b} Agg diff --git a/MatterControl.Winforms/WindowsPlatformsFeatures.cs b/MatterControl.Winforms/WindowsPlatformsFeatures.cs index 170c7a4dd..c7429bc9a 100644 --- a/MatterControl.Winforms/WindowsPlatformsFeatures.cs +++ b/MatterControl.Winforms/WindowsPlatformsFeatures.cs @@ -35,7 +35,6 @@ using MatterHackers.Agg; using MatterHackers.Agg.Image; using MatterHackers.Agg.Platform; using MatterHackers.Agg.UI; -using MatterHackers.MatterControl.PluginSystem; using MatterHackers.MatterControl.PrinterControls.PrinterConnections; namespace MatterHackers.MatterControl @@ -91,14 +90,6 @@ namespace MatterHackers.MatterControl { } - public void FindAndInstantiatePlugins(SystemWindow systemWindow) - { - foreach (MatterControlPlugin plugin in PluginFinder.CreateInstancesOf()) - { - plugin.Initialize(systemWindow); - } - } - public void ProcessCommandline() { var commandLineArgs = Environment.GetCommandLineArgs(); diff --git a/MatterControl.csproj b/MatterControl.csproj index 109f2499e..f60ac7cc4 100644 --- a/MatterControl.csproj +++ b/MatterControl.csproj @@ -65,6 +65,9 @@ + + PreserveNewest + @@ -103,6 +106,8 @@ {b0aed568-8796-42b9-baa9-ebc796134e78} MatterSlice + + diff --git a/MatterControl.sln b/MatterControl.sln index 750694cf5..7d70f1529 100644 --- a/MatterControl.sln +++ b/MatterControl.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.27130.2010 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.28516.95 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tesselate", "Submodules\agg-sharp\Tesselate\Tesselate.csproj", "{AE37DE1F-22F7-49EE-8732-FC6BC8DC58D9}" EndProject @@ -36,8 +36,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "clipper_library", "Submodul EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MarchingSquares", "Submodules\agg-sharp\MarchingSquares\MarchingSquares.csproj", "{DF6845CD-64C6-4263-8357-DA8066855739}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MatterControlPluginSystem", "PluginSystem\MatterControlPluginSystem.csproj", "{865172A0-A1A9-49C2-9386-F2FDB4E141B7}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Launcher", "Launcher\Launcher.csproj", "{3DF4CB3D-9A03-4256-9A81-70523AAD828B}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "agg-sharp", "agg-sharp", "{2AB9B589-5C98-4C05-BBEA-F97DAE168EAB}" @@ -96,6 +94,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Typography.One", "Submodule EndProject Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Typography.OpenFont", "Submodules\agg-sharp\Typography.OpenFont\Typography.OpenFont.shproj", "{235A071B-8D06-40AE-A5C5-B1CE59715EE9}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MatterControl.Common", "MatterControl.Common\MatterControl.Common.csproj", "{50505F12-985B-4C5F-8DAB-D5BEA734CD51}" +EndProject Global GlobalSection(SharedMSBuildProjectFiles) = preSolution Submodules\agg-sharp\Typography.OpenFont\Typography.OpenFont.projitems*{235a071b-8d06-40ae-a5c5-b1ce59715ee9}*SharedItemsImports = 13 @@ -222,14 +222,6 @@ Global {DF6845CD-64C6-4263-8357-DA8066855739}.Release|Any CPU.Build.0 = Release|Any CPU {DF6845CD-64C6-4263-8357-DA8066855739}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {DF6845CD-64C6-4263-8357-DA8066855739}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {865172A0-A1A9-49C2-9386-F2FDB4E141B7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {865172A0-A1A9-49C2-9386-F2FDB4E141B7}.Debug|Any CPU.Build.0 = Debug|Any CPU - {865172A0-A1A9-49C2-9386-F2FDB4E141B7}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {865172A0-A1A9-49C2-9386-F2FDB4E141B7}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {865172A0-A1A9-49C2-9386-F2FDB4E141B7}.Release|Any CPU.ActiveCfg = Release|Any CPU - {865172A0-A1A9-49C2-9386-F2FDB4E141B7}.Release|Any CPU.Build.0 = Release|Any CPU - {865172A0-A1A9-49C2-9386-F2FDB4E141B7}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {865172A0-A1A9-49C2-9386-F2FDB4E141B7}.Release|Mixed Platforms.Build.0 = Release|Any CPU {3DF4CB3D-9A03-4256-9A81-70523AAD828B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {3DF4CB3D-9A03-4256-9A81-70523AAD828B}.Debug|Any CPU.Build.0 = Debug|Any CPU {3DF4CB3D-9A03-4256-9A81-70523AAD828B}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU @@ -414,6 +406,14 @@ Global {07F53C22-F178-4A25-963F-11DB59024ACA}.Release|Any CPU.Build.0 = Release|Any CPU {07F53C22-F178-4A25-963F-11DB59024ACA}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {07F53C22-F178-4A25-963F-11DB59024ACA}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {50505F12-985B-4C5F-8DAB-D5BEA734CD51}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {50505F12-985B-4C5F-8DAB-D5BEA734CD51}.Debug|Any CPU.Build.0 = Debug|Any CPU + {50505F12-985B-4C5F-8DAB-D5BEA734CD51}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {50505F12-985B-4C5F-8DAB-D5BEA734CD51}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {50505F12-985B-4C5F-8DAB-D5BEA734CD51}.Release|Any CPU.ActiveCfg = Release|Any CPU + {50505F12-985B-4C5F-8DAB-D5BEA734CD51}.Release|Any CPU.Build.0 = Release|Any CPU + {50505F12-985B-4C5F-8DAB-D5BEA734CD51}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {50505F12-985B-4C5F-8DAB-D5BEA734CD51}.Release|Mixed Platforms.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -433,7 +433,6 @@ Global {036BCCBA-52D8-457C-84AE-8821F209FE4A} = {2AB9B589-5C98-4C05-BBEA-F97DAE168EAB} {9B062971-A88E-4A3D-B3C9-12B78D15FA66} = {2AB9B589-5C98-4C05-BBEA-F97DAE168EAB} {DF6845CD-64C6-4263-8357-DA8066855739} = {2AB9B589-5C98-4C05-BBEA-F97DAE168EAB} - {865172A0-A1A9-49C2-9386-F2FDB4E141B7} = {FED00F38-E911-45E1-A788-26980E84C3D6} {3DF4CB3D-9A03-4256-9A81-70523AAD828B} = {FED00F38-E911-45E1-A788-26980E84C3D6} {990A9AD3-B6A4-407B-9DFC-9C722AF7C9B9} = {FED00F38-E911-45E1-A788-26980E84C3D6} {04667764-DC7B-4B95-AEF6-B4E6C87A54E9} = {2AB9B589-5C98-4C05-BBEA-F97DAE168EAB} @@ -457,6 +456,7 @@ Global {D8861CF8-C506-472B-8A57-632BD6CA6496} = {2AB9B589-5C98-4C05-BBEA-F97DAE168EAB} {07F53C22-F178-4A25-963F-11DB59024ACA} = {2AB9B589-5C98-4C05-BBEA-F97DAE168EAB} {235A071B-8D06-40AE-A5C5-B1CE59715EE9} = {2AB9B589-5C98-4C05-BBEA-F97DAE168EAB} + {50505F12-985B-4C5F-8DAB-D5BEA734CD51} = {FED00F38-E911-45E1-A788-26980E84C3D6} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {42D74E06-00EA-43D2-A05B-9BEAD4A2C8A0} diff --git a/MatterControlLib/ApplicationView/ApplicationController.cs b/MatterControlLib/ApplicationView/ApplicationController.cs index 0854a68e2..30f95b3b5 100644 --- a/MatterControlLib/ApplicationView/ApplicationController.cs +++ b/MatterControlLib/ApplicationView/ApplicationController.cs @@ -68,6 +68,7 @@ namespace MatterHackers.MatterControl using MatterHackers.MatterControl.ConfigurationPage.PrintLeveling; using MatterHackers.MatterControl.DesignTools; using MatterHackers.MatterControl.DesignTools.Operations; + using MatterHackers.MatterControl.Extensibility; using MatterHackers.MatterControl.Library; using MatterHackers.MatterControl.PartPreviewWindow; using MatterHackers.MatterControl.PartPreviewWindow.View3D; @@ -267,7 +268,7 @@ namespace MatterHackers.MatterControl public IEnumerable ActivePrinters => this.Workspaces.Where(w => w.Printer != null).Select(w => w.Printer); - private Dictionary> objectEditorsByType; + public ExtensionsConfig Extensions { get; } public PopupMenu GetActionMenuForSceneItem(IObject3D selectedItem, InteractiveScene scene, bool addInSubmenu, IEnumerable nodeOperations = null) { @@ -1069,6 +1070,10 @@ namespace MatterHackers.MatterControl this.RebuildSceneOperations(this.Theme); + this.Extensions = new ExtensionsConfig(this.Library); + this.Extensions.Register(new ImageEditor()); + this.Extensions.Register(new PublicPropertyEditor()); + HelpArticle helpArticle = null; string helpPath = Path.Combine("OEMSettings", "toc.json"); @@ -1475,26 +1480,6 @@ namespace MatterHackers.MatterControl this.InitializeLibrary(); - HashSet mappedEditors; - objectEditorsByType = new Dictionary>(); - - // Initialize plugins, passing the MatterControl assembly as the only non-dll instance - //PluginFinder.Initialize(Assembly.GetExecutingAssembly()); - - foreach (IObject3DEditor editor in PluginFinder.CreateInstancesOf()) - { - foreach (Type type in editor.SupportedTypes()) - { - if (!objectEditorsByType.TryGetValue(type, out mappedEditors)) - { - mappedEditors = new HashSet(); - objectEditorsByType.Add(type, mappedEditors); - } - - mappedEditors.Add(editor); - } - } - this.Graph.PrimaryOperations.Add(typeof(ImageObject3D), new List { this.Graph.Operations["ImageConverter"], this.Graph.Operations["ImageToPath"], }); this.Graph.PrimaryOperations.Add(typeof(ImageToPathObject3D), new List { this.Graph.Operations["LinearExtrude"], this.Graph.Operations["SmoothPath"], this.Graph.Operations["InflatePath"] }); this.Graph.PrimaryOperations.Add(typeof(SmoothPathObject3D), new List { this.Graph.Operations["LinearExtrude"], this.Graph.Operations["InflatePath"] }); @@ -1643,29 +1628,6 @@ namespace MatterHackers.MatterControl return false; } - public HashSet GetEditorsForType(Type selectedItemType) - { - HashSet mappedEditors; - objectEditorsByType.TryGetValue(selectedItemType, out mappedEditors); - - if (mappedEditors == null) - { - foreach (var kvp in objectEditorsByType) - { - var editorType = kvp.Key; - - if (editorType.IsAssignableFrom(selectedItemType) - && selectedItemType != typeof(Object3D)) - { - mappedEditors = kvp.Value; - break; - } - } - } - - return mappedEditors; - } - public void Shutdown() { // Ensure all threads shutdown gracefully on close @@ -1721,7 +1683,6 @@ namespace MatterHackers.MatterControl return TypeFaceCache[Name]; } - private static TypeFace titilliumTypeFace = null; public static TypeFace TitilliumTypeFace { @@ -1736,7 +1697,6 @@ namespace MatterHackers.MatterControl } } - public static string LoadCachedFile(string cacheKey, string cacheScope) { string cachePath = CacheablePath(cacheScope, cacheKey); @@ -2629,6 +2589,23 @@ If you experience adhesion problems, please re-run leveling." }); } + private static PluginManager pluginManager = null; + + public static PluginManager Plugins + { + get + { + // PluginManager initialization must occur late, after the config is loaded and after localization libraries + // have occurred, which currently is driven by MatterControlApplication init + if (pluginManager == null) + { + pluginManager = new PluginManager(); + } + + return pluginManager; + } + } + /// /// Archives MCX and validates GCode results before starting a print operation /// @@ -3544,7 +3521,7 @@ If you experience adhesion problems, please re-run leveling." } reporter?.Invoke(0.3, (loading != null) ? loading : "Plugins"); - AppContext.Platform.FindAndInstantiatePlugins(systemWindow); + ApplicationController.Plugins.InitializePlugins(systemWindow); reporter?.Invoke(0.4, (loading != null) ? loading : "MainView"); applicationController.MainView = new MainViewWidget(applicationController.Theme); diff --git a/MatterControlLib/ApplicationView/ExtensionsConfig.cs b/MatterControlLib/ApplicationView/ExtensionsConfig.cs new file mode 100644 index 000000000..da418ba35 --- /dev/null +++ b/MatterControlLib/ApplicationView/ExtensionsConfig.cs @@ -0,0 +1,116 @@ +/* +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; +using System.Collections.Generic; +using System.Runtime.CompilerServices; + +[assembly: InternalsVisibleTo("MatterControl.Tests")] +[assembly: InternalsVisibleTo("MatterControl.AutomationTests")] +[assembly: InternalsVisibleTo("CloudServices.Tests")] + +namespace MatterHackers.MatterControl +{ + using MatterHackers.DataConverters3D; + using MatterHackers.MatterControl.Library; + using MatterHackers.MatterControl.PartPreviewWindow; + using MatterHackers.MeshVisualizer; + using Newtonsoft.Json.Linq; + + public class ExtensionsConfig + { + private List _iaVolumeProviders = new List(); + + private LibraryConfig libraryConfig; + + //private List _IObject3DEditorProviders = new List() + //{ + // new IntersectionEditor(), + // new SubtractEditor(), + // new SubtractAndReplace() + //}; + + public ExtensionsConfig(LibraryConfig libraryConfig) + { + this.libraryConfig = libraryConfig; + + objectEditorsByType = new Dictionary>(); + } + + private void MapTypesToEditor(IObject3DEditor editor) + { + foreach (Type type in editor.SupportedTypes()) + { + if (!objectEditorsByType.TryGetValue(type, out HashSet mappedEditors)) + { + mappedEditors = new HashSet(); + objectEditorsByType.Add(type, mappedEditors); + } + + mappedEditors.Add(editor); + } + } + + public IEnumerable IAVolumeProviders => _iaVolumeProviders; + + public void Register(IInteractionVolumeProvider volumeProvider) + { + _iaVolumeProviders.Add(volumeProvider); + } + public void Register(IObject3DEditor object3DEditor) + { + this.MapTypesToEditor(object3DEditor); + } + + private Dictionary> objectEditorsByType; + + public HashSet GetEditorsForType(Type selectedItemType) + { + HashSet mappedEditors; + objectEditorsByType.TryGetValue(selectedItemType, out mappedEditors); + + if (mappedEditors == null) + { + foreach (var kvp in objectEditorsByType) + { + var editorType = kvp.Key; + + if (editorType.IsAssignableFrom(selectedItemType) + && selectedItemType != typeof(Object3D)) + { + mappedEditors = kvp.Value; + break; + } + } + } + + return mappedEditors; + } + } +} diff --git a/MatterControlLib/ConfigurationPage/ApplicationSettings/PluginsPage.cs b/MatterControlLib/ConfigurationPage/ApplicationSettings/PluginsPage.cs new file mode 100644 index 000000000..11854e2b0 --- /dev/null +++ b/MatterControlLib/ConfigurationPage/ApplicationSettings/PluginsPage.cs @@ -0,0 +1,96 @@ +/* +Copyright (c) 2019, 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 MatterHackers.Agg.UI; +using MatterHackers.Localizations; +using MatterHackers.MatterControl.ConfigurationPage; + +namespace MatterHackers.MatterControl +{ + public class PluginsPage : DialogPage + { + public PluginsPage() + { + this.AnchorAll(); + + this.HeaderText = this.WindowTitle = "MatterControl Plugins".Localize(); + + var contentScroll = new ScrollableWidget(true); + contentScroll.ScrollArea.HAnchor |= HAnchor.Stretch; + contentScroll.ScrollArea.VAnchor = VAnchor.Fit; + contentScroll.AnchorAll(); + + var formContainer = new FlowLayoutWidget(FlowDirection.TopToBottom) + { + HAnchor = HAnchor.Stretch + }; + + // TODO: Move to instance + var plugins = ApplicationController.Plugins; + + foreach (var plugin in plugins.KnownPlugins) + { + // Touch Screen Mode + formContainer.AddChild( + new SettingsItem( + plugin.Name, + theme, + new SettingsItem.ToggleSwitchConfig() + { + Checked = !plugins.Disabled.Contains(plugin.TypeName), + ToggleAction = (itemChecked) => + { + if (itemChecked) + { + plugins.Enable(plugin.TypeName); + } + else + { + plugins.Disable(plugin.TypeName); + } + } + }, + enforceGutter: false)); + } + + contentScroll.AddChild(formContainer); + + contentRow.AddChild(contentScroll); + + var saveButton = theme.CreateDialogButton("Save".Localize()); + saveButton.Click += (s,e) => + { + ApplicationController.Plugins.Save(); + this.DialogWindow.CloseOnIdle(); + }; + + this.AddPageAction(saveButton); + } + } +} \ No newline at end of file diff --git a/MatterControlLib/DesignTools/Braille/BrailleGrade2Mapping.cs b/MatterControlLib/DesignTools/Braille/BrailleGrade2Mapping.cs index 083ef27ba..519b4de35 100644 --- a/MatterControlLib/DesignTools/Braille/BrailleGrade2Mapping.cs +++ b/MatterControlLib/DesignTools/Braille/BrailleGrade2Mapping.cs @@ -27,14 +27,7 @@ of the authors and should not be interpreted as representing official policies, either expressed or implied, of the FreeBSD Project. */ -using MatterHackers.Agg.UI; -using MatterHackers.MatterControl.PluginSystem; -using System; -using System.Collections.Generic; -using System.Text; - // finish a, b, t - namespace MatterHackers.MatterControl.Plugins.BrailleBuilder { public static class BrailleGrade2Mapping diff --git a/MatterControlLib/DesignTools/PublicPropertyEditor.cs b/MatterControlLib/DesignTools/PublicPropertyEditor.cs index f7d13c5de..17c347010 100644 --- a/MatterControlLib/DesignTools/PublicPropertyEditor.cs +++ b/MatterControlLib/DesignTools/PublicPropertyEditor.cs @@ -631,7 +631,7 @@ namespace MatterHackers.MatterControl.DesignTools } // Use known IObject3D editors else if (propertyValue is IObject3D item - && ApplicationController.Instance.GetEditorsForType(property.PropertyType)?.FirstOrDefault() is IObject3DEditor iObject3DEditor) + && ApplicationController.Instance.Extensions.GetEditorsForType(property.PropertyType)?.FirstOrDefault() is IObject3DEditor iObject3DEditor) { rowContainer = iObject3DEditor.Create(item, theme); } diff --git a/MatterControlLib/MatterControlApplication.cs b/MatterControlLib/MatterControlApplication.cs index 66b59c055..cbb99f590 100644 --- a/MatterControlLib/MatterControlApplication.cs +++ b/MatterControlLib/MatterControlApplication.cs @@ -67,7 +67,6 @@ namespace MatterHackers.MatterControl MatterHackers.Agg.ImageProcessing.InvertLightness.AssertDebugNotDefined(); MatterHackers.Localizations.TranslationMap.AssertDebugNotDefined(); MatterHackers.MarchingSquares.MarchingSquaresByte.AssertDebugNotDefined(); - MatterHackers.MatterControl.PluginSystem.MatterControlPlugin.AssertDebugNotDefined(); MatterHackers.MatterSlice.MatterSlice.AssertDebugNotDefined(); MatterHackers.RenderOpenGl.GLMeshTrianglePlugin.AssertDebugNotDefined(); } diff --git a/MatterControlLib/MatterControlLib.csproj b/MatterControlLib/MatterControlLib.csproj index 87469627e..5b5c01ac3 100644 --- a/MatterControlLib/MatterControlLib.csproj +++ b/MatterControlLib/MatterControlLib.csproj @@ -62,6 +62,7 @@ + @@ -77,7 +78,6 @@ - diff --git a/MatterControlLib/PartPreviewWindow/SelectedObjectPanel.cs b/MatterControlLib/PartPreviewWindow/SelectedObjectPanel.cs index 699ab1f3e..328887230 100644 --- a/MatterControlLib/PartPreviewWindow/SelectedObjectPanel.cs +++ b/MatterControlLib/PartPreviewWindow/SelectedObjectPanel.cs @@ -235,7 +235,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow editorSectionWidget.Text = selectedItem.Name ?? selectedItemType.Name; - HashSet mappedEditors = ApplicationController.Instance.GetEditorsForType(selectedItemType); + HashSet mappedEditors = ApplicationController.Instance.Extensions.GetEditorsForType(selectedItemType); var undoBuffer = sceneContext.Scene.UndoBuffer; @@ -309,7 +309,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow { if (instance is IObject3D object3D) { - if (ApplicationController.Instance.GetEditorsForType(object3D.GetType())?.FirstOrDefault() is IObject3DEditor editor) + if (ApplicationController.Instance.Extensions.GetEditorsForType(object3D.GetType())?.FirstOrDefault() is IObject3DEditor editor) { ShowObjectEditor((editor, object3D, object3D.Name), selectedItem, allowOperations: allowOperations); } @@ -346,7 +346,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow } else { - if (ApplicationController.Instance.GetEditorsForType(item.GetType())?.FirstOrDefault() is IObject3DEditor editor) + if (ApplicationController.Instance.Extensions.GetEditorsForType(item.GetType())?.FirstOrDefault() is IObject3DEditor editor) { ShowObjectEditor((editor, item, item.Name), selectedItem, allowOperations: allowOperations); } diff --git a/MatterControlLib/PartPreviewWindow/View3D/Actions/ImageEditor.cs b/MatterControlLib/PartPreviewWindow/View3D/Actions/ImageEditor.cs index 0548f3aba..7b6584ae3 100644 --- a/MatterControlLib/PartPreviewWindow/View3D/Actions/ImageEditor.cs +++ b/MatterControlLib/PartPreviewWindow/View3D/Actions/ImageEditor.cs @@ -43,7 +43,6 @@ namespace MatterHackers.MatterControl.DesignTools using DataConverters3D; using MatterHackers.Agg.Platform; using MatterHackers.MatterControl.DataStorage; - using MatterHackers.MatterControl.Library; public class ImageEditor : IObject3DEditor { diff --git a/MatterControlLib/PartPreviewWindow/View3D/InteractionVolume.cs b/MatterControlLib/PartPreviewWindow/View3D/InteractionVolume.cs index 098c1f382..2d81527cd 100644 --- a/MatterControlLib/PartPreviewWindow/View3D/InteractionVolume.cs +++ b/MatterControlLib/PartPreviewWindow/View3D/InteractionVolume.cs @@ -35,6 +35,7 @@ using MatterHackers.Agg.Transform; using MatterHackers.Agg.UI; using MatterHackers.Agg.VertexSource; using MatterHackers.DataConverters3D; +using MatterHackers.MatterControl.Extensibility; using MatterHackers.RayTracer; using MatterHackers.VectorMath; @@ -195,11 +196,8 @@ namespace MatterHackers.MeshVisualizer double SnapGridDistance { get; } } - public class InteractionVolumePlugin + public interface IInteractionVolumeProvider { - public virtual InteractionVolume CreateInteractionVolume(IInteractionVolumeContext context) - { - return null; - } + IEnumerable Create(IInteractionVolumeContext context); } } \ No newline at end of file diff --git a/MatterControlLib/PartPreviewWindow/View3D/View3DWidget.cs b/MatterControlLib/PartPreviewWindow/View3D/View3DWidget.cs index 10ce456e3..7efbb37f4 100644 --- a/MatterControlLib/PartPreviewWindow/View3D/View3DWidget.cs +++ b/MatterControlLib/PartPreviewWindow/View3D/View3DWidget.cs @@ -45,6 +45,7 @@ using MatterHackers.DataConverters3D; using MatterHackers.Localizations; using MatterHackers.MatterControl.CustomWidgets; using MatterHackers.MatterControl.DesignTools; +using MatterHackers.MatterControl.Extensibility; using MatterHackers.MatterControl.Library; using MatterHackers.MatterControl.PrinterControls.PrinterConnections; using MatterHackers.MatterControl.SlicerConfiguration; @@ -353,10 +354,10 @@ namespace MatterHackers.MatterControl.PartPreviewWindow interactionVolumes.Add(new SelectionShadow(this.InteractionLayer)); interactionVolumes.Add(new SnappingIndicators(this.InteractionLayer, this.CurrentSelectInfo)); - var interactionVolumePlugins = PluginFinder.CreateInstancesOf(); - foreach (InteractionVolumePlugin plugin in interactionVolumePlugins) + // Add IAVolumeProviderPlugins + foreach (var ivProvider in ApplicationController.Instance.Extensions.IAVolumeProviders) { - interactionVolumes.Add(plugin.CreateInteractionVolume(this.InteractionLayer)); + interactionVolumes.AddRange(ivProvider.Create(this.InteractionLayer)); } meshViewerWidget.AfterDraw += AfterDraw3DContent; diff --git a/MatterControlLib/SettingsManagement/ApplicationSettingsPage.cs b/MatterControlLib/SettingsManagement/ApplicationSettingsPage.cs index a01c3e48a..ab90f4520 100644 --- a/MatterControlLib/SettingsManagement/ApplicationSettingsPage.cs +++ b/MatterControlLib/SettingsManagement/ApplicationSettingsPage.cs @@ -77,9 +77,11 @@ namespace MatterHackers.MatterControl // Camera Monitoring bool hasCamera = true || ApplicationSettings.Instance.get(ApplicationSettingsKey.HardwareHasCamera) == "true"; + var configureIcon = AggContext.StaticData.LoadIcon("fa-cog_16.png", IconColor.Raw); + var previewButton = new IconButton(configureIcon, theme) { - ToolTipText = "Configure Camera View".Localize() + ToolTipText = "Preview".Localize() }; previewButton.Click += (s, e) => { @@ -362,6 +364,28 @@ namespace MatterHackers.MatterControl theme), advancedPanel); +#if DEBUG + var configurePluginsButton = new IconButton(configureIcon, theme) + { + ToolTipText = "Configure Plugins".Localize(), + Margin = 0 + }; + configurePluginsButton.Click += (s, e) => + { + UiThread.RunOnIdle(() => + { + DialogWindow.Show(); + }); + }; + + this.AddSettingsRow( + new SettingsItem( + "Plugins".Localize(), + configurePluginsButton, + theme), + advancedPanel); +#endif + advancedPanel.Children().First().Border = new BorderDouble(0, 1); // Enforce consistent SectionWidget spacing and last child borders diff --git a/PluginSystem/MatterControlPluginBase.cs b/PluginSystem/MatterControlPluginBase.cs deleted file mode 100644 index 40457e107..000000000 --- a/PluginSystem/MatterControlPluginBase.cs +++ /dev/null @@ -1,59 +0,0 @@ -using MatterHackers.Agg.UI; -using System; - -namespace MatterHackers.MatterControl.PluginSystem -{ - public class MatterControlPlugin - { - /// - /// Each plugin that is found will be instantiated and passed the main application widget. - /// It is then up to the plugin to do whatever initialization or registration that it requires. - /// - /// - public virtual void Initialize(GuiWidget application) - { - } - - /// - /// Return a json string representing plugin information - /// { - /// "Name": "MatterHackers Test Plugin", - /// "UUID": "22cf8c90-66c3-11e3-949a-0800200c9a66", - /// "About": "This is a sample plugin info that shows some of the expected values that can be present in a plugin info.", - /// "Developer": "MatterHackers, Inc." - /// "URL": "https://www.matterhackers.com" - /// } - /// - /// - public virtual string GetPluginInfoJSon() - { - return ""; - } - - public static GuiWidget FindNamedWidgetRecursive(GuiWidget root, string name) - { - foreach (GuiWidget child in root.Children) - { - if (child.Name == name) - { - return child; - } - - GuiWidget foundWidget = FindNamedWidgetRecursive(child, name); - if (foundWidget != null) - { - return foundWidget; - } - } - - return null; - } - - public static void AssertDebugNotDefined() - { -#if DEBUG - throw new Exception("DEBUG is defined and should not be!"); -#endif - } - } -} \ No newline at end of file diff --git a/Tests/MatterControl.AutomationTests/MatterControl.AutomationTests.csproj b/Tests/MatterControl.AutomationTests/MatterControl.AutomationTests.csproj index de4067ede..3ba5f046e 100644 --- a/Tests/MatterControl.AutomationTests/MatterControl.AutomationTests.csproj +++ b/Tests/MatterControl.AutomationTests/MatterControl.AutomationTests.csproj @@ -75,6 +75,10 @@ + + {2af30557-fc50-4de3-ad1c-7eb57131a9c5} + MatterControl.Common + {97d5ade3-c1b4-4b46-8a3e-718a4f7f079f} MatterControl.Printing @@ -87,10 +91,6 @@ {D557B079-612F-467F-AE0D-3F77BCD627F7} MatterControlLib - - {865172a0-a1a9-49c2-9386-f2fdb4e141b7} - MatterControlPluginSystem - {657dbc6d-c3ea-4398-a3fa-ddb73c14f71b} Agg diff --git a/Tests/MatterControl.Tests/MatterControl.Tests.csproj b/Tests/MatterControl.Tests/MatterControl.Tests.csproj index 2050ad8b4..2fa4cd81f 100644 --- a/Tests/MatterControl.Tests/MatterControl.Tests.csproj +++ b/Tests/MatterControl.Tests/MatterControl.Tests.csproj @@ -83,6 +83,10 @@ {f1653f20-d47d-4f29-8c55-3c835542af5f} Community.CsharpSqlite + + {2af30557-fc50-4de3-ad1c-7eb57131a9c5} + MatterControl.Common + {97d5ade3-c1b4-4b46-8a3e-718a4f7f079f} MatterControl.Printing @@ -95,10 +99,6 @@ {D557B079-612F-467F-AE0D-3F77BCD627F7} MatterControlLib - - {865172a0-a1a9-49c2-9386-f2fdb4e141b7} - MatterControlPluginSystem - {657dbc6d-c3ea-4398-a3fa-ddb73c14f71b} Agg