Revised CalibrationWizard home page

This commit is contained in:
John Lewin 2019-04-25 08:03:46 -07:00 committed by jlewin
parent 582a51b959
commit 3b22db983e

View file

@ -29,10 +29,14 @@ either expressed or implied, of the FreeBSD Project.
using System;
using System.Collections.Generic;
using System.Linq;
using MatterHackers.Agg;
using MatterHackers.Agg.UI;
using MatterHackers.Localizations;
using MatterHackers.MatterControl.ConfigurationPage.PrintLeveling;
using MatterHackers.MatterControl.CustomWidgets;
using MatterHackers.MatterControl.PrinterControls;
using MatterHackers.MatterControl.SlicerConfiguration;
using MatterHackers.VectorMath;
namespace MatterHackers.MatterControl
@ -55,16 +59,117 @@ namespace MatterHackers.MatterControl
HeaderText = "Printer Setup & Calibration".Localize()
};
homePage.ContentRow.AddChild(
var contentRow = homePage.ContentRow;
contentRow.AddChild(
new WrappedTextWidget(
@"Select the calibration task on the left to continue".Replace("\r\n", "\n"),
pointSize: theme.DefaultFontSize,
textColor: theme.TextColor));
contentRow.BackgroundColor = Color.Transparent;
foreach (var stage in this.Stages)
{
var widget = new GuiWidget();
if (stage is ProbeCalibrationWizard probeWizard)
{
var column = CreateColumn(theme);
column.FlowDirection = FlowDirection.LeftToRight;
var offset = printer.Settings.GetValue<Vector3>(SettingsKey.probe_offset);
column.AddChild(new TextWidget("Z Offset".Localize(), pointSize: theme.DefaultFontSize, textColor: theme.TextColor)
{
Margin = new BorderDouble(bottom: 4)
});
column.AddChild(new TextWidget(offset.Z.ToString("0.###"), pointSize: theme.DefaultFontSize, textColor: theme.TextColor)
{
Margin = new BorderDouble(bottom: 4)
});
widget = column;
}
if (stage is PrintLevelingWizard levelingWizard)
{
PrintLevelingData levelingData = printer.Settings.Helpers.PrintLevelingData;
if (levelingData != null
&& printer.Settings?.GetValue<bool>(SettingsKey.print_leveling_enabled) == true)
{
//levelingWizard.LevelingPlan
//
//if (currentLevelingFunctions == null
// || currentProbeZOffset != printer.Settings.GetValue<Vector3>(SettingsKey.probe_offset)
// || !levelingData.SamplesAreSame(currentLevelingFunctions.SampledPositions))
//{
// currentProbeZOffset = printer.Settings.GetValue<Vector3>(SettingsKey.probe_offset);
// currentLevelingFunctions = new LevelingFunctions(printer, levelingData);
//}
var positions = levelingData.SampledPositions;
var levelingSolution = printer.Settings.GetValue(SettingsKey.print_leveling_solution);
var column = CreateColumn(theme);
column.AddChild(new TextWidget(levelingSolution, pointSize: theme.DefaultFontSize, textColor: theme.TextColor)
{
Margin = new BorderDouble(bottom: 4)
});
var probeWidget = new ProbePositionsWidget(printer, positions.Select(v => new Vector2(v)).ToList(), positions.Select(v => new ProbePosition() { position = v }).ToList(), theme)
{
HAnchor = HAnchor.Absolute,
VAnchor = VAnchor.Absolute,
Height = 200,
Width = 200,
RenderLevelingData = true,
RenderProbePath = false,
SimplePoints = true,
};
column.AddChild(probeWidget);
var row = new FlowLayoutWidget();
row.AddChild(column);
widget = row;
}
}
if (stage.SetupRequired)
{
var column = CreateColumn(theme);
column.AddChild(new TextWidget("Setup Required".Localize(), pointSize: theme.DefaultFontSize, textColor: theme.TextColor));
widget = column;
}
var section = new SectionWidget(stage.Title, widget, theme, expandingContent: false);
theme.ApplyBoxStyle(section);
section.Margin = section.Margin.Clone(left: 0);
if (stage.SetupRequired)
{
section.BackgroundColor = Color.Red.WithAlpha(30);
}
contentRow.AddChild(section);
}
return homePage;
};
}
private static FlowLayoutWidget CreateColumn(ThemeConfig theme)
{
return new FlowLayoutWidget(FlowDirection.TopToBottom)
{
Margin = new BorderDouble(15, theme.DefaultContainerPadding, theme.DefaultContainerPadding, 4)
};
}
public string Title { get; } = "Printer Calibration".Localize();
public Vector2 WindowSize { get; } = new Vector2(1200, 700);