ssg: advanced configuration Authoring panel

This commit is contained in:
Nick Vella 2019-07-25 00:40:08 +10:00
parent 01e7e63abe
commit 0f386718e4
4 changed files with 484 additions and 0 deletions

View File

@ -0,0 +1,344 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for details.
using System;
using System.Collections;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
using OpenLiveWriter.Localization;
using OpenLiveWriter.Localization.Bidi;
using OpenLiveWriter.Controls;
using OpenLiveWriter.CoreServices;
using OpenLiveWriter.CoreServices.Layout;
using OpenLiveWriter.BlogClient;
using OpenLiveWriter.PostEditor;
using OpenLiveWriter.ApplicationFramework.Preferences;
using OpenLiveWriter.PostEditor.Configuration.Wizard;
namespace OpenLiveWriter.PostEditor.Configuration.StaticSiteAdvanced
{
/// <summary>
/// Summary description for AccountPanel.
/// </summary>
public class AuthoringPanel : PreferencesPanel
{
private Label labelPostsPath;
private TextBox textBoxPostsPath;
private GroupBox groupBoxPosts;
private CheckBox checkBoxDraftsEnabled;
private TextBox textBoxDraftsPath;
private Label labelDraftsPath;
private GroupBox groupBoxPages;
private CheckBox checkBoxPagesStoredInRoot;
private CheckBox checkBoxPagesEnabled;
private TextBox textBoxPagesPath;
private Label labelPagesPath;
private GroupBox groupBoxImages;
private CheckBox checkBoxImagesEnabled;
private TextBox textBoxImagesPath;
private Label labelImagesPath;
/// <summary>
/// Required designer variable.
/// </summary>
// private System.ComponentModel.Container components = null;
private PreferencesController _controller;
public string PostsPath
{
get => textBoxPostsPath.Text;
set => textBoxPostsPath.Text = value;
}
public bool DraftsEnabled
{
get => checkBoxDraftsEnabled.Checked;
set => checkBoxDraftsEnabled.Checked = value;
}
public string DraftsPath
{
get => textBoxDraftsPath.Text;
set => textBoxDraftsPath.Text = value;
}
public bool PagesEnabled
{
get => checkBoxPagesEnabled.Checked;
set => checkBoxPagesEnabled.Checked = value;
}
public string PagesPath
{
get => textBoxPagesPath.Text;
set => textBoxPagesPath.Text = value;
}
public bool PagesStoredInRoot
{
get => checkBoxPagesStoredInRoot.Checked;
set => checkBoxPagesStoredInRoot.Checked = value;
}
public bool ImagesEnabled
{
get => checkBoxImagesEnabled.Checked;
set => checkBoxImagesEnabled.Checked = value;
}
public string ImagesPath
{
get => textBoxImagesPath.Text;
set => textBoxImagesPath.Text = value;
}
public AuthoringPanel(PreferencesController controller)
: base()
{
// This call is required by the Windows.Forms Form Designer.
InitializeComponent();
//UpdateStrings();
_controller = controller;
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
RecomputeEnabledStates();
LayoutHelper.NaturalizeHeightAndDistributeNoScale(5, labelPostsPath, textBoxPostsPath, checkBoxDraftsEnabled, labelDraftsPath, textBoxDraftsPath);
LayoutHelper.NaturalizeHeightAndDistributeNoScale(5, checkBoxPagesEnabled, labelPagesPath, textBoxPagesPath, checkBoxPagesStoredInRoot);
LayoutHelper.NaturalizeHeightAndDistributeNoScale(5, checkBoxImagesEnabled, labelImagesPath, textBoxImagesPath);
}
#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.labelPostsPath = new System.Windows.Forms.Label();
this.textBoxPostsPath = new System.Windows.Forms.TextBox();
this.groupBoxPosts = new System.Windows.Forms.GroupBox();
this.groupBoxPages = new System.Windows.Forms.GroupBox();
this.textBoxPagesPath = new System.Windows.Forms.TextBox();
this.labelPagesPath = new System.Windows.Forms.Label();
this.checkBoxPagesEnabled = new System.Windows.Forms.CheckBox();
this.checkBoxPagesStoredInRoot = new System.Windows.Forms.CheckBox();
this.groupBoxImages = new System.Windows.Forms.GroupBox();
this.checkBoxDraftsEnabled = new System.Windows.Forms.CheckBox();
this.textBoxDraftsPath = new System.Windows.Forms.TextBox();
this.labelDraftsPath = new System.Windows.Forms.Label();
this.checkBoxImagesEnabled = new System.Windows.Forms.CheckBox();
this.textBoxImagesPath = new System.Windows.Forms.TextBox();
this.labelImagesPath = new System.Windows.Forms.Label();
this.groupBoxPosts.SuspendLayout();
this.groupBoxPages.SuspendLayout();
this.groupBoxImages.SuspendLayout();
this.SuspendLayout();
//
// labelPostsPath
//
this.labelPostsPath.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.labelPostsPath.Location = new System.Drawing.Point(16, 19);
this.labelPostsPath.Name = "labelPostsPath";
this.labelPostsPath.Size = new System.Drawing.Size(144, 16);
this.labelPostsPath.TabIndex = 0;
this.labelPostsPath.Text = "Posts Path:";
//
// textBoxPostsPath
//
this.textBoxPostsPath.Location = new System.Drawing.Point(16, 38);
this.textBoxPostsPath.Name = "textBoxPostsPath";
this.textBoxPostsPath.Size = new System.Drawing.Size(316, 23);
this.textBoxPostsPath.TabIndex = 1;
//
// groupBoxPosts
//
this.groupBoxPosts.Controls.Add(this.checkBoxDraftsEnabled);
this.groupBoxPosts.Controls.Add(this.textBoxPostsPath);
this.groupBoxPosts.Controls.Add(this.textBoxDraftsPath);
this.groupBoxPosts.Controls.Add(this.labelPostsPath);
this.groupBoxPosts.Controls.Add(this.labelDraftsPath);
this.groupBoxPosts.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.groupBoxPosts.Location = new System.Drawing.Point(8, 32);
this.groupBoxPosts.Name = "groupBoxPosts";
this.groupBoxPosts.Size = new System.Drawing.Size(345, 144);
this.groupBoxPosts.TabIndex = 1;
this.groupBoxPosts.TabStop = false;
this.groupBoxPosts.Text = "Posts and Drafts";
//
// groupBoxPages
//
this.groupBoxPages.Controls.Add(this.checkBoxPagesStoredInRoot);
this.groupBoxPages.Controls.Add(this.checkBoxPagesEnabled);
this.groupBoxPages.Controls.Add(this.textBoxPagesPath);
this.groupBoxPages.Controls.Add(this.labelPagesPath);
this.groupBoxPages.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.groupBoxPages.Location = new System.Drawing.Point(8, 182);
this.groupBoxPages.Name = "groupBoxPages";
this.groupBoxPages.Size = new System.Drawing.Size(345, 120);
this.groupBoxPages.TabIndex = 2;
this.groupBoxPages.TabStop = false;
this.groupBoxPages.Text = "Pages";
//
// textBoxPagesPath
//
this.textBoxPagesPath.Location = new System.Drawing.Point(16, 63);
this.textBoxPagesPath.Name = "textBoxPagesPath";
this.textBoxPagesPath.Size = new System.Drawing.Size(316, 23);
this.textBoxPagesPath.TabIndex = 1;
//
// labelPagesPath
//
this.labelPagesPath.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.labelPagesPath.Location = new System.Drawing.Point(16, 44);
this.labelPagesPath.Name = "labelPagesPath";
this.labelPagesPath.Size = new System.Drawing.Size(144, 16);
this.labelPagesPath.TabIndex = 0;
this.labelPagesPath.Text = "Pages Path:";
//
// checkBoxPagesEnabled
//
this.checkBoxPagesEnabled.AutoSize = true;
this.checkBoxPagesEnabled.Location = new System.Drawing.Point(16, 22);
this.checkBoxPagesEnabled.Name = "checkBoxPagesEnabled";
this.checkBoxPagesEnabled.Size = new System.Drawing.Size(95, 19);
this.checkBoxPagesEnabled.TabIndex = 2;
this.checkBoxPagesEnabled.Text = "Enable Pages";
this.checkBoxPagesEnabled.UseVisualStyleBackColor = true;
this.checkBoxPagesEnabled.CheckedChanged += new System.EventHandler(this.CheckBoxPagesEnabled_CheckedChanged);
//
// checkBoxPagesStoredInRoot
//
this.checkBoxPagesStoredInRoot.AutoSize = true;
this.checkBoxPagesStoredInRoot.Location = new System.Drawing.Point(16, 92);
this.checkBoxPagesStoredInRoot.Name = "checkBoxPagesStoredInRoot";
this.checkBoxPagesStoredInRoot.Size = new System.Drawing.Size(175, 19);
this.checkBoxPagesStoredInRoot.TabIndex = 3;
this.checkBoxPagesStoredInRoot.Text = "Pages Stored In Project Root";
this.checkBoxPagesStoredInRoot.UseVisualStyleBackColor = true;
this.checkBoxPagesStoredInRoot.CheckedChanged += new System.EventHandler(this.CheckBoxPagesStoredInRoot_CheckedChanged);
//
// groupBoxImages
//
this.groupBoxImages.Controls.Add(this.checkBoxImagesEnabled);
this.groupBoxImages.Controls.Add(this.textBoxImagesPath);
this.groupBoxImages.Controls.Add(this.labelImagesPath);
this.groupBoxImages.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.groupBoxImages.Location = new System.Drawing.Point(8, 308);
this.groupBoxImages.Name = "groupBoxImages";
this.groupBoxImages.Size = new System.Drawing.Size(345, 101);
this.groupBoxImages.TabIndex = 4;
this.groupBoxImages.TabStop = false;
this.groupBoxImages.Text = "Images";
//
// checkBoxDraftsEnabled
//
this.checkBoxDraftsEnabled.AutoSize = true;
this.checkBoxDraftsEnabled.Location = new System.Drawing.Point(16, 67);
this.checkBoxDraftsEnabled.Name = "checkBoxDraftsEnabled";
this.checkBoxDraftsEnabled.Size = new System.Drawing.Size(95, 19);
this.checkBoxDraftsEnabled.TabIndex = 2;
this.checkBoxDraftsEnabled.Text = "Enable Drafts";
this.checkBoxDraftsEnabled.UseVisualStyleBackColor = true;
this.checkBoxDraftsEnabled.CheckedChanged += new System.EventHandler(this.CheckBoxDraftsEnabled_CheckedChanged);
//
// textBoxDraftsPath
//
this.textBoxDraftsPath.Location = new System.Drawing.Point(16, 108);
this.textBoxDraftsPath.Name = "textBoxDraftsPath";
this.textBoxDraftsPath.Size = new System.Drawing.Size(316, 23);
this.textBoxDraftsPath.TabIndex = 1;
//
// labelDraftsPath
//
this.labelDraftsPath.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.labelDraftsPath.Location = new System.Drawing.Point(16, 89);
this.labelDraftsPath.Name = "labelDraftsPath";
this.labelDraftsPath.Size = new System.Drawing.Size(144, 16);
this.labelDraftsPath.TabIndex = 0;
this.labelDraftsPath.Text = "Drafts Path:";
//
// checkBoxImagesEnabled
//
this.checkBoxImagesEnabled.AutoSize = true;
this.checkBoxImagesEnabled.Location = new System.Drawing.Point(16, 22);
this.checkBoxImagesEnabled.Name = "checkBoxImagesEnabled";
this.checkBoxImagesEnabled.Size = new System.Drawing.Size(102, 19);
this.checkBoxImagesEnabled.TabIndex = 5;
this.checkBoxImagesEnabled.Text = "Enable Images";
this.checkBoxImagesEnabled.UseVisualStyleBackColor = true;
this.checkBoxImagesEnabled.CheckedChanged += new System.EventHandler(this.CheckBoxImagesEnabled_CheckedChanged);
//
// textBoxImagesPath
//
this.textBoxImagesPath.Location = new System.Drawing.Point(16, 63);
this.textBoxImagesPath.Name = "textBoxImagesPath";
this.textBoxImagesPath.Size = new System.Drawing.Size(316, 23);
this.textBoxImagesPath.TabIndex = 4;
//
// labelImagesPath
//
this.labelImagesPath.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.labelImagesPath.Location = new System.Drawing.Point(16, 44);
this.labelImagesPath.Name = "labelImagesPath";
this.labelImagesPath.Size = new System.Drawing.Size(144, 16);
this.labelImagesPath.TabIndex = 3;
this.labelImagesPath.Text = "Images Path:";
//
// AuthoringPanel
//
this.AccessibleName = "Authoring";
this.Controls.Add(this.groupBoxImages);
this.Controls.Add(this.groupBoxPages);
this.Controls.Add(this.groupBoxPosts);
this.Name = "AuthoringPanel";
this.PanelName = "Authoring";
this.Size = new System.Drawing.Size(370, 425);
this.Controls.SetChildIndex(this.groupBoxPosts, 0);
this.Controls.SetChildIndex(this.groupBoxPages, 0);
this.Controls.SetChildIndex(this.groupBoxImages, 0);
this.groupBoxPosts.ResumeLayout(false);
this.groupBoxPosts.PerformLayout();
this.groupBoxPages.ResumeLayout(false);
this.groupBoxPages.PerformLayout();
this.groupBoxImages.ResumeLayout(false);
this.groupBoxImages.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private void CheckBoxDraftsEnabled_CheckedChanged(object sender, EventArgs e)
=> RecomputeEnabledStates();
private void CheckBoxPagesEnabled_CheckedChanged(object sender, EventArgs e)
=> RecomputeEnabledStates();
private void CheckBoxPagesStoredInRoot_CheckedChanged(object sender, EventArgs e)
{
RecomputeEnabledStates();
if (checkBoxPagesStoredInRoot.Checked) textBoxPagesPath.Text = ".";
}
private void CheckBoxImagesEnabled_CheckedChanged(object sender, EventArgs e)
=> RecomputeEnabledStates();
private void RecomputeEnabledStates()
{
textBoxDraftsPath.Enabled = checkBoxDraftsEnabled.Checked;
textBoxPagesPath.Enabled = checkBoxPagesEnabled.Checked && !checkBoxPagesStoredInRoot.Checked;
checkBoxPagesStoredInRoot.Enabled = checkBoxPagesEnabled.Checked;
textBoxImagesPath.Enabled = checkBoxImagesEnabled.Checked;
}
}
}

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

@ -19,6 +19,7 @@ namespace OpenLiveWriter.PostEditor.Configuration.StaticSiteAdvanced
private PreferencesForm _form; private PreferencesForm _form;
private GeneralPanel panelGeneral; private GeneralPanel panelGeneral;
private AuthoringPanel panelAuthoring;
public PreferencesController(TemporaryBlogSettings blogSettings) public PreferencesController(TemporaryBlogSettings blogSettings)
{ {
@ -26,6 +27,7 @@ namespace OpenLiveWriter.PostEditor.Configuration.StaticSiteAdvanced
_form = new PreferencesForm(); _form = new PreferencesForm();
panelGeneral = new GeneralPanel(this); panelGeneral = new GeneralPanel(this);
panelAuthoring = new AuthoringPanel(this);
} }
private bool EditWeblogTemporarySettings(IWin32Window owner) private bool EditWeblogTemporarySettings(IWin32Window owner)
@ -43,6 +45,7 @@ namespace OpenLiveWriter.PostEditor.Configuration.StaticSiteAdvanced
// Add panels // Add panels
int iPanel = 0; int iPanel = 0;
preferencesForm.SetEntry(iPanel++, panelGeneral); preferencesForm.SetEntry(iPanel++, panelGeneral);
preferencesForm.SetEntry(iPanel++, panelAuthoring);
preferencesForm.SelectedIndex = 0; preferencesForm.SelectedIndex = 0;
@ -67,6 +70,16 @@ namespace OpenLiveWriter.PostEditor.Configuration.StaticSiteAdvanced
panelGeneral.SiteTitle = ssgConfig.SiteTitle; panelGeneral.SiteTitle = ssgConfig.SiteTitle;
panelGeneral.SiteUrl = ssgConfig.SiteUrl; panelGeneral.SiteUrl = ssgConfig.SiteUrl;
panelGeneral.LocalSitePath = ssgConfig.LocalSitePath; panelGeneral.LocalSitePath = ssgConfig.LocalSitePath;
// Authoring
panelAuthoring.PostsPath = ssgConfig.PostsPath;
panelAuthoring.DraftsEnabled = ssgConfig.DraftsEnabled;
panelAuthoring.DraftsPath = ssgConfig.DraftsPath;
panelAuthoring.PagesEnabled = ssgConfig.PagesEnabled;
panelAuthoring.PagesPath = ssgConfig.PagesPath;
panelAuthoring.PagesStoredInRoot = ssgConfig.PagesPath == ".";
panelAuthoring.ImagesEnabled = ssgConfig.ImagesEnabled;
panelAuthoring.ImagesPath = ssgConfig.ImagesPath;
} }
public void GeneralPanel_RunAccountWizard() public void GeneralPanel_RunAccountWizard()

View File

@ -289,6 +289,9 @@
<Compile Include="Configuration\Settings\WeblogSettingsPanel.cs"> <Compile Include="Configuration\Settings\WeblogSettingsPanel.cs">
<SubType>UserControl</SubType> <SubType>UserControl</SubType>
</Compile> </Compile>
<Compile Include="Configuration\StaticSiteAdvanced\AuthoringPanel.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Configuration\StaticSiteAdvanced\GeneralPanel.cs"> <Compile Include="Configuration\StaticSiteAdvanced\GeneralPanel.cs">
<SubType>UserControl</SubType> <SubType>UserControl</SubType>
</Compile> </Compile>
@ -1045,6 +1048,10 @@
<DependentUpon>WeblogSettingsPanel.cs</DependentUpon> <DependentUpon>WeblogSettingsPanel.cs</DependentUpon>
<SubType>Designer</SubType> <SubType>Designer</SubType>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="Configuration\StaticSiteAdvanced\AuthoringPanel.resx">
<DependentUpon>AuthoringPanel.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Configuration\StaticSiteAdvanced\GeneralPanel.resx"> <EmbeddedResource Include="Configuration\StaticSiteAdvanced\GeneralPanel.resx">
<DependentUpon>GeneralPanel.cs</DependentUpon> <DependentUpon>GeneralPanel.cs</DependentUpon>
<SubType>Designer</SubType> <SubType>Designer</SubType>