Open printer if count == 1

This commit is contained in:
jlewin 2019-05-07 11:50:01 -07:00
parent fcae79528d
commit 728a2c421b

View file

@ -28,6 +28,7 @@ either expressed or implied, of the FreeBSD Project.
*/
using System;
using System.Linq;
using MatterHackers.Agg.Platform;
using MatterHackers.Agg.UI;
using MatterHackers.Localizations;
@ -45,10 +46,25 @@ namespace MatterHackers.MatterControl
: base(continueButtonText)
{
this.printerLoaded = printerLoaded;
HardwareTreeView.CreatePrinterProfilesTree(rootPrintersNode, theme);
}
public override async void OnLoad(EventArgs args)
{
base.OnLoad(args);
if (ProfileManager.Instance.ActiveProfiles.Count() == 1)
{
// select the printer
var printerInfo = ProfileManager.Instance.ActiveProfiles.FirstOrDefault();
var printer = await ApplicationController.Instance.OpenEmptyPrinter(printerInfo.ID);
printerLoaded?.Invoke(printer);
this.DialogWindow.CloseOnIdle();
}
}
protected override void OnTreeNodeDoubleClicked(TreeNode treeNode)
{
if (treeNode.Tag is PrinterInfo printerInfo)