diff --git a/ApplicationView/MainApplicationWidget.cs b/ApplicationView/MainApplicationWidget.cs index 21da53d44..916d552c7 100644 --- a/ApplicationView/MainApplicationWidget.cs +++ b/ApplicationView/MainApplicationWidget.cs @@ -296,8 +296,6 @@ namespace MatterHackers.MatterControl return monoSpacedTypeFace; } - - private set { } } /// diff --git a/ControlElements/RegisteredCreators.cs b/ControlElements/RegisteredCreators.cs index dd72da441..243213062 100644 --- a/ControlElements/RegisteredCreators.cs +++ b/ControlElements/RegisteredCreators.cs @@ -45,19 +45,20 @@ namespace MatterHackers.MatterControl.CreatorPlugins public delegate void UnlockRegisterFunction(EventHandler functionToCallOnEvent, ref EventHandler functionThatWillBeCalledToUnregisterEvent); public UnlockRegisterFunction unlockRegisterFunction; - public EventHandler functionToLaunchCreator; + public Action Show; public string iconPath; public string description; public bool paidAddOnFlag; - public CreatorInformation(EventHandler functionToLaunchCreator, + public CreatorInformation( + Action showFunction, string iconPath, string description, bool paidAddOnFlag = false, UnlockFunction unlockFunction = null, PermissionFunction permissionFunction = null, UnlockRegisterFunction unlockRegisterFunction = null) { - this.functionToLaunchCreator = functionToLaunchCreator; + this.Show = showFunction; this.iconPath = iconPath; this.description = description; this.paidAddOnFlag = paidAddOnFlag; diff --git a/CustomWidgets/PluginChooserWindow.cs b/CustomWidgets/PluginChooserWindow.cs index 07e4ed80b..247820420 100644 --- a/CustomWidgets/PluginChooserWindow.cs +++ b/CustomWidgets/PluginChooserWindow.cs @@ -259,13 +259,11 @@ namespace MatterHackers.MatterControl.CreatorPlugins private void CloseOnIdle(object state) { Close(); - CreatorInformation callCorrectFunctionHold = state as CreatorInformation; - if (callCorrectFunctionHold != null) + + CreatorInformation creatorInfo = state as CreatorInformation; + if (creatorInfo != null) { - UiThread.RunOnIdle(() => - { - callCorrectFunctionHold.functionToLaunchCreator(null, null); - }); + UiThread.RunOnIdle(creatorInfo.Show); } } } diff --git a/PartPreviewWindow/ViewGcodeWidget.cs b/PartPreviewWindow/ViewGcodeWidget.cs index e724f8439..ca156d185 100644 --- a/PartPreviewWindow/ViewGcodeWidget.cs +++ b/PartPreviewWindow/ViewGcodeWidget.cs @@ -45,7 +45,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow { public class ViewGcodeWidget : GuiWidget { - public EventHandler DoneLoading; + public event EventHandler DoneLoading; public ProgressChangedEventHandler LoadingProgressChanged; diff --git a/PrinterControls/EditMacrosWindow.cs b/PrinterControls/EditMacrosWindow.cs index 7fca54cb5..de2e10ea4 100644 --- a/PrinterControls/EditMacrosWindow.cs +++ b/PrinterControls/EditMacrosWindow.cs @@ -34,7 +34,6 @@ using MatterHackers.Agg.UI; using MatterHackers.Localizations; using MatterHackers.MatterControl.CustomWidgets; using MatterHackers.MatterControl.FieldValidation; -using MatterHackers.MatterControl.PrinterControls; using MatterHackers.MatterControl.SlicerConfiguration; using MatterHackers.VectorMath; @@ -43,15 +42,13 @@ namespace MatterHackers.MatterControl public class EditMacrosWindow : SystemWindow { public GCodeMacro ActiveMacro; - public EventHandler FunctionToCallOnSave; private static EditMacrosWindow editMacrosWindow = null; - public EditMacrosWindow(EventHandler functionToCallOnSave) + public EditMacrosWindow() : base(560, 420) { AlwaysOnTopOfMain = true; Title = "Macro Editor".Localize(); - this.FunctionToCallOnSave = functionToCallOnSave; BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor; ChangeToMacroList(); ShowAsSystemWindow(); @@ -62,7 +59,7 @@ namespace MatterHackers.MatterControl { if (editMacrosWindow == null) { - editMacrosWindow = new EditMacrosWindow(ReloadMacros); + editMacrosWindow = new EditMacrosWindow(); editMacrosWindow.Closed += (popupWindowSender, popupWindowSenderE) => { editMacrosWindow = null; }; } else @@ -88,7 +85,7 @@ namespace MatterHackers.MatterControl UiThread.RunOnIdle(DoChangeToMacroList); } - protected static void ReloadMacros(object sender, EventArgs e) + public void RefreshMacros() { ActiveSliceSettings.Instance.Save(); ApplicationController.Instance.ReloadAll(); @@ -284,7 +281,8 @@ namespace MatterHackers.MatterControl if (ValidateMacroForm()) { SaveActiveMacro(); - windowController.FunctionToCallOnSave(this, null); + + windowController.RefreshMacros(); windowController.ChangeToMacroList(); } }); @@ -372,8 +370,8 @@ namespace MatterHackers.MatterControl macroRow.AddChild(new HorizontalSpacer()); - // You can't pass a foreach variable into a link function or it wall always be the last item. - // So we make a local variable copy of it and pass that. This will get the right one. + // You can't use the foreach variable inside the lambda functions directly or it will always be the last item. + // We make a local variable to create a closure around it to ensure we get the correct instance var localMacroReference = macro; Button editLink = linkButtonFactory.Generate("edit".Localize()); @@ -388,7 +386,8 @@ namespace MatterHackers.MatterControl removeLink.Click += (sender, e) => { ActiveSliceSettings.Instance.Macros.Remove(localMacroReference); - windowController.FunctionToCallOnSave(this, null); + + windowController.RefreshMacros(); windowController.ChangeToMacroList(); }; macroRow.AddChild(removeLink); diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index 96c879330..87b30048a 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit 96c879330d24238469b5f5a91df84d4842f0e527 +Subproject commit 87b30048af006ae4c3028d790594daac31cb9c6e diff --git a/Tests/MatterControl.AutomationTests/SliceSetingsTests.cs b/Tests/MatterControl.AutomationTests/SliceSetingsTests.cs index 4c086df4f..94f502742 100644 --- a/Tests/MatterControl.AutomationTests/SliceSetingsTests.cs +++ b/Tests/MatterControl.AutomationTests/SliceSetingsTests.cs @@ -121,7 +121,7 @@ namespace MatterHackers.MatterControl.Tests.Automation testRunner.Wait(.1); } - [Test, Apartment(ApartmentState.STA)] + [Test, Apartment(ApartmentState.STA) /* Test will fail if screen size is and "HeatBeforeHoming" falls below the fold */] public async Task ClearingCheckBoxClearsUserOverride() { AutomationTest testToRun = (testRunner) => diff --git a/TextCreator/TextCreator.cs b/TextCreator/TextCreator.cs index bba814757..a32494f41 100644 --- a/TextCreator/TextCreator.cs +++ b/TextCreator/TextCreator.cs @@ -37,17 +37,14 @@ namespace MatterHackers.MatterControl.Plugins.TextCreator { public class TextCreatorPlugin : MatterControlPlugin { - public TextCreatorPlugin() - { - } - - private GuiWidget mainApplication; - public override void Initialize(GuiWidget application) { - CreatorInformation information = new CreatorInformation(LaunchNewTextCreator, "TC_32x32.png", "Text Creator".Localize()); + var information = new CreatorInformation( + () => new TextCreatorMainWindow(), + "TC_32x32.png", + "Text Creator".Localize()); + RegisteredCreators.Instance.RegisterLaunchFunction(information); - mainApplication = application; } public override string GetPluginInfoJSon() @@ -60,10 +57,5 @@ namespace MatterHackers.MatterControl.Plugins.TextCreator "\"URL\": \"https://www.matterhackers.com\"" + "}"; } - - public void LaunchNewTextCreator(object sender, EventArgs e) - { - TextCreatorMainWindow mainWindow = new TextCreatorMainWindow(); - } } } \ No newline at end of file