diff --git a/Library/Widgets/ListView/ListView.cs b/Library/Widgets/ListView/ListView.cs index 060bd0677..dabbd2cb6 100644 --- a/Library/Widgets/ListView/ListView.cs +++ b/Library/Widgets/ListView/ListView.cs @@ -38,6 +38,7 @@ using MatterHackers.Agg.Image; using MatterHackers.Agg.PlatformAbstract; using MatterHackers.Agg.UI; using MatterHackers.MatterControl.Library; +using MatterHackers.MatterControl.PrinterCommunication; using MatterHackers.VectorMath; namespace MatterHackers.MatterControl.CustomWidgets @@ -80,6 +81,17 @@ namespace MatterHackers.MatterControl.CustomWidgets this.ListContentView = new IconListView(); context.ContainerChanged += ActiveContainer_Changed; context.ContainerReloaded += ActiveContainer_Reloaded; + + bool printerConnected = false; + PrinterConnection.Instance.CommunicationStateChanged.RegisterEvent(async (s, e) => + { + bool isConnected = PrinterConnection.Instance.PrinterIsConnected; + if (printerConnected != isConnected) + { + await DisplayContainerContent(ActiveContainer); + printerConnected = isConnected; + } + }, ref unregisterEvents); } public ILibraryContainer ActiveContainer => this.LibraryContext.ActiveContainer; diff --git a/Library/Widgets/ListView/ListViewItemBase.cs b/Library/Widgets/ListView/ListViewItemBase.cs index ea58416d4..7b95c3e78 100644 --- a/Library/Widgets/ListView/ListViewItemBase.cs +++ b/Library/Widgets/ListView/ListViewItemBase.cs @@ -28,6 +28,7 @@ either expressed or implied, of the FreeBSD Project. */ using System; +using System.IO; using System.Threading.Tasks; using MatterHackers.Agg; using MatterHackers.Agg.Image; @@ -145,7 +146,10 @@ namespace MatterHackers.MatterControl.CustomWidgets && ApplicationController.Instance.Library.IsContentFileType(stream.FileName)); bool isContainerLink = listViewItem.Model is ILibraryContainerLink; - if (isContentItem || isValidStream || isContainerLink) + bool isGCode = listViewItem.Model is FileSystemFileItem item && Path.GetExtension(item.FileName.ToUpper()) == ".GCODE" + || listViewItem.Model is SDCardFileItem sdItem && Path.GetExtension(sdItem.Name.ToUpper()) == ".GCODE"; + + if (isContentItem || isValidStream || isContainerLink || isGCode) { if (this.IsSelected) { diff --git a/Library/Widgets/PrintLibraryWidget.cs b/Library/Widgets/PrintLibraryWidget.cs index 2e0144fc7..13f423d41 100644 --- a/Library/Widgets/PrintLibraryWidget.cs +++ b/Library/Widgets/PrintLibraryWidget.cs @@ -37,8 +37,10 @@ using MatterHackers.Agg.UI; using MatterHackers.DataConverters3D; using MatterHackers.Localizations; using MatterHackers.MatterControl.CustomWidgets; +using MatterHackers.MatterControl.DataStorage; using MatterHackers.MatterControl.Library; using MatterHackers.MatterControl.PartPreviewWindow; +using MatterHackers.MatterControl.PrinterCommunication; using MatterHackers.MatterControl.PrintQueue; using MatterHackers.MatterControl.SettingsManagement; using MatterHackers.MatterControl.SlicerConfiguration; @@ -370,17 +372,30 @@ namespace MatterHackers.MatterControl.PrintLibrary { menuActions.Add(new PrintItemAction() { - Title = "Pin to Library", + Title = "Print", AllowMultiple = false, - AllowContainers = true, + AllowContainers = false, AllowProtected = true, Action = (selectedLibraryItems, listView) => { - Console.WriteLine(); + var firstItem = selectedLibraryItems.FirstOrDefault(); + if (firstItem is SDCardFileItem sdcardItem) + { + ApplicationController.Instance.ActivePrintItem = new PrintItemWrapper(new PrintItem(sdcardItem.Name, QueueData.SdCardFileName)); + } + else if (firstItem is FileSystemFileItem fileItem && Path.GetExtension(fileItem.FileName).ToUpper() == ".GCODE") + { + ApplicationController.Instance.ActivePrintItem = new PrintItemWrapper(new PrintItem(fileItem.Name, fileItem.Path)); + } + else + { + //TODO: Otherwise add the selected items to the plate + } + + ApplicationController.Instance.PrintActivePart(); } }); - // edit menu item menuActions.Add(new PrintItemAction() { diff --git a/StaticData/Translations/Master.txt b/StaticData/Translations/Master.txt index ac360a7ac..755e12c2d 100644 --- a/StaticData/Translations/Master.txt +++ b/StaticData/Translations/Master.txt @@ -4225,3 +4225,15 @@ Translated:Location: 'Settings & Controls' -> 'Settings' -> 'General' -> 'Speed' English:Location: 'Settings & Controls' -> 'Settings' -> 'Filament' -> 'Filament' -> 'Retraction' Translated:Location: 'Settings & Controls' -> 'Settings' -> 'Filament' -> 'Filament' -> 'Retraction' +English:Thumbnails +Translated:Thumbnails + +English:Note: Slice Settings are applied before the print actually starts. Changes while printing will not effect the active print. +Translated:Note: Slice Settings are applied before the print actually starts. Changes while printing will not effect the active print. + +English:Material 1 +Translated:Material 1 + +English:Extruder 2 +Translated:Extruder 2 + diff --git a/Tests/MatterControl.AutomationTests/PrintingTests.cs b/Tests/MatterControl.AutomationTests/PrintingTests.cs index 4facb4b70..5d7e0d88b 100644 --- a/Tests/MatterControl.AutomationTests/PrintingTests.cs +++ b/Tests/MatterControl.AutomationTests/PrintingTests.cs @@ -432,7 +432,7 @@ namespace MatterHackers.MatterControl.Tests.Automation } [Test, Category("Emulator")] - public async Task CancelingSdCardPrintLeavesHeatAndFanOn() + public async Task CloseShouldNotStopSDPrint() { await MatterControlUtilities.RunTest((testRunner) => { @@ -442,13 +442,14 @@ namespace MatterHackers.MatterControl.Tests.Automation { Assert.IsTrue(ProfileManager.Instance.ActiveProfile != null); - testRunner.ClickByName("Queue... Menu"); - testRunner.ClickByName(" Remove All Menu Item"); - testRunner.ClickByName("Queue... Menu"); - testRunner.ClickByName(" Load Files Menu Item"); - testRunner.Delay(2); + testRunner.WaitForName("SD Card Row Item Collection"); + testRunner.NavigateToFolder("SD Card Row Item Collection"); + + testRunner.ClickByName("Row Item Item 1.gcode"); + + testRunner.ClickByName("Print Library Overflow Menu", delayBeforeReturn: 1); + testRunner.ClickByName("Print Menu Item"); - testRunner.ClickByName("Start Print Button"); testRunner.Delay(2); int tempChangedCount = 0;