From 5ab68c97847670950eb6f1b54223ab80ea7e89c9 Mon Sep 17 00:00:00 2001 From: YoshiRulz Date: Sat, 29 Feb 2020 07:23:22 +1000 Subject: [PATCH] Add some more custom controls --- .../BizHawk.Client.EmuHawk.csproj | 5 ++++ .../CustomControls/AutosizedLabel.cs | 18 +++++++++++++ .../CustomControls/FLPInGroupBox.cs | 19 ++++++++++++++ .../CustomControls/SingleColumnFLP.cs | 15 +++++++++++ .../CustomControls/SingleRowFLP.cs | 14 +++++++++++ .../CustomControls/TLPInGroupBox.cs | 25 +++++++++++++++++++ 6 files changed, 96 insertions(+) create mode 100644 BizHawk.Client.EmuHawk/CustomControls/AutosizedLabel.cs create mode 100644 BizHawk.Client.EmuHawk/CustomControls/FLPInGroupBox.cs create mode 100644 BizHawk.Client.EmuHawk/CustomControls/SingleColumnFLP.cs create mode 100644 BizHawk.Client.EmuHawk/CustomControls/SingleRowFLP.cs create mode 100644 BizHawk.Client.EmuHawk/CustomControls/TLPInGroupBox.cs diff --git a/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj b/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj index 0e4d52bacd..26f95634bf 100644 --- a/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj +++ b/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj @@ -418,9 +418,11 @@ + + @@ -432,6 +434,9 @@ + + + diff --git a/BizHawk.Client.EmuHawk/CustomControls/AutosizedLabel.cs b/BizHawk.Client.EmuHawk/CustomControls/AutosizedLabel.cs new file mode 100644 index 0000000000..6f5258b847 --- /dev/null +++ b/BizHawk.Client.EmuHawk/CustomControls/AutosizedLabel.cs @@ -0,0 +1,18 @@ +using System.Windows.Forms; + +namespace BizHawk.Client.EmuHawk.CustomControls +{ + public class AutosizedLabel : Label + { + public override bool AutoSize => true; + + public AutosizedLabel() : base() { + Anchor = AnchorStyles.None; + } + + public AutosizedLabel(string labelText) : this() + { + Text = labelText; + } + } +} diff --git a/BizHawk.Client.EmuHawk/CustomControls/FLPInGroupBox.cs b/BizHawk.Client.EmuHawk/CustomControls/FLPInGroupBox.cs new file mode 100644 index 0000000000..47939fe5a7 --- /dev/null +++ b/BizHawk.Client.EmuHawk/CustomControls/FLPInGroupBox.cs @@ -0,0 +1,19 @@ +using System.Windows.Forms; + +namespace BizHawk.Client.EmuHawk.CustomControls +{ + /// + public class FLPInGroupBox : GroupBox + { + public new ControlCollection Controls => InnerFLP.Controls; + + public FlowLayoutPanel InnerFLP { get; } = new FlowLayoutPanel + { + Dock = DockStyle.Fill, + FlowDirection = FlowDirection.TopDown, + WrapContents = false + }; + + public FLPInGroupBox() : base() => base.Controls.Add(InnerFLP); + } +} diff --git a/BizHawk.Client.EmuHawk/CustomControls/SingleColumnFLP.cs b/BizHawk.Client.EmuHawk/CustomControls/SingleColumnFLP.cs new file mode 100644 index 0000000000..a921d04604 --- /dev/null +++ b/BizHawk.Client.EmuHawk/CustomControls/SingleColumnFLP.cs @@ -0,0 +1,15 @@ +using System.Windows.Forms; + +namespace BizHawk.Client.EmuHawk.CustomControls +{ + /// + public class SingleColumnFLP : FlowLayoutPanel + { + public SingleColumnFLP() : base() + { + AutoSize = true; + FlowDirection = FlowDirection.TopDown; + WrapContents = false; + } + } +} diff --git a/BizHawk.Client.EmuHawk/CustomControls/SingleRowFLP.cs b/BizHawk.Client.EmuHawk/CustomControls/SingleRowFLP.cs new file mode 100644 index 0000000000..ba74c0dffc --- /dev/null +++ b/BizHawk.Client.EmuHawk/CustomControls/SingleRowFLP.cs @@ -0,0 +1,14 @@ +using System.Windows.Forms; + +namespace BizHawk.Client.EmuHawk.CustomControls +{ + /// + public class SingleRowFLP : FlowLayoutPanel + { + public SingleRowFLP() : base() + { + AutoSize = true; + WrapContents = false; + } + } +} diff --git a/BizHawk.Client.EmuHawk/CustomControls/TLPInGroupBox.cs b/BizHawk.Client.EmuHawk/CustomControls/TLPInGroupBox.cs new file mode 100644 index 0000000000..d24f91ea61 --- /dev/null +++ b/BizHawk.Client.EmuHawk/CustomControls/TLPInGroupBox.cs @@ -0,0 +1,25 @@ +using System.Windows.Forms; + +namespace BizHawk.Client.EmuHawk.CustomControls +{ + /// + public class TLPInGroupBox : GroupBox + { + public new TableLayoutControlCollection Controls => InnerTLP.Controls; + + public TableLayoutPanel InnerTLP { get; } = new TableLayoutPanel { + AutoSize = true, + Dock = DockStyle.Fill + }; + + public TLPInGroupBox() : base() => base.Controls.Add(InnerTLP); + + public TLPInGroupBox(int columns, int rows) : this() + { + InnerTLP.ColumnCount = columns; + for (var i = columns; i != 0; i--) InnerTLP.ColumnStyles.Add(new ColumnStyle()); + InnerTLP.RowCount = rows; + for (var i = rows; i != 0; i--) InnerTLP.RowStyles.Add(new RowStyle()); + } + } +}