Continue migrating features to new layout
- Create toolbar for printer - Migrate ActionBarPlus code to new toolbar - Migrate printer specific actions from Options to new toolbar - Consolidate and reuse theme factory instances - Restore F1 reporting of unnamed widgets, useful for finding types
This commit is contained in:
parent
88ff455851
commit
69e83b3dd9
16 changed files with 243 additions and 267 deletions
|
|
@ -30,7 +30,6 @@ either expressed or implied, of the FreeBSD Project.
|
|||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.MatterControl.ActionBar;
|
||||
using MatterHackers.MatterControl.PrintQueue;
|
||||
|
||||
namespace MatterHackers.MatterControl
|
||||
{
|
||||
|
|
|
|||
|
|
@ -70,27 +70,12 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
private Button skipButton;
|
||||
private Button startButton;
|
||||
private Button finishSetupButton;
|
||||
private TextImageButtonFactory textImageButtonFactory;
|
||||
private EventHandler unregisterEvents;
|
||||
|
||||
public PrintActionRow()
|
||||
{
|
||||
this.HAnchor = HAnchor.ParentLeftRight;
|
||||
|
||||
textImageButtonFactory = new TextImageButtonFactory()
|
||||
{
|
||||
normalTextColor = RGBA_Bytes.White,
|
||||
disabledTextColor = RGBA_Bytes.LightGray,
|
||||
hoverTextColor = RGBA_Bytes.White,
|
||||
pressedTextColor = RGBA_Bytes.White,
|
||||
AllowThemeToAdjustImage = false,
|
||||
borderWidth = 1,
|
||||
FixedHeight = 52 * GuiWidget.DeviceScale,
|
||||
fontSize = 14,
|
||||
normalBorderColor = new RGBA_Bytes(255, 255, 255, 100),
|
||||
hoverBorderColor = new RGBA_Bytes(255, 255, 255, 100)
|
||||
};
|
||||
|
||||
AddChildElements();
|
||||
|
||||
// Add Handlers
|
||||
|
|
@ -101,7 +86,9 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
|
||||
protected void AddChildElements()
|
||||
{
|
||||
addButton = textImageButtonFactory.GenerateTooltipButton("Add".Localize(), StaticData.Instance.LoadIcon("icon_circle_plus.png",32,32).InvertLightness());
|
||||
var buttonFactory = ApplicationController.Instance.Theme.ActionRowButtonFactory;
|
||||
|
||||
addButton = buttonFactory.GenerateTooltipButton("Add".Localize(), StaticData.Instance.LoadIcon("icon_circle_plus.png",32,32).InvertLightness());
|
||||
addButton.ToolTipText = "Add a file to be printed".Localize();
|
||||
addButton.Margin = new BorderDouble(6, 6, 6, 3);
|
||||
addButton.Click += (s, e) =>
|
||||
|
|
@ -109,21 +96,21 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
UiThread.RunOnIdle(AddButtonOnIdle);
|
||||
};
|
||||
|
||||
startButton = textImageButtonFactory.GenerateTooltipButton("Print".Localize(), StaticData.Instance.LoadIcon("icon_play_32x32.png",32,32).InvertLightness());
|
||||
startButton = buttonFactory.GenerateTooltipButton("Print".Localize(), StaticData.Instance.LoadIcon("icon_play_32x32.png",32,32).InvertLightness());
|
||||
startButton.Name = "Start Print Button";
|
||||
startButton.ToolTipText = "Begin printing the selected item.".Localize();
|
||||
startButton.Margin = new BorderDouble(6, 6, 6, 3);
|
||||
startButton.Click += onStartButton_Click;
|
||||
|
||||
finishSetupButton = textImageButtonFactory.GenerateTooltipButton("Finish Setup...".Localize());
|
||||
finishSetupButton = buttonFactory.GenerateTooltipButton("Finish Setup...".Localize());
|
||||
finishSetupButton.Name = "Finish Setup Button";
|
||||
finishSetupButton.ToolTipText = "Run setup configuration for printer.".Localize();
|
||||
finishSetupButton.Margin = new BorderDouble(6, 6, 6, 3);
|
||||
finishSetupButton.Click += onStartButton_Click;
|
||||
|
||||
touchScreenConnectButton = textImageButtonFactory.GenerateTooltipButton("Connect".Localize(), StaticData.Instance.LoadIcon("connect.png", 32,32).InvertLightness());
|
||||
touchScreenConnectButton = buttonFactory.GenerateTooltipButton("Connect".Localize(), StaticData.Instance.LoadIcon("connect.png", 32,32).InvertLightness());
|
||||
touchScreenConnectButton.ToolTipText = "Connect to the printer".Localize();
|
||||
touchScreenConnectButton.Margin = new BorderDouble(6, 6, 6, 3);
|
||||
touchScreenConnectButton.Margin = new BorderDouble(0, 6, 6, 3);
|
||||
touchScreenConnectButton.Click += (s, e) =>
|
||||
{
|
||||
if (ActiveSliceSettings.Instance.PrinterSelected)
|
||||
|
|
@ -144,7 +131,7 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
}
|
||||
};
|
||||
|
||||
addPrinterButton = textImageButtonFactory.GenerateTooltipButton("Add Printer".Localize());
|
||||
addPrinterButton = buttonFactory.GenerateTooltipButton("Add Printer".Localize());
|
||||
addPrinterButton.ToolTipText = "Select and add a new printer.".Localize();
|
||||
addPrinterButton.Margin = new BorderDouble(6, 6, 6, 3);
|
||||
addPrinterButton.Click += (s, e) =>
|
||||
|
|
@ -152,7 +139,7 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
UiThread.RunOnIdle(() => WizardWindow.ShowPrinterSetup(true));
|
||||
};
|
||||
|
||||
selectPrinterButton = textImageButtonFactory.GenerateTooltipButton("Select Printer".Localize());
|
||||
selectPrinterButton = buttonFactory.GenerateTooltipButton("Select Printer".Localize());
|
||||
selectPrinterButton.ToolTipText = "Select an existing printer.".Localize();
|
||||
selectPrinterButton.Margin = new BorderDouble(6, 6, 6, 3);
|
||||
selectPrinterButton.Click += (s, e) =>
|
||||
|
|
@ -160,7 +147,7 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
WizardWindow.Show<SetupOptionsPage>("/SetupOptions", "Setup Wizard");
|
||||
};
|
||||
|
||||
resetConnectionButton = textImageButtonFactory.GenerateTooltipButton("Reset".Localize(), StaticData.Instance.LoadIcon("e_stop4.png", 32,32).InvertLightness());
|
||||
resetConnectionButton = buttonFactory.GenerateTooltipButton("Reset".Localize(), StaticData.Instance.LoadIcon("e_stop4.png", 32,32).InvertLightness());
|
||||
resetConnectionButton.ToolTipText = "Reboots the firmware on the controller".Localize();
|
||||
resetConnectionButton.Margin = new BorderDouble(6, 6, 6, 3);
|
||||
resetConnectionButton.Click += (s, e) => UiThread.RunOnIdle(PrinterConnectionAndCommunication.Instance.RebootBoard);
|
||||
|
|
@ -289,9 +276,10 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
|
||||
protected Button makeButton(string buttonText, string buttonToolTip = "")
|
||||
{
|
||||
Button button = textImageButtonFactory.GenerateTooltipButton(buttonText);
|
||||
Button button = ApplicationController.Instance.Theme.ActionRowButtonFactory.GenerateTooltipButton(buttonText);
|
||||
button.ToolTipText = buttonToolTip;
|
||||
button.Margin = new BorderDouble(0, 6, 6, 3);
|
||||
|
||||
return button;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -43,9 +43,7 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
{
|
||||
public class PrintStatusRow : FlowLayoutWidget
|
||||
{
|
||||
private TextWidget activePrintLabel;
|
||||
private TextWidget activePrintName;
|
||||
private PartThumbnailWidget activePrintPreviewImage;
|
||||
private TextWidget activePrintStatus;
|
||||
private TemperatureWidgetBase bedTemperatureWidget;
|
||||
private TemperatureWidgetBase extruderTemperatureWidget;
|
||||
|
|
@ -55,7 +53,8 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
{
|
||||
UiThread.RunOnIdle(OnIdle);
|
||||
|
||||
this.Margin = new BorderDouble(6, 3, 6, 6);
|
||||
this.Margin = 0;
|
||||
this.Padding = 0;
|
||||
this.HAnchor = HAnchor.ParentLeftRight;
|
||||
|
||||
AddChildElements();
|
||||
|
|
@ -75,31 +74,16 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
{
|
||||
UpdatePrintStatus();
|
||||
}, ref unregisterEvents);
|
||||
|
||||
PrinterConnectionAndCommunication.Instance.ActivePrintItemChanged.RegisterEvent(onActivePrintItemChanged, ref unregisterEvents);
|
||||
|
||||
onActivePrintItemChanged(null, null);
|
||||
}
|
||||
|
||||
public override void OnClosed(ClosedEventArgs e)
|
||||
{
|
||||
if (activePrintPreviewImage.ItemWrapper != null)
|
||||
{
|
||||
activePrintPreviewImage.ItemWrapper.SlicingOutputMessage -= PrintItem_SlicingOutputMessage;
|
||||
}
|
||||
|
||||
unregisterEvents?.Invoke(this, null);
|
||||
base.OnClosed(e);
|
||||
}
|
||||
|
||||
private void AddChildElements()
|
||||
{
|
||||
activePrintPreviewImage = new PartThumbnailWidget(null, "part_icon_transparent_100x100.png", "building_thumbnail_100x100.png", PartThumbnailWidget.ImageSizes.Size115x115);
|
||||
activePrintPreviewImage.VAnchor = VAnchor.ParentTop;
|
||||
activePrintPreviewImage.Padding = new BorderDouble(0);
|
||||
activePrintPreviewImage.HoverBackgroundColor = new RGBA_Bytes();
|
||||
activePrintPreviewImage.BorderWidth = 3;
|
||||
|
||||
FlowLayoutWidget temperatureWidgets = new FlowLayoutWidget(FlowDirection.TopToBottom);
|
||||
{
|
||||
extruderTemperatureWidget = new TemperatureWidgetExtruder();
|
||||
|
|
@ -123,7 +107,6 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
iconContainer.Margin = new BorderDouble(top: 3);
|
||||
iconContainer.AddChild(GetAutoLevelIndicator());
|
||||
|
||||
this.AddChild(activePrintPreviewImage);
|
||||
this.AddChild(printStatusContainer);
|
||||
this.AddChild(iconContainer);
|
||||
this.AddChild(temperatureWidgets);
|
||||
|
|
@ -134,30 +117,21 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
|
||||
private FlowLayoutWidget CreateActivePrinterInfoWidget()
|
||||
{
|
||||
FlowLayoutWidget container = new FlowLayoutWidget(FlowDirection.TopToBottom);
|
||||
container.Margin = new BorderDouble(6, 0, 6, 0);
|
||||
container.HAnchor = HAnchor.ParentLeftRight;
|
||||
container.VAnchor |= VAnchor.ParentTop;
|
||||
|
||||
FlowLayoutWidget topRow = new FlowLayoutWidget();
|
||||
topRow.Name = "PrintStatusRow.ActivePrinterInfo.TopRow";
|
||||
topRow.HAnchor = HAnchor.ParentLeftRight;
|
||||
|
||||
activePrintLabel = getPrintStatusLabel("Next Print".Localize() + ":", pointSize: 11);
|
||||
activePrintLabel.VAnchor = VAnchor.ParentTop;
|
||||
|
||||
topRow.AddChild(activePrintLabel);
|
||||
var container = new FlowLayoutWidget(FlowDirection.TopToBottom)
|
||||
{
|
||||
Margin = new BorderDouble(6, 0, 6, 0),
|
||||
HAnchor = HAnchor.ParentLeftRight,
|
||||
VAnchor = VAnchor.ParentBottom | VAnchor.FitToChildren,
|
||||
};
|
||||
|
||||
activePrintName = getPrintStatusLabel("this is the biggest name we will allow", pointSize: 14);
|
||||
activePrintName.AutoExpandBoundsToText = false;
|
||||
container.AddChild(activePrintName);
|
||||
|
||||
activePrintStatus = getPrintStatusLabel("this is the biggest label we will allow - bigger", pointSize: 11);
|
||||
activePrintStatus.AutoExpandBoundsToText = false;
|
||||
activePrintStatus.Text = "";
|
||||
activePrintStatus.Margin = new BorderDouble(top: 3);
|
||||
|
||||
container.AddChild(topRow);
|
||||
container.AddChild(activePrintName);
|
||||
container.AddChild(activePrintStatus);
|
||||
|
||||
return container;
|
||||
|
|
@ -168,6 +142,7 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
ImageButtonFactory imageButtonFactory = new ImageButtonFactory();
|
||||
imageButtonFactory.InvertImageColor = false;
|
||||
ImageBuffer levelingImage = StaticData.Instance.LoadIcon("leveling_32x32.png", 16, 16).InvertLightness();
|
||||
|
||||
Button autoLevelButton = imageButtonFactory.Generate(levelingImage, levelingImage);
|
||||
autoLevelButton.Margin = new Agg.BorderDouble(top: 3);
|
||||
autoLevelButton.ToolTipText = "Print leveling is enabled.".Localize();
|
||||
|
|
@ -191,25 +166,6 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
return widget;
|
||||
}
|
||||
|
||||
private void onActivePrintItemChanged(object sender, EventArgs e)
|
||||
{
|
||||
// first we have to remove any link to an old part (the part currently in the view)
|
||||
if (activePrintPreviewImage.ItemWrapper != null)
|
||||
{
|
||||
activePrintPreviewImage.ItemWrapper.SlicingOutputMessage -= PrintItem_SlicingOutputMessage;
|
||||
}
|
||||
|
||||
activePrintPreviewImage.ItemWrapper = PrinterConnectionAndCommunication.Instance.ActivePrintItem;
|
||||
|
||||
// then hook up our new part
|
||||
if (activePrintPreviewImage.ItemWrapper != null)
|
||||
{
|
||||
activePrintPreviewImage.ItemWrapper.SlicingOutputMessage += PrintItem_SlicingOutputMessage;
|
||||
}
|
||||
|
||||
activePrintPreviewImage.Invalidate();
|
||||
}
|
||||
|
||||
private void OnIdle()
|
||||
{
|
||||
if (PrinterConnectionAndCommunication.Instance.PrinterIsPrinting)
|
||||
|
|
@ -340,7 +296,6 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
printerStatus = "Press 'Add' to choose an item to print".Localize();
|
||||
}
|
||||
|
||||
activePrintLabel.Text = printLabel;
|
||||
activePrintStatus.Text = printerStatus;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,7 +43,6 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
{
|
||||
public class PrinterConnectAndSelectControl : FlowLayoutWidget
|
||||
{
|
||||
private TextImageButtonFactory actionBarButtonFactory = new TextImageButtonFactory();
|
||||
private Button connectPrinterButton;
|
||||
private Button editPrinterButton;
|
||||
private string disconnectAndCancelTitle = "Disconnect and stop the current print?".Localize();
|
||||
|
|
@ -59,18 +58,6 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
{
|
||||
this.HAnchor = HAnchor.ParentLeftRight;
|
||||
|
||||
actionBarButtonFactory.normalTextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||
actionBarButtonFactory.hoverTextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||
actionBarButtonFactory.pressedTextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||
|
||||
actionBarButtonFactory.disabledTextColor = ActiveTheme.Instance.TabLabelUnselected;
|
||||
actionBarButtonFactory.disabledFillColor = ActiveTheme.Instance.PrimaryBackgroundColor;
|
||||
actionBarButtonFactory.disabledBorderColor = ActiveTheme.Instance.SecondaryBackgroundColor;
|
||||
|
||||
actionBarButtonFactory.hoverFillColor = ActiveTheme.Instance.PrimaryBackgroundColor;
|
||||
|
||||
actionBarButtonFactory.invertImageLocation = true;
|
||||
actionBarButtonFactory.borderWidth = 0;
|
||||
this.BackgroundColor = ActiveTheme.Instance.PrimaryBackgroundColor;
|
||||
|
||||
AddChildElements();
|
||||
|
|
@ -84,27 +71,16 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
|
||||
protected void AddChildElements()
|
||||
{
|
||||
actionBarButtonFactory.invertImageLocation = false;
|
||||
actionBarButtonFactory.borderWidth = 1;
|
||||
if (ActiveTheme.Instance.IsDarkTheme)
|
||||
{
|
||||
actionBarButtonFactory.normalBorderColor = new RGBA_Bytes(77, 77, 77);
|
||||
}
|
||||
else
|
||||
{
|
||||
actionBarButtonFactory.normalBorderColor = new RGBA_Bytes(190, 190, 190);
|
||||
}
|
||||
actionBarButtonFactory.hoverBorderColor = new RGBA_Bytes(128, 128, 128);
|
||||
|
||||
var buttonFactory = ApplicationController.Instance.Theme.PrinterConnectButtonFactory;
|
||||
// connect and disconnect buttons
|
||||
{
|
||||
var normalImage = StaticData.Instance.LoadIcon("connect.png", 32, 32);
|
||||
|
||||
// Create the image button with the normal and disabled ImageBuffers
|
||||
connectPrinterButton = actionBarButtonFactory.Generate("Connect".Localize().ToUpper(), normalImage);
|
||||
connectPrinterButton = buttonFactory.Generate("Connect".Localize().ToUpper(), normalImage);
|
||||
connectPrinterButton.Name = "Connect to printer button";
|
||||
connectPrinterButton.ToolTipText = "Connect to the currently selected printer".Localize();
|
||||
connectPrinterButton.Margin = new BorderDouble(6, 0, 3, 3);
|
||||
connectPrinterButton.Margin = new BorderDouble(0, 0, 3, 3);
|
||||
|
||||
connectPrinterButton.VAnchor = VAnchor.ParentTop;
|
||||
connectPrinterButton.Cursor = Cursors.Hand;
|
||||
|
|
@ -120,7 +96,7 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
}
|
||||
};
|
||||
|
||||
disconnectPrinterButton = actionBarButtonFactory.Generate("Disconnect".Localize().ToUpper(), StaticData.Instance.LoadIcon("connect.png", 32, 32));
|
||||
disconnectPrinterButton = buttonFactory.Generate("Disconnect".Localize().ToUpper(), StaticData.Instance.LoadIcon("connect.png", 32, 32));
|
||||
disconnectPrinterButton.Name = "Disconnect from printer button";
|
||||
disconnectPrinterButton.ToolTipText = "Disconnect from current printer".Localize();
|
||||
disconnectPrinterButton.Margin = new BorderDouble(6, 0, 3, 3);
|
||||
|
|
@ -128,8 +104,6 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
disconnectPrinterButton.Cursor = Cursors.Hand;
|
||||
disconnectPrinterButton.Click += (s, e) => UiThread.RunOnIdle(OnIdleDisconnect);
|
||||
|
||||
actionBarButtonFactory.invertImageLocation = true;
|
||||
|
||||
this.AddChild(connectPrinterButton);
|
||||
this.AddChild(disconnectPrinterButton);
|
||||
}
|
||||
|
|
@ -179,7 +153,7 @@ namespace MatterHackers.MatterControl.ActionBar
|
|||
// reset connection button
|
||||
{
|
||||
string resetConnectionText = "Reset\nConnection".Localize().ToUpper();
|
||||
Button resetConnectionButton = actionBarButtonFactory.Generate(resetConnectionText, "e_stop4.png");
|
||||
Button resetConnectionButton = buttonFactory.Generate(resetConnectionText, "e_stop4.png");
|
||||
resetConnectionButton.Margin = new BorderDouble(6, 0, 3, 3);
|
||||
this.AddChild(resetConnectionButton);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue