From a54a903a8e71d77e698bd954631c51cb6681f715 Mon Sep 17 00:00:00 2001 From: matty <10895809+murrty@users.noreply.github.com> Date: Thu, 16 Dec 2021 23:52:16 -0600 Subject: [PATCH] add custom richtextbox this control automatically scrolls when text is appended to it --- youtube-dl-gui/App.config | 2 +- youtube-dl-gui/Controls/ExtendedRichTextBox.cs | 18 ++++++++++++++++++ youtube-dl-gui/Forms/frmConverter.Designer.cs | 4 ++-- youtube-dl-gui/Forms/frmDownloader.Designer.cs | 4 ++-- youtube-dl-gui/Forms/frmException.cs | 2 +- youtube-dl-gui/Properties/Settings.Designer.cs | 2 +- youtube-dl-gui/Properties/Settings.settings | 2 +- youtube-dl-gui/youtube-dl-gui.csproj | 3 +++ 8 files changed, 29 insertions(+), 8 deletions(-) create mode 100644 youtube-dl-gui/Controls/ExtendedRichTextBox.cs diff --git a/youtube-dl-gui/App.config b/youtube-dl-gui/App.config index 24eaa5bc..cd79621e 100644 --- a/youtube-dl-gui/App.config +++ b/youtube-dl-gui/App.config @@ -675,7 +675,7 @@ 2.263 - 2021-11-25 + 2021-12-17 True diff --git a/youtube-dl-gui/Controls/ExtendedRichTextBox.cs b/youtube-dl-gui/Controls/ExtendedRichTextBox.cs new file mode 100644 index 00000000..f97e0a91 --- /dev/null +++ b/youtube-dl-gui/Controls/ExtendedRichTextBox.cs @@ -0,0 +1,18 @@ +using System; +using System.Windows.Forms; + +namespace youtube_dl_gui.Controls { + class ExtendedRichTextBox : RichTextBox { + public const int WM_VSCROLL = 277; + public const int SB_PAGEBOTTOM = 7; + + /// + /// Appends text to the rich text box, scrolling to the bottom when necessary. + /// + /// Text to append. + public new void AppendText(string text) { + this.Text += text; + NativeMethods.SendMessage(this.Handle, WM_VSCROLL, (IntPtr)SB_PAGEBOTTOM, IntPtr.Zero); + } + } +} diff --git a/youtube-dl-gui/Forms/frmConverter.Designer.cs b/youtube-dl-gui/Forms/frmConverter.Designer.cs index 199423fe..55264b54 100644 --- a/youtube-dl-gui/Forms/frmConverter.Designer.cs +++ b/youtube-dl-gui/Forms/frmConverter.Designer.cs @@ -26,7 +26,7 @@ private void InitializeComponent() { this.components = new System.ComponentModel.Container(); this.chkConverterCloseAfterConversion = new System.Windows.Forms.CheckBox(); this.btnConverterCancelExit = new System.Windows.Forms.Button(); - this.rtbConsoleOutput = new System.Windows.Forms.RichTextBox(); + this.rtbConsoleOutput = new Controls.ExtendedRichTextBox(); this.tmrTitleActivity = new System.Windows.Forms.Timer(this.components); this.txtArgumentsGenerated = new System.Windows.Forms.TextBox(); this.btnConverterAbortBatchConversions = new System.Windows.Forms.Button(); @@ -135,7 +135,7 @@ private void InitializeComponent() { private System.Windows.Forms.CheckBox chkConverterCloseAfterConversion; private System.Windows.Forms.Button btnConverterCancelExit; - private System.Windows.Forms.RichTextBox rtbConsoleOutput; + private Controls.ExtendedRichTextBox rtbConsoleOutput; private System.Windows.Forms.Timer tmrTitleActivity; private System.Windows.Forms.TextBox txtArgumentsGenerated; private System.Windows.Forms.Button btnConverterAbortBatchConversions; diff --git a/youtube-dl-gui/Forms/frmDownloader.Designer.cs b/youtube-dl-gui/Forms/frmDownloader.Designer.cs index 0a05393f..052bfaa9 100644 --- a/youtube-dl-gui/Forms/frmDownloader.Designer.cs +++ b/youtube-dl-gui/Forms/frmDownloader.Designer.cs @@ -26,7 +26,7 @@ private void InitializeComponent() { this.components = new System.ComponentModel.Container(); this.btnDownloaderCancelExit = new System.Windows.Forms.Button(); this.chkDownloaderCloseAfterDownload = new System.Windows.Forms.CheckBox(); - this.rtbConsoleOutput = new System.Windows.Forms.RichTextBox(); + this.rtbConsoleOutput = new Controls.ExtendedRichTextBox(); this.tmrTitleActivity = new System.Windows.Forms.Timer(this.components); this.txtArgumentsGenerated = new System.Windows.Forms.TextBox(); this.btnDownloaderAbortBatchDownload = new System.Windows.Forms.Button(); @@ -136,7 +136,7 @@ private void InitializeComponent() { private System.Windows.Forms.Button btnDownloaderCancelExit; private System.Windows.Forms.CheckBox chkDownloaderCloseAfterDownload; - private System.Windows.Forms.RichTextBox rtbConsoleOutput; + private Controls.ExtendedRichTextBox rtbConsoleOutput; private System.Windows.Forms.Timer tmrTitleActivity; private System.Windows.Forms.TextBox txtArgumentsGenerated; private System.Windows.Forms.Button btnDownloaderAbortBatchDownload; diff --git a/youtube-dl-gui/Forms/frmException.cs b/youtube-dl-gui/Forms/frmException.cs index d1140f52..059f9f34 100644 --- a/youtube-dl-gui/Forms/frmException.cs +++ b/youtube-dl-gui/Forms/frmException.cs @@ -65,7 +65,7 @@ private void loadLanguage() { } public static string GetRelevantInformation() { - string NewRelevantInfo = "Lanugage: {0}\n Current Culture: {1}\nOS: {2}"; + string NewRelevantInfo = "Current version: {0}\nCurrent culture: {1}\nOS: {2}\n"; if (Properties.Settings.Default.IsBetaVersion) { return string.Format(NewRelevantInfo, diff --git a/youtube-dl-gui/Properties/Settings.Designer.cs b/youtube-dl-gui/Properties/Settings.Designer.cs index 2961548c..b16ed892 100644 --- a/youtube-dl-gui/Properties/Settings.Designer.cs +++ b/youtube-dl-gui/Properties/Settings.Designer.cs @@ -46,7 +46,7 @@ public bool firstTime { [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("2021-11-25")] + [global::System.Configuration.DefaultSettingValueAttribute("2021-12-17")] public string LastDebugDate { get { return ((string)(this["LastDebugDate"])); diff --git a/youtube-dl-gui/Properties/Settings.settings b/youtube-dl-gui/Properties/Settings.settings index 08c84af5..d2cf2802 100644 --- a/youtube-dl-gui/Properties/Settings.settings +++ b/youtube-dl-gui/Properties/Settings.settings @@ -9,7 +9,7 @@ True - 2021-11-25 + 2021-12-17 -1 diff --git a/youtube-dl-gui/youtube-dl-gui.csproj b/youtube-dl-gui/youtube-dl-gui.csproj index 08e30fcd..a6d897b0 100644 --- a/youtube-dl-gui/youtube-dl-gui.csproj +++ b/youtube-dl-gui/youtube-dl-gui.csproj @@ -81,6 +81,9 @@ + + Component + Component