2014-10-15 16:57:26 -07:00
|
|
|
|
/*
|
2017-06-23 15:13:39 -07:00
|
|
|
|
Copyright (c) 2017, Kevin Pope, John Lewin
|
2014-10-15 16:57:26 -07:00
|
|
|
|
All rights reserved.
|
|
|
|
|
|
|
|
|
|
|
|
Redistribution and use in source and binary forms, with or without
|
2015-04-08 15:20:10 -07:00
|
|
|
|
modification, are permitted provided that the following conditions are met:
|
2014-10-15 16:57:26 -07:00
|
|
|
|
|
|
|
|
|
|
1. Redistributions of source code must retain the above copyright notice, this
|
2015-04-08 15:20:10 -07:00
|
|
|
|
list of conditions and the following disclaimer.
|
2014-10-15 16:57:26 -07:00
|
|
|
|
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
|
|
this list of conditions and the following disclaimer in the documentation
|
2015-04-08 15:20:10 -07:00
|
|
|
|
and/or other materials provided with the distribution.
|
2014-10-15 16:57:26 -07:00
|
|
|
|
|
|
|
|
|
|
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
|
2015-04-08 15:20:10 -07:00
|
|
|
|
of the authors and should not be interpreted as representing official policies,
|
2014-10-15 16:57:26 -07:00
|
|
|
|
either expressed or implied, of the FreeBSD Project.
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2017-06-23 15:13:39 -07:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
2014-10-15 16:57:26 -07:00
|
|
|
|
using MatterHackers.Agg;
|
2017-08-20 02:34:39 -07:00
|
|
|
|
using MatterHackers.Agg.Platform;
|
2014-10-15 16:57:26 -07:00
|
|
|
|
using MatterHackers.Agg.UI;
|
|
|
|
|
|
using MatterHackers.Localizations;
|
2016-01-13 07:39:22 -08:00
|
|
|
|
using MatterHackers.MatterControl.CustomWidgets;
|
2014-10-15 16:57:26 -07:00
|
|
|
|
using MatterHackers.MatterControl.PrinterCommunication;
|
2016-04-18 11:31:31 -07:00
|
|
|
|
using MatterHackers.MatterControl.SlicerConfiguration;
|
2015-11-23 13:08:21 -08:00
|
|
|
|
using MatterHackers.MatterControl.Utilities;
|
2015-04-08 15:20:10 -07:00
|
|
|
|
using MatterHackers.VectorMath;
|
2014-10-15 16:57:26 -07:00
|
|
|
|
|
|
|
|
|
|
namespace MatterHackers.MatterControl.PrinterControls
|
|
|
|
|
|
{
|
2018-01-10 16:34:24 -08:00
|
|
|
|
public class MovementControls : FlowLayoutWidget
|
2015-04-08 15:20:10 -07:00
|
|
|
|
{
|
2017-09-15 12:08:00 -07:00
|
|
|
|
private PrinterConfig printer;
|
2018-01-10 15:00:59 -08:00
|
|
|
|
private ThemeConfig theme;
|
2015-11-23 10:49:08 -08:00
|
|
|
|
public FlowLayoutWidget manualControlsLayout;
|
|
|
|
|
|
private EditManualMovementSpeedsWindow editManualMovementSettingsWindow;
|
2016-01-13 07:39:22 -08:00
|
|
|
|
internal JogControls jogControls;
|
2017-11-08 08:07:55 -08:00
|
|
|
|
|
2016-01-13 07:39:22 -08:00
|
|
|
|
// Provides a list of DisableableWidgets controls that can be toggled on/off at runtime
|
|
|
|
|
|
internal List<DisableableWidget> DisableableWidgets = new List<DisableableWidget>();
|
|
|
|
|
|
|
2015-11-23 13:08:21 -08:00
|
|
|
|
private LimitCallingFrequency reportDestinationChanged = null;
|
|
|
|
|
|
|
2016-12-29 06:55:12 -08:00
|
|
|
|
private EventHandler unregisterEvents;
|
2015-11-23 13:08:21 -08:00
|
|
|
|
|
2018-01-10 18:22:13 -08:00
|
|
|
|
private MovementControls(PrinterConfig printer, ThemeConfig theme)
|
|
|
|
|
|
: base (FlowDirection.TopToBottom)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.printer = printer;
|
|
|
|
|
|
this.theme = theme;
|
|
|
|
|
|
|
|
|
|
|
|
jogControls = new JogControls(printer, new XYZColors())
|
|
|
|
|
|
{
|
|
|
|
|
|
HAnchor = HAnchor.Left | HAnchor.Stretch,
|
|
|
|
|
|
Margin = 0
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
this.AddChild(CreateDisableableContainer(GetHomeButtonBar()));
|
|
|
|
|
|
|
|
|
|
|
|
this.AddChild(jogControls);
|
|
|
|
|
|
|
|
|
|
|
|
this.AddChild(CreateDisableableContainer(GetHWDestinationBar()));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static SectionWidget CreateSection(PrinterConfig printer, ThemeConfig theme)
|
|
|
|
|
|
{
|
|
|
|
|
|
var widget = new MovementControls(printer, theme);
|
|
|
|
|
|
|
|
|
|
|
|
var editButton = new IconButton(AggContext.StaticData.LoadIcon("icon_edit.png", 16, 16, IconColor.Theme), theme);
|
|
|
|
|
|
editButton.Click += (s, e) => widget.EditOptions();
|
|
|
|
|
|
|
|
|
|
|
|
return new SectionWidget(
|
|
|
|
|
|
"Movement".Localize(),
|
|
|
|
|
|
widget,
|
|
|
|
|
|
theme,
|
|
|
|
|
|
editButton);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-02-03 13:06:08 -08:00
|
|
|
|
public override void OnClosed(ClosedEventArgs e)
|
2015-11-23 13:08:21 -08:00
|
|
|
|
{
|
2016-04-18 11:31:31 -07:00
|
|
|
|
unregisterEvents?.Invoke(this, null);
|
2015-11-23 13:08:21 -08:00
|
|
|
|
base.OnClosed(e);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-01-10 18:22:13 -08:00
|
|
|
|
private void EditOptions()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (editManualMovementSettingsWindow == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
editManualMovementSettingsWindow = new EditManualMovementSpeedsWindow("Movement Speeds".Localize(), printer.Settings.Helpers.GetMovementSpeedsString(), SetMovementSpeeds);
|
|
|
|
|
|
editManualMovementSettingsWindow.Closed += (s, e) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
editManualMovementSettingsWindow = null;
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
editManualMovementSettingsWindow.BringToFront();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2016-01-13 07:39:22 -08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Helper method to create DisableableWidget containers and populate the DisableableWidgets local property.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="widget">The widget to wrap.</param>
|
|
|
|
|
|
private DisableableWidget CreateDisableableContainer(GuiWidget widget)
|
|
|
|
|
|
{
|
2017-10-31 17:27:37 -07:00
|
|
|
|
var container = new DisableableWidget()
|
|
|
|
|
|
{
|
|
|
|
|
|
HAnchor = HAnchor.Left | HAnchor.Stretch
|
|
|
|
|
|
};
|
2016-01-13 07:39:22 -08:00
|
|
|
|
container.AddChild(widget);
|
2017-10-31 17:27:37 -07:00
|
|
|
|
|
2016-01-13 07:39:22 -08:00
|
|
|
|
DisableableWidgets.Add(container);
|
|
|
|
|
|
|
|
|
|
|
|
return container;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-09-05 10:33:14 -07:00
|
|
|
|
private void SetMovementSpeeds(string speedString)
|
2015-11-23 10:49:08 -08:00
|
|
|
|
{
|
2017-02-16 10:38:03 -08:00
|
|
|
|
if (!string.IsNullOrEmpty(speedString))
|
2015-11-23 10:49:08 -08:00
|
|
|
|
{
|
2017-09-15 12:08:00 -07:00
|
|
|
|
printer.Settings.SetValue(SettingsKey.manual_movement_speeds, speedString);
|
2017-10-30 16:49:22 -07:00
|
|
|
|
printer.Bed.GCodeRenderer?.Clear3DGCode();
|
2015-11-23 10:49:08 -08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2015-04-08 15:20:10 -07:00
|
|
|
|
private FlowLayoutWidget GetHomeButtonBar()
|
|
|
|
|
|
{
|
2018-01-11 09:23:12 -08:00
|
|
|
|
var toolbar = new FlowLayoutWidget
|
2017-02-16 10:38:03 -08:00
|
|
|
|
{
|
2018-01-11 09:23:12 -08:00
|
|
|
|
HAnchor = HAnchor.Stretch,
|
|
|
|
|
|
Margin = new BorderDouble(bottom: 10)
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var homeIcon = new IconButton(AggContext.StaticData.LoadIcon("fa-home_16.png", IconColor.Theme), theme)
|
|
|
|
|
|
{
|
|
|
|
|
|
ToolTipText = ToolTipText = "Home X, Y and Z".Localize(),
|
2018-01-11 18:03:35 -08:00
|
|
|
|
BackgroundColor = theme.MinimalShade,
|
2018-01-11 09:23:12 -08:00
|
|
|
|
Margin = theme.ButtonSpacing
|
2017-02-16 10:38:03 -08:00
|
|
|
|
};
|
2018-01-11 09:23:12 -08:00
|
|
|
|
homeIcon.Click += (s, e) => printer.Connection.HomeAxis(PrinterConnection.Axis.XYZ);
|
|
|
|
|
|
toolbar.AddChild(homeIcon);
|
2015-08-25 14:10:33 -07:00
|
|
|
|
|
2018-01-11 09:23:12 -08:00
|
|
|
|
var homeXButton = new TextButton("X", theme)
|
|
|
|
|
|
{
|
|
|
|
|
|
ToolTipText = "Home X".Localize(),
|
2018-01-11 18:03:35 -08:00
|
|
|
|
BackgroundColor = theme.MinimalShade,
|
2018-01-11 09:23:12 -08:00
|
|
|
|
Margin = theme.ButtonSpacing
|
|
|
|
|
|
};
|
|
|
|
|
|
homeXButton.Click += (s, e) => printer.Connection.HomeAxis(PrinterConnection.Axis.X);
|
|
|
|
|
|
toolbar.AddChild(homeXButton);
|
|
|
|
|
|
|
|
|
|
|
|
var homeYButton = new TextButton("Y", theme)
|
|
|
|
|
|
{
|
|
|
|
|
|
ToolTipText = "Home Y".Localize(),
|
2018-01-11 18:03:35 -08:00
|
|
|
|
BackgroundColor = theme.MinimalShade,
|
2018-01-11 09:23:12 -08:00
|
|
|
|
Margin = theme.ButtonSpacing
|
|
|
|
|
|
};
|
|
|
|
|
|
homeYButton.Click += (s, e) => printer.Connection.HomeAxis(PrinterConnection.Axis.Y);
|
|
|
|
|
|
toolbar.AddChild(homeYButton);
|
2016-01-13 07:39:22 -08:00
|
|
|
|
|
2018-01-11 09:23:12 -08:00
|
|
|
|
var homeZButton = new TextButton("Z", theme)
|
|
|
|
|
|
{
|
|
|
|
|
|
ToolTipText = "Home Z".Localize(),
|
2018-01-11 18:03:35 -08:00
|
|
|
|
BackgroundColor = theme.MinimalShade,
|
2018-01-11 09:23:12 -08:00
|
|
|
|
Margin = theme.ButtonSpacing
|
|
|
|
|
|
};
|
|
|
|
|
|
homeZButton.Click += (s, e) => printer.Connection.HomeAxis(PrinterConnection.Axis.Z);
|
|
|
|
|
|
toolbar.AddChild(homeZButton);
|
|
|
|
|
|
|
|
|
|
|
|
// Display the current baby step offset stream values
|
|
|
|
|
|
var offsetStreamLabel = new TextWidget("Z Offset".Localize() + ":", pointSize: 8)
|
2017-01-11 06:19:19 -08:00
|
|
|
|
{
|
|
|
|
|
|
TextColor = ActiveTheme.Instance.PrimaryTextColor,
|
|
|
|
|
|
Margin = new BorderDouble(left: 10),
|
|
|
|
|
|
AutoExpandBoundsToText = true,
|
2017-08-07 15:47:27 -07:00
|
|
|
|
VAnchor = VAnchor.Center
|
2017-01-11 06:19:19 -08:00
|
|
|
|
};
|
2018-01-11 09:23:12 -08:00
|
|
|
|
toolbar.AddChild(offsetStreamLabel);
|
2016-01-13 07:39:22 -08:00
|
|
|
|
|
2018-01-10 15:00:59 -08:00
|
|
|
|
var ztuningWidget = new ZTuningWidget(printer.Settings, theme);
|
2018-01-11 09:23:12 -08:00
|
|
|
|
toolbar.AddChild(ztuningWidget);
|
|
|
|
|
|
|
|
|
|
|
|
toolbar.AddChild(new HorizontalSpacer());
|
2018-01-10 15:00:59 -08:00
|
|
|
|
|
2018-01-11 09:23:12 -08:00
|
|
|
|
// Create 'Release' button
|
|
|
|
|
|
var disableMotors = new TextButton("Release".Localize(), theme)
|
|
|
|
|
|
{
|
2018-01-11 18:03:35 -08:00
|
|
|
|
BackgroundColor = theme.MinimalShade,
|
2018-01-11 09:23:12 -08:00
|
|
|
|
};
|
|
|
|
|
|
disableMotors.Click += (s, e) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
printer.Connection.ReleaseMotors(true);
|
|
|
|
|
|
};
|
|
|
|
|
|
toolbar.AddChild(disableMotors);
|
2015-04-08 15:20:10 -07:00
|
|
|
|
|
2018-01-11 09:23:12 -08:00
|
|
|
|
return toolbar;
|
2015-04-08 15:20:10 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2015-11-23 13:08:21 -08:00
|
|
|
|
private FlowLayoutWidget GetHWDestinationBar()
|
|
|
|
|
|
{
|
|
|
|
|
|
FlowLayoutWidget hwDestinationBar = new FlowLayoutWidget();
|
2017-08-07 15:47:27 -07:00
|
|
|
|
hwDestinationBar.HAnchor = HAnchor.Stretch;
|
2017-10-31 17:27:37 -07:00
|
|
|
|
hwDestinationBar.Margin = new BorderDouble(top: 8);
|
|
|
|
|
|
hwDestinationBar.Padding = 0;
|
2015-11-23 13:08:21 -08:00
|
|
|
|
|
|
|
|
|
|
TextWidget xPosition = new TextWidget("X: 0.0 ", pointSize: 12, textColor: ActiveTheme.Instance.PrimaryTextColor);
|
|
|
|
|
|
TextWidget yPosition = new TextWidget("Y: 0.0 ", pointSize: 12, textColor: ActiveTheme.Instance.PrimaryTextColor);
|
|
|
|
|
|
TextWidget zPosition = new TextWidget("Z: 0.0 ", pointSize: 12, textColor: ActiveTheme.Instance.PrimaryTextColor);
|
|
|
|
|
|
|
|
|
|
|
|
hwDestinationBar.AddChild(xPosition);
|
|
|
|
|
|
hwDestinationBar.AddChild(yPosition);
|
|
|
|
|
|
hwDestinationBar.AddChild(zPosition);
|
|
|
|
|
|
|
2015-11-23 15:45:35 -08:00
|
|
|
|
SetDestinationPositionText(xPosition, yPosition, zPosition);
|
|
|
|
|
|
|
2015-11-23 13:08:21 -08:00
|
|
|
|
reportDestinationChanged = new LimitCallingFrequency(1, () =>
|
|
|
|
|
|
{
|
|
|
|
|
|
UiThread.RunOnIdle(() =>
|
|
|
|
|
|
{
|
2015-11-23 15:45:35 -08:00
|
|
|
|
SetDestinationPositionText(xPosition, yPosition, zPosition);
|
2015-11-23 13:08:21 -08:00
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2017-09-15 12:08:00 -07:00
|
|
|
|
printer.Connection.DestinationChanged.RegisterEvent((object sender, EventArgs e) =>
|
2015-11-23 13:08:21 -08:00
|
|
|
|
{
|
|
|
|
|
|
reportDestinationChanged.CallEvent();
|
|
|
|
|
|
}, ref unregisterEvents);
|
|
|
|
|
|
|
|
|
|
|
|
return hwDestinationBar;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-09-02 08:36:54 -07:00
|
|
|
|
private void SetDestinationPositionText(TextWidget xPosition, TextWidget yPosition, TextWidget zPosition)
|
2015-11-23 15:45:35 -08:00
|
|
|
|
{
|
2017-09-15 12:08:00 -07:00
|
|
|
|
Vector3 destinationPosition = printer.Connection.CurrentDestination;
|
2017-10-31 12:51:16 -07:00
|
|
|
|
xPosition.Text = "X: {0:0.00}".FormatWith(destinationPosition.X);
|
|
|
|
|
|
yPosition.Text = "Y: {0:0.00}".FormatWith(destinationPosition.Y);
|
|
|
|
|
|
zPosition.Text = "Z: {0:0.00}".FormatWith(destinationPosition.Z);
|
2015-11-23 15:45:35 -08:00
|
|
|
|
}
|
2015-11-23 10:49:08 -08:00
|
|
|
|
}
|
2015-04-08 15:20:10 -07:00
|
|
|
|
|
2015-11-23 10:49:08 -08:00
|
|
|
|
public class XYZColors
|
|
|
|
|
|
{
|
2017-10-31 11:43:25 -07:00
|
|
|
|
public static Color eColor = new Color(180, 180, 180);
|
|
|
|
|
|
public static Color xColor = new Color(180, 180, 180);
|
|
|
|
|
|
public static Color yColor = new Color(255, 255, 255);
|
|
|
|
|
|
public static Color zColor = new Color(255, 255, 255);
|
2015-11-23 10:49:08 -08:00
|
|
|
|
|
|
|
|
|
|
public XYZColors()
|
2015-04-08 15:20:10 -07:00
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-01-19 10:56:28 -08:00
|
|
|
|
|
|
|
|
|
|
public class ZTuningWidget : GuiWidget
|
|
|
|
|
|
{
|
|
|
|
|
|
private TextWidget zOffsetStreamDisplay;
|
|
|
|
|
|
private Button clearZOffsetButton;
|
|
|
|
|
|
private FlowLayoutWidget zOffsetStreamContainer;
|
|
|
|
|
|
|
|
|
|
|
|
private EventHandler unregisterEvents;
|
2017-02-17 16:46:38 -08:00
|
|
|
|
private bool allowRemoveButton;
|
2017-09-05 10:33:14 -07:00
|
|
|
|
PrinterSettings printerSettings;
|
2017-01-19 10:56:28 -08:00
|
|
|
|
|
2018-01-10 15:00:59 -08:00
|
|
|
|
public ZTuningWidget(PrinterSettings printerSettings, ThemeConfig theme, bool allowRemoveButton = true)
|
2017-01-19 10:56:28 -08:00
|
|
|
|
{
|
2017-09-05 10:33:14 -07:00
|
|
|
|
this.printerSettings = printerSettings;
|
2017-02-17 16:46:38 -08:00
|
|
|
|
this.allowRemoveButton = allowRemoveButton;
|
2017-08-07 15:47:27 -07:00
|
|
|
|
this.HAnchor = HAnchor.Fit;
|
|
|
|
|
|
this.VAnchor = VAnchor.Fit | VAnchor.Center;
|
2017-01-19 10:56:28 -08:00
|
|
|
|
|
2017-02-01 13:38:14 -08:00
|
|
|
|
ActiveSliceSettings.SettingChanged.RegisterEvent((s, e) =>
|
2017-01-19 10:56:28 -08:00
|
|
|
|
{
|
2017-02-01 15:46:11 -08:00
|
|
|
|
if ((e as StringEventArgs)?.Data == SettingsKey.baby_step_z_offset)
|
2017-02-01 13:38:14 -08:00
|
|
|
|
{
|
2017-02-01 15:46:11 -08:00
|
|
|
|
OffsetStreamChanged(null, null);
|
2017-02-01 13:38:14 -08:00
|
|
|
|
}
|
2017-01-19 10:56:28 -08:00
|
|
|
|
}, ref unregisterEvents);
|
|
|
|
|
|
|
|
|
|
|
|
zOffsetStreamContainer = new FlowLayoutWidget(FlowDirection.LeftToRight)
|
|
|
|
|
|
{
|
|
|
|
|
|
Margin = new BorderDouble(3, 0),
|
|
|
|
|
|
Padding = new BorderDouble(3),
|
2017-08-07 15:47:27 -07:00
|
|
|
|
HAnchor = HAnchor.Fit,
|
|
|
|
|
|
VAnchor = VAnchor.Center,
|
2017-01-19 10:56:28 -08:00
|
|
|
|
BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor,
|
|
|
|
|
|
Height = 20
|
|
|
|
|
|
};
|
|
|
|
|
|
this.AddChild(zOffsetStreamContainer);
|
|
|
|
|
|
|
2017-09-05 10:33:14 -07:00
|
|
|
|
double zoffset = printerSettings.GetValue<double>(SettingsKey.baby_step_z_offset);
|
2017-02-13 15:10:46 -08:00
|
|
|
|
zOffsetStreamDisplay = new TextWidget(zoffset.ToString("0.##"))
|
2017-01-19 10:56:28 -08:00
|
|
|
|
{
|
|
|
|
|
|
AutoExpandBoundsToText = true,
|
|
|
|
|
|
TextColor = ActiveTheme.Instance.PrimaryTextColor,
|
|
|
|
|
|
Margin = new BorderDouble(5, 0, 8, 0),
|
2017-08-07 15:47:27 -07:00
|
|
|
|
VAnchor = VAnchor.Center
|
2017-01-19 10:56:28 -08:00
|
|
|
|
};
|
|
|
|
|
|
zOffsetStreamContainer.AddChild(zOffsetStreamDisplay);
|
|
|
|
|
|
|
2018-01-10 15:00:59 -08:00
|
|
|
|
clearZOffsetButton = theme.CreateSmallResetButton();
|
2017-06-11 14:29:42 -07:00
|
|
|
|
clearZOffsetButton.Name = "Clear ZOffset button";
|
|
|
|
|
|
clearZOffsetButton.ToolTipText = "Clear ZOffset".Localize();
|
|
|
|
|
|
clearZOffsetButton.Visible = allowRemoveButton && zoffset != 0;
|
2017-02-01 13:38:14 -08:00
|
|
|
|
clearZOffsetButton.Click += (sender, e) =>
|
|
|
|
|
|
{
|
2017-09-05 10:33:14 -07:00
|
|
|
|
printerSettings.SetValue(SettingsKey.baby_step_z_offset, "0");
|
2017-02-01 13:38:14 -08:00
|
|
|
|
};
|
2017-01-19 10:56:28 -08:00
|
|
|
|
zOffsetStreamContainer.AddChild(clearZOffsetButton);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
internal void OffsetStreamChanged(object sender, EventArgs e)
|
|
|
|
|
|
{
|
2017-09-05 10:33:14 -07:00
|
|
|
|
double zoffset = printerSettings.GetValue<double>(SettingsKey.baby_step_z_offset);
|
2017-01-19 10:56:28 -08:00
|
|
|
|
bool hasOverriddenZOffset = (zoffset != 0);
|
|
|
|
|
|
|
2017-09-13 21:56:13 -07:00
|
|
|
|
zOffsetStreamContainer.BackgroundColor = (allowRemoveButton && hasOverriddenZOffset) ? SliceSettingsRow.userSettingBackgroundColor : ActiveTheme.Instance.SecondaryBackgroundColor;
|
2017-02-17 16:46:38 -08:00
|
|
|
|
clearZOffsetButton.Visible = allowRemoveButton && hasOverriddenZOffset;
|
2017-01-19 10:56:28 -08:00
|
|
|
|
|
|
|
|
|
|
zOffsetStreamDisplay.Text = zoffset.ToString("0.##");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-02-03 13:06:08 -08:00
|
|
|
|
public override void OnClosed(ClosedEventArgs e)
|
2017-01-19 10:56:28 -08:00
|
|
|
|
{
|
|
|
|
|
|
unregisterEvents?.Invoke(null, null);
|
|
|
|
|
|
base.OnClosed(e);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2016-09-07 13:19:04 -07:00
|
|
|
|
}
|