More work on configuration page.
This commit is contained in:
parent
5663289ef7
commit
bda5ac173e
8 changed files with 299 additions and 36 deletions
|
|
@ -20,59 +20,163 @@ namespace MatterHackers.MatterControl.ConfigurationPage
|
|||
Button configureAutoLevelButton;
|
||||
Button configureEePromButton;
|
||||
|
||||
DisableableWidget eePromControlsContainer;
|
||||
DisableableWidget terminalCommunicationsContainer;
|
||||
DisableableWidget printLevelingContainer;
|
||||
|
||||
event EventHandler unregisterEvents;
|
||||
|
||||
public HardwareSettingsWidget()
|
||||
: base("Hardware Settings")
|
||||
{
|
||||
mainContainer.AddChild(GetAutoLevelControl());
|
||||
{
|
||||
|
||||
eePromControlsContainer = new DisableableWidget();
|
||||
eePromControlsContainer.AddChild(GetEEPromControl());
|
||||
terminalCommunicationsContainer = new DisableableWidget();
|
||||
printLevelingContainer = new DisableableWidget();
|
||||
printLevelingContainer.AddChild(GetAutoLevelControl());
|
||||
|
||||
mainContainer.AddChild(printLevelingContainer); ;
|
||||
mainContainer.AddChild(new HorizontalLine(separatorLineColor));
|
||||
mainContainer.AddChild(GetEEPromControl());
|
||||
mainContainer.AddChild(eePromControlsContainer);
|
||||
|
||||
AddChild(mainContainer);
|
||||
|
||||
AddHandlers();
|
||||
SetVisibleControls();
|
||||
}
|
||||
|
||||
|
||||
|
||||
EditLevelingSettingsWindow editLevelingSettingsWindow;
|
||||
Button enablePrintLevelingButton;
|
||||
Button disablePrintLevelingButton;
|
||||
TextWidget printLevelingStatusLabel;
|
||||
private FlowLayoutWidget GetAutoLevelControl()
|
||||
{
|
||||
FlowLayoutWidget buttonRow = new FlowLayoutWidget();
|
||||
buttonRow.HAnchor = HAnchor.ParentLeftRight;
|
||||
buttonRow.Margin = new BorderDouble(top: 4);
|
||||
buttonRow.Margin = new BorderDouble(0,4);
|
||||
|
||||
configureEePromButton = textImageButtonFactory.Generate("Configure".Localize().ToUpper());
|
||||
configureEePromButton.Margin = new BorderDouble(left: 6);
|
||||
configureEePromButton.VAnchor = VAnchor.ParentCenter;
|
||||
configureAutoLevelButton = textImageButtonFactory.Generate("Configure".Localize().ToUpper());
|
||||
configureAutoLevelButton.Margin = new BorderDouble(left: 6);
|
||||
configureAutoLevelButton.VAnchor = VAnchor.ParentCenter;
|
||||
|
||||
TextWidget notificationSettingsLabel = new TextWidget("Automatic Print Leveling");
|
||||
notificationSettingsLabel.AutoExpandBoundsToText = true;
|
||||
notificationSettingsLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||
notificationSettingsLabel.VAnchor = VAnchor.ParentCenter;
|
||||
|
||||
buttonRow.AddChild(notificationSettingsLabel);
|
||||
Button editButton = textImageButtonFactory.GenerateEditButton();
|
||||
editButton.VAnchor = Agg.UI.VAnchor.ParentCenter;
|
||||
editButton.Click += (sender, e) =>
|
||||
{
|
||||
UiThread.RunOnIdle((state) =>
|
||||
{
|
||||
if (editLevelingSettingsWindow == null)
|
||||
{
|
||||
editLevelingSettingsWindow = new EditLevelingSettingsWindow();
|
||||
editLevelingSettingsWindow.Closed += (sender2, e2) =>
|
||||
{
|
||||
editLevelingSettingsWindow = null;
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
editLevelingSettingsWindow.BringToFront();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
Button runPrintLevelingButton = textImageButtonFactory.Generate("Configure".Localize().ToUpper());
|
||||
runPrintLevelingButton.Margin = new BorderDouble(left:6);
|
||||
runPrintLevelingButton.VAnchor = VAnchor.ParentCenter;
|
||||
runPrintLevelingButton.Click += (sender, e) =>
|
||||
{
|
||||
UiThread.RunOnIdle((state) =>
|
||||
{
|
||||
LevelWizardBase.ShowPrintLevelWizard(LevelWizardBase.RuningState.UserRequestedCalibration);
|
||||
});
|
||||
};
|
||||
|
||||
Agg.Image.ImageBuffer levelingImage = new Agg.Image.ImageBuffer();
|
||||
ImageIO.LoadImageData(Path.Combine(ApplicationDataStorage.Instance.ApplicationStaticDataPath,"Icons", "PrintStatusControls", "leveling-24x24.png"), levelingImage);
|
||||
if (!ActiveTheme.Instance.IsDarkTheme)
|
||||
{
|
||||
InvertLightness.DoInvertLightness(levelingImage);
|
||||
}
|
||||
|
||||
ImageWidget levelingIcon = new ImageWidget(levelingImage);
|
||||
levelingIcon.Margin = new BorderDouble (right: 6);
|
||||
|
||||
enablePrintLevelingButton = textImageButtonFactory.Generate("Enable".Localize().ToUpper());
|
||||
enablePrintLevelingButton.Margin = new BorderDouble(left:6);
|
||||
enablePrintLevelingButton.VAnchor = VAnchor.ParentCenter;
|
||||
enablePrintLevelingButton.Click += new ButtonBase.ButtonEventHandler(enablePrintLeveling_Click);
|
||||
|
||||
disablePrintLevelingButton = textImageButtonFactory.Generate("Disable".Localize().ToUpper());
|
||||
disablePrintLevelingButton.Margin = new BorderDouble(left:6);
|
||||
disablePrintLevelingButton.VAnchor = VAnchor.ParentCenter;
|
||||
disablePrintLevelingButton.Click += new ButtonBase.ButtonEventHandler(disablePrintLeveling_Click);
|
||||
|
||||
printLevelingStatusLabel = new TextWidget ("");
|
||||
printLevelingStatusLabel.AutoExpandBoundsToText = true;
|
||||
printLevelingStatusLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||
printLevelingStatusLabel.VAnchor = VAnchor.ParentCenter;
|
||||
|
||||
GuiWidget hSpacer = new GuiWidget ();
|
||||
hSpacer.HAnchor = HAnchor.ParentLeftRight;
|
||||
|
||||
ActivePrinterProfile.Instance.DoPrintLevelingChanged.RegisterEvent((sender, e) =>
|
||||
{
|
||||
SetPrintLevelButtonVisiblity();
|
||||
|
||||
}, ref unregisterEvents);
|
||||
|
||||
buttonRow.AddChild(levelingIcon);
|
||||
buttonRow.AddChild(printLevelingStatusLabel);
|
||||
buttonRow.AddChild(editButton);
|
||||
buttonRow.AddChild(new HorizontalSpacer());
|
||||
buttonRow.AddChild(configureEePromButton);
|
||||
buttonRow.AddChild(enablePrintLevelingButton);
|
||||
buttonRow.AddChild(disablePrintLevelingButton);
|
||||
buttonRow.AddChild(runPrintLevelingButton);
|
||||
SetPrintLevelButtonVisiblity();
|
||||
return buttonRow;
|
||||
}
|
||||
|
||||
static EePromMarlinWidget openEePromMarlinWidget = null;
|
||||
static EePromRepetierWidget openEePromRepetierWidget = null;
|
||||
string noEepromMappingMessage = "Oops! There is no eeprom mapping for your printer's firmware.".Localize();
|
||||
string noEepromMappingTitle = "Warning no eeprom mapping".Localize();
|
||||
string groupBoxTitle = "EEProm Settings".Localize();
|
||||
private FlowLayoutWidget GetEEPromControl()
|
||||
{
|
||||
FlowLayoutWidget buttonRow = new FlowLayoutWidget();
|
||||
buttonRow.HAnchor = HAnchor.ParentLeftRight;
|
||||
buttonRow.Margin = new BorderDouble(top: 4);
|
||||
buttonRow.Margin = new BorderDouble(0,4);
|
||||
|
||||
configureAutoLevelButton = textImageButtonFactory.Generate("Configure".Localize().ToUpper());
|
||||
configureAutoLevelButton.Margin = new BorderDouble(left: 6);
|
||||
configureAutoLevelButton.VAnchor = VAnchor.ParentCenter;
|
||||
|
||||
TextWidget notificationSettingsLabel = new TextWidget("EEProm Settings");
|
||||
notificationSettingsLabel.AutoExpandBoundsToText = true;
|
||||
notificationSettingsLabel.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||
notificationSettingsLabel.VAnchor = VAnchor.ParentCenter;
|
||||
|
||||
|
||||
Agg.Image.ImageBuffer eePromImage = new Agg.Image.ImageBuffer();
|
||||
ImageIO.LoadImageData(Path.Combine(ApplicationDataStorage.Instance.ApplicationStaticDataPath, "Icons", "PrintStatusControls", "leveling-24x24.png"), eePromImage);
|
||||
if (!ActiveTheme.Instance.IsDarkTheme)
|
||||
{
|
||||
InvertLightness.DoInvertLightness(eePromImage);
|
||||
}
|
||||
ImageWidget eePromIcon = new ImageWidget(eePromImage);
|
||||
eePromIcon.Margin = new BorderDouble(right: 6);
|
||||
|
||||
configureEePromButton = textImageButtonFactory.Generate("Configure".Localize().ToUpper());
|
||||
|
||||
//buttonRow.AddChild(eePromIcon);
|
||||
buttonRow.AddChild(notificationSettingsLabel);
|
||||
buttonRow.AddChild(new HorizontalSpacer());
|
||||
buttonRow.AddChild(configureAutoLevelButton);
|
||||
buttonRow.AddChild(configureEePromButton);
|
||||
|
||||
return buttonRow;
|
||||
}
|
||||
|
||||
|
|
@ -80,13 +184,54 @@ namespace MatterHackers.MatterControl.ConfigurationPage
|
|||
{
|
||||
configureAutoLevelButton.Click += new ButtonBase.ButtonEventHandler(configureAutoLevelButton_Click);
|
||||
configureEePromButton.Click += new ButtonBase.ButtonEventHandler(configureEePromButton_Click);
|
||||
PrinterConnectionAndCommunication.Instance.CommunicationStateChanged.RegisterEvent(onPrinterStatusChanged, ref unregisterEvents);
|
||||
PrinterConnectionAndCommunication.Instance.EnableChanged.RegisterEvent(onPrinterStatusChanged, ref unregisterEvents);
|
||||
}
|
||||
|
||||
void configureEePromButton_Click(object sender, MouseEventArgs mouseEvent)
|
||||
{
|
||||
UiThread.RunOnIdle((state) =>
|
||||
{
|
||||
//Do stuff
|
||||
#if false // This is to force the creation of the repetier window for testing when we don't have repetier firmware.
|
||||
new MatterHackers.MatterControl.EeProm.EePromRepetierWidget();
|
||||
#else
|
||||
switch (PrinterConnectionAndCommunication.Instance.FirmwareType)
|
||||
{
|
||||
case PrinterConnectionAndCommunication.FirmwareTypes.Repetier:
|
||||
if (openEePromRepetierWidget != null)
|
||||
{
|
||||
openEePromRepetierWidget.BringToFront();
|
||||
}
|
||||
else
|
||||
{
|
||||
openEePromRepetierWidget = new EePromRepetierWidget();
|
||||
openEePromRepetierWidget.Closed += (RepetierWidget, RepetierEvent) =>
|
||||
{
|
||||
openEePromRepetierWidget = null;
|
||||
};
|
||||
}
|
||||
break;
|
||||
|
||||
case PrinterConnectionAndCommunication.FirmwareTypes.Marlin:
|
||||
if (openEePromMarlinWidget != null)
|
||||
{
|
||||
openEePromMarlinWidget.BringToFront();
|
||||
}
|
||||
else
|
||||
{
|
||||
openEePromMarlinWidget = new EePromMarlinWidget();
|
||||
openEePromMarlinWidget.Closed += (marlinWidget, marlinEvent) =>
|
||||
{
|
||||
openEePromMarlinWidget = null;
|
||||
};
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
StyledMessageBox.ShowMessageBox(noEepromMappingMessage, noEepromMappingTitle, StyledMessageBox.MessageType.OK);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -98,5 +243,107 @@ namespace MatterHackers.MatterControl.ConfigurationPage
|
|||
});
|
||||
}
|
||||
|
||||
private void onPrinterStatusChanged(object sender, EventArgs e)
|
||||
{
|
||||
SetVisibleControls();
|
||||
this.Invalidate();
|
||||
}
|
||||
|
||||
void enablePrintLeveling_Click(object sender, MouseEventArgs mouseEvent)
|
||||
{
|
||||
ActivePrinterProfile.Instance.DoPrintLeveling = true;
|
||||
}
|
||||
|
||||
void disablePrintLeveling_Click(object sender, MouseEventArgs mouseEvent)
|
||||
{
|
||||
ActivePrinterProfile.Instance.DoPrintLeveling = false;
|
||||
}
|
||||
|
||||
void SetPrintLevelButtonVisiblity()
|
||||
{
|
||||
enablePrintLevelingButton.Visible = !ActivePrinterProfile.Instance.DoPrintLeveling;
|
||||
disablePrintLevelingButton.Visible = ActivePrinterProfile.Instance.DoPrintLeveling;
|
||||
|
||||
if (ActivePrinterProfile.Instance.DoPrintLeveling)
|
||||
{
|
||||
printLevelingStatusLabel.Text = LocalizedString.Get("Automatic Print Leveling (enabled)");
|
||||
}
|
||||
else
|
||||
{
|
||||
printLevelingStatusLabel.Text = LocalizedString.Get("Automatic Print Leveling (disabled)");
|
||||
}
|
||||
}
|
||||
|
||||
private void SetVisibleControls()
|
||||
{
|
||||
if (ActivePrinterProfile.Instance.ActivePrinter == null)
|
||||
{
|
||||
// no printer selected
|
||||
eePromControlsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Disabled);
|
||||
terminalCommunicationsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Enabled);
|
||||
printLevelingContainer.SetEnableLevel(DisableableWidget.EnableLevel.Disabled);
|
||||
//cloudMonitorContainer.SetEnableLevel(DisableableWidget.EnableLevel.Disabled);
|
||||
}
|
||||
else // we at least have a printer selected
|
||||
{
|
||||
//cloudMonitorContainer.SetEnableLevel(DisableableWidget.EnableLevel.Enabled);
|
||||
switch (PrinterConnectionAndCommunication.Instance.CommunicationState)
|
||||
{
|
||||
case PrinterConnectionAndCommunication.CommunicationStates.Disconnecting:
|
||||
case PrinterConnectionAndCommunication.CommunicationStates.ConnectionLost:
|
||||
case PrinterConnectionAndCommunication.CommunicationStates.Disconnected:
|
||||
case PrinterConnectionAndCommunication.CommunicationStates.AttemptingToConnect:
|
||||
case PrinterConnectionAndCommunication.CommunicationStates.FailedToConnect:
|
||||
eePromControlsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Disabled);
|
||||
printLevelingContainer.SetEnableLevel(DisableableWidget.EnableLevel.Enabled);
|
||||
terminalCommunicationsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Enabled);
|
||||
break;
|
||||
|
||||
case PrinterConnectionAndCommunication.CommunicationStates.FinishedPrint:
|
||||
case PrinterConnectionAndCommunication.CommunicationStates.Connected:
|
||||
eePromControlsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Enabled);
|
||||
printLevelingContainer.SetEnableLevel(DisableableWidget.EnableLevel.Enabled);
|
||||
terminalCommunicationsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Enabled);
|
||||
break;
|
||||
|
||||
case PrinterConnectionAndCommunication.CommunicationStates.PrintingFromSd:
|
||||
eePromControlsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Disabled);
|
||||
printLevelingContainer.SetEnableLevel(DisableableWidget.EnableLevel.Disabled);
|
||||
terminalCommunicationsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Enabled);
|
||||
break;
|
||||
|
||||
case PrinterConnectionAndCommunication.CommunicationStates.PreparingToPrint:
|
||||
case PrinterConnectionAndCommunication.CommunicationStates.PreparingToPrintToSd:
|
||||
case PrinterConnectionAndCommunication.CommunicationStates.PrintingToSd:
|
||||
case PrinterConnectionAndCommunication.CommunicationStates.Printing:
|
||||
switch (PrinterConnectionAndCommunication.Instance.PrintingState)
|
||||
{
|
||||
case PrinterConnectionAndCommunication.DetailedPrintingState.HomingAxis:
|
||||
case PrinterConnectionAndCommunication.DetailedPrintingState.HeatingBed:
|
||||
case PrinterConnectionAndCommunication.DetailedPrintingState.HeatingExtruder:
|
||||
case PrinterConnectionAndCommunication.DetailedPrintingState.Printing:
|
||||
eePromControlsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Disabled);
|
||||
printLevelingContainer.SetEnableLevel(DisableableWidget.EnableLevel.Disabled);
|
||||
terminalCommunicationsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Enabled);
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
break;
|
||||
|
||||
case PrinterConnectionAndCommunication.CommunicationStates.Paused:
|
||||
eePromControlsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Enabled);
|
||||
printLevelingContainer.SetEnableLevel(DisableableWidget.EnableLevel.Disabled);
|
||||
terminalCommunicationsContainer.SetEnableLevel(DisableableWidget.EnableLevel.Enabled);
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue