diff --git a/MatterControlLib/ActionBar/TemperatureWidgetBed.cs b/MatterControlLib/ActionBar/TemperatureWidgetBed.cs index 84fd29045..17f33a94a 100644 --- a/MatterControlLib/ActionBar/TemperatureWidgetBed.cs +++ b/MatterControlLib/ActionBar/TemperatureWidgetBed.cs @@ -145,7 +145,7 @@ namespace MatterHackers.MatterControl.ActionBar { graph.AddData(this.ActualTemperature); }, 1); - this.Closed += (s, e) => runningInterval.Continue = false; + this.Closed += (s, e) => UiThread.ClearInterval(runningInterval); var settingsRow = temperatureRow.DescendantsAndSelf().FirstOrDefault(); void SettingChanged(object s, EventArgs e) diff --git a/MatterControlLib/ActionBar/TemperatureWidgetExtruder.cs b/MatterControlLib/ActionBar/TemperatureWidgetExtruder.cs index 8aac03004..b811c6419 100644 --- a/MatterControlLib/ActionBar/TemperatureWidgetExtruder.cs +++ b/MatterControlLib/ActionBar/TemperatureWidgetExtruder.cs @@ -288,7 +288,7 @@ namespace MatterHackers.MatterControl.ActionBar { graph.AddData(this.ActualTemperature); }, 1); - this.Closed += (s, e) => runningInterval.Continue = false; + this.Closed += (s, e) => UiThread.ClearInterval(runningInterval); var valueField = temperatureRow.Descendants().FirstOrDefault(); valueField.Name = "Temperature Input"; diff --git a/MatterControlLib/ApplicationView/ApplicationController.cs b/MatterControlLib/ApplicationView/ApplicationController.cs index 97c17f499..fc4cb6598 100644 --- a/MatterControlLib/ApplicationView/ApplicationController.cs +++ b/MatterControlLib/ApplicationView/ApplicationController.cs @@ -402,6 +402,8 @@ namespace MatterHackers.MatterControl { this.OnOpenPrintersChanged(new OpenPrintersChangedEventArgs(printer, OpenPrintersChangedEventArgs.OperationType.Remove)); } + + printer.Dispose(); } diff --git a/MatterControlLib/ApplicationView/ThumbnailsConfig.cs b/MatterControlLib/ApplicationView/ThumbnailsConfig.cs index 8808e0ce4..22b222bc3 100644 --- a/MatterControlLib/ApplicationView/ThumbnailsConfig.cs +++ b/MatterControlLib/ApplicationView/ThumbnailsConfig.cs @@ -91,12 +91,14 @@ namespace MatterHackers.MatterControl { // try to load it from the users cache var expectedCachePath = this.CachePath(libraryItem, width, height); + ImageBuffer cachedItem = LoadImage(expectedCachePath); if(cachedItem != null) { cachedItem.SetRecieveBlender(new BlenderPreMultBGRA()); return cachedItem; } + // if we don't find it see if it is in the cache at a bigger size foreach(var cacheSize in CacheSizes.Where(s => s > width)) { @@ -104,8 +106,10 @@ namespace MatterHackers.MatterControl if(cachedItem != null) { cachedItem = cachedItem.CreateScaledImage(width, height); - AggContext.ImageIO.SaveImageData(expectedCachePath, cachedItem); cachedItem.SetRecieveBlender(new BlenderPreMultBGRA()); + + AggContext.ImageIO.SaveImageData(expectedCachePath, cachedItem); + return cachedItem; } } @@ -115,9 +119,12 @@ namespace MatterHackers.MatterControl if (AggContext.StaticData.FileExists(staticDataFilename)) { cachedItem = AggContext.StaticData.LoadImage(staticDataFilename); - cachedItem = cachedItem.CreateScaledImage(width, height); - AggContext.ImageIO.SaveImageData(expectedCachePath, cachedItem); cachedItem.SetRecieveBlender(new BlenderPreMultBGRA()); + + cachedItem = cachedItem.CreateScaledImage(width, height); + + AggContext.ImageIO.SaveImageData(expectedCachePath, cachedItem); + return cachedItem; } diff --git a/MatterControlLib/ConfigurationPage/PrintLeveling/LoadFilamentWizard.cs b/MatterControlLib/ConfigurationPage/PrintLeveling/LoadFilamentWizard.cs index 3a6e9ce50..4fad9dfa1 100644 --- a/MatterControlLib/ConfigurationPage/PrintLeveling/LoadFilamentWizard.cs +++ b/MatterControlLib/ConfigurationPage/PrintLeveling/LoadFilamentWizard.cs @@ -151,7 +151,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling int secondsToRun = 300; if (runningTime.ElapsedMilliseconds > secondsToRun * 1000) { - runningGCodeCommands.Continue = false; + UiThread.ClearInterval(runningGCodeCommands); } } }, @@ -159,19 +159,17 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling }, BecomingInactive = () => { - if (runningGCodeCommands != null - && runningGCodeCommands.Continue) + if (runningGCodeCommands != null) { - runningGCodeCommands.Continue = false; + UiThread.ClearInterval(runningGCodeCommands); } } }; insertFilamentPage.Closed += (s, e) => { - if (runningGCodeCommands != null - && runningGCodeCommands.Continue) + if (runningGCodeCommands != null) { - runningGCodeCommands.Continue = false; + UiThread.ClearInterval(runningGCodeCommands); } }; @@ -251,11 +249,10 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling } } - if (runningGCodeCommands.Continue == true - && progressBar.RatioComplete == 1 + if (progressBar.RatioComplete == 1 && remainingLengthMm <= .001) { - runningGCodeCommands.Continue = false; + UiThread.ClearInterval(runningGCodeCommands); loadingFilamentPage.NextButton.InvokeClick(); } }, @@ -263,18 +260,12 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling }, BecomingInactive = () => { - if (runningGCodeCommands.Continue) - { - runningGCodeCommands.Continue = false; - } + UiThread.ClearInterval(runningGCodeCommands); } }; loadingFilamentPage.Closed += (s, e) => { - if (runningGCodeCommands.Continue) - { - runningGCodeCommands.Continue = false; - } + UiThread.ClearInterval(runningGCodeCommands); }; yield return loadingFilamentPage; @@ -320,7 +311,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling int secondsToRun = 90; if (runningTime.ElapsedMilliseconds > secondsToRun * 1000) { - runningGCodeCommands.Continue = false; + UiThread.ClearInterval(runningGCodeCommands); } } }, @@ -328,18 +319,12 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling }, BecomingInactive = () => { - if (runningGCodeCommands.Continue) - { - runningGCodeCommands.Continue = false; - } + UiThread.ClearInterval(runningGCodeCommands); } }; runningCleanPage.Closed += (s, e) => { - if (runningGCodeCommands.Continue) - { - runningGCodeCommands.Continue = false; - } + UiThread.ClearInterval(runningGCodeCommands); printer.Settings.SetValue(SettingsKey.filament_has_been_loaded, "1"); }; diff --git a/MatterControlLib/ConfigurationPage/PrintLeveling/UnloadFilamentWizard.cs b/MatterControlLib/ConfigurationPage/PrintLeveling/UnloadFilamentWizard.cs index f6cc549bc..749397bd2 100644 --- a/MatterControlLib/ConfigurationPage/PrintLeveling/UnloadFilamentWizard.cs +++ b/MatterControlLib/ConfigurationPage/PrintLeveling/UnloadFilamentWizard.cs @@ -171,11 +171,10 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling } } - if (runningGCodeCommands.Continue == true - && progressBar.RatioComplete == 1 + if (progressBar.RatioComplete == 1 && remainingLengthMm <= .001) { - runningGCodeCommands.Continue = false; + UiThread.ClearInterval(runningGCodeCommands); unloadingFilamentPage.NextButton.InvokeClick(); } }, @@ -183,18 +182,12 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling }, BecomingInactive = () => { - if (runningGCodeCommands.Continue) - { - runningGCodeCommands.Continue = false; - } + UiThread.ClearInterval(runningGCodeCommands); } }; unloadingFilamentPage.Closed += (s, e) => { - if (runningGCodeCommands.Continue) - { - runningGCodeCommands.Continue = false; - } + UiThread.ClearInterval(runningGCodeCommands); }; yield return unloadingFilamentPage; diff --git a/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/FindBedHeight.cs b/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/FindBedHeight.cs index 142eeab12..68bd8c519 100644 --- a/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/FindBedHeight.cs +++ b/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/FindBedHeight.cs @@ -81,7 +81,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling zPosition.Text = "Z: {0:0.00}".FormatWith(destinationPosition.Z); }, .3); - this.Closed += (s, e) => runningInterval.Continue = false; + this.Closed += (s, e) => UiThread.ClearInterval(runningInterval); zButtonsAndInfo.AddChild(zPosition); diff --git a/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/WaitForTempPage.cs b/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/WaitForTempPage.cs index 2864919e8..49a2044de 100644 --- a/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/WaitForTempPage.cs +++ b/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/WaitForTempPage.cs @@ -168,7 +168,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling bedStartingTemp = printer.Connection.ActualBedTemperature; var runningInterval = UiThread.SetInterval(ShowTempChangeProgress, 1); - this.Closed += (s, e) => runningInterval.Continue = false; + this.Closed += (s, e) => UiThread.ClearInterval(runningInterval); if (bedTargetTemp > 0) { diff --git a/MatterControlLib/ControlElements/AttentionGetter.cs b/MatterControlLib/ControlElements/AttentionGetter.cs index ab05d1a95..28d7a2b46 100644 --- a/MatterControlLib/ControlElements/AttentionGetter.cs +++ b/MatterControlLib/ControlElements/AttentionGetter.cs @@ -128,7 +128,7 @@ namespace MatterHackers.MatterControl timeSinceStart = Stopwatch.StartNew(); widgetToHighlight.AfterDraw -= ConnectToWidget; var runningInterval = UiThread.SetInterval(ChangeBackgroundColor, animationDelay); - parent.Closed += (s, e2) => runningInterval.Continue = false; + parent.Closed += (s, e2) => UiThread.ClearInterval(runningInterval); } } } \ No newline at end of file diff --git a/MatterControlLib/CustomWidgets/InlineEditControl.cs b/MatterControlLib/CustomWidgets/InlineEditControl.cs index e7a4c4933..19b9cb18b 100644 --- a/MatterControlLib/CustomWidgets/InlineEditControl.cs +++ b/MatterControlLib/CustomWidgets/InlineEditControl.cs @@ -82,7 +82,7 @@ namespace MatterHackers.MatterControl.CustomWidgets HAnchor = HAnchor.Fit; var runningInterval = UiThread.SetInterval(HideIfApplicable, .1); - this.Closed += (s, e) => runningInterval.Continue = false; + this.Closed += (s, e) => UiThread.ClearInterval(runningInterval); } public Color TextColor { get; set; } = Color.Black; diff --git a/MatterControlLib/Library/Providers/FileSystem/FileSystemContainer.cs b/MatterControlLib/Library/Providers/FileSystem/FileSystemContainer.cs index 3f51fa725..50769a3f8 100644 --- a/MatterControlLib/Library/Providers/FileSystem/FileSystemContainer.cs +++ b/MatterControlLib/Library/Providers/FileSystem/FileSystemContainer.cs @@ -118,13 +118,16 @@ namespace MatterHackers.MatterControl.Library } long lastTimeContentsChanged; - RunningInterval waitingForRefresh; + + private RunningInterval waitingForRefresh; + private void DirectoryContentsChanged(object sender, EventArgs e) { // Flag for reload isDirty = true; lastTimeContentsChanged = UiThread.CurrentTimerMs; + // Only refresh content if we're the active container if (isActiveContainer && waitingForRefresh == null) @@ -138,7 +141,8 @@ namespace MatterHackers.MatterControl.Library if (UiThread.CurrentTimerMs > lastTimeContentsChanged + 500 && waitingForRefresh != null) { - waitingForRefresh.Continue = false; + UiThread.ClearInterval(waitingForRefresh); + waitingForRefresh = null; this.ReloadContent(); } diff --git a/MatterControlLib/PartPreviewWindow/MainViewWidget.cs b/MatterControlLib/PartPreviewWindow/MainViewWidget.cs index 6117e5eeb..7f2bb145e 100644 --- a/MatterControlLib/PartPreviewWindow/MainViewWidget.cs +++ b/MatterControlLib/PartPreviewWindow/MainViewWidget.cs @@ -177,7 +177,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow { if (showUpdateInterval != null) { - showUpdateInterval.Continue = false; + UiThread.ClearInterval(showUpdateInterval); showUpdateInterval = null; } return; diff --git a/MatterControlLib/PartPreviewWindow/PrinterTabPage.cs b/MatterControlLib/PartPreviewWindow/PrinterTabPage.cs index 23f749fc4..11c8252cb 100644 --- a/MatterControlLib/PartPreviewWindow/PrinterTabPage.cs +++ b/MatterControlLib/PartPreviewWindow/PrinterTabPage.cs @@ -630,7 +630,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow break; } }, 1); - bodyRow.Closed += (s, e) => runningInterval.Continue = false; + bodyRow.Closed += (s, e) => UiThread.ClearInterval(runningInterval); bodyRow.Visible = false; diff --git a/MatterControlLib/PartPreviewWindow/RunningTaskRow.cs b/MatterControlLib/PartPreviewWindow/RunningTaskRow.cs index d09601267..73a82a666 100644 --- a/MatterControlLib/PartPreviewWindow/RunningTaskRow.cs +++ b/MatterControlLib/PartPreviewWindow/RunningTaskRow.cs @@ -125,7 +125,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow } if (this.HasBeenClosed) { - runningInterval.Continue = false; + UiThread.ClearInterval(runningInterval); } }, .2); diff --git a/MatterControlLib/PrinterCommunication/PrinterConnection.cs b/MatterControlLib/PrinterCommunication/PrinterConnection.cs index b91d1aa54..899cd2966 100644 --- a/MatterControlLib/PrinterCommunication/PrinterConnection.cs +++ b/MatterControlLib/PrinterCommunication/PrinterConnection.cs @@ -84,9 +84,9 @@ namespace MatterHackers.MatterControl.PrinterCommunication public event EventHandler BedTemperatureRead; - public EventHandler CommunicationStateChanged; + public event EventHandler CommunicationStateChanged; - public EventHandler ConnectionFailed; + public event EventHandler ConnectionFailed; public event EventHandler ConnectionSucceeded; @@ -101,9 +101,9 @@ namespace MatterHackers.MatterControl.PrinterCommunication public event EventHandler HotendTemperatureRead; - public EventHandler FanSpeedSet; + public event EventHandler FanSpeedSet; - public EventHandler FirmwareVersionRead; + public event EventHandler FirmwareVersionRead; public void OnFilamentRunout(NamedItemEventArgs namedItemEventArgs) { diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index 190c148a7..b118a6cbf 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit 190c148a7494d0a13ee318f5f3a80dc9f6989e61 +Subproject commit b118a6cbf254179ec6e6e70b394c4ca29cadf883