From bb6d3bfa1d3eabc5766014c8b57fab32f5eca7e6 Mon Sep 17 00:00:00 2001 From: Nick Vella Date: Mon, 22 Jul 2019 20:00:54 +1000 Subject: [PATCH] ssg: begin work on advanced config --- .../Configuration/Settings/AccountPanel.cs | 13 +- .../StaticSiteAdvancedConfigController.cs | 36 ++++++ .../StaticSiteAdvancedConfigForm.Designer.cs | 106 ++++++++++++++++ .../StaticSiteAdvancedConfigForm.cs | 46 +++++++ .../StaticSiteAdvancedConfigForm.resx | 120 ++++++++++++++++++ .../StaticSiteAdvancedConfigPanel.Designer.cs | 99 +++++++++++++++ .../StaticSiteAdvancedConfigPanel.cs | 21 +++ .../StaticSiteAdvancedConfigPanel.resx | 120 ++++++++++++++++++ .../OpenLiveWriter.PostEditor.csproj | 19 +++ 9 files changed, 578 insertions(+), 2 deletions(-) create mode 100644 src/managed/OpenLiveWriter.PostEditor/Configuration/StaticSite/StaticSiteAdvancedConfigController.cs create mode 100644 src/managed/OpenLiveWriter.PostEditor/Configuration/StaticSite/StaticSiteAdvancedConfigForm.Designer.cs create mode 100644 src/managed/OpenLiveWriter.PostEditor/Configuration/StaticSite/StaticSiteAdvancedConfigForm.cs create mode 100644 src/managed/OpenLiveWriter.PostEditor/Configuration/StaticSite/StaticSiteAdvancedConfigForm.resx create mode 100644 src/managed/OpenLiveWriter.PostEditor/Configuration/StaticSite/StaticSiteAdvancedConfigPanel.Designer.cs create mode 100644 src/managed/OpenLiveWriter.PostEditor/Configuration/StaticSite/StaticSiteAdvancedConfigPanel.cs create mode 100644 src/managed/OpenLiveWriter.PostEditor/Configuration/StaticSite/StaticSiteAdvancedConfigPanel.resx diff --git a/src/managed/OpenLiveWriter.PostEditor/Configuration/Settings/AccountPanel.cs b/src/managed/OpenLiveWriter.PostEditor/Configuration/Settings/AccountPanel.cs index 26fa7644..23cf3f4e 100644 --- a/src/managed/OpenLiveWriter.PostEditor/Configuration/Settings/AccountPanel.cs +++ b/src/managed/OpenLiveWriter.PostEditor/Configuration/Settings/AccountPanel.cs @@ -16,6 +16,7 @@ using OpenLiveWriter.BlogClient; using OpenLiveWriter.PostEditor; using OpenLiveWriter.ApplicationFramework.Preferences; using OpenLiveWriter.PostEditor.Configuration.Wizard; +using OpenLiveWriter.PostEditor.Configuration.StaticSite; namespace OpenLiveWriter.PostEditor.Configuration.Settings { @@ -122,13 +123,21 @@ namespace OpenLiveWriter.PostEditor.Configuration.Settings TemporaryBlogSettingsModified = true; } + private delegate bool EditTemporarySettingsDelegate(IWin32Window window, TemporaryBlogSettings settings); + private void buttonEditConfiguration_Click(object sender, EventArgs e) { // make a copy of the temporary settings to edit TemporaryBlogSettings blogSettings = TemporaryBlogSettings.Clone() as TemporaryBlogSettings; - // edit account info - if (WeblogConfigurationWizardController.EditTemporarySettings(FindForm(), blogSettings)) + // Edit account info + // For static sites, the advanced configuration panel will be displayed + // Otherwise, display the wizard + bool settingsModified = blogSettings.IsStaticSiteBlog + ? StaticSiteAdvancedConfigController.EditTemporarySettings(FindForm(), blogSettings) + : WeblogConfigurationWizardController.EditTemporarySettings(FindForm(), blogSettings); + + if (settingsModified) { // go ahead and save the settings back TemporaryBlogSettings.CopyFrom(blogSettings); diff --git a/src/managed/OpenLiveWriter.PostEditor/Configuration/StaticSite/StaticSiteAdvancedConfigController.cs b/src/managed/OpenLiveWriter.PostEditor/Configuration/StaticSite/StaticSiteAdvancedConfigController.cs new file mode 100644 index 00000000..0859d18c --- /dev/null +++ b/src/managed/OpenLiveWriter.PostEditor/Configuration/StaticSite/StaticSiteAdvancedConfigController.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using OpenLiveWriter.PostEditor.Configuration; + +namespace OpenLiveWriter.PostEditor.Configuration.StaticSite +{ + public class StaticSiteAdvancedConfigController + { + private TemporaryBlogSettings _temporarySettings; + private StaticSiteAdvancedConfigForm _form; + + public bool SettingsModified { get; set; } = false; + + public StaticSiteAdvancedConfigController(TemporaryBlogSettings blogSettings) + { + _temporarySettings = blogSettings; + + _form = new StaticSiteAdvancedConfigForm(this); + _form.AddTabPage("test1", new StaticSiteAdvancedConfigPanel()); + _form.AddTabPage("test2", new StaticSiteAdvancedConfigPanel()); + } + + private bool EditWeblogTemporarySettings(IWin32Window owner) + { + _form.ShowDialog(owner); + return SettingsModified; + } + + public static bool EditTemporarySettings(IWin32Window owner, TemporaryBlogSettings settings) + => new StaticSiteAdvancedConfigController(settings).EditWeblogTemporarySettings(owner); + } +} \ No newline at end of file diff --git a/src/managed/OpenLiveWriter.PostEditor/Configuration/StaticSite/StaticSiteAdvancedConfigForm.Designer.cs b/src/managed/OpenLiveWriter.PostEditor/Configuration/StaticSite/StaticSiteAdvancedConfigForm.Designer.cs new file mode 100644 index 00000000..cfb0a24f --- /dev/null +++ b/src/managed/OpenLiveWriter.PostEditor/Configuration/StaticSite/StaticSiteAdvancedConfigForm.Designer.cs @@ -0,0 +1,106 @@ +namespace OpenLiveWriter.PostEditor.Configuration.StaticSite +{ + partial class StaticSiteAdvancedConfigForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.tabControl = new System.Windows.Forms.TabControl(); + this.applyBtn = new System.Windows.Forms.Button(); + this.cancelBtn = new System.Windows.Forms.Button(); + this.okBtn = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // tabControl + // + this.tabControl.Location = new System.Drawing.Point(2, 2); + this.tabControl.Multiline = true; + this.tabControl.Name = "tabControl"; + this.tabControl.SelectedIndex = 0; + this.tabControl.Size = new System.Drawing.Size(245, 270); + this.tabControl.TabIndex = 0; + // + // applyBtn + // + this.applyBtn.Location = new System.Drawing.Point(355, 481); + this.applyBtn.Name = "applyBtn"; + this.applyBtn.Size = new System.Drawing.Size(75, 23); + this.applyBtn.TabIndex = 1; + this.applyBtn.Text = "Apply"; + this.applyBtn.UseVisualStyleBackColor = true; + this.applyBtn.Click += new System.EventHandler(this.ApplyButton_Click); + // + // cancelBtn + // + this.cancelBtn.DialogResult = System.Windows.Forms.DialogResult.Cancel; + this.cancelBtn.Location = new System.Drawing.Point(274, 481); + this.cancelBtn.Name = "cancelBtn"; + this.cancelBtn.Size = new System.Drawing.Size(75, 23); + this.cancelBtn.TabIndex = 2; + this.cancelBtn.Text = "Cancel"; + this.cancelBtn.UseVisualStyleBackColor = true; + this.cancelBtn.Click += new System.EventHandler(this.CancelButton_Click); + // + // okBtn + // + this.okBtn.Location = new System.Drawing.Point(193, 481); + this.okBtn.Name = "okBtn"; + this.okBtn.Size = new System.Drawing.Size(75, 23); + this.okBtn.TabIndex = 3; + this.okBtn.Text = "OK"; + this.okBtn.UseVisualStyleBackColor = true; + this.okBtn.Click += new System.EventHandler(this.OkButton_Click); + // + // StaticSiteAdvancedConfigForm + // + this.AcceptButton = this.okBtn; + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.CancelButton = this.cancelBtn; + this.ClientSize = new System.Drawing.Size(450, 550); + this.Controls.Add(this.okBtn); + this.Controls.Add(this.cancelBtn); + this.Controls.Add(this.applyBtn); + this.Controls.Add(this.tabControl); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "StaticSiteAdvancedConfigForm"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.Text = "Static Site Advanced Configuration"; + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.TabControl tabControl; + private System.Windows.Forms.Button applyBtn; + private System.Windows.Forms.Button cancelBtn; + private System.Windows.Forms.Button okBtn; + } +} \ No newline at end of file diff --git a/src/managed/OpenLiveWriter.PostEditor/Configuration/StaticSite/StaticSiteAdvancedConfigForm.cs b/src/managed/OpenLiveWriter.PostEditor/Configuration/StaticSite/StaticSiteAdvancedConfigForm.cs new file mode 100644 index 00000000..b589afbd --- /dev/null +++ b/src/managed/OpenLiveWriter.PostEditor/Configuration/StaticSite/StaticSiteAdvancedConfigForm.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace OpenLiveWriter.PostEditor.Configuration.StaticSite +{ + public partial class StaticSiteAdvancedConfigForm : Form + { + private StaticSiteAdvancedConfigController _controller; + + public StaticSiteAdvancedConfigForm(StaticSiteAdvancedConfigController controller) + { + InitializeComponent(); + _controller = controller; + } + + public void AddTabPage(string title, Control tabPageControl) + { + var page = new TabPage(title); + page.Controls.Add(tabPageControl); + tabControl.TabPages.Add(page); + } + + private void OkButton_Click(object sender, EventArgs e) + { + _controller.SettingsModified = true; + Close(); + } + + private void CancelButton_Click(object sender, EventArgs e) + { + Close(); + } + + private void ApplyButton_Click(object sender, EventArgs e) + { + _controller.SettingsModified = true; + } + } +} diff --git a/src/managed/OpenLiveWriter.PostEditor/Configuration/StaticSite/StaticSiteAdvancedConfigForm.resx b/src/managed/OpenLiveWriter.PostEditor/Configuration/StaticSite/StaticSiteAdvancedConfigForm.resx new file mode 100644 index 00000000..1af7de15 --- /dev/null +++ b/src/managed/OpenLiveWriter.PostEditor/Configuration/StaticSite/StaticSiteAdvancedConfigForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/src/managed/OpenLiveWriter.PostEditor/Configuration/StaticSite/StaticSiteAdvancedConfigPanel.Designer.cs b/src/managed/OpenLiveWriter.PostEditor/Configuration/StaticSite/StaticSiteAdvancedConfigPanel.Designer.cs new file mode 100644 index 00000000..588bdbcd --- /dev/null +++ b/src/managed/OpenLiveWriter.PostEditor/Configuration/StaticSite/StaticSiteAdvancedConfigPanel.Designer.cs @@ -0,0 +1,99 @@ +namespace OpenLiveWriter.PostEditor.Configuration.StaticSite +{ + partial class StaticSiteAdvancedConfigPanel + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); + this.textBox1 = new System.Windows.Forms.TextBox(); + this.textBox2 = new System.Windows.Forms.TextBox(); + this.textBox3 = new System.Windows.Forms.TextBox(); + this.tableLayoutPanel1.SuspendLayout(); + this.SuspendLayout(); + // + // tableLayoutPanel1 + // + this.tableLayoutPanel1.AutoSize = true; + this.tableLayoutPanel1.ColumnCount = 1; + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tableLayoutPanel1.Controls.Add(this.textBox1, 0, 0); + this.tableLayoutPanel1.Controls.Add(this.textBox2, 0, 1); + this.tableLayoutPanel1.Controls.Add(this.textBox3, 0, 2); + this.tableLayoutPanel1.Location = new System.Drawing.Point(85, 45); + this.tableLayoutPanel1.Name = "tableLayoutPanel1"; + this.tableLayoutPanel1.RowCount = 3; + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); + this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tableLayoutPanel1.Size = new System.Drawing.Size(200, 100); + this.tableLayoutPanel1.TabIndex = 0; + // + // textBox1 + // + this.textBox1.Location = new System.Drawing.Point(3, 3); + this.textBox1.Name = "textBox1"; + this.textBox1.Size = new System.Drawing.Size(100, 20); + this.textBox1.TabIndex = 0; + // + // textBox2 + // + this.textBox2.Location = new System.Drawing.Point(3, 43); + this.textBox2.Name = "textBox2"; + this.textBox2.Size = new System.Drawing.Size(100, 20); + this.textBox2.TabIndex = 1; + // + // textBox3 + // + this.textBox3.Location = new System.Drawing.Point(3, 83); + this.textBox3.Name = "textBox3"; + this.textBox3.Size = new System.Drawing.Size(100, 20); + this.textBox3.TabIndex = 2; + // + // StaticSiteAdvancedConfigPanel + // + this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; + this.AutoSize = true; + this.BackColor = System.Drawing.SystemColors.Window; + this.Controls.Add(this.tableLayoutPanel1); + this.Name = "StaticSiteAdvancedConfigPanel"; + this.Size = new System.Drawing.Size(425, 425); + this.tableLayoutPanel1.ResumeLayout(false); + this.tableLayoutPanel1.PerformLayout(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; + private System.Windows.Forms.TextBox textBox1; + private System.Windows.Forms.TextBox textBox2; + private System.Windows.Forms.TextBox textBox3; + } +} diff --git a/src/managed/OpenLiveWriter.PostEditor/Configuration/StaticSite/StaticSiteAdvancedConfigPanel.cs b/src/managed/OpenLiveWriter.PostEditor/Configuration/StaticSite/StaticSiteAdvancedConfigPanel.cs new file mode 100644 index 00000000..f5c400d1 --- /dev/null +++ b/src/managed/OpenLiveWriter.PostEditor/Configuration/StaticSite/StaticSiteAdvancedConfigPanel.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace OpenLiveWriter.PostEditor.Configuration.StaticSite +{ + public partial class StaticSiteAdvancedConfigPanel : UserControl + { + public StaticSiteAdvancedConfigPanel() + { + InitializeComponent(); + Dock = DockStyle.Fill; // Fill tab control + } + } +} diff --git a/src/managed/OpenLiveWriter.PostEditor/Configuration/StaticSite/StaticSiteAdvancedConfigPanel.resx b/src/managed/OpenLiveWriter.PostEditor/Configuration/StaticSite/StaticSiteAdvancedConfigPanel.resx new file mode 100644 index 00000000..1af7de15 --- /dev/null +++ b/src/managed/OpenLiveWriter.PostEditor/Configuration/StaticSite/StaticSiteAdvancedConfigPanel.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/src/managed/OpenLiveWriter.PostEditor/OpenLiveWriter.PostEditor.csproj b/src/managed/OpenLiveWriter.PostEditor/OpenLiveWriter.PostEditor.csproj index 1e17eeb1..6f4a1260 100644 --- a/src/managed/OpenLiveWriter.PostEditor/OpenLiveWriter.PostEditor.csproj +++ b/src/managed/OpenLiveWriter.PostEditor/OpenLiveWriter.PostEditor.csproj @@ -289,6 +289,19 @@ UserControl + + + Form + + + StaticSiteAdvancedConfigForm.cs + + + UserControl + + + StaticSiteAdvancedConfigPanel.cs + @@ -1033,6 +1046,12 @@ WeblogSettingsPanel.cs Designer + + StaticSiteAdvancedConfigForm.cs + + + StaticSiteAdvancedConfigPanel.cs +