ssg: begin work on advanced config

This commit is contained in:
Nick Vella 2019-07-22 20:00:54 +10:00
parent 89fbbc1a3c
commit bb6d3bfa1d
9 changed files with 578 additions and 2 deletions

View File

@ -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);

View File

@ -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);
}
}

View File

@ -0,0 +1,106 @@
namespace OpenLiveWriter.PostEditor.Configuration.StaticSite
{
partial class StaticSiteAdvancedConfigForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
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;
}
}

View File

@ -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;
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,99 @@
namespace OpenLiveWriter.PostEditor.Configuration.StaticSite
{
partial class StaticSiteAdvancedConfigPanel
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
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;
}
}

View File

@ -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
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -289,6 +289,19 @@
<Compile Include="Configuration\Settings\WeblogSettingsPanel.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Configuration\StaticSite\StaticSiteAdvancedConfigController.cs" />
<Compile Include="Configuration\StaticSite\StaticSiteAdvancedConfigForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Configuration\StaticSite\StaticSiteAdvancedConfigForm.Designer.cs">
<DependentUpon>StaticSiteAdvancedConfigForm.cs</DependentUpon>
</Compile>
<Compile Include="Configuration\StaticSite\StaticSiteAdvancedConfigPanel.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Configuration\StaticSite\StaticSiteAdvancedConfigPanel.Designer.cs">
<DependentUpon>StaticSiteAdvancedConfigPanel.cs</DependentUpon>
</Compile>
<Compile Include="Configuration\TemporaryBlogSettings.cs" />
<Compile Include="Configuration\Wizard\BlogProviderAccountWizard.cs" />
<Compile Include="Configuration\Wizard\WeblogConfigurationWizard.cs">
@ -1033,6 +1046,12 @@
<DependentUpon>WeblogSettingsPanel.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Configuration\StaticSite\StaticSiteAdvancedConfigForm.resx">
<DependentUpon>StaticSiteAdvancedConfigForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Configuration\StaticSite\StaticSiteAdvancedConfigPanel.resx">
<DependentUpon>StaticSiteAdvancedConfigPanel.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Configuration\Wizard\Images\LiveID16.gif" />
<EmbeddedResource Include="Configuration\Wizard\Images\WeblogWizardHeader.png" />
<EmbeddedResource Include="Configuration\Wizard\WeblogConfigurationWizard.resx">