Made edit printer available and work on Android

This commit is contained in:
Lars Brubaker 2016-06-07 16:19:26 -07:00
parent 275b320425
commit 6d14dcbbfc
3 changed files with 80 additions and 66 deletions

View file

@ -47,7 +47,7 @@ namespace MatterHackers.MatterControl.ActionBar
private string disconnectAndCancelTitle = "WARNING: Disconnecting will cancel the print.".Localize(); private string disconnectAndCancelTitle = "WARNING: Disconnecting will cancel the print.".Localize();
private Button disconnectPrinterButton; private Button disconnectPrinterButton;
private Button resetConnectionButton; private Button resetConnectionButton;
private PrinterSelector selectActivePrinterButton; private PrinterSelector printerSelector;
private event EventHandler unregisterEvents; private event EventHandler unregisterEvents;
static EventHandler staticUnregisterEvents; static EventHandler staticUnregisterEvents;
@ -110,19 +110,6 @@ namespace MatterHackers.MatterControl.ActionBar
disconnectPrinterButton.VAnchor = VAnchor.ParentTop; disconnectPrinterButton.VAnchor = VAnchor.ParentTop;
disconnectPrinterButton.Cursor = Cursors.Hand; disconnectPrinterButton.Cursor = Cursors.Hand;
selectActivePrinterButton = new PrinterSelector();
selectActivePrinterButton.HAnchor = HAnchor.ParentLeftRight;
selectActivePrinterButton.Cursor = Cursors.Hand;
selectActivePrinterButton.AddPrinter += (s, e) => WizardWindow.Show();
if (ApplicationController.Instance.WidescreenMode)
{
selectActivePrinterButton.Margin = new BorderDouble(0, 6, 0, 3);
}
else
{
selectActivePrinterButton.Margin = new BorderDouble(0, 6, 6, 3);
}
string resetConnectionText = "Reset\nConnection".Localize().ToUpper(); string resetConnectionText = "Reset\nConnection".Localize().ToUpper();
resetConnectionButton = actionBarButtonFactory.Generate(resetConnectionText, "e_stop4.png"); resetConnectionButton = actionBarButtonFactory.Generate(resetConnectionText, "e_stop4.png");
if (ApplicationController.Instance.WidescreenMode) if (ApplicationController.Instance.WidescreenMode)
@ -146,10 +133,22 @@ namespace MatterHackers.MatterControl.ActionBar
{ {
HAnchor = HAnchor.ParentLeftRight, HAnchor = HAnchor.ParentLeftRight,
}; };
printerSelectorAndEditButton.AddChild(selectActivePrinterButton); printerSelector = new PrinterSelector();
printerSelector.HAnchor = HAnchor.ParentLeftRight;
printerSelector.Cursor = Cursors.Hand;
printerSelector.AddPrinter += (s, e) => WizardWindow.Show();
if (ApplicationController.Instance.WidescreenMode)
{
printerSelector.Margin = new BorderDouble(0, 6, 0, 3);
}
else
{
printerSelector.Margin = new BorderDouble(0, 6, 6, 3);
}
printerSelectorAndEditButton.AddChild(printerSelector);
Button editButton = TextImageButtonFactory.GetThemedEditButton(); Button editButton = TextImageButtonFactory.GetThemedEditButton();
editButton.VAnchor = VAnchor.ParentCenter; editButton.VAnchor = VAnchor.ParentCenter;
editButton.Click += EditButton_Click; editButton.Click += UiNavigation.GoToEditPrinter_Click;
printerSelectorAndEditButton.AddChild(editButton); printerSelectorAndEditButton.AddChild(editButton);
this.AddChild(printerSelectorAndEditButton); this.AddChild(printerSelectorAndEditButton);
@ -157,21 +156,6 @@ namespace MatterHackers.MatterControl.ActionBar
//this.AddChild(CreateOptionsMenu()); //this.AddChild(CreateOptionsMenu());
} }
private void EditButton_Click(object sender, EventArgs e)
{
Button editButton = sender as Button;
editButton.ToolTipText = "Edit Current Printer Settings".Localize();
if (editButton != null)
{
editButton.Closed += (s, e2) =>
{
editButton.Click -= EditButton_Click;
};
UiNavigation.GoToPrinterSettings("MatterControl.BaudRate Edit Field,MatterControl.AutoConnect Edit Field,MatterControl.ComPort Edit Field");
}
}
protected override void AddHandlers() protected override void AddHandlers()
{ {
ActiveSliceSettings.ActivePrinterChanged.RegisterEvent(onActivePrinterChanged, ref unregisterEvents); ActiveSliceSettings.ActivePrinterChanged.RegisterEvent(onActivePrinterChanged, ref unregisterEvents);
@ -224,7 +208,7 @@ namespace MatterHackers.MatterControl.ActionBar
{ {
PrinterConnectionAndCommunication.Instance.Stop(); PrinterConnectionAndCommunication.Instance.Stop();
PrinterConnectionAndCommunication.Instance.Disable(); PrinterConnectionAndCommunication.Instance.Disable();
selectActivePrinterButton.Invalidate(); printerSelector.Invalidate();
} }
} }
@ -258,7 +242,7 @@ namespace MatterHackers.MatterControl.ActionBar
else else
{ {
PrinterConnectionAndCommunication.Instance.Disable(); PrinterConnectionAndCommunication.Instance.Disable();
selectActivePrinterButton.Invalidate(); printerSelector.Invalidate();
} }
} }

View file

@ -30,6 +30,9 @@ either expressed or implied, of the FreeBSD Project.
using MatterHackers.Agg; using MatterHackers.Agg;
using MatterHackers.Agg.UI; using MatterHackers.Agg.UI;
using MatterHackers.GuiAutomation; using MatterHackers.GuiAutomation;
using MatterHackers.Localizations;
using MatterHackers.MatterControl.PrinterCommunication;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -40,41 +43,65 @@ namespace MatterHackers.MatterControl
{ {
static bool runingNavigation; static bool runingNavigation;
public static void GoToEditPrinter_Click(object sender, EventArgs e)
{
Button editButton = sender as Button;
editButton.ToolTipText = "Edit Current Printer Settings".Localize();
if (editButton != null)
{
editButton.Closed += (s, e2) =>
{
editButton.Click -= GoToEditPrinter_Click;
};
UiNavigation.GoToPrinterSettings("MatterControl.BaudRate Edit Field,MatterControl.AutoConnect Edit Field,MatterControl.ComPort Edit Field");
}
}
public static void GoToPrinterSettings(string widgetNameToHighlight) public static void GoToPrinterSettings(string widgetNameToHighlight)
{ {
if (!runingNavigation) if (PrinterConnectionAndCommunication.Instance?.ActivePrinter?.ID != null)
{ {
runingNavigation = true; if (!runingNavigation)
Task.Run(() =>
{ {
AutomationRunner testRunner = new AutomationRunner(inputType: AutomationRunner.InputType.Simulated, drawSimulatedMouse: false); runingNavigation = true;
testRunner.TimeToMoveMouse = 0; Task.Run(() =>
testRunner.UpDelaySeconds = 0;
if (testRunner.NameExists("SettingsAndControls"))
{ {
testRunner.ClickByName("SettingsAndControls", 5); AutomationRunner testRunner = new AutomationRunner(inputType: AutomationRunner.InputType.Simulated, drawSimulatedMouse: false);
testRunner.Wait(.2); testRunner.TimeToMoveMouse = 0;
} testRunner.UpDelaySeconds = 0;
testRunner.ClickByName("Slice Settings Tab", .1);
testRunner.ClickByName("Printer Tab", .2);
testRunner.ClickByName("Connection Tab", .1);
if (widgetNameToHighlight.Contains(",")) if (testRunner.NameExists("Done"))
{
foreach (string item in widgetNameToHighlight.Split(','))
{ {
HighlightWidget(testRunner, item); testRunner.ClickByName("Done");
testRunner.Wait(.2);
} }
}
else
{
HighlightWidget(testRunner, widgetNameToHighlight);
}
testRunner.Dispose(); if (testRunner.NameExists("SettingsAndControls"))
runingNavigation = false; {
}); testRunner.ClickByName("SettingsAndControls", 5);
testRunner.Wait(.2);
}
testRunner.ClickByName("Slice Settings Tab", .1);
testRunner.ClickByName("Printer Tab", .2);
testRunner.ClickByName("Connection Tab", .1);
if (widgetNameToHighlight.Contains(","))
{
foreach (string item in widgetNameToHighlight.Split(','))
{
HighlightWidget(testRunner, item);
}
}
else
{
HighlightWidget(testRunner, widgetNameToHighlight);
}
testRunner.Dispose();
runingNavigation = false;
});
}
} }
} }

View file

@ -23,12 +23,6 @@ namespace MatterHackers.MatterControl
{ {
TextImageButtonFactory setupButtonFactory = new TextImageButtonFactory(); TextImageButtonFactory setupButtonFactory = new TextImageButtonFactory();
Button addProfileButton;
Button editProfilesButton;
Button setupWifiButton;
Button troubleshootButton;
Button accountButton;
public SetupWizardHome(WizardWindow windowController) public SetupWizardHome(WizardWindow windowController)
: base(windowController, unlocalizedTextForCancelButton: "Done") : base(windowController, unlocalizedTextForCancelButton: "Done")
{ {
@ -133,7 +127,16 @@ namespace MatterHackers.MatterControl
var printerSelector = new PrinterSelector(); var printerSelector = new PrinterSelector();
printerSelector.AddPrinter += (s, e) => this.windowController.ChangeToSetupPrinterForm(); printerSelector.AddPrinter += (s, e) => this.windowController.ChangeToSetupPrinterForm();
buttonContainer.AddChild(printerSelector); FlowLayoutWidget printerSelectorAndEditButton = new FlowLayoutWidget()
{
HAnchor = HAnchor.ParentLeftRight,
};
printerSelectorAndEditButton.AddChild(printerSelector);
Button editButton = TextImageButtonFactory.GetThemedEditButton();
editButton.VAnchor = VAnchor.ParentCenter;
editButton.Click += UiNavigation.GoToEditPrinter_Click;
printerSelectorAndEditButton.AddChild(editButton);
buttonContainer.AddChild(printerSelectorAndEditButton);
disconnectButton = textImageButtonFactory.Generate("Disconnect"); disconnectButton = textImageButtonFactory.Generate("Disconnect");
disconnectButton.Margin = new BorderDouble(left: 12); disconnectButton.Margin = new BorderDouble(left: 12);