Merge pull request #3990 from jlewin/master
Revise SetInterval implementation
This commit is contained in:
commit
ebafeca415
16 changed files with 48 additions and 57 deletions
|
|
@ -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<SliceSettingsRow>().FirstOrDefault();
|
||||
void SettingChanged(object s, EventArgs e)
|
||||
|
|
|
|||
|
|
@ -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<MHNumberEdit>().FirstOrDefault();
|
||||
valueField.Name = "Temperature Input";
|
||||
|
|
|
|||
|
|
@ -402,6 +402,8 @@ namespace MatterHackers.MatterControl
|
|||
{
|
||||
this.OnOpenPrintersChanged(new OpenPrintersChangedEventArgs(printer, OpenPrintersChangedEventArgs.OperationType.Remove));
|
||||
}
|
||||
|
||||
printer.Dispose();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -177,7 +177,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
{
|
||||
if (showUpdateInterval != null)
|
||||
{
|
||||
showUpdateInterval.Continue = false;
|
||||
UiThread.ClearInterval(showUpdateInterval);
|
||||
showUpdateInterval = null;
|
||||
}
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ namespace MatterHackers.MatterControl.PartPreviewWindow
|
|||
}
|
||||
if (this.HasBeenClosed)
|
||||
{
|
||||
runningInterval.Continue = false;
|
||||
UiThread.ClearInterval(runningInterval);
|
||||
}
|
||||
}, .2);
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 190c148a7494d0a13ee318f5f3a80dc9f6989e61
|
||||
Subproject commit b118a6cbf254179ec6e6e70b394c4ca29cadf883
|
||||
Loading…
Add table
Add a link
Reference in a new issue