From b1cbb5c6ad573ab0cd3e549cae907e24206b456e Mon Sep 17 00:00:00 2001 From: Nick Vella Date: Thu, 1 Aug 2019 23:53:13 +1000 Subject: [PATCH] ssg: advanced config: impl StaticSitePreferencesPanel with common protected attributes, make all panels inherit it --- .../StaticSiteAdvanced/AuthoringPanel.cs | 12 +++------- .../StaticSiteAdvanced/BuildPublishPanel.cs | 15 ++++--------- .../StaticSiteAdvanced/FrontMatterPanel.cs | 12 ++++------ .../StaticSiteAdvanced/GeneralPanel.cs | 12 +++------- .../StaticSitePreferencesPanel.cs | 22 +++++++++++++++++++ 5 files changed, 36 insertions(+), 37 deletions(-) create mode 100644 src/managed/OpenLiveWriter.PostEditor/Configuration/StaticSiteAdvanced/StaticSitePreferencesPanel.cs diff --git a/src/managed/OpenLiveWriter.PostEditor/Configuration/StaticSiteAdvanced/AuthoringPanel.cs b/src/managed/OpenLiveWriter.PostEditor/Configuration/StaticSiteAdvanced/AuthoringPanel.cs index cb630549..1998cfee 100644 --- a/src/managed/OpenLiveWriter.PostEditor/Configuration/StaticSiteAdvanced/AuthoringPanel.cs +++ b/src/managed/OpenLiveWriter.PostEditor/Configuration/StaticSiteAdvanced/AuthoringPanel.cs @@ -23,7 +23,7 @@ namespace OpenLiveWriter.PostEditor.Configuration.StaticSiteAdvanced /// /// Summary description for AccountPanel. /// - public class AuthoringPanel : PreferencesPanel + public class AuthoringPanel : StaticSitePreferencesPanel { private Label labelPostsPath; private TextBox textBoxPostsPath; @@ -46,8 +46,6 @@ namespace OpenLiveWriter.PostEditor.Configuration.StaticSiteAdvanced /// // private System.ComponentModel.Container components = null; - private PreferencesController _controller; - public string PostsPath { get => textBoxPostsPath.Text; @@ -96,14 +94,10 @@ namespace OpenLiveWriter.PostEditor.Configuration.StaticSiteAdvanced set => textBoxImagesPath.Text = value; } - public AuthoringPanel(PreferencesController controller) - : base() + public AuthoringPanel(StaticSitePreferencesController controller, TemporaryBlogSettings blogSettings) + : base(controller, blogSettings) { - // This call is required by the Windows.Forms Form Designer. InitializeComponent(); - //UpdateStrings(); - - _controller = controller; } protected override void OnLoad(EventArgs e) diff --git a/src/managed/OpenLiveWriter.PostEditor/Configuration/StaticSiteAdvanced/BuildPublishPanel.cs b/src/managed/OpenLiveWriter.PostEditor/Configuration/StaticSiteAdvanced/BuildPublishPanel.cs index 8df954ee..fb6069fd 100644 --- a/src/managed/OpenLiveWriter.PostEditor/Configuration/StaticSiteAdvanced/BuildPublishPanel.cs +++ b/src/managed/OpenLiveWriter.PostEditor/Configuration/StaticSiteAdvanced/BuildPublishPanel.cs @@ -24,7 +24,7 @@ namespace OpenLiveWriter.PostEditor.Configuration.StaticSiteAdvanced /// /// Summary description for BuildPublishPanel. /// - public class BuildPublishPanel : PreferencesPanel + public class BuildPublishPanel : StaticSitePreferencesPanel { private System.Windows.Forms.GroupBox groupBoxGeneral; private CheckBox checkBoxShowCommandWindows; @@ -46,18 +46,11 @@ namespace OpenLiveWriter.PostEditor.Configuration.StaticSiteAdvanced /// // private System.ComponentModel.Container components = null; - private PreferencesController _controller; - - public BuildPublishPanel(PreferencesController controller) - : base() + public BuildPublishPanel(StaticSitePreferencesController controller, TemporaryBlogSettings blogSettings) + : base(controller, blogSettings) { - // This call is required by the Windows.Forms Form Designer. InitializeComponent(); numericUpDownCmdTimeout.Maximum = int.MaxValue; - - //UpdateStrings(); - - _controller = controller; } protected override void OnLoad(EventArgs e) @@ -79,7 +72,7 @@ namespace OpenLiveWriter.PostEditor.Configuration.StaticSiteAdvanced if (checkBoxEnableCmdTimeout.Checked) return Convert.ToInt32(numericUpDownCmdTimeout.Value); - return StaticSiteConfig.DEFAULT_CMD_TIMEOUT; + return -1; // -1 for disabled } set diff --git a/src/managed/OpenLiveWriter.PostEditor/Configuration/StaticSiteAdvanced/FrontMatterPanel.cs b/src/managed/OpenLiveWriter.PostEditor/Configuration/StaticSiteAdvanced/FrontMatterPanel.cs index dc2a5a32..f54b58cf 100644 --- a/src/managed/OpenLiveWriter.PostEditor/Configuration/StaticSiteAdvanced/FrontMatterPanel.cs +++ b/src/managed/OpenLiveWriter.PostEditor/Configuration/StaticSiteAdvanced/FrontMatterPanel.cs @@ -27,7 +27,7 @@ namespace OpenLiveWriter.PostEditor.Configuration.StaticSiteAdvanced /// /// Summary description for AccountPanel. /// - public class FrontMatterPanel : PreferencesPanel + public class FrontMatterPanel : StaticSitePreferencesPanel { private DataGridView dataGridView; @@ -35,22 +35,18 @@ namespace OpenLiveWriter.PostEditor.Configuration.StaticSiteAdvanced /// Required designer variable. /// // private System.ComponentModel.Container components = null; - private PreferencesController _controller; private DataGridViewTextBoxColumn colProperty; private DataGridViewTextBoxColumn colKey; private Label labelSubtitle; private Dictionary _keyRowMap = new Dictionary(); - public FrontMatterPanel(PreferencesController controller) - : base() + public FrontMatterPanel(StaticSitePreferencesController controller, TemporaryBlogSettings blogSettings) + : base(controller, blogSettings) { - // This call is required by the Windows.Forms Form Designer. InitializeComponent(); - //UpdateStrings(); - - _controller = controller; } + protected override void OnLayout(LayoutEventArgs e) { base.OnLayout(e); diff --git a/src/managed/OpenLiveWriter.PostEditor/Configuration/StaticSiteAdvanced/GeneralPanel.cs b/src/managed/OpenLiveWriter.PostEditor/Configuration/StaticSiteAdvanced/GeneralPanel.cs index 84db51e2..a961cc31 100644 --- a/src/managed/OpenLiveWriter.PostEditor/Configuration/StaticSiteAdvanced/GeneralPanel.cs +++ b/src/managed/OpenLiveWriter.PostEditor/Configuration/StaticSiteAdvanced/GeneralPanel.cs @@ -23,7 +23,7 @@ namespace OpenLiveWriter.PostEditor.Configuration.StaticSiteAdvanced /// /// Summary description for AccountPanel. /// - public class GeneralPanel : PreferencesPanel + public class GeneralPanel : StaticSitePreferencesPanel { private System.Windows.Forms.GroupBox groupBoxSetup; private TextBox textBoxSiteTitle; @@ -44,8 +44,6 @@ namespace OpenLiveWriter.PostEditor.Configuration.StaticSiteAdvanced /// // private System.ComponentModel.Container components = null; - private PreferencesController _controller; - public string SiteTitle { get => textBoxSiteTitle.Text; @@ -64,14 +62,10 @@ namespace OpenLiveWriter.PostEditor.Configuration.StaticSiteAdvanced set => textBoxLocalSitePath.Text = value; } - public GeneralPanel(PreferencesController controller) - : base() + public GeneralPanel(StaticSitePreferencesController controller, TemporaryBlogSettings blogSettings) + : base(controller, blogSettings) { - // This call is required by the Windows.Forms Form Designer. InitializeComponent(); - //UpdateStrings(); - - _controller = controller; } protected override void OnLoad(EventArgs e) diff --git a/src/managed/OpenLiveWriter.PostEditor/Configuration/StaticSiteAdvanced/StaticSitePreferencesPanel.cs b/src/managed/OpenLiveWriter.PostEditor/Configuration/StaticSiteAdvanced/StaticSitePreferencesPanel.cs new file mode 100644 index 00000000..163eec71 --- /dev/null +++ b/src/managed/OpenLiveWriter.PostEditor/Configuration/StaticSiteAdvanced/StaticSitePreferencesPanel.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +using OpenLiveWriter.ApplicationFramework.Preferences; + +namespace OpenLiveWriter.PostEditor.Configuration.StaticSiteAdvanced +{ + public abstract class StaticSitePreferencesPanel : PreferencesPanel + { + protected StaticSitePreferencesController _controller; + protected TemporaryBlogSettings _blogSettings; + + public StaticSitePreferencesPanel(StaticSitePreferencesController controller, TemporaryBlogSettings blogSettings) : base() + { + _controller = controller; + _blogSettings = blogSettings; + } + } +}