From 4cf28cdb04825d350267a145d7ed28515b562f02 Mon Sep 17 00:00:00 2001 From: Nick Vella Date: Wed, 3 Jul 2019 18:18:01 +1000 Subject: [PATCH] ssg: wizard: begin multistep wizard, impl step 1 - initial --- .../OpenLiveWriter.Localization/StringId.cs | 12 +- .../OpenLiveWriter.Localization/Strings.csv | 3 +- .../OpenLiveWriter.Localization/Strings.resx | 9 +- .../WeblogConfigurationWizardController.cs | 7 +- ...onfigurationWizardPanelStaticSiteConfig.cs | 402 ------------------ ...nfigurationWizardPanelStaticSiteInitial.cs | 236 ++++++++++ ...gurationWizardPanelStaticSiteInitial.resx} | 3 + .../OpenLiveWriter.PostEditor.csproj | 13 +- .../OpenLiveWriter.Ribbon.vcxproj | 6 +- 9 files changed, 271 insertions(+), 420 deletions(-) delete mode 100644 src/managed/OpenLiveWriter.PostEditor/Configuration/Wizard/WeblogConfigurationWizardPanelStaticSiteConfig.cs create mode 100644 src/managed/OpenLiveWriter.PostEditor/Configuration/Wizard/WeblogConfigurationWizardPanelStaticSiteInitial.cs rename src/managed/OpenLiveWriter.PostEditor/Configuration/Wizard/{WeblogConfigurationWizardPanelStaticSiteConfig.resx => WeblogConfigurationWizardPanelStaticSiteInitial.resx} (94%) diff --git a/src/managed/OpenLiveWriter.Localization/StringId.cs b/src/managed/OpenLiveWriter.Localization/StringId.cs index d396cddb..1f561e7e 100644 --- a/src/managed/OpenLiveWriter.Localization/StringId.cs +++ b/src/managed/OpenLiveWriter.Localization/StringId.cs @@ -1126,10 +1126,6 @@ namespace OpenLiveWriter.Localization /// (example555@hotmail.com) /// CWSpacesUsernameExample, - /// - /// Provide static site configuration - /// - CWStaticSiteAddSiteTitle, /// /// Build command: /// @@ -1138,6 +1134,14 @@ namespace OpenLiveWriter.Localization /// Enable building /// CWStaticSiteEnableBuilding, + /// + /// {0} will attempt to automatically detect your static site configuration based on files present in your site project folder. Please select the project folder of your static site (eg. Git repository) + /// + CWStaticSiteInitialSubtitle, + /// + /// Provide static site configuration + /// + CWStaticSiteInitialTitle, /// /// Please select the project folder of your static site (eg. Git repository) /// diff --git a/src/managed/OpenLiveWriter.Localization/Strings.csv b/src/managed/OpenLiveWriter.Localization/Strings.csv index d7f90d66..fcb8540d 100644 --- a/src/managed/OpenLiveWriter.Localization/Strings.csv +++ b/src/managed/OpenLiveWriter.Localization/Strings.csv @@ -372,7 +372,8 @@ CWSharePointUseSystemLogin,Use my &Windows user name and password, CWGoogleBloggerTitle,Provide Google Blogger Login, CWGoogleBloggerDescription,To configure Google Blogger please sign in., CWGoogleBloggerSignInSuccess,Successfully signed in, -CWStaticSiteAddSiteTitle,Provide static site configuration, +CWStaticSiteInitialTitle,Provide static site configuration, +CWStaticSiteInitialSubtitle,{0} will attempt to automatically detect your static site configuration based on files present in your site project folder. Please select the project folder of your static site (eg. Git repository),{0} - Product name CWStaticSiteLocalSitePath,Path to local static site:, CWStaticSitePostsPath,Posts path: (relative), CWStaticSitePagesPath,Pages path: (relative), diff --git a/src/managed/OpenLiveWriter.Localization/Strings.resx b/src/managed/OpenLiveWriter.Localization/Strings.resx index 3dfad894..f226a23a 100644 --- a/src/managed/OpenLiveWriter.Localization/Strings.resx +++ b/src/managed/OpenLiveWriter.Localization/Strings.resx @@ -967,15 +967,18 @@ (example555@hotmail.com) Example of Microsoft Account ID - - Provide static site configuration - Build command: Enable building + + {0} will attempt to automatically detect your static site configuration based on files present in your site project folder. Please select the project folder of your static site (eg. Git repository) + {0} - Product name + + Provide static site configuration + Please select the project folder of your static site (eg. Git repository) diff --git a/src/managed/OpenLiveWriter.PostEditor/Configuration/Wizard/WeblogConfigurationWizardController.cs b/src/managed/OpenLiveWriter.PostEditor/Configuration/Wizard/WeblogConfigurationWizardController.cs index cfbade6d..217bbcb0 100644 --- a/src/managed/OpenLiveWriter.PostEditor/Configuration/Wizard/WeblogConfigurationWizardController.cs +++ b/src/managed/OpenLiveWriter.PostEditor/Configuration/Wizard/WeblogConfigurationWizardController.cs @@ -248,7 +248,7 @@ namespace OpenLiveWriter.PostEditor.Configuration.Wizard private void AddStaticSiteConfigSubStep() { - var configPanel = new WeblogConfigurationWizardPanelStaticSiteConfig(); + var configPanel = new WeblogConfigurationWizardPanelStaticSiteInitial(); addWizardSubStep( new WizardSubStep(configPanel, null, @@ -491,14 +491,14 @@ namespace OpenLiveWriter.PostEditor.Configuration.Wizard private void OnStaticSiteConfigDisplayed(Object stepControl) { // Populate data - var panel = (stepControl as WeblogConfigurationWizardPanelStaticSiteConfig); + var panel = (stepControl as WeblogConfigurationWizardPanelStaticSiteInitial); var config = StaticSiteConfig.LoadConfigFromCredentials( _temporarySettings.Credentials); panel.LoadFromConfig(config); } private void OnStaticSiteConfigCompleted(Object stepControl) { - var panel = (stepControl as WeblogConfigurationWizardPanelStaticSiteConfig); + var panel = (stepControl as WeblogConfigurationWizardPanelStaticSiteInitial); // Fill blog settings _temporarySettings.SetProvider( @@ -507,7 +507,6 @@ namespace OpenLiveWriter.PostEditor.Configuration.Wizard StaticSiteClient.POST_API_URL, StaticSiteClient.CLIENT_TYPE ); - _temporarySettings.HomepageUrl = panel.HomepageUrl; // TODO Find a place for this that persists between panels var config = new StaticSiteConfig(); diff --git a/src/managed/OpenLiveWriter.PostEditor/Configuration/Wizard/WeblogConfigurationWizardPanelStaticSiteConfig.cs b/src/managed/OpenLiveWriter.PostEditor/Configuration/Wizard/WeblogConfigurationWizardPanelStaticSiteConfig.cs deleted file mode 100644 index 500368a5..00000000 --- a/src/managed/OpenLiveWriter.PostEditor/Configuration/Wizard/WeblogConfigurationWizardPanelStaticSiteConfig.cs +++ /dev/null @@ -1,402 +0,0 @@ -// 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.IO; -using System.ComponentModel; -using System.Diagnostics; -using System.Drawing; -using System.Globalization; -using System.Text.RegularExpressions; -using System.Windows.Forms; -using OpenLiveWriter.ApplicationFramework.Preferences; -using OpenLiveWriter.BlogClient; -using OpenLiveWriter.BlogClient.Clients; -using OpenLiveWriter.CoreServices; -using OpenLiveWriter.CoreServices.Layout; -using OpenLiveWriter.Extensibility.BlogClient; -using OpenLiveWriter.Localization; -using OpenLiveWriter.Localization.Bidi; -using OpenLiveWriter.PostEditor.BlogProviderButtons; - -using StaticSiteClient = OpenLiveWriter.BlogClient.Clients.StaticSiteClient; - -namespace OpenLiveWriter.PostEditor.Configuration.Wizard -{ - /// - /// Summary description for WelcomeToBlogControl. - /// - internal class WeblogConfigurationWizardPanelStaticSiteConfig : WeblogConfigurationWizardPanel - { - private System.Windows.Forms.Label labelLocalSitePath; - private System.Windows.Forms.Label labelPostsPath; - private System.Windows.Forms.Label labelPagesPath; - private System.Windows.Forms.Label labelBuildCmd; - private System.Windows.Forms.Label labelPublishCmd; - - private System.Windows.Forms.TextBox textBoxLocalSitePath; - private System.Windows.Forms.TextBox textBoxPostsPath; - private System.Windows.Forms.TextBox textBoxPagesPath; - private System.Windows.Forms.TextBox textBoxBuildCmd; - private System.Windows.Forms.TextBox textBoxPublishCmd; - - private System.Windows.Forms.Button btnLocalSiteBrowse; - - private System.Windows.Forms.CheckBox checkBoxEnableBuilding; - - /// - /// Required designer variable. - /// - private Container components = null; - - public WeblogConfigurationWizardPanelStaticSiteConfig() - { - // This call is required by the Windows.Forms Form Designer. - InitializeComponent(); - - this.labelHeader.Text = Res.Get(StringId.CWStaticSiteAddSiteTitle); - this.labelLocalSitePath.Text = Res.Get(StringId.CWStaticSiteLocalSitePath); - this.labelPostsPath.Text = Res.Get(StringId.CWStaticSitePostsPath); - this.labelPagesPath.Text = Res.Get(StringId.CWStaticSitePagesPath); - this.labelBuildCmd.Text = Res.Get(StringId.CWStaticSiteBuildCommand); - this.labelPublishCmd.Text = Res.Get(StringId.CWStaticSitePublishCommand); - this.checkBoxEnableBuilding.Text = Res.Get(StringId.CWStaticSiteEnableBuilding); - } - - public override void NaturalizeLayout() - { - // Wizard views are very broken in the VS Form Designer, due to runtime control layout. - if (DesignMode) return; - - MaximizeWidth(labelLocalSitePath); - MaximizeWidth(labelBuildCmd); - MaximizeWidth(labelPublishCmd); - //MaximizeWidth(checkBoxEnableBuilding); - - LayoutHelper.NaturalizeHeightAndDistribute(3, labelLocalSitePath, textBoxLocalSitePath); - LayoutHelper.NaturalizeHeightAndDistribute(3, labelPostsPath, textBoxPostsPath); - LayoutHelper.NaturalizeHeightAndDistribute(3, labelPagesPath, textBoxPagesPath); - LayoutHelper.NaturalizeHeightAndDistribute(3, labelBuildCmd, textBoxBuildCmd); - LayoutHelper.NaturalizeHeightAndDistribute(3, labelPublishCmd, textBoxPublishCmd); - LayoutHelper.DistributeVertically(10, false, - new ControlGroup(labelLocalSitePath, textBoxLocalSitePath), - new ControlGroup(labelPostsPath, textBoxPostsPath, labelPagesPath, textBoxPagesPath), - new ControlGroup(labelBuildCmd, textBoxBuildCmd), - new ControlGroup(labelPublishCmd, textBoxPublishCmd) - ); - - // Align Pages path label and input next to Posts path - labelPagesPath.Left = textBoxPagesPath.Left = textBoxPostsPath.Left + textBoxPostsPath.Width + 20; - - // Align Browse button with Local Site Path top and right - btnLocalSiteBrowse.Left = textBoxLocalSitePath.Left + textBoxLocalSitePath.Width + 3; - btnLocalSiteBrowse.Top = textBoxLocalSitePath.Top; - btnLocalSiteBrowse.Height = textBoxLocalSitePath.Height; - } - - public override ConfigPanelId? PanelId - { - get { return ConfigPanelId.StaticSiteConfig; } - } - - public override bool ShowProxySettingsLink - { - get { return false; } - } - - public IBlogProviderAccountWizardDescription ProviderAccountWizard - { - set { } - } - - public string AccountId - { - set { } - } - - public string LocalSitePath - { - get => PathHelper.RemoveLeadingAndTrailingSlash(textBoxLocalSitePath.Text); - set { textBoxLocalSitePath.Text = value; } - } - - public string PostsPath - { - get => PathHelper.RemoveLeadingAndTrailingSlash(textBoxPostsPath.Text); - set { textBoxPostsPath.Text = value; } - } - - public string PagesPath - { - get => PathHelper.RemoveLeadingAndTrailingSlash(textBoxPagesPath.Text); - set { textBoxPagesPath.Text = value; } - } - - public string BuildCmd - { - get => textBoxBuildCmd.Text; - set { textBoxBuildCmd.Text = value; } - } - - public string PublishCmd - { - get => textBoxPublishCmd.Text; - set { textBoxPublishCmd.Text = value; } - } - - public string HomepageUrl { get; set; } = "http://localhost"; - - public bool BuildEnabled - { - get => checkBoxEnableBuilding.Checked; - set { checkBoxEnableBuilding.Checked = value; } - } - - public bool IsDirty(TemporaryBlogSettings settings) - { - return false; // TODO - - } - - public override bool ValidatePanel() - { - if (!Directory.Exists(LocalSitePath)) - { - ShowValidationError(textBoxLocalSitePath, MessageId.FolderNotFound, LocalSitePath); - return false; - } - - var postsPathFull = $"{LocalSitePath}\\{PostsPath}"; - var pagesPathFull = $"{LocalSitePath}\\{PagesPath}"; - - // If the Posts path is empty or doesn't exist, display an error - if (PagesPath.Trim().Length == 0 || !Directory.Exists(postsPathFull)) - { - ShowValidationError(textBoxPostsPath, MessageId.FolderNotFound, postsPathFull); - return false; - } - - // If the Pages path is over 0 (pages enabled) and the path doesn't exist, display an error - if (PagesPath.Trim().Length > 0 && !Directory.Exists(pagesPathFull)) - { - ShowValidationError(textBoxPagesPath, MessageId.FolderNotFound, pagesPathFull); - return false; - } - - // Publish commands are required - if(PublishCmd.Trim().Length == 0) - { - ShowValidationError(textBoxPublishCmd, MessageId.SSGPublishCommandRequired); - return false; - } - - return true; - } - - /// - /// Saves panel form fields into a StaticSiteConfig - /// - /// a StaticSiteConfig instance - public void SaveToConfig(StaticSiteConfig config) - { - config.LocalSitePath = LocalSitePath; - config.PostsPath = PostsPath; - config.PagesPath = PagesPath; - config.BuildCommand = BuildCmd; - config.PublishCommand = PublishCmd; - } - - /// - /// Loads panel form fields from a StaticSiteConfig - /// - /// a StaticSiteConfig instance - public void LoadFromConfig(StaticSiteConfig config) - { - LocalSitePath = config.LocalSitePath; - PostsPath = config.PostsPath; - PagesPath = config.PagesPath; - BuildCmd = config.BuildCommand; - PublishCmd = config.PublishCommand; - } - - /// - /// Clean up any resources being used. - /// - protected override void Dispose(bool disposing) - { - if (disposing) - { - if (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.labelLocalSitePath = new System.Windows.Forms.Label(); - this.labelPostsPath = new System.Windows.Forms.Label(); - this.labelPagesPath = new System.Windows.Forms.Label(); - this.labelBuildCmd = new System.Windows.Forms.Label(); - this.labelPublishCmd = new System.Windows.Forms.Label(); - - this.checkBoxEnableBuilding = new System.Windows.Forms.CheckBox(); - this.textBoxLocalSitePath = new System.Windows.Forms.TextBox(); - this.textBoxPostsPath = new System.Windows.Forms.TextBox(); - this.textBoxPagesPath = new System.Windows.Forms.TextBox(); - this.textBoxBuildCmd = new System.Windows.Forms.TextBox(); - this.textBoxPublishCmd = new System.Windows.Forms.TextBox(); - - this.btnLocalSiteBrowse = new System.Windows.Forms.Button(); - - this.panelMain.SuspendLayout(); - this.SuspendLayout(); - panelMain.Controls.Add(labelLocalSitePath); - panelMain.Controls.Add(textBoxLocalSitePath); - panelMain.Controls.Add(btnLocalSiteBrowse); - panelMain.Controls.Add(labelPostsPath); - panelMain.Controls.Add(textBoxPostsPath); - panelMain.Controls.Add(labelPagesPath); - panelMain.Controls.Add(textBoxPagesPath); - panelMain.Controls.Add(labelBuildCmd); - panelMain.Controls.Add(textBoxBuildCmd); - panelMain.Controls.Add(labelPublishCmd); - panelMain.Controls.Add(textBoxPublishCmd); - // - // checkBoxSavePassword - // - /*this.checkBoxSavePassword.FlatStyle = System.Windows.Forms.FlatStyle.System; - this.checkBoxSavePassword.Location = new System.Drawing.Point(20, 98); - this.checkBoxSavePassword.Name = "checkBoxSavePassword"; - this.checkBoxSavePassword.Size = new System.Drawing.Size(165, 26); - this.checkBoxSavePassword.TabIndex = 5; - this.checkBoxSavePassword.Text = "&Remember my password"; - this.checkBoxSavePassword.TextAlign = System.Drawing.ContentAlignment.TopLeft;*/ - - // - // labelLocalSitePath - // - this.labelLocalSitePath.FlatStyle = System.Windows.Forms.FlatStyle.System; - this.labelLocalSitePath.Location = new System.Drawing.Point(20, 0); - this.labelLocalSitePath.Name = "labelLocalSitePath"; - this.labelLocalSitePath.Size = new System.Drawing.Size(167, 13); - this.labelLocalSitePath.TabIndex = 1; - this.labelLocalSitePath.Text = "Path to local site:"; - // - // textBoxLocalSitePath - // - this.textBoxLocalSitePath.Location = new System.Drawing.Point(20, 74); - this.textBoxLocalSitePath.Name = "labelLocalSitePath"; - this.textBoxLocalSitePath.Size = new System.Drawing.Size(275, 22); - this.textBoxLocalSitePath.TabIndex = 2; - // - // btnLocalSiteBrowse - // - this.btnLocalSiteBrowse.Location = new System.Drawing.Point(20, 74); - this.btnLocalSiteBrowse.Name = "btnLocalSiteBrowse"; - this.btnLocalSiteBrowse.Text = "..."; - this.btnLocalSiteBrowse.FlatStyle = FlatStyle.System; - this.btnLocalSiteBrowse.Size = new System.Drawing.Size(20, 22); - this.btnLocalSiteBrowse.Margin = new Padding(0); - this.btnLocalSiteBrowse.TabIndex = 3; - this.btnLocalSiteBrowse.Click += new System.EventHandler(this.BtnLocalSiteBrowse_Click); - // - // labelPostsPath - // - this.labelPostsPath.FlatStyle = System.Windows.Forms.FlatStyle.System; - this.labelPostsPath.Location = new System.Drawing.Point(20, 0); - this.labelPostsPath.Name = "labelPostsPath"; - this.labelPostsPath.Size = new System.Drawing.Size(167, 13); - this.labelPostsPath.TabIndex = 4; - this.labelPostsPath.Text = "Path to posts directory: (relative)"; - // - // textBoxPostsPath - // - this.textBoxPostsPath.Location = new System.Drawing.Point(20, 74); - this.textBoxPostsPath.Name = "textBoxPostsPath"; - this.textBoxPostsPath.Size = new System.Drawing.Size(180, 22); - this.textBoxPostsPath.TabIndex = 5; - // - // labelPagesPath - // - this.labelPagesPath.FlatStyle = System.Windows.Forms.FlatStyle.System; - this.labelPagesPath.Location = new System.Drawing.Point(20, 0); - this.labelPagesPath.Name = "labelPagesPath"; - this.labelPagesPath.Size = new System.Drawing.Size(167, 13); - this.labelPagesPath.TabIndex = 6; - this.labelPagesPath.Text = "Path to posts directory: (relative)"; - // - // textBoxPagesPath - // - this.textBoxPagesPath.Location = new System.Drawing.Point(20, 74); - this.textBoxPagesPath.Name = "textBoxPagesPath"; - this.textBoxPagesPath.Size = new System.Drawing.Size(180, 22); - this.textBoxPagesPath.TabIndex = 7; - // - // labelBuildCmd - // - this.labelBuildCmd.FlatStyle = System.Windows.Forms.FlatStyle.System; - this.labelBuildCmd.Location = new System.Drawing.Point(20, 0); - this.labelBuildCmd.Name = "labelBuildCmd"; - this.labelBuildCmd.Size = new System.Drawing.Size(167, 13); - this.labelBuildCmd.TabIndex = 8; - this.labelBuildCmd.Text = "Build command:"; - // - // textBoxBuildCmd - // - this.textBoxBuildCmd.Location = new System.Drawing.Point(20, 74); - this.textBoxBuildCmd.Name = "textBoxBuildCmd"; - this.textBoxBuildCmd.Size = new System.Drawing.Size(275, 22); - this.textBoxBuildCmd.TabIndex = 9; - // - // labelPublishCmd - // - this.labelPublishCmd.FlatStyle = System.Windows.Forms.FlatStyle.System; - this.labelPublishCmd.Location = new System.Drawing.Point(20, 0); - this.labelPublishCmd.Name = "labelBuildCmd"; - this.labelPublishCmd.Size = new System.Drawing.Size(167, 13); - this.labelPublishCmd.TabIndex = 10; - this.labelPublishCmd.Text = "Publish command:"; - // - // textBoxPublishCmd - // - this.textBoxPublishCmd.Location = new System.Drawing.Point(20, 74); - this.textBoxPublishCmd.Name = "textBoxBuildCmd"; - this.textBoxPublishCmd.Size = new System.Drawing.Size(275, 22); - this.textBoxPublishCmd.TabIndex = 11; - - // - // WeblogConfigurationWizardPanelBasicInfo - // - this.Name = "WeblogConfigurationWizardPanelStaticSiteConfig"; - this.Size = new System.Drawing.Size(432, 244); - this.AutoSize = true; - this.panelMain.ResumeLayout(false); - this.ResumeLayout(false); - - } - #endregion - - private void BtnLocalSiteBrowse_Click(object sender, EventArgs args) - { - var folderBrowserDialog = new FolderBrowserDialog(); - folderBrowserDialog.ShowNewFolderButton = false; - folderBrowserDialog.Description = Res.Get(StringId.CWStaticSiteLocalSiteFolderPicker); - var result = folderBrowserDialog.ShowDialog(); - - if (result == DialogResult.OK) - { - textBoxLocalSitePath.Text = folderBrowserDialog.SelectedPath; - } - } - - - } -} \ No newline at end of file diff --git a/src/managed/OpenLiveWriter.PostEditor/Configuration/Wizard/WeblogConfigurationWizardPanelStaticSiteInitial.cs b/src/managed/OpenLiveWriter.PostEditor/Configuration/Wizard/WeblogConfigurationWizardPanelStaticSiteInitial.cs new file mode 100644 index 00000000..3db68f78 --- /dev/null +++ b/src/managed/OpenLiveWriter.PostEditor/Configuration/Wizard/WeblogConfigurationWizardPanelStaticSiteInitial.cs @@ -0,0 +1,236 @@ +// 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.IO; +using System.ComponentModel; +using System.Diagnostics; +using System.Drawing; +using System.Globalization; +using System.Text.RegularExpressions; +using System.Windows.Forms; +using OpenLiveWriter.ApplicationFramework.Preferences; +using OpenLiveWriter.BlogClient; +using OpenLiveWriter.BlogClient.Clients; +using OpenLiveWriter.CoreServices; +using OpenLiveWriter.CoreServices.Layout; +using OpenLiveWriter.Extensibility.BlogClient; +using OpenLiveWriter.Localization; +using OpenLiveWriter.Localization.Bidi; +using OpenLiveWriter.PostEditor.BlogProviderButtons; + +using StaticSiteClient = OpenLiveWriter.BlogClient.Clients.StaticSiteClient; + +namespace OpenLiveWriter.PostEditor.Configuration.Wizard +{ + /// + /// Summary description for WelcomeToBlogControl. + /// + internal class WeblogConfigurationWizardPanelStaticSiteInitial : WeblogConfigurationWizardPanel + { + private System.Windows.Forms.Label labelSubtitle; + private System.Windows.Forms.Label labelLocalSitePath; + + private System.Windows.Forms.TextBox textBoxLocalSitePath; + private System.Windows.Forms.Button btnLocalSiteBrowse; + + /// + /// Required designer variable. + /// + private Container components = null; + + public WeblogConfigurationWizardPanelStaticSiteInitial() + { + // This call is required by the Windows.Forms Form Designer. + InitializeComponent(); + + this.labelHeader.Text = Res.Get(StringId.CWStaticSiteInitialTitle); + this.labelSubtitle.Text = string.Format(Res.Get(StringId.CWStaticSiteInitialSubtitle), Res.Get(StringId.ProductNameVersioned)); + this.labelLocalSitePath.Text = Res.Get(StringId.CWStaticSiteLocalSitePath); + } + + public override void NaturalizeLayout() + { + // Wizard views are very broken in the VS Form Designer, due to runtime control layout. + if (DesignMode) return; + + MaximizeWidth(labelSubtitle); + MaximizeWidth(labelLocalSitePath); + + LayoutHelper.DistributeHorizontally(5, textBoxLocalSitePath, btnLocalSiteBrowse); + LayoutHelper.NaturalizeHeight(labelSubtitle); + LayoutHelper.NaturalizeHeightAndDistribute(3, labelLocalSitePath, textBoxLocalSitePath); + + // Align browse button exactly with textbox + btnLocalSiteBrowse.Height = textBoxLocalSitePath.Height; + btnLocalSiteBrowse.Top = textBoxLocalSitePath.Top; + + LayoutHelper.DistributeVertically(20, false, + labelSubtitle, + new ControlGroup(labelLocalSitePath, textBoxLocalSitePath, btnLocalSiteBrowse) + ); + } + + public override ConfigPanelId? PanelId + { + get { return ConfigPanelId.StaticSiteConfig; } + } + + public override bool ShowProxySettingsLink + { + get { return false; } + } + + public IBlogProviderAccountWizardDescription ProviderAccountWizard + { + set { } + } + + public string AccountId + { + set { } + } + + public string LocalSitePath + { + get => PathHelper.RemoveLeadingAndTrailingSlash(textBoxLocalSitePath.Text); + set { textBoxLocalSitePath.Text = value; } + } + + public bool IsDirty(TemporaryBlogSettings settings) + { + return false; // TODO + + } + + public override bool ValidatePanel() + { + if (!Directory.Exists(LocalSitePath)) + { + ShowValidationError(textBoxLocalSitePath, MessageId.FolderNotFound, LocalSitePath); + return false; + } + + return true; + } + + /// + /// Saves panel form fields into a StaticSiteConfig + /// + /// a StaticSiteConfig instance + public void SaveToConfig(StaticSiteConfig config) + { + config.LocalSitePath = LocalSitePath; + } + + /// + /// Loads panel form fields from a StaticSiteConfig + /// + /// a StaticSiteConfig instance + public void LoadFromConfig(StaticSiteConfig config) + { + LocalSitePath = config.LocalSitePath; + } + + /// + /// Clean up any resources being used. + /// + protected override void Dispose(bool disposing) + { + if (disposing) + { + if (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() + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(WeblogConfigurationWizardPanelStaticSiteInitial)); + this.labelSubtitle = new System.Windows.Forms.Label(); + this.labelLocalSitePath = new System.Windows.Forms.Label(); + this.textBoxLocalSitePath = new System.Windows.Forms.TextBox(); + this.btnLocalSiteBrowse = new System.Windows.Forms.Button(); + this.panelMain.SuspendLayout(); + this.SuspendLayout(); + // + // panelMain + // + this.panelMain.Controls.Add(this.labelSubtitle); + this.panelMain.Controls.Add(this.labelLocalSitePath); + this.panelMain.Controls.Add(this.textBoxLocalSitePath); + this.panelMain.Controls.Add(this.btnLocalSiteBrowse); + this.panelMain.Size = new System.Drawing.Size(435, 215); + // + // labelSubtitle + // + this.labelSubtitle.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.labelSubtitle.Location = new System.Drawing.Point(20, 0); + this.labelSubtitle.Margin = new System.Windows.Forms.Padding(0); + this.labelSubtitle.Name = "labelSubtitle"; + this.labelSubtitle.Size = new System.Drawing.Size(415, 75); + this.labelSubtitle.TabIndex = 0; + this.labelSubtitle.Text = resources.GetString("labelSubtitle.Text"); + // + // labelLocalSitePath + // + this.labelLocalSitePath.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.labelLocalSitePath.Location = new System.Drawing.Point(20, 75); + this.labelLocalSitePath.Name = "labelLocalSitePath"; + this.labelLocalSitePath.Size = new System.Drawing.Size(167, 13); + this.labelLocalSitePath.TabIndex = 1; + this.labelLocalSitePath.Text = "Path to local site:"; + // + // textBoxLocalSitePath + // + this.textBoxLocalSitePath.Location = new System.Drawing.Point(20, 91); + this.textBoxLocalSitePath.Name = "textBoxLocalSitePath"; + this.textBoxLocalSitePath.Size = new System.Drawing.Size(275, 20); + this.textBoxLocalSitePath.TabIndex = 2; + // + // btnLocalSiteBrowse + // + this.btnLocalSiteBrowse.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.btnLocalSiteBrowse.Location = new System.Drawing.Point(298, 91); + this.btnLocalSiteBrowse.Margin = new System.Windows.Forms.Padding(0); + this.btnLocalSiteBrowse.Name = "btnLocalSiteBrowse"; + this.btnLocalSiteBrowse.Size = new System.Drawing.Size(20, 23); + this.btnLocalSiteBrowse.TabIndex = 3; + this.btnLocalSiteBrowse.Text = "..."; + this.btnLocalSiteBrowse.Click += new System.EventHandler(this.BtnLocalSiteBrowse_Click); + // + // WeblogConfigurationWizardPanelStaticSiteInitial + // + this.AutoSize = true; + this.Name = "WeblogConfigurationWizardPanelStaticSiteInitial"; + this.Size = new System.Drawing.Size(455, 264); + this.panelMain.ResumeLayout(false); + this.panelMain.PerformLayout(); + this.ResumeLayout(false); + + } + #endregion + + private void BtnLocalSiteBrowse_Click(object sender, EventArgs args) + { + var folderBrowserDialog = new FolderBrowserDialog(); + folderBrowserDialog.ShowNewFolderButton = false; + folderBrowserDialog.Description = Res.Get(StringId.CWStaticSiteLocalSiteFolderPicker); + var result = folderBrowserDialog.ShowDialog(); + + if (result == DialogResult.OK) + { + textBoxLocalSitePath.Text = folderBrowserDialog.SelectedPath; + } + } + + } +} \ No newline at end of file diff --git a/src/managed/OpenLiveWriter.PostEditor/Configuration/Wizard/WeblogConfigurationWizardPanelStaticSiteConfig.resx b/src/managed/OpenLiveWriter.PostEditor/Configuration/Wizard/WeblogConfigurationWizardPanelStaticSiteInitial.resx similarity index 94% rename from src/managed/OpenLiveWriter.PostEditor/Configuration/Wizard/WeblogConfigurationWizardPanelStaticSiteConfig.resx rename to src/managed/OpenLiveWriter.PostEditor/Configuration/Wizard/WeblogConfigurationWizardPanelStaticSiteInitial.resx index d58980a3..5e3ab0fb 100644 --- a/src/managed/OpenLiveWriter.PostEditor/Configuration/Wizard/WeblogConfigurationWizardPanelStaticSiteConfig.resx +++ b/src/managed/OpenLiveWriter.PostEditor/Configuration/Wizard/WeblogConfigurationWizardPanelStaticSiteInitial.resx @@ -117,4 +117,7 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + Open Live Writer will attempt to automatically detect your static site configuration based on files present in your site project folder. Please select the project folder of your static site (eg. Git repository) + \ 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 c3c1abf0..b255c6fa 100644 --- a/src/managed/OpenLiveWriter.PostEditor/OpenLiveWriter.PostEditor.csproj +++ b/src/managed/OpenLiveWriter.PostEditor/OpenLiveWriter.PostEditor.csproj @@ -304,7 +304,10 @@ UserControl - + + UserControl + + UserControl @@ -1039,8 +1042,12 @@ WeblogConfigurationWizardPanelAutoDetection.cs Designer - - WeblogConfigurationWizardPanelStaticSiteConfig.cs + + WeblogConfigurationWizardPanelStaticSitePaths.cs + Designer + + + WeblogConfigurationWizardPanelStaticSiteInitial.cs Designer diff --git a/src/unmanaged/OpenLiveWriter.Ribbon/OpenLiveWriter.Ribbon.vcxproj b/src/unmanaged/OpenLiveWriter.Ribbon/OpenLiveWriter.Ribbon.vcxproj index 3b0884c0..f4c712a8 100644 --- a/src/unmanaged/OpenLiveWriter.Ribbon/OpenLiveWriter.Ribbon.vcxproj +++ b/src/unmanaged/OpenLiveWriter.Ribbon/OpenLiveWriter.Ribbon.vcxproj @@ -15,19 +15,19 @@ {195A60BF-7A4D-42E6-B5F4-FEBC679E19F0} Win32Proj OpenLiveWriter.Ribbon - 10.0.17763.0 + 10.0 DynamicLibrary true - v141 + v142 Unicode DynamicLibrary false - v141 + v142 true Unicode