Merge pull request #4014 from jlewin/master

Use HoverImageWidget
This commit is contained in:
johnlewin 2018-11-21 19:34:53 -08:00 committed by GitHub
commit d8564f4076
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 54 additions and 20 deletions

View file

@ -348,7 +348,7 @@ namespace MatterHackers.MatterControl
// PrinterConnection.IsPrinterConnected, that could should be updated to iterate ActiverPrinters, checking each one and acting on each as it would
// have for the single case
[Obsolete("ActivePrinter references should be migrated to logic than supports multi-printer mode")]
public PrinterConfig ActivePrinter { get; private set; } = PrinterConfig.EmptyPrinter;
public PrinterConfig ActivePrinter => this.ActivePrinters.FirstOrDefault() ?? PrinterConfig.EmptyPrinter;
public Action RedeemDesignCode;
public Action EnterShareCode;

View file

@ -44,9 +44,9 @@ namespace MatterHackers.MatterControl
public class ThemeConfig
{
private static ImageBuffer restoreNormal;
private static ImageBuffer restoreHover;
private static ImageBuffer restorePressed;
private ImageBuffer restoreNormal;
private ImageBuffer restoreHover;
private ImageBuffer restorePressed;
public int FontSize7 { get; } = 7;
public int FontSize8 { get; } = 8;
@ -421,14 +421,9 @@ namespace MatterHackers.MatterControl
return imageBuffer;
}
public Button CreateSmallResetButton()
public GuiWidget CreateSmallResetButton()
{
return new Button(
new ButtonViewStates(
new ImageWidget(restoreNormal),
new ImageWidget(restoreHover),
new ImageWidget(restorePressed),
new ImageWidget(restoreNormal)))
return new HoverImageWidget(restoreNormal, restoreHover)
{
VAnchor = VAnchor.Center,
Margin = new BorderDouble(0, 0, 5, 0)

View file

@ -515,7 +515,7 @@ namespace MatterHackers.MatterControl.PrintLibrary
public class SearchInputBox : GuiWidget
{
internal MHTextEditWidget searchInput;
public Button ResetButton { get; }
public GuiWidget ResetButton { get; }
public SearchInputBox(ThemeConfig theme, string emptyText = null)
{

View file

@ -248,7 +248,7 @@ namespace MatterHackers.MatterControl.PrinterControls
public class ZTuningWidget : GuiWidget
{
private TextWidget zOffsetStreamDisplay;
private Button clearZOffsetButton;
private GuiWidget clearZOffsetButton;
private FlowLayoutWidget zOffsetStreamContainer;
private bool allowRemoveButton;

View file

@ -46,7 +46,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
private GuiWidget dataArea;
private GuiWidget unitsArea;
private GuiWidget restoreArea;
private Button restoreButton = null;
private GuiWidget restoreButton = null;
public SliceSettingsRow(PrinterConfig printer, SettingsContext settingsContext, SliceSettingData settingData, ThemeConfig theme, bool fullRowSelect = false)
: base (settingData.PresentationName.Localize(), settingData.HelpText.Localize(), theme, fullRowSelect: fullRowSelect)

View file

@ -6,6 +6,7 @@ using MatterHackers.Agg;
using MatterHackers.Agg.Platform;
using MatterHackers.Agg.UI;
using MatterHackers.GuiAutomation;
using MatterHackers.MatterControl.PartPreviewWindow;
using MatterHackers.MatterControl.SlicerConfiguration;
using MatterHackers.VectorMath;
using NUnit.Framework;
@ -498,7 +499,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
testRunner.AddAndSelectPrinter("Airwolf 3D", "HD");
testRunner.SwitchToSliceSettings();
var printer = ApplicationController.Instance.ActivePrinter;
var printer = ApplicationController.Instance.ActivePrinters.First();
testRunner.SelectSliceSettingsField("Advanced", "layer_height");
testRunner.Type(".5");
@ -515,17 +516,24 @@ namespace MatterHackers.MatterControl.Tests.Automation
testRunner.WaitFor(() => printer.Settings.GetValue<double>(SettingsKey.layer_height) == 0.1);
Assert.AreEqual(printer.Settings.GetValue<double>(SettingsKey.layer_height).ToString(), "0.1", "Layer height is the fine override");
// Close Airwolf
CloseFirstPrinterTab(testRunner);
testRunner.AddAndSelectPrinter("BCN", "Sigma");
// Check Guest printer count
Assert.AreEqual(2, ProfileManager.Instance.ActiveProfiles.Count(), "ProfileManager has 2 Profiles");
Assert.AreEqual(2, ProfileManager.Instance.ActiveProfiles.Count(), "ProfileManager has 2 profiles");
Assert.AreEqual(1, ProfileManager.Instance.OpenPrinterIDs.Count(), "ProfileManager has 1 open profiles");
// Check if Guest printer names exists in dropdown
// Close BCN
CloseFirstPrinterTab(testRunner);
// Reopen Airwolf
testRunner.SwitchToHardwareTab();
testRunner.DoubleClickByName("Airwolf 3D HD Node");
testRunner.Delay(0.2);
printer = ApplicationController.Instance.ActivePrinter;
printer = ApplicationController.Instance.ActivePrinters.First();
testRunner.WaitFor(() => printer.Settings.GetValue<double>(SettingsKey.layer_height) == 0.1);
Assert.AreEqual(printer.Settings.GetValue<double>(SettingsKey.layer_height).ToString(), "0.1", "Layer height is the fine override");
@ -542,5 +550,30 @@ namespace MatterHackers.MatterControl.Tests.Automation
return Task.CompletedTask;
}, maxTimeToRun: 120);
}
private void CloseFirstPrinterTab(AutomationRunner testRunner)
{
// Close all printer tabs
var mainViewWidget = testRunner.GetWidgetByName("PartPreviewContent", out _) as MainViewWidget;
if (mainViewWidget.TabControl.AllTabs.First(t => t.TabContent is PrinterTabPage) is GuiWidget widget)
{
var closeWidget = widget.Descendants<ImageWidget>().First();
closeWidget.InvokeClick();
}
}
private void CloseAllPrinterTabs(AutomationRunner testRunner)
{
// Close all printer tabs
var mainViewWidget = testRunner.GetWidgetByName("PartPreviewContent", out _) as MainViewWidget;
foreach (var tab in mainViewWidget.TabControl.AllTabs.Where(t => t.TabContent is PrinterTabPage).ToList())
{
if (tab is GuiWidget widget)
{
var closeWidget = widget.Descendants<ImageWidget>().First();
closeWidget.InvokeClick();
}
}
}
}
}

View file

@ -240,7 +240,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
testRunner.WaitForName("Disconnect from printer button");
testRunner.Delay();
if (testRunner.NameExists("Already Loaded Button"))
if (testRunner.NamedWidgetExists("Already Loaded Button"))
{
testRunner.ClickByName("Already Loaded Button");
}
@ -773,7 +773,7 @@ namespace MatterHackers.MatterControl.Tests.Automation
/// <param name="testRunner"></param>
public static void OpenPrintPopupMenu(this AutomationRunner testRunner)
{
var printerConnection = ApplicationController.Instance.ActivePrinter.Connection;
var printerConnection = ApplicationController.Instance.DragDropData.View3DWidget.Printer.Connection;
if (printerConnection.CommunicationState != CommunicationStates.Connected
&& printerConnection.CommunicationState != CommunicationStates.FinishedPrint)
@ -782,6 +782,12 @@ namespace MatterHackers.MatterControl.Tests.Automation
testRunner.WaitFor(() => printerConnection.CommunicationState == CommunicationStates.Connected);
}
if (testRunner.NamedWidgetExists("Finish Setup Button"))
{
testRunner.ClickByName("Finish Setup Button");
testRunner.ClickByName("Already Loaded Button");
}
// Wait for button to become enabled
var printerPopup = testRunner.GetWidgetByName("PrintPopupMenu", out _);
testRunner.WaitFor(() => printerPopup.Enabled);