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>();
|
||||
TextImageButtonFactory textImageButtonFactory = new TextImageButtonFactory();
|
||||
TextImageButtonFactory editButtonFactory = new TextImageButtonFactory();
|
||||
Button closeButton;
|
||||
Button enterEditModeButton;
|
||||
Button leaveEditModeButton;
|
||||
|
||||
bool editMode;
|
||||
|
||||
public ChooseConnectionWidget(ConnectionWindow windowController, SystemWindow container, bool editMode = false)
|
||||
|
|
@ -26,6 +30,13 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
|||
textImageButtonFactory.disabledTextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||
textImageButtonFactory.pressedTextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||
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.BackgroundColor = ActiveTheme.Instance.SecondaryBackgroundColor;
|
||||
|
|
@ -39,7 +50,7 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
|||
FlowLayoutWidget headerRow = new FlowLayoutWidget(FlowDirection.LeftToRight);
|
||||
headerRow.HAnchor = HAnchor.ParentLeftRight;
|
||||
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");
|
||||
|
|
@ -48,24 +59,31 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
|||
TextWidget elementHeader = new TextWidget(string.Format(chooseThreeDPrinterConfigFull), pointSize: 14);
|
||||
elementHeader.TextColor = this.defaultTextColor;
|
||||
elementHeader.HAnchor = HAnchor.ParentLeftRight;
|
||||
elementHeader.VAnchor = Agg.UI.VAnchor.ParentBottom;
|
||||
elementHeader.VAnchor = Agg.UI.VAnchor.ParentCenter;
|
||||
|
||||
ActionLink editModeLink;
|
||||
if (!this.editMode)
|
||||
{
|
||||
editModeLink = actionLinkFactory.Generate(LocalizedString.Get("Edit"), 12, EditModeOnLink_Click);
|
||||
}
|
||||
else
|
||||
{
|
||||
editModeLink = actionLinkFactory.Generate(LocalizedString.Get("Done"), 12, EditModeOffLink_Click);
|
||||
}
|
||||
// ActionLink editModeLink;
|
||||
|
||||
//editModeLink.TextColor = new RGBA_Bytes(250, 250, 250);
|
||||
editModeLink.TextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||
editModeLink.VAnchor = Agg.UI.VAnchor.ParentBottom;
|
||||
enterEditModeButton = editButtonFactory.Generate (LocalizedString.Get ("Edit"), centerText: true);
|
||||
enterEditModeButton.Click += EditModeOnLink_Click;
|
||||
leaveEditModeButton = editButtonFactory.Generate (LocalizedString.Get ("Done"), centerText: true);
|
||||
leaveEditModeButton.Click += EditModeOffLink_Click;
|
||||
|
||||
headerRow.AddChild(elementHeader);
|
||||
headerRow.AddChild(editModeLink);
|
||||
if (!this.editMode)
|
||||
{
|
||||
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
|
||||
|
|
@ -137,15 +155,22 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
|||
closeButton.UnbindClickEvents();
|
||||
closeButton.Click += new ButtonBase.ButtonEventHandler(CloseWindow);
|
||||
}
|
||||
|
||||
|
||||
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)
|
||||
{
|
||||
this.windowController.ChangeToChoosePrinter(false);
|
||||
|
||||
this.windowController.ChangeToChoosePrinter(false);
|
||||
enterEditModeButton.Visible = true;
|
||||
leaveEditModeButton.Visible = false;
|
||||
}
|
||||
|
||||
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 hoverTextColor = new RGBA_Bytes(34, 34, 34);
|
||||
SlideWidget rightButtonOverlay;
|
||||
|
||||
public PrinterListItemView(Printer printerRecord, ConnectionWindow windowController)
|
||||
:base(printerRecord, windowController)
|
||||
|
|
@ -73,19 +74,78 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
|||
availableIndicator.Padding = new BorderDouble(3, 0, 0, 3);
|
||||
availableIndicator.VAnchor = Agg.UI.VAnchor.ParentCenter;
|
||||
|
||||
rightButtonOverlay = getItemActionButtons();
|
||||
rightButtonOverlay.Visible = false;
|
||||
this.AddChild(printerName);
|
||||
this.AddChild(availableIndicator);
|
||||
this.AddChild (rightButtonOverlay);
|
||||
//this.AddChild(availableIndicator);
|
||||
this.HAnchor = HAnchor.ParentLeftRight;
|
||||
|
||||
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()
|
||||
{
|
||||
this.MouseEnter += new EventHandler(onMouse_Enter);
|
||||
this.MouseLeave += new EventHandler(onMouse_Leave);
|
||||
this.MouseUp += new MouseEventHandler(onMouse_Up);
|
||||
}
|
||||
|
||||
|
||||
void onMouse_Up(object sender, MouseEventArgs mouseEvent)
|
||||
{
|
||||
|
|
@ -104,14 +164,19 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections
|
|||
|
||||
void onMouse_Enter(object sender, EventArgs args)
|
||||
{
|
||||
this.rightButtonOverlay.SlideIn ();
|
||||
this.BackgroundColor = this.hoverBackgroundColor;
|
||||
this.printerName.TextColor = this.hoverTextColor;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void onMouse_Leave(object sender, EventArgs args)
|
||||
{
|
||||
this.rightButtonOverlay.SlideOut ();
|
||||
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