From 576205c633300341f36dc20845b8f44736de6a9c Mon Sep 17 00:00:00 2001 From: gregory-diaz Date: Tue, 21 Oct 2014 14:15:47 -0700 Subject: [PATCH] Added slide buttons to PrinterListItem. No functionality --- .../PrinterConnections/PrinterListItems.cs | 68 +++++++++++++++++-- 1 file changed, 64 insertions(+), 4 deletions(-) diff --git a/PrinterControls/PrinterConnections/PrinterListItems.cs b/PrinterControls/PrinterConnections/PrinterListItems.cs index 9c140d07d..6649f7335 100644 --- a/PrinterControls/PrinterConnections/PrinterListItems.cs +++ b/PrinterControls/PrinterConnections/PrinterListItems.cs @@ -35,13 +35,15 @@ 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) { this.Margin = new BorderDouble(1); this.BackgroundColor = this.defaultBackgroundColor; - this.Padding = new BorderDouble(5); + this.Padding = new BorderDouble(5); string[] comportNames = FrostedSerialPort.GetPortNames(); bool portIsAvailable = comportNames.Contains(printerRecord.ComPort); @@ -73,13 +75,69 @@ 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 printButton = new ClickWidget(); + printButton.VAnchor = VAnchor.ParentBottomTop; + printButton.BackgroundColor = ActiveTheme.Instance.PrimaryAccentColor; + printButton.Width = 60; + + TextWidget printLabel = new TextWidget("edit".Localize()); + printLabel.TextColor = RGBA_Bytes.White; + printLabel.VAnchor = VAnchor.ParentCenter; + printLabel.HAnchor = HAnchor.ParentCenter; + + printButton.AddChild(printLabel); + printButton.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("remove".Localize()); + editLabel.TextColor = RGBA_Bytes.White; + editLabel.VAnchor = VAnchor.ParentCenter; + editLabel.HAnchor = HAnchor.ParentCenter; + + editButton.AddChild(editLabel); + //editButton.Click += onViewPartClick; + + buttonFlowContainer.AddChild(editButton); + buttonFlowContainer.AddChild(printButton); + + buttonContainer.AddChild(buttonFlowContainer); + buttonContainer.Width = 120; + + return buttonContainer; + } + + public void BindHandlers() { this.MouseEnter += new EventHandler(onMouse_Enter); @@ -106,12 +164,14 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections { this.BackgroundColor = this.hoverBackgroundColor; this.printerName.TextColor = this.hoverTextColor; + this.rightButtonOverlay.SlideIn(); } void onMouse_Leave(object sender, EventArgs args) { this.BackgroundColor = this.defaultBackgroundColor; - this.printerName.TextColor = this.defaultTextColor; + this.printerName.TextColor = this.defaultTextColor; + this.rightButtonOverlay.SlideOut(); } } @@ -159,7 +219,7 @@ namespace MatterHackers.MatterControl.PrinterControls.PrinterConnections BindHandlers(); } - + public void BindHandlers() { editLink.Click += new ButtonBase.ButtonEventHandler(EditConnectionLink_Click);