commit
b7da8de443
2 changed files with 110 additions and 20 deletions
|
|
@ -12,7 +12,11 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
||||||
|
|
||||||
List<GuiWidget> radioButtonsOfKnownPrinters = new List<GuiWidget>();
|
List<GuiWidget> radioButtonsOfKnownPrinters = new List<GuiWidget>();
|
||||||
TextImageButtonFactory textImageButtonFactory = new TextImageButtonFactory();
|
TextImageButtonFactory textImageButtonFactory = new TextImageButtonFactory();
|
||||||
|
TextImageButtonFactory editButtonFactory = new TextImageButtonFactory();
|
||||||
Button closeButton;
|
Button closeButton;
|
||||||
|
Button enterEditModeButton;
|
||||||
|
Button leaveEditModeButton;
|
||||||
|
|
||||||
bool editMode;
|
bool editMode;
|
||||||
|
|
||||||
public ChooseConnectionWidget(ConnectionWindow windowController, SystemWindow container, bool editMode = false)
|
public ChooseConnectionWidget(ConnectionWindow windowController, SystemWindow container, bool editMode = false)
|
||||||
|
|
@ -26,6 +30,13 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
||||||
textImageButtonFactory.disabledTextColor = ActiveTheme.Instance.PrimaryTextColor;
|
textImageButtonFactory.disabledTextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||||
textImageButtonFactory.pressedTextColor = ActiveTheme.Instance.PrimaryTextColor;
|
textImageButtonFactory.pressedTextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||||
textImageButtonFactory.borderWidth = 0;
|
textImageButtonFactory.borderWidth = 0;
|
||||||
|
|
||||||
|
editButtonFactory.normalTextColor = ActiveTheme.Instance.SecondaryAccentColor;
|
||||||
|
editButtonFactory.hoverTextColor = RGBA_Bytes.White;
|
||||||
|
editButtonFactory.disabledTextColor = ActiveTheme.Instance.SecondaryAccentColor;
|
||||||
|
editButtonFactory.pressedTextColor = RGBA_Bytes.White;
|
||||||
|
editButtonFactory.borderWidth = 0;
|
||||||
|
editButtonFactory.FixedWidth = 50;
|
||||||
|
|
||||||
this.AnchorAll();
|
this.AnchorAll();
|
||||||
this.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;
|
this.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;
|
||||||
|
|
@ -39,7 +50,7 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
||||||
FlowLayoutWidget headerRow = new FlowLayoutWidget(FlowDirection.LeftToRight);
|
FlowLayoutWidget headerRow = new FlowLayoutWidget(FlowDirection.LeftToRight);
|
||||||
headerRow.HAnchor = HAnchor.ParentLeftRight;
|
headerRow.HAnchor = HAnchor.ParentLeftRight;
|
||||||
headerRow.Margin = new BorderDouble(0, 3, 0, 0);
|
headerRow.Margin = new BorderDouble(0, 3, 0, 0);
|
||||||
headerRow.Padding = new BorderDouble(0, 3, 0, 3);
|
headerRow.Padding = new BorderDouble(0, 3, 0, 0);
|
||||||
|
|
||||||
{
|
{
|
||||||
string chooseThreeDPrinterConfigLabel = LocalizedString.Get("Choose a 3D Printer Configuration");
|
string chooseThreeDPrinterConfigLabel = LocalizedString.Get("Choose a 3D Printer Configuration");
|
||||||
|
|
@ -48,24 +59,31 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
||||||
TextWidget elementHeader = new TextWidget(string.Format(chooseThreeDPrinterConfigFull), pointSize: 14);
|
TextWidget elementHeader = new TextWidget(string.Format(chooseThreeDPrinterConfigFull), pointSize: 14);
|
||||||
elementHeader.TextColor = this.defaultTextColor;
|
elementHeader.TextColor = this.defaultTextColor;
|
||||||
elementHeader.HAnchor = HAnchor.ParentLeftRight;
|
elementHeader.HAnchor = HAnchor.ParentLeftRight;
|
||||||
elementHeader.VAnchor = Agg.UI.VAnchor.ParentBottom;
|
elementHeader.VAnchor = Agg.UI.VAnchor.ParentCenter;
|
||||||
|
|
||||||
ActionLink editModeLink;
|
// ActionLink editModeLink;
|
||||||
if (!this.editMode)
|
|
||||||
{
|
|
||||||
editModeLink = actionLinkFactory.Generate(LocalizedString.Get("Edit"), 12, EditModeOnLink_Click);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
editModeLink = actionLinkFactory.Generate(LocalizedString.Get("Done"), 12, EditModeOffLink_Click);
|
|
||||||
}
|
|
||||||
|
|
||||||
//editModeLink.TextColor = new RGBA_Bytes(250, 250, 250);
|
enterEditModeButton = editButtonFactory.Generate (LocalizedString.Get ("Edit"), centerText: true);
|
||||||
editModeLink.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
enterEditModeButton.Click += EditModeOnLink_Click;
|
||||||
editModeLink.VAnchor = Agg.UI.VAnchor.ParentBottom;
|
leaveEditModeButton = editButtonFactory.Generate (LocalizedString.Get ("Done"), centerText: true);
|
||||||
|
leaveEditModeButton.Click += EditModeOffLink_Click;
|
||||||
|
|
||||||
headerRow.AddChild(elementHeader);
|
if (!this.editMode)
|
||||||
headerRow.AddChild(editModeLink);
|
{
|
||||||
|
leaveEditModeButton.Visible = false;
|
||||||
|
enterEditModeButton.Visible = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
leaveEditModeButton.Visible = true;
|
||||||
|
enterEditModeButton.Visible = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
headerRow.AddChild(enterEditModeButton);
|
||||||
|
headerRow.AddChild (leaveEditModeButton);
|
||||||
|
headerRow.AddChild(elementHeader);
|
||||||
}
|
}
|
||||||
|
|
||||||
//To do - replace with scrollable widget
|
//To do - replace with scrollable widget
|
||||||
|
|
@ -137,15 +155,22 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
||||||
closeButton.UnbindClickEvents();
|
closeButton.UnbindClickEvents();
|
||||||
closeButton.Click += new ButtonBase.ButtonEventHandler(CloseWindow);
|
closeButton.Click += new ButtonBase.ButtonEventHandler(CloseWindow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EditModeOnLink_Click(object sender, MouseEventArgs mouseEvent)
|
void EditModeOnLink_Click(object sender, MouseEventArgs mouseEvent)
|
||||||
{
|
{
|
||||||
this.windowController.ChangeToChoosePrinter(true);
|
|
||||||
|
this.windowController.ChangeToChoosePrinter(true);
|
||||||
|
enterEditModeButton.Visible = false;
|
||||||
|
leaveEditModeButton.Visible = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditModeOffLink_Click(object sender, MouseEventArgs mouseEvent)
|
void EditModeOffLink_Click(object sender, MouseEventArgs mouseEvent)
|
||||||
{
|
{
|
||||||
this.windowController.ChangeToChoosePrinter(false);
|
|
||||||
|
this.windowController.ChangeToChoosePrinter(false);
|
||||||
|
enterEditModeButton.Visible = true;
|
||||||
|
leaveEditModeButton.Visible = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddConnectionLink_Click(object sender, MouseEventArgs mouseEvent)
|
void AddConnectionLink_Click(object sender, MouseEventArgs mouseEvent)
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
||||||
|
|
||||||
RGBA_Bytes defaultTextColor = new RGBA_Bytes(34, 34, 34);
|
RGBA_Bytes defaultTextColor = new RGBA_Bytes(34, 34, 34);
|
||||||
RGBA_Bytes hoverTextColor = new RGBA_Bytes(34, 34, 34);
|
RGBA_Bytes hoverTextColor = new RGBA_Bytes(34, 34, 34);
|
||||||
|
SlideWidget rightButtonOverlay;
|
||||||
|
|
||||||
public PrinterListItemView(Printer printerRecord, ConnectionWindow windowController)
|
public PrinterListItemView(Printer printerRecord, ConnectionWindow windowController)
|
||||||
:base(printerRecord, windowController)
|
:base(printerRecord, windowController)
|
||||||
|
|
@ -73,19 +74,78 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
||||||
availableIndicator.Padding = new BorderDouble(3, 0, 0, 3);
|
availableIndicator.Padding = new BorderDouble(3, 0, 0, 3);
|
||||||
availableIndicator.VAnchor = Agg.UI.VAnchor.ParentCenter;
|
availableIndicator.VAnchor = Agg.UI.VAnchor.ParentCenter;
|
||||||
|
|
||||||
|
rightButtonOverlay = getItemActionButtons();
|
||||||
|
rightButtonOverlay.Visible = false;
|
||||||
this.AddChild(printerName);
|
this.AddChild(printerName);
|
||||||
this.AddChild(availableIndicator);
|
this.AddChild (rightButtonOverlay);
|
||||||
|
//this.AddChild(availableIndicator);
|
||||||
this.HAnchor = HAnchor.ParentLeftRight;
|
this.HAnchor = HAnchor.ParentLeftRight;
|
||||||
|
|
||||||
BindHandlers();
|
BindHandlers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SlideWidget getItemActionButtons()
|
||||||
|
{
|
||||||
|
SlideWidget buttonContainer = new SlideWidget();
|
||||||
|
buttonContainer.VAnchor = VAnchor.ParentBottomTop;
|
||||||
|
|
||||||
|
FlowLayoutWidget buttonFlowContainer = new FlowLayoutWidget(FlowDirection.LeftToRight);
|
||||||
|
buttonFlowContainer.VAnchor = VAnchor.ParentBottomTop;
|
||||||
|
|
||||||
|
ClickWidget removeButton = new ClickWidget();
|
||||||
|
removeButton.VAnchor = VAnchor.ParentBottomTop;
|
||||||
|
removeButton.BackgroundColor = ActiveTheme.Instance.PrimaryAccentColor;
|
||||||
|
removeButton.Width = 60;
|
||||||
|
|
||||||
|
TextWidget printLabel = new TextWidget("remove".Localize());
|
||||||
|
printLabel.TextColor = RGBA_Bytes.White;
|
||||||
|
printLabel.VAnchor = VAnchor.ParentCenter;
|
||||||
|
printLabel.HAnchor = HAnchor.ParentCenter;
|
||||||
|
|
||||||
|
removeButton.AddChild(printLabel);
|
||||||
|
removeButton.Click += (sender, e) =>
|
||||||
|
{
|
||||||
|
// QueueData.Instance.AddItem(this.printItemWrapper,0);
|
||||||
|
// QueueData.Instance.SelectedIndex = 0;
|
||||||
|
// this.Invalidate();
|
||||||
|
|
||||||
|
};;
|
||||||
|
|
||||||
|
ClickWidget editButton = new ClickWidget();
|
||||||
|
editButton.VAnchor = VAnchor.ParentBottomTop;
|
||||||
|
editButton.BackgroundColor = ActiveTheme.Instance.SecondaryAccentColor;
|
||||||
|
editButton.Width = 60;
|
||||||
|
|
||||||
|
|
||||||
|
TextWidget editLabel = new TextWidget("edit".Localize());
|
||||||
|
editLabel.TextColor = RGBA_Bytes.White;
|
||||||
|
editLabel.VAnchor = VAnchor.ParentCenter;
|
||||||
|
editLabel.HAnchor = HAnchor.ParentCenter;
|
||||||
|
|
||||||
|
editButton.AddChild(editLabel);
|
||||||
|
editButton.Click += (sender, e) =>
|
||||||
|
{
|
||||||
|
this.windowController.ChangedToEditPrinter(this.printerRecord);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
buttonFlowContainer.AddChild(editButton);
|
||||||
|
buttonFlowContainer.AddChild(removeButton);
|
||||||
|
|
||||||
|
buttonContainer.AddChild(buttonFlowContainer);
|
||||||
|
buttonContainer.Width = 120;
|
||||||
|
return buttonContainer;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void BindHandlers()
|
public void BindHandlers()
|
||||||
{
|
{
|
||||||
this.MouseEnter += new EventHandler(onMouse_Enter);
|
this.MouseEnter += new EventHandler(onMouse_Enter);
|
||||||
this.MouseLeave += new EventHandler(onMouse_Leave);
|
this.MouseLeave += new EventHandler(onMouse_Leave);
|
||||||
this.MouseUp += new MouseEventHandler(onMouse_Up);
|
this.MouseUp += new MouseEventHandler(onMouse_Up);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void onMouse_Up(object sender, MouseEventArgs mouseEvent)
|
void onMouse_Up(object sender, MouseEventArgs mouseEvent)
|
||||||
{
|
{
|
||||||
|
|
@ -104,14 +164,19 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
||||||
|
|
||||||
void onMouse_Enter(object sender, EventArgs args)
|
void onMouse_Enter(object sender, EventArgs args)
|
||||||
{
|
{
|
||||||
|
this.rightButtonOverlay.SlideIn ();
|
||||||
this.BackgroundColor = this.hoverBackgroundColor;
|
this.BackgroundColor = this.hoverBackgroundColor;
|
||||||
this.printerName.TextColor = this.hoverTextColor;
|
this.printerName.TextColor = this.hoverTextColor;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void onMouse_Leave(object sender, EventArgs args)
|
void onMouse_Leave(object sender, EventArgs args)
|
||||||
{
|
{
|
||||||
|
this.rightButtonOverlay.SlideOut ();
|
||||||
this.BackgroundColor = this.defaultBackgroundColor;
|
this.BackgroundColor = this.defaultBackgroundColor;
|
||||||
this.printerName.TextColor = this.defaultTextColor;
|
this.printerName.TextColor = this.defaultTextColor;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue