mattercontrol/PrinterControls/PrinterConnections/ConnectionWizardPanel.cs

81 lines
2.3 KiB
C#
Raw Normal View History

2015-04-08 15:20:10 -07:00
using MatterHackers.Agg;
2014-01-29 19:09:30 -08:00
using MatterHackers.Agg.UI;
using MatterHackers.Localizations;
2014-01-29 19:09:30 -08:00
using MatterHackers.MatterControl.DataStorage;
using MatterHackers.MatterControl.PrinterCommunication;
2016-04-18 11:31:31 -07:00
using MatterHackers.MatterControl.SlicerConfiguration;
2015-04-08 15:20:10 -07:00
using System;
2014-01-29 19:09:30 -08:00
namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
2015-04-08 15:20:10 -07:00
{
public class ConnectionWizardPanel : WizardPanel
2015-04-08 15:20:10 -07:00
{
private PrinterInfo activePrinter;
2015-04-08 15:20:10 -07:00
public ConnectionWizardPanel(WizardWindow wizard)
: base(
wizard,
"Cancel",
new TextImageButtonFactory()
{
normalTextColor = ActiveTheme.Instance.PrimaryTextColor,
hoverTextColor = ActiveTheme.Instance.PrimaryTextColor,
disabledTextColor = ActiveTheme.Instance.PrimaryTextColor,
pressedTextColor = ActiveTheme.Instance.PrimaryTextColor,
borderWidth = 0
})
2015-04-08 15:20:10 -07:00
{
linkButtonFactory.textColor = ActiveTheme.Instance.PrimaryTextColor;
linkButtonFactory.fontSize = 10;
2015-04-08 15:20:10 -07:00
this.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;
this.Padding = new BorderDouble(0); //To be re-enabled once native borders are turned off
2015-04-08 15:20:10 -07:00
cancelButton.Click += (s, e) => PrinterConnectionAndCommunication.Instance.HaltConnectionThread();
mainContainer.Padding = new BorderDouble(3, 5, 3, 5);
2015-04-08 15:20:10 -07:00
headerRow.Padding = new BorderDouble(0, 3, 0, 3);
headerLabel.PointSize = 14;
headerLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor;
2015-04-08 15:20:10 -07:00
contentRow.Padding = new BorderDouble(5);
footerRow.Margin = new BorderDouble(0, 3);
}
public PrinterInfo ActivePrinter
{
get
{
if (activePrinter == null)
{
var settings = ActiveSliceSettings.Instance;
activePrinter = new PrinterInfo
{
AutoConnect = settings.DoAutoConnect(),
BaudRate = settings.BaudRate(),
ComPort = settings.ComPort(),
DriverType = settings.DriverType(),
Id = settings.ID,
Name = settings.Name()
};
}
2015-04-08 15:20:10 -07:00
return activePrinter;
}
2015-04-08 15:20:10 -07:00
}
protected void SaveAndExit()
{
2016-04-18 11:31:31 -07:00
ActiveSliceSettings.Instance.RunInTransaction(settings =>
{
settings.SetAutoConnect(ActivePrinter.AutoConnect);
settings.SetBaudRate(ActivePrinter.BaudRate);
settings.SetComPort(ActivePrinter.ComPort);
settings.SetDriverType(ActivePrinter.DriverType);
settings.SetName(ActivePrinter.Name);
2016-04-18 11:31:31 -07:00
});
UiThread.RunOnIdle(wizardWindow.Close);
2015-04-08 15:20:10 -07:00
}
}
}