From a58a1b347a54d311c6230bdf458e210ef8bb6bb3 Mon Sep 17 00:00:00 2001 From: chylex <contact@chylex.com> Date: Sun, 16 Jul 2023 22:59:16 +0200 Subject: [PATCH] Show a deprecation notice on launch References #360 --- windows/TweetDuck/Configuration/Arguments.cs | 1 + .../Dialogs/DeprecationNoticeDialog.cs | 36 +++++++++++++++++++ windows/TweetDuck/Dialogs/FormMessage.cs | 22 +++++++----- windows/TweetDuck/Program.cs | 4 +++ windows/TweetDuck/Reporter.cs | 15 +++----- 5 files changed, 58 insertions(+), 20 deletions(-) create mode 100644 windows/TweetDuck/Dialogs/DeprecationNoticeDialog.cs diff --git a/windows/TweetDuck/Configuration/Arguments.cs b/windows/TweetDuck/Configuration/Arguments.cs index e3c8137c..b2c4da31 100644 --- a/windows/TweetDuck/Configuration/Arguments.cs +++ b/windows/TweetDuck/Configuration/Arguments.cs @@ -9,6 +9,7 @@ static class Arguments { public const string ArgIgnoreGDPR = "-nogdpr"; public const string ArgHttpVideo = "-httpvideo"; public const string ArgFreeze = "-freeze"; + public const string ArgHideDeprecation = "-hidedeprecation"; // internal args public const string ArgRestart = "-restart"; diff --git a/windows/TweetDuck/Dialogs/DeprecationNoticeDialog.cs b/windows/TweetDuck/Dialogs/DeprecationNoticeDialog.cs new file mode 100644 index 00000000..5a2d49a2 --- /dev/null +++ b/windows/TweetDuck/Dialogs/DeprecationNoticeDialog.cs @@ -0,0 +1,36 @@ +using System; +using System.Windows.Forms; +using TweetLib.Core; + +namespace TweetDuck.Dialogs; + +static class DeprecationNoticeDialog { + public static bool Show() { + const string contents = """ + TweetDuck is no longer being maintained: + - Twitter has been constantly breaking TweetDeck and therefore also breaking TweetDuck. + - Twitter will be replacing TweetDeck with a new version that is incompatible with most of the app's features. + - Twitter is planning to put TweetDeck behind a subscription paywall. + + There will be no more updates. + Continue at your own risk. + """; + + using FormMessage message = new FormMessage("TweetDuck Deprecation Notice", contents, MessageBoxIcon.Warning); + + message.AddButton("Exit", DialogResult.Cancel, ControlType.Cancel); + message.AddButton("Continue", DialogResult.OK, ControlType.Accept | ControlType.Focused); + + Button btnLearnMore = message.CreateButton("Learn More", x: 9, width: 106); + btnLearnMore.Anchor |= AnchorStyles.Left; + btnLearnMore.Margin = new Padding(0, 0, 48, 0); + btnLearnMore.Click += OnBtnLearnMoreClick; + message.AddActionControl(btnLearnMore); + + return message.ShowDialog() == DialogResult.OK; + } + + private static void OnBtnLearnMoreClick(object? sender, EventArgs args) { + App.SystemHandler.OpenBrowser(Program.Website + "/deprecation"); + } +} diff --git a/windows/TweetDuck/Dialogs/FormMessage.cs b/windows/TweetDuck/Dialogs/FormMessage.cs index 4ac61657..a73f1b8c 100644 --- a/windows/TweetDuck/Dialogs/FormMessage.cs +++ b/windows/TweetDuck/Dialogs/FormMessage.cs @@ -124,15 +124,7 @@ public Button AddButton(string title, ControlType type) { } public Button AddButton(string title, DialogResult result = DialogResult.OK, ControlType type = ControlType.None) { - Button button = new Button { - Anchor = AnchorStyles.Bottom, - Font = SystemFonts.MessageBoxFont, - Location = new Point(0, 12), - Size = new Size(BrowserUtils.Scale(88, dpiScale), BrowserUtils.Scale(26, dpiScale)), - TabIndex = 256 - buttonCount, - Text = title, - UseVisualStyleBackColor = true - }; + Button button = CreateButton(title); button.Click += (_, _) => { ClickedButton = button; @@ -162,6 +154,18 @@ public Button AddButton(string title, DialogResult result = DialogResult.OK, Con return button; } + public Button CreateButton(string title, int x = 0, int width = 88) { + return new Button { + Anchor = AnchorStyles.Bottom, + Font = SystemFonts.MessageBoxFont, + Location = new Point(x, 12), + Size = new Size(BrowserUtils.Scale(width, dpiScale), BrowserUtils.Scale(26, dpiScale)), + TabIndex = 256 - buttonCount, + Text = title, + UseVisualStyleBackColor = true + }; + } + public void AddActionControl(Control control) { panelActions.Controls.Add(control); diff --git a/windows/TweetDuck/Program.cs b/windows/TweetDuck/Program.cs index dfc02d37..44f9a8c7 100644 --- a/windows/TweetDuck/Program.cs +++ b/windows/TweetDuck/Program.cs @@ -108,6 +108,10 @@ public void BeforeLaunch() { if (Config.System.Migrate()) { Config.System.Save(); } + + if (!Arguments.HasFlag(Arguments.ArgHideDeprecation) && !DeprecationNoticeDialog.Show()) { + Environment.Exit(0); + } } public void Launch(ResourceCache resourceCache, PluginManager pluginManager) { diff --git a/windows/TweetDuck/Reporter.cs b/windows/TweetDuck/Reporter.cs index e5262c2a..f941f369 100644 --- a/windows/TweetDuck/Reporter.cs +++ b/windows/TweetDuck/Reporter.cs @@ -1,6 +1,5 @@ using System; using System.Diagnostics; -using System.Drawing; using System.Windows.Forms; using TweetDuck.Dialogs; using TweetDuck.Management; @@ -36,16 +35,10 @@ public void HandleException(string caption, string message, bool canIgnore, Exce btnIgnore.Enabled = canIgnore; form.ActiveControl = canIgnore ? btnIgnore : btnExit; - Button btnOpenLog = new Button { - Anchor = AnchorStyles.Bottom | AnchorStyles.Left, - Enabled = loggedSuccessfully, - Font = SystemFonts.MessageBoxFont, - Location = new Point(9, 12), - Margin = new Padding(0, 0, 48, 0), - Size = new Size(106, 26), - Text = "Show Error Log", - UseVisualStyleBackColor = true - }; + Button btnOpenLog = form.CreateButton("Show Error Log", x: 9, width: 106); + btnOpenLog.Anchor |= AnchorStyles.Left; + btnOpenLog.Enabled = loggedSuccessfully; + btnOpenLog.Margin = new Padding(0, 0, 48, 0); btnOpenLog.Click += static (_, _) => { if (!OpenLogFile()) {