Add 'Print' menu action, implement Print for GCode and SD card GCode

- Fix and rename CloseShouldNotStopSDPrint test
- Fix product bugs regarding selecting and printing GCode
This commit is contained in:
John Lewin 2017-06-21 07:43:40 -07:00
parent aba13453a7
commit d9b28cdd86
5 changed files with 56 additions and 12 deletions

View file

@ -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;

View file

@ -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)
{

View file

@ -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()
{

View file

@ -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

View file

@ -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;