commit
7fb26eabc4
7 changed files with 99 additions and 102 deletions
|
|
@ -28,11 +28,11 @@ either expressed or implied, of the FreeBSD Project.
|
|||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.ImageProcessing;
|
||||
using MatterHackers.Agg.Platform;
|
||||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.MatterControl.CustomWidgets;
|
||||
using MatterHackers.MatterControl.PartPreviewWindow;
|
||||
|
||||
namespace MatterHackers.MatterControl.ActionBar
|
||||
|
|
@ -52,12 +52,11 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
|
||||
protected EventHandler unregisterEvents;
|
||||
protected PrinterConfig printer;
|
||||
protected List<GuiWidget> alwaysEnabled;
|
||||
|
||||
protected virtual int ActualTemperature { get; }
|
||||
protected virtual int TargetTemperature { get; }
|
||||
|
||||
private DisableablePanel disableablePanel;
|
||||
|
||||
public TemperatureWidgetBase(PrinterConfig printer, string textValue)
|
||||
{
|
||||
this.AlignToRightEdge = true;
|
||||
|
|
@ -66,9 +65,11 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
this.HAnchor = HAnchor.Fit;
|
||||
this.VAnchor = VAnchor.Fit | VAnchor.Center;
|
||||
this.Cursor = Cursors.Hand;
|
||||
|
||||
this.MakeScrollable = false;
|
||||
this.AlignToRightEdge = true;
|
||||
|
||||
alwaysEnabled = new List<GuiWidget>();
|
||||
|
||||
var container = new FlowLayoutWidget()
|
||||
{
|
||||
HAnchor = HAnchor.Fit,
|
||||
|
|
@ -106,11 +107,23 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
};
|
||||
container.AddChild(DirectionIndicator);
|
||||
|
||||
|
||||
bool isEnabled = printer.Connection.IsConnected;
|
||||
|
||||
printer.Connection.CommunicationStateChanged.RegisterEvent((s, e) =>
|
||||
{
|
||||
if (disableablePanel != null)
|
||||
if (isEnabled != printer.Connection.IsConnected)
|
||||
{
|
||||
disableablePanel.Enabled = printer.Connection.IsConnected;
|
||||
isEnabled = printer.Connection.IsConnected;
|
||||
|
||||
var flowLayout = this.PopupContent.Children.OfType<FlowLayoutWidget>().FirstOrDefault();
|
||||
if (flowLayout != null)
|
||||
{
|
||||
foreach (var child in flowLayout.Children.Except(alwaysEnabled))
|
||||
{
|
||||
child.Enabled = isEnabled;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}, ref unregisterEvents);
|
||||
|
|
@ -140,19 +153,6 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
|
||||
protected virtual void SetTargetTemperature(double targetTemp) { }
|
||||
|
||||
protected abstract GuiWidget GetPopupContent();
|
||||
|
||||
public override void OnLoad(EventArgs args)
|
||||
{
|
||||
// Wrap popup content in a DisableablePanel
|
||||
disableablePanel = new DisableablePanel(this.GetPopupContent(), printer.Connection.IsConnected, alpha: 140);
|
||||
|
||||
// Set as popup
|
||||
this.PopupContent = disableablePanel;
|
||||
|
||||
base.OnLoad(args);
|
||||
}
|
||||
|
||||
public override void OnClosed(ClosedEventArgs e)
|
||||
{
|
||||
unregisterEvents?.Invoke(this, null);
|
||||
|
|
|
|||
|
|
@ -56,13 +56,15 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
|
||||
this.ImageWidget.Image = AggContext.StaticData.LoadIcon("bed.png", IconColor.Theme);
|
||||
|
||||
this.PopupContent = this.GetPopupContent();
|
||||
|
||||
printer.Connection.BedTemperatureRead.RegisterEvent((s, e) => DisplayCurrentTemperature(), ref unregisterEvents);
|
||||
}
|
||||
|
||||
protected override int ActualTemperature => (int)printer.Connection.ActualBedTemperature;
|
||||
protected override int TargetTemperature => (int)printer.Connection.TargetBedTemperature;
|
||||
|
||||
protected override GuiWidget GetPopupContent()
|
||||
private GuiWidget GetPopupContent()
|
||||
{
|
||||
var widget = new IgnoredPopupWidget()
|
||||
{
|
||||
|
|
@ -113,9 +115,10 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
var settingsContext = new SettingsContext(printer, null, NamedSettingsLayers.All);
|
||||
|
||||
var settingsData = SettingsOrganizer.Instance.GetSettingsData(SettingsKey.bed_temperature);
|
||||
var row = SliceSettingsTabView.CreateItemRow(settingsData, settingsContext, printer, Color.Black, ApplicationController.Instance.Theme, ref tabIndex);
|
||||
var temperatureRow = SliceSettingsTabView.CreateItemRow(settingsData, settingsContext, printer, Color.Black, ApplicationController.Instance.Theme, ref tabIndex);
|
||||
container.AddChild(temperatureRow);
|
||||
|
||||
container.AddChild(row);
|
||||
alwaysEnabled.Add(hotendRow);
|
||||
|
||||
// add in the temp graph
|
||||
var graph = new DataViewGraph()
|
||||
|
|
@ -136,8 +139,8 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
graph.AddData(this.ActualTemperature);
|
||||
}, 1, () => !HasBeenClosed);
|
||||
|
||||
var valueField = row.Descendants<MHNumberEdit>().FirstOrDefault();
|
||||
var settingsRow = row.DescendantsAndSelf<SliceSettingsRow>().FirstOrDefault();
|
||||
var valueField = temperatureRow.Descendants<MHNumberEdit>().FirstOrDefault();
|
||||
var settingsRow = temperatureRow.DescendantsAndSelf<SliceSettingsRow>().FirstOrDefault();
|
||||
ActiveSliceSettings.SettingChanged.RegisterEvent((s, e) =>
|
||||
{
|
||||
if (e is StringEventArgs stringEvent)
|
||||
|
|
|
|||
|
|
@ -49,8 +49,7 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
internal ControlContentExtruder(PrinterConfig printer, int extruderIndex, ThemeConfig theme)
|
||||
: base(FlowDirection.TopToBottom)
|
||||
{
|
||||
HAnchor = HAnchor.Stretch;
|
||||
|
||||
this.HAnchor = HAnchor.Stretch;
|
||||
this.printer = printer;
|
||||
|
||||
GuiWidget macroButtons = null;
|
||||
|
|
@ -58,7 +57,33 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
if (extruderIndex == 0)
|
||||
{
|
||||
// add in load and unload buttons
|
||||
macroButtons = GetExtruderMacros(extruderIndex, theme.MenuButtonFactory);
|
||||
macroButtons = new FlowLayoutWidget()
|
||||
{
|
||||
Padding = theme.ToolbarPadding,
|
||||
};
|
||||
|
||||
var loadFilament = new GCodeMacro()
|
||||
{
|
||||
GCode = AggContext.StaticData.ReadAllText(Path.Combine("SliceSettings", "load_filament.txt"))
|
||||
};
|
||||
|
||||
Button loadButton = theme.MenuButtonFactory.Generate("Load".Localize());
|
||||
loadButton.Margin = theme.ButtonSpacing;
|
||||
loadButton.ToolTipText = "Load filament".Localize();
|
||||
loadButton.Click += (s, e) => loadFilament.Run(printer.Connection);
|
||||
macroButtons.AddChild(loadButton);
|
||||
|
||||
var unloadFilament = new GCodeMacro()
|
||||
{
|
||||
GCode = AggContext.StaticData.ReadAllText(Path.Combine("SliceSettings", "unload_filament.txt"))
|
||||
};
|
||||
|
||||
Button unloadButton = theme.MenuButtonFactory.Generate("Unload".Localize());
|
||||
unloadButton.Margin = theme.ButtonSpacing;
|
||||
loadButton.ToolTipText = "Unload filament".Localize();
|
||||
unloadButton.Click += (s, e) => unloadFilament.Run(printer.Connection);
|
||||
macroButtons.AddChild(unloadButton);
|
||||
|
||||
this.AddChild(new SettingsItem("Filament".Localize(), macroButtons, enforceGutter: false));
|
||||
}
|
||||
|
||||
|
|
@ -66,12 +91,13 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
var buttonContainer = new FlowLayoutWidget()
|
||||
{
|
||||
HAnchor = HAnchor.Fit,
|
||||
VAnchor = VAnchor.Fit
|
||||
VAnchor = VAnchor.Fit,
|
||||
Padding = theme.ToolbarPadding,
|
||||
};
|
||||
|
||||
var retractButton = theme.MenuButtonFactory.Generate("Retract".Localize());
|
||||
retractButton.Margin = theme.ButtonSpacing;
|
||||
retractButton.ToolTipText = "Retract filament".Localize();
|
||||
retractButton.Margin = new BorderDouble(8, 0);
|
||||
retractButton.Click += (s, e) =>
|
||||
{
|
||||
printer.Connection.MoveExtruderRelative(moveAmount * -1, printer.Settings.EFeedRate(extruderIndex), extruderIndex);
|
||||
|
|
@ -81,9 +107,9 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
int extruderButtonTopMargin = macroButtons == null ? 8 : 0;
|
||||
|
||||
var extrudeButton = theme.MenuButtonFactory.Generate("Extrude".Localize());
|
||||
extrudeButton.Margin = theme.ButtonSpacing;
|
||||
extrudeButton.Name = "Extrude Button";
|
||||
extrudeButton.ToolTipText = "Extrude filament".Localize();
|
||||
extrudeButton.Margin = new BorderDouble(0, 0, 0, extruderButtonTopMargin);
|
||||
extrudeButton.Click += (s, e) =>
|
||||
{
|
||||
printer.Connection.MoveExtruderRelative(moveAmount, printer.Settings.EFeedRate(extruderIndex), extruderIndex);
|
||||
|
|
@ -97,9 +123,9 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
|
||||
var moveButtonsContainer = new FlowLayoutWidget()
|
||||
{
|
||||
VAnchor = VAnchor.Fit,
|
||||
VAnchor = VAnchor.Fit | VAnchor.Center,
|
||||
HAnchor = HAnchor.Fit,
|
||||
Margin = new BorderDouble(0, 3)
|
||||
Padding = theme.ToolbarPadding,
|
||||
};
|
||||
|
||||
RadioButton oneButton = theme.MicroButtonMenu.GenerateRadioButton("1");
|
||||
|
|
@ -145,26 +171,6 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
|
||||
this.AddChild(new SettingsItem("Distance".Localize(), moveButtonsContainer, enforceGutter: false));
|
||||
}
|
||||
|
||||
private GuiWidget GetExtruderMacros(int extruderIndex, TextImageButtonFactory buttonFactory)
|
||||
{
|
||||
var row = new FlowLayoutWidget();
|
||||
|
||||
GCodeMacro loadFilament = new GCodeMacro();
|
||||
loadFilament.GCode = AggContext.StaticData.ReadAllText(Path.Combine("SliceSettings", "load_filament.txt"));
|
||||
Button loadButton = buttonFactory.Generate("Load".Localize());
|
||||
loadButton.Margin = new BorderDouble(0, 8, 8, 4);
|
||||
loadButton.Click += (s, e) => loadFilament.Run(printer.Connection);
|
||||
row.AddChild(loadButton);
|
||||
|
||||
GCodeMacro unloadFilament = new GCodeMacro();
|
||||
unloadFilament.GCode = AggContext.StaticData.ReadAllText(Path.Combine("SliceSettings", "unload_filament.txt"));
|
||||
Button unloadButton = buttonFactory.Generate("Unload".Localize());
|
||||
unloadButton.Click += (s, e) => unloadFilament.Run(printer.Connection);
|
||||
row.AddChild(unloadButton);
|
||||
|
||||
return row;
|
||||
}
|
||||
}
|
||||
|
||||
internal class TemperatureWidgetHotend : TemperatureWidgetBase
|
||||
|
|
@ -184,21 +190,20 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
this.ToolTipText = "Current extruder temperature".Localize();
|
||||
this.theme = theme;
|
||||
|
||||
this.PopupContent = this.GetPopupContent();
|
||||
|
||||
printer.Connection.HotendTemperatureRead.RegisterEvent((s, e) => DisplayCurrentTemperature(), ref unregisterEvents);
|
||||
}
|
||||
|
||||
protected override int ActualTemperature => (int)printer.Connection.GetActualHotendTemperature(this.hotendIndex);
|
||||
protected override int TargetTemperature => (int)printer.Connection.GetTargetHotendTemperature(this.hotendIndex);
|
||||
|
||||
string TemperatureKey
|
||||
private string TemperatureKey
|
||||
{
|
||||
get
|
||||
{
|
||||
return "temperature" + ((this.hotendIndex > 0 && this.hotendIndex < 4) ? hotendIndex.ToString() : "");
|
||||
}
|
||||
get => "temperature" + ((this.hotendIndex > 0 && this.hotendIndex < 4) ? hotendIndex.ToString() : "");
|
||||
}
|
||||
|
||||
protected override GuiWidget GetPopupContent()
|
||||
private GuiWidget GetPopupContent()
|
||||
{
|
||||
var widget = new IgnoredPopupWidget()
|
||||
{
|
||||
|
|
@ -248,9 +253,11 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
var settingsContext = new SettingsContext(printer, null, NamedSettingsLayers.All);
|
||||
// TODO: make this be for the correct extruder
|
||||
var settingsData = SettingsOrganizer.Instance.GetSettingsData(TemperatureKey);
|
||||
var row = SliceSettingsTabView.CreateItemRow(settingsData, settingsContext, printer, Color.Black, ApplicationController.Instance.Theme, ref tabIndex);
|
||||
var temperatureRow = SliceSettingsTabView.CreateItemRow(settingsData, settingsContext, printer, Color.Black, ApplicationController.Instance.Theme, ref tabIndex);
|
||||
container.AddChild(temperatureRow);
|
||||
|
||||
container.AddChild(row);
|
||||
// Add the temperature row to the always enabled list ensuring the field can be set when disconnected
|
||||
alwaysEnabled.Add(temperatureRow);
|
||||
|
||||
// add in the temp graph
|
||||
var graph = new DataViewGraph()
|
||||
|
|
@ -269,9 +276,9 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
graph.AddData(this.ActualTemperature);
|
||||
}, 1, () => !HasBeenClosed);
|
||||
|
||||
var valueField = row.Descendants<MHNumberEdit>().FirstOrDefault();
|
||||
var valueField = temperatureRow.Descendants<MHNumberEdit>().FirstOrDefault();
|
||||
valueField.Name = "Temperature Input";
|
||||
var settingsRow = row.DescendantsAndSelf<SliceSettingsRow>().FirstOrDefault();
|
||||
var settingsRow = temperatureRow.DescendantsAndSelf<SliceSettingsRow>().FirstOrDefault();
|
||||
ActiveSliceSettings.SettingChanged.RegisterEvent((s, e) =>
|
||||
{
|
||||
if (e is StringEventArgs stringEvent)
|
||||
|
|
@ -295,35 +302,38 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
if (hotendIndex == 0)
|
||||
{
|
||||
// put in the material selector
|
||||
var presetsSelector = new PresetSelectorWidget(printer, "Material".Localize(), Color.Transparent, NamedSettingsLayers.Material, true)
|
||||
{
|
||||
Margin = 0,
|
||||
BackgroundColor = Color.Transparent,
|
||||
HAnchor = HAnchor.Absolute,
|
||||
Width = 150
|
||||
};
|
||||
|
||||
var presetsSelector = new PresetSelectorWidget(printer, "Material".Localize(), Color.Transparent, NamedSettingsLayers.Material, true);
|
||||
presetsSelector.DropDownList.Name = "Hotend Preset Selector";
|
||||
|
||||
this.Width = 150;
|
||||
|
||||
// HACK: remove undesired item
|
||||
var label = presetsSelector.Children<TextWidget>().FirstOrDefault();
|
||||
label.Close();
|
||||
|
||||
var pulldownContainer = presetsSelector.FindNamedChildRecursive("Preset Pulldown Container");
|
||||
if (pulldownContainer != null)
|
||||
{
|
||||
pulldownContainer.Padding = 0;
|
||||
pulldownContainer.Padding = theme.ToolbarPadding;
|
||||
pulldownContainer.HAnchor = HAnchor.Fit;
|
||||
pulldownContainer.Margin = 0;
|
||||
}
|
||||
|
||||
var dropList = presetsSelector.FindNamedChildRecursive("Material") as DropDownList;
|
||||
var dropList = pulldownContainer.Children.OfType<DropDownList>().FirstOrDefault();
|
||||
if (dropList != null)
|
||||
{
|
||||
dropList.Name = "Hotend Preset Selector";
|
||||
dropList.HAnchor = HAnchor.Fit;
|
||||
dropList.TextColor = Color.Black;
|
||||
dropList.Margin = 0;
|
||||
}
|
||||
|
||||
container.AddChild(new SettingsItem("Material".Localize(), presetsSelector, enforceGutter: false));
|
||||
// Remove the pulldowncontainer from its parent and add it to our Material row
|
||||
pulldownContainer.Parent.RemoveChild(pulldownContainer);
|
||||
pulldownContainer.ClearRemovedFlag();
|
||||
container.AddChild(
|
||||
new SettingsItem("Material".Localize(), pulldownContainer, enforceGutter: false)
|
||||
{
|
||||
Border = new BorderDouble(0, 1)
|
||||
});
|
||||
|
||||
// Close the presetsSelector
|
||||
presetsSelector.Close();
|
||||
|
||||
}
|
||||
else // put in a temperature selector for the correct material
|
||||
{
|
||||
|
|
|
|||
|
|
@ -88,8 +88,6 @@ namespace MatterHackers.MatterControl.CustomWidgets
|
|||
|
||||
Color backgroundGridColor = Color.Gray;
|
||||
|
||||
graphics2D.Line(0, 0, Width, 0, backgroundGridColor);
|
||||
graphics2D.Line(0, Height, Width, Height, backgroundGridColor);
|
||||
|
||||
double pixelSkip = Height;
|
||||
for (int i = 0; i < Width / pixelSkip; i++)
|
||||
|
|
|
|||
|
|
@ -89,8 +89,6 @@ namespace MatterHackers.MatterControl.DataStorage
|
|||
isSaved = false;
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
[PrimaryKey, AutoIncrement]
|
||||
public int Id { get; set; }
|
||||
|
||||
|
|
@ -147,16 +145,6 @@ namespace MatterHackers.MatterControl.DataStorage
|
|||
return this.hashCode;
|
||||
}
|
||||
|
||||
protected void OnPropertyChanged(string name)
|
||||
{
|
||||
PropertyChangedEventHandler handler = PropertyChanged;
|
||||
this.hashCode = 0;
|
||||
if (handler != null)
|
||||
{
|
||||
handler(this, new PropertyChangedEventArgs(name));
|
||||
}
|
||||
}
|
||||
|
||||
private void TryHandleInsert()
|
||||
{
|
||||
retryCount++;
|
||||
|
|
|
|||
|
|
@ -51,8 +51,10 @@ namespace MatterHackers.MatterControl.CustomWidgets
|
|||
private double right;
|
||||
private RoundedRect backgroundBar;
|
||||
|
||||
private double toggleRadius = 10;
|
||||
private double toggleRadiusPlusPadding = 11;
|
||||
private double minWidth = 45 * DeviceScale;
|
||||
private double barHeight = 12.6 * DeviceScale;
|
||||
private double toggleRadius = 9 * DeviceScale;
|
||||
private double toggleRadiusPlusPadding = 10 * DeviceScale;
|
||||
|
||||
private bool _checked;
|
||||
public bool Checked
|
||||
|
|
@ -77,7 +79,7 @@ namespace MatterHackers.MatterControl.CustomWidgets
|
|||
inactiveBarColor = theme.Colors.IsDarkTheme ? theme.Shade : theme.SlightShade;
|
||||
activeBarColor = new Color(theme.Colors.PrimaryAccentColor, (theme.Colors.IsDarkTheme ? 100 : 70));
|
||||
|
||||
this.MinimumSize = new Vector2(50, theme.ButtonHeight);
|
||||
this.MinimumSize = new Vector2(minWidth, theme.ButtonHeight);
|
||||
}
|
||||
|
||||
public override void OnMouseDown(MouseEventArgs mouseEvent)
|
||||
|
|
@ -179,9 +181,7 @@ namespace MatterHackers.MatterControl.CustomWidgets
|
|||
{
|
||||
centerY = this.LocalBounds.YCenter;
|
||||
|
||||
var barHeight = 14;
|
||||
|
||||
int halfBarHeight = barHeight / 2;
|
||||
var halfBarHeight = barHeight / 2;
|
||||
|
||||
var diff = toggleRadiusPlusPadding - halfBarHeight;
|
||||
|
||||
|
|
|
|||
|
|
@ -465,8 +465,6 @@ namespace MatterHackers.MatterControl.PrinterCommunication
|
|||
{
|
||||
if (activePrintTask != null)
|
||||
{
|
||||
TimeSpan printTimeSpan = DateTime.Now.Subtract(activePrintTask.PrintStart);
|
||||
|
||||
activePrintTask.PrintEnd = DateTime.Now;
|
||||
activePrintTask.PercentDone = 100;
|
||||
activePrintTask.PrintComplete = true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue