2018-04-11 10:22:06 -07:00
|
|
|
|
/*
|
2019-03-20 16:05:06 -07:00
|
|
|
|
Copyright (c) 2019, Lars Brubaker, John Lewin
|
2018-04-11 10:22:06 -07:00
|
|
|
|
All rights reserved.
|
|
|
|
|
|
|
|
|
|
|
|
Redistribution and use in source and binary forms, with or without
|
|
|
|
|
|
modification, are permitted provided that the following conditions are met:
|
|
|
|
|
|
|
|
|
|
|
|
1. Redistributions of source code must retain the above copyright notice, this
|
|
|
|
|
|
list of conditions and the following disclaimer.
|
|
|
|
|
|
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
|
|
this list of conditions and the following disclaimer in the documentation
|
|
|
|
|
|
and/or other materials provided with the distribution.
|
|
|
|
|
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
|
|
|
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
|
|
|
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
|
|
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
|
|
|
|
|
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
|
|
|
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
|
|
|
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
|
|
|
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
|
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
|
|
|
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
|
|
|
|
|
|
The views and conclusions contained in the software and documentation are those
|
|
|
|
|
|
of the authors and should not be interpreted as representing official policies,
|
|
|
|
|
|
either expressed or implied, of the FreeBSD Project.
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
using System;
|
2017-10-14 23:18:06 -07:00
|
|
|
|
using MatterHackers.Agg;
|
2017-08-20 02:34:39 -07:00
|
|
|
|
using MatterHackers.Agg.Platform;
|
2015-10-16 13:39:50 -07:00
|
|
|
|
using MatterHackers.Agg.UI;
|
2021-05-21 15:23:25 -07:00
|
|
|
|
using MatterHackers.ImageProcessing;
|
2015-10-16 13:39:50 -07:00
|
|
|
|
using MatterHackers.Localizations;
|
2018-11-02 16:14:37 -07:00
|
|
|
|
using MatterHackers.MatterControl.ConfigurationPage.PrintLeveling;
|
2015-10-16 13:39:50 -07:00
|
|
|
|
using MatterHackers.MatterControl.CustomWidgets;
|
|
|
|
|
|
using MatterHackers.MatterControl.PrinterCommunication;
|
2017-10-14 23:18:06 -07:00
|
|
|
|
using MatterHackers.MatterControl.SlicerConfiguration;
|
2019-03-25 15:35:36 -07:00
|
|
|
|
using MatterHackers.VectorMath;
|
2015-10-16 13:39:50 -07:00
|
|
|
|
|
2018-01-10 16:37:13 -08:00
|
|
|
|
namespace MatterHackers.MatterControl.PrinterControls
|
2015-10-16 13:39:50 -07:00
|
|
|
|
{
|
2018-01-10 16:37:13 -08:00
|
|
|
|
public class CalibrationControls : FlowLayoutWidget
|
2015-10-16 13:39:50 -07:00
|
|
|
|
{
|
2019-05-11 12:08:03 -07:00
|
|
|
|
private readonly PrinterConfig printer;
|
2017-08-06 19:22:47 -07:00
|
|
|
|
|
2018-01-10 18:22:13 -08:00
|
|
|
|
private CalibrationControls(PrinterConfig printer, ThemeConfig theme)
|
2018-01-10 16:34:24 -08:00
|
|
|
|
: base(FlowDirection.TopToBottom)
|
2015-10-16 13:39:50 -07:00
|
|
|
|
{
|
2017-09-15 12:08:00 -07:00
|
|
|
|
this.printer = printer;
|
2017-08-06 19:22:47 -07:00
|
|
|
|
|
2018-03-09 18:22:38 -08:00
|
|
|
|
// add in the controls for configuring auto leveling
|
2017-06-23 15:13:39 -07:00
|
|
|
|
{
|
2019-05-14 15:27:30 -07:00
|
|
|
|
SettingsRow calibrationRow;
|
2018-03-09 18:22:38 -08:00
|
|
|
|
|
2019-05-14 15:27:30 -07:00
|
|
|
|
this.AddChild(calibrationRow = new SettingsRow(
|
2019-03-20 17:06:50 -07:00
|
|
|
|
"Printer Calibration".Localize(),
|
2018-04-06 16:32:46 -07:00
|
|
|
|
null,
|
2019-03-20 17:06:50 -07:00
|
|
|
|
theme));
|
2018-03-09 18:22:38 -08:00
|
|
|
|
|
2022-07-16 07:46:44 -07:00
|
|
|
|
var runWizardButton = new ThemedIconButton(StaticData.Instance.LoadIcon("compass.png", 16, 16).SetToColor(theme.TextColor), theme)
|
2017-10-31 17:27:37 -07:00
|
|
|
|
{
|
2018-04-03 09:50:26 -07:00
|
|
|
|
VAnchor = VAnchor.Center,
|
2018-04-06 16:09:11 -07:00
|
|
|
|
Margin = theme.ButtonSpacing,
|
2019-05-29 17:01:44 -07:00
|
|
|
|
Name = "Printer Calibration Button",
|
2018-09-13 19:00:35 -07:00
|
|
|
|
ToolTipText = "Run Calibration".Localize()
|
2018-03-09 18:22:38 -08:00
|
|
|
|
};
|
2019-03-20 16:05:06 -07:00
|
|
|
|
|
2018-04-03 09:50:26 -07:00
|
|
|
|
runWizardButton.Click += (s, e) =>
|
2015-10-16 13:39:50 -07:00
|
|
|
|
{
|
2018-03-09 18:22:38 -08:00
|
|
|
|
UiThread.RunOnIdle(() =>
|
|
|
|
|
|
{
|
2019-04-04 17:18:12 -07:00
|
|
|
|
DialogWindow.Show(new PrinterCalibrationWizard(printer, theme));
|
2018-03-09 18:22:38 -08:00
|
|
|
|
});
|
|
|
|
|
|
};
|
2019-05-14 15:27:30 -07:00
|
|
|
|
calibrationRow.AddChild(runWizardButton);
|
2016-01-16 21:33:11 -08:00
|
|
|
|
}
|
2015-10-16 13:39:50 -07:00
|
|
|
|
|
2018-11-16 08:44:56 -08:00
|
|
|
|
// Register listeners
|
2018-11-09 13:19:14 -08:00
|
|
|
|
printer.Connection.CommunicationStateChanged += PrinterStatusChanged;
|
2018-01-10 18:22:13 -08:00
|
|
|
|
|
|
|
|
|
|
SetVisibleControls();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static SectionWidget CreateSection(PrinterConfig printer, ThemeConfig theme)
|
|
|
|
|
|
{
|
|
|
|
|
|
return new SectionWidget(
|
|
|
|
|
|
"Calibration".Localize(),
|
2018-02-01 23:26:40 -08:00
|
|
|
|
new CalibrationControls(printer, theme),
|
2019-05-15 17:42:42 -07:00
|
|
|
|
theme);
|
2015-10-16 13:39:50 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-08-23 16:44:11 -07:00
|
|
|
|
public override void OnClosed(EventArgs e)
|
2015-10-16 13:39:50 -07:00
|
|
|
|
{
|
2018-11-16 08:44:56 -08:00
|
|
|
|
// Unregister listeners
|
|
|
|
|
|
printer.Connection.CommunicationStateChanged -= PrinterStatusChanged;
|
|
|
|
|
|
|
2015-10-16 13:39:50 -07:00
|
|
|
|
base.OnClosed(e);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2016-05-04 08:11:19 -07:00
|
|
|
|
private void PrinterStatusChanged(object sender, EventArgs e)
|
2015-10-16 13:39:50 -07:00
|
|
|
|
{
|
2019-04-04 14:22:44 -07:00
|
|
|
|
this.SetVisibleControls();
|
2015-10-16 13:39:50 -07:00
|
|
|
|
this.Invalidate();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void SetVisibleControls()
|
|
|
|
|
|
{
|
2017-09-15 12:08:00 -07:00
|
|
|
|
if (!printer.Settings.PrinterSelected
|
2020-11-12 21:56:20 -08:00
|
|
|
|
|| printer.Connection.Printing
|
2019-02-06 10:34:19 -08:00
|
|
|
|
|| printer.Connection.Paused)
|
2015-10-16 13:39:50 -07:00
|
|
|
|
{
|
2018-01-10 16:34:24 -08:00
|
|
|
|
this.Enabled = false;
|
2015-10-16 13:39:50 -07:00
|
|
|
|
}
|
2015-12-23 11:37:51 -08:00
|
|
|
|
else
|
2015-10-16 13:39:50 -07:00
|
|
|
|
{
|
2018-01-10 16:34:24 -08:00
|
|
|
|
this.Enabled = true;
|
2015-10-16 13:39:50 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|