Took out a bunch of redundant code that was in both PrinterSetupStatus and SetupStepMakeModelName (took out of SetupStepMakeModelName) renamed PrinterSetupStaus variable to currentPrinterSetupStatus as the first is also the name of the class and quite confusing.
141 lines
6 KiB
C#
141 lines
6 KiB
C#
using System;
|
|
|
|
using MatterHackers.Agg;
|
|
using MatterHackers.Agg.UI;
|
|
using MatterHackers.Localizations;
|
|
using MatterHackers.MatterControl.PrinterCommunication;
|
|
using MatterHackers.SerialPortCommunication.FrostedSerial;
|
|
|
|
namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
|
{
|
|
public class SetupStepComPortOne : SetupConnectionWidgetBase
|
|
{
|
|
|
|
Button nextButton;
|
|
|
|
public SetupStepComPortOne(ConnectionWindow windowController, GuiWidget containerWindowToClose, PrinterSetupStatus setupPrinter)
|
|
: base(windowController, containerWindowToClose, setupPrinter)
|
|
{
|
|
contentRow.AddChild(createPrinterConnectionMessageContainer());
|
|
{
|
|
//Construct buttons
|
|
nextButton = textImageButtonFactory.Generate(LocalizedString.Get("Continue"));
|
|
nextButton.Click += new EventHandler(NextButton_Click);
|
|
|
|
GuiWidget hSpacer = new GuiWidget();
|
|
hSpacer.HAnchor = HAnchor.ParentLeftRight;
|
|
|
|
//Add buttons to buttonContainer
|
|
footerRow.AddChild(nextButton);
|
|
footerRow.AddChild(hSpacer);
|
|
|
|
footerRow.AddChild(cancelButton);
|
|
}
|
|
}
|
|
|
|
public FlowLayoutWidget createPrinterConnectionMessageContainer()
|
|
{
|
|
|
|
FlowLayoutWidget container = new FlowLayoutWidget(FlowDirection.TopToBottom);
|
|
container.VAnchor = VAnchor.ParentBottomTop;
|
|
container.Margin = new BorderDouble(5);
|
|
BorderDouble elementMargin = new BorderDouble(top: 5);
|
|
|
|
TextWidget printerMessageOne = new TextWidget(LocalizedString.Get("MatterControl will now attempt to auto-detect printer."), 0, 0, 10);
|
|
printerMessageOne.Margin = new BorderDouble(0, 10, 0,5);
|
|
printerMessageOne.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
|
printerMessageOne.HAnchor = HAnchor.ParentLeftRight;
|
|
printerMessageOne.Margin = elementMargin;
|
|
|
|
string printerMessageTwoTxt = LocalizedString.Get("Disconnect printer");
|
|
string printerMessageTwoTxtEnd = LocalizedString.Get("if currently connected");
|
|
string printerMessageTwoTxtFull = string.Format ("1.) {0} ({1}).", printerMessageTwoTxt, printerMessageTwoTxtEnd);
|
|
TextWidget printerMessageTwo = new TextWidget(printerMessageTwoTxtFull, 0, 0, 12);
|
|
printerMessageTwo.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
|
printerMessageTwo.HAnchor = HAnchor.ParentLeftRight;
|
|
printerMessageTwo.Margin = elementMargin;
|
|
|
|
string printerMessageThreeTxt = LocalizedString.Get("Press");
|
|
string printerMessageThreeTxtEnd = LocalizedString.Get ("Continue");
|
|
string printerMessageThreeFull = string.Format ("2.) {0} '{1}'.", printerMessageThreeTxt, printerMessageThreeTxtEnd);
|
|
TextWidget printerMessageThree = new TextWidget(printerMessageThreeFull, 0, 0, 12);
|
|
printerMessageThree.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
|
printerMessageThree.HAnchor = HAnchor.ParentLeftRight;
|
|
printerMessageThree.Margin = elementMargin;
|
|
|
|
GuiWidget vSpacer = new GuiWidget();
|
|
vSpacer.VAnchor = VAnchor.ParentBottomTop;
|
|
|
|
string setupManualConfigurationOrSkipConnectionText = LocalizedString.Get(("You can also")) ;
|
|
string setupManualConfigurationOrSkipConnectionTextFull = String.Format("{0}:", setupManualConfigurationOrSkipConnectionText);
|
|
TextWidget setupManualConfigurationOrSkipConnectionWidget = new TextWidget(setupManualConfigurationOrSkipConnectionTextFull, 0, 0, 10);
|
|
setupManualConfigurationOrSkipConnectionWidget.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
|
setupManualConfigurationOrSkipConnectionWidget.HAnchor = HAnchor.ParentLeftRight;
|
|
setupManualConfigurationOrSkipConnectionWidget.Margin = elementMargin;
|
|
|
|
Button manualLink = linkButtonFactory.Generate(LocalizedString.Get("Manually Configure Connection"));
|
|
manualLink.Margin = new BorderDouble(0, 5);
|
|
manualLink.Click += new EventHandler(ManualLink_Click);
|
|
|
|
string printerMessageFourText = LocalizedString.Get("or");
|
|
TextWidget printerMessageFour = new TextWidget (printerMessageFourText, 0, 0, 10);
|
|
printerMessageFour.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
|
printerMessageFour.HAnchor = HAnchor.ParentLeftRight;
|
|
printerMessageFour.Margin = elementMargin;
|
|
|
|
Button skipConnectionLink = linkButtonFactory.Generate(LocalizedString.Get("Skip Connection Setup"));
|
|
skipConnectionLink.Margin = new BorderDouble(0, 8);
|
|
skipConnectionLink.Click += new EventHandler(SkipConnectionLink_Click);
|
|
|
|
|
|
container.AddChild(printerMessageOne);
|
|
container.AddChild(printerMessageTwo);
|
|
container.AddChild(printerMessageThree);
|
|
container.AddChild(vSpacer);
|
|
container.AddChild(setupManualConfigurationOrSkipConnectionWidget);
|
|
container.AddChild(manualLink);
|
|
container.AddChild(printerMessageFour);
|
|
container.AddChild(skipConnectionLink);
|
|
|
|
|
|
container.HAnchor = HAnchor.ParentLeftRight;
|
|
return container;
|
|
}
|
|
|
|
void ManualLink_Click(object sender, EventArgs mouseEvent)
|
|
{
|
|
UiThread.RunOnIdle(MoveToManualConfiguration);
|
|
}
|
|
|
|
void MoveToManualConfiguration(object state)
|
|
{
|
|
Parent.AddChild(new SetupStepComPortManual((ConnectionWindow)Parent, Parent, this.currentPrinterSetupStatus));
|
|
Parent.RemoveChild(this);
|
|
}
|
|
|
|
void NextButton_Click(object sender, EventArgs mouseEvent)
|
|
{
|
|
UiThread.RunOnIdle(MoveToNextWidget);
|
|
}
|
|
|
|
void MoveToNextWidget(object state)
|
|
{
|
|
Parent.AddChild(new SetupStepComPortTwo((ConnectionWindow)Parent, Parent, this.currentPrinterSetupStatus));
|
|
Parent.RemoveChild(this);
|
|
}
|
|
|
|
void SkipConnectionLink_Click(object sender, EventArgs mouseEvent)
|
|
{
|
|
PrinterConnectionAndCommunication.Instance.HaltConnectionThread();
|
|
if (GetPrinterRecordCount () > 0)
|
|
{
|
|
this.windowController.ChangeToChoosePrinter ();
|
|
}
|
|
else
|
|
{
|
|
Parent.Close();
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|