From eba6628440ec7ad9bd30107c98919fa50fe6f221 Mon Sep 17 00:00:00 2001 From: Miepee Date: Fri, 2 Sep 2022 14:07:13 +0200 Subject: [PATCH] Simplify URL Image button --- .../MainForm/CustomControls/URLImageButton.cs | 21 +++++++++++++++ .../AM2RLauncher/MainForm/MainForm.UI.cs | 26 +++++-------------- 2 files changed, 27 insertions(+), 20 deletions(-) create mode 100644 AM2RLauncher/AM2RLauncher/MainForm/CustomControls/URLImageButton.cs diff --git a/AM2RLauncher/AM2RLauncher/MainForm/CustomControls/URLImageButton.cs b/AM2RLauncher/AM2RLauncher/MainForm/CustomControls/URLImageButton.cs new file mode 100644 index 0000000..5ffac2f --- /dev/null +++ b/AM2RLauncher/AM2RLauncher/MainForm/CustomControls/URLImageButton.cs @@ -0,0 +1,21 @@ +using AM2RLauncherLib; +using Eto.Drawing; +using Pablo.Controls; + +namespace AM2RLauncher; + +public class URLImageButton : ImageButton +{ + public URLImageButton(Bitmap image, string url, string tooltip = "") + { + Image = image; + ToolTip = tooltip; + + Click += (_, _) => CrossPlatformOperations.OpenURL(url); + } + + public URLImageButton(byte[] image, string url, string tooltip = "") : this(new Bitmap(image), url, tooltip) + { + + } +} \ No newline at end of file diff --git a/AM2RLauncher/AM2RLauncher/MainForm/MainForm.UI.cs b/AM2RLauncher/AM2RLauncher/MainForm/MainForm.UI.cs index 69e2847..503cab3 100644 --- a/AM2RLauncher/AM2RLauncher/MainForm/MainForm.UI.cs +++ b/AM2RLauncher/AM2RLauncher/MainForm/MainForm.UI.cs @@ -221,6 +221,7 @@ public partial class MainForm : Form // Mac gets a default BackgroundColor because it looks waaaaaaay better. profileDropDown = new DropDown { + TextColor = LauncherColors.Green, BackgroundColor = OS.IsWindows ? LauncherColors.BGNoAlpha : new Color() }; @@ -264,26 +265,11 @@ public partial class MainForm : Form centerInterface.AddRow(saveWarningLabel); // Social buttons - Bitmap redditIcon = new Bitmap(Resources.redditIcon48); - var redditButton = new ImageButton { ToolTip = Text.RedditToolTip, Image = redditIcon }; - redditButton.Click += (_, _) => CrossPlatformOperations.OpenURL("https://www.reddit.com/r/AM2R"); - - Bitmap githubIcon = new Bitmap(Resources.githubIcon48); - var githubButton = new ImageButton { ToolTip = Text.GithubToolTip, Image = githubIcon }; - githubButton.Click += (_, _) => CrossPlatformOperations.OpenURL("https://www.github.com/AM2R-Community-Developers"); - - Bitmap youtubeIcon = new Bitmap(Resources.youtubeIcon48); - var youtubeButton = new ImageButton { ToolTip = Text.YoutubeToolTip, Image = youtubeIcon }; - youtubeButton.Click += (_, _) => CrossPlatformOperations.OpenURL("https://www.youtube.com/c/AM2RCommunityUpdates"); - - Bitmap discordIcon = new Bitmap(Resources.discordIcon48); - var discordButton = new ImageButton { ToolTip = Text.DiscordToolTip, Image = discordIcon }; - discordButton.Click += (_, _) => CrossPlatformOperations.OpenURL("https://discord.gg/nk7UYPbd5u"); - - //TODO: this needs a new tooltip - Bitmap matrixIcon = new Bitmap(Resources.matrixIcon48); - var matrixButton = new ImageButton { ToolTip = Text.MatrixToolTip, Image = matrixIcon }; - matrixButton.Click += (_, _) => CrossPlatformOperations.OpenURL("https://matrix.to/#/#am2r-space:matrix.org"); + var redditButton = new URLImageButton(Resources.redditIcon48, "https://www.reddit.com/r/AM2R", Text.RedditToolTip); + var githubButton = new URLImageButton(Resources.githubIcon48, "https://www.github.com/AM2R-Community-Developers", Text.GithubToolTip); + var youtubeButton = new URLImageButton(Resources.youtubeIcon48, "https://www.youtube.com/c/AM2RCommunityUpdates", Text.YoutubeToolTip); + var discordButton = new URLImageButton(Resources.discordIcon48, "https://discord.gg/nk7UYPbd5u", Text.DiscordToolTip); + var matrixButton = new URLImageButton(Resources.matrixIcon48, "https://matrix.to/#/#am2r-space:matrix.org", Text.MatrixToolTip); // Social button panel DynamicLayout socialPanel = new DynamicLayout();