Fix button position/size - use consistent type for icon actions

This commit is contained in:
John Lewin 2017-09-25 13:45:42 -07:00
parent 4b5137fdb6
commit 5a856f6d8f
10 changed files with 213 additions and 125 deletions

View file

@ -70,102 +70,6 @@ namespace MatterHackers.MatterControl.ActionBar
}
}
public class SimpleButton : FlowLayoutWidget
{
public ImageBuffer Image { get; set; }
public BorderDouble ImageMargin { get; set; }
public BorderDouble ImagePadding { get; set; }
public double FontSize { get; set; } = 12;
public int BorderWidth { get; set; }
public RGBA_Bytes BorderColor { get; set; } = RGBA_Bytes.Transparent;
private int borderRadius = 0;
public SimpleButton(string text, ImageBuffer image = null)
{
this.HAnchor = HAnchor.Left | HAnchor.Fit;
this.VAnchor = VAnchor.Top | VAnchor.Fit;
this.Text = text;
this.Image = image;
this.AddChild(new GuiWidget() { BackgroundColor = RGBA_Bytes.Green, Height = 10, Width = 20 });
UiThread.RunOnIdle(() =>
{
if (this.Image != null)
{
this.AddChild(
new ImageWidget(this.Image)
{
Margin = ImageMargin,
Padding = ImagePadding,
VAnchor = VAnchor.Stretch,
});
}
if (!string.IsNullOrEmpty(this.Text))
{
this.AddChild(new TextWidget(this.Text, pointSize: this.FontSize));
}
this.AddChild(new GuiWidget() { BackgroundColor = RGBA_Bytes.Red, Height = 10, Width = 20 });
});
}
public override void OnLayout(LayoutEventArgs layoutEventArgs)
{
base.OnLayout(layoutEventArgs);
}
/*
public override void OnLoad(EventArgs args)
{
if (this.Image != null)
{
this.AddChild(new ImageWidget(this.Image)
{
Margin = ImageMargin
});
}
if (!string.IsNullOrEmpty(this.Text))
{
this.AddChild(new TextWidget(this.Text, pointSize: this.FontSize));
}
base.OnLoad(args);
}*/
public override void OnDraw(Graphics2D graphics2D)
{
if (this.BorderColor.Alpha0To255 > 0)
{
RectangleDouble borderRectangle = LocalBounds;
if (BorderWidth > 0)
{
if (BorderWidth == 1)
{
graphics2D.Rectangle(borderRectangle, this.BorderColor);
}
else
{
graphics2D.Render(
new Stroke(
new RoundedRect(borderRectangle, this.borderRadius),
BorderWidth),
this.BorderColor);
}
}
}
base.OnDraw(graphics2D);
}
}
public class PrinterConnectButton : GuiWidget
{
private readonly string disconnectAndCancelTitle = "Disconnect and stop the current print?".Localize();