From 95ae06e63a7e8431fee65b40eeab6dcf7345ed35 Mon Sep 17 00:00:00 2001 From: allisterb Date: Sat, 14 Sep 2024 18:35:13 -0400 Subject: [PATCH] Start SolidityProjectWizard implementation. Can popup dialog on project create. --- .../Solidity.vstemplate | 4 ++ .../Stratis.VS.SolidityProjectTemplate.csproj | 1 + src/Stratis.VS.StratisEVM/BaseWizard.cs | 66 +++++++++++++++++++ .../SolidityProjectWizardUserInputForm.cs | 44 +++++++++++++ .../Stratis.VS.StratisEVM.csproj | 12 +++- .../source.extension.vsixmanifest | 1 + 6 files changed, 125 insertions(+), 3 deletions(-) create mode 100644 src/Stratis.VS.StratisEVM/BaseWizard.cs create mode 100644 src/Stratis.VS.StratisEVM/SolidityProjectWizardUserInputForm.cs diff --git a/src/Stratis.VS.SolidityProjectTemplate/Solidity.vstemplate b/src/Stratis.VS.SolidityProjectTemplate/Solidity.vstemplate index d0b7b29..541def3 100644 --- a/src/Stratis.VS.SolidityProjectTemplate/Solidity.vstemplate +++ b/src/Stratis.VS.SolidityProjectTemplate/Solidity.vstemplate @@ -20,4 +20,8 @@ SmartContract1.sol + + Stratis.VS.StratisEVM, Version=0.1.0.0, Culture=neutral, PublicKeyToken=null + Stratis.VS.StratisEVM.WizardImplementation + \ No newline at end of file diff --git a/src/Stratis.VS.SolidityProjectTemplate/Stratis.VS.SolidityProjectTemplate.csproj b/src/Stratis.VS.SolidityProjectTemplate/Stratis.VS.SolidityProjectTemplate.csproj index 2fea92e..322a161 100644 --- a/src/Stratis.VS.SolidityProjectTemplate/Stratis.VS.SolidityProjectTemplate.csproj +++ b/src/Stratis.VS.SolidityProjectTemplate/Stratis.VS.SolidityProjectTemplate.csproj @@ -59,6 +59,7 @@ + diff --git a/src/Stratis.VS.StratisEVM/BaseWizard.cs b/src/Stratis.VS.StratisEVM/BaseWizard.cs new file mode 100644 index 0000000..2d3c03a --- /dev/null +++ b/src/Stratis.VS.StratisEVM/BaseWizard.cs @@ -0,0 +1,66 @@ +using System; +using System.Collections.Generic; +using Microsoft.VisualStudio.TemplateWizard; +using System.Windows.Forms; +using EnvDTE; + +namespace Stratis.VS.StratisEVM +{ + public class WizardImplementation : IWizard + { + private SolidityProjectWizardUserInputForm inputForm; + private string customMessage; + + // This method is called before opening any item that + // has the OpenInEditor attribute. + public void BeforeOpeningFile(ProjectItem projectItem) + { + } + + public void ProjectFinishedGenerating(Project project) + { + } + + // This method is only called for item templates, + // not for project templates. + public void ProjectItemFinishedGenerating(ProjectItem + projectItem) + { + } + + // This method is called after the project is created. + public void RunFinished() + { + } + + public void RunStarted(object automationObject, + Dictionary replacementsDictionary, + WizardRunKind runKind, object[] customParams) + { + try + { + // Display a form to the user. The form collects + // input for the custom message. + inputForm = new SolidityProjectWizardUserInputForm(); + inputForm.ShowDialog(); + + customMessage = SolidityProjectWizardUserInputForm.CustomMessage; + + // Add custom parameters. + replacementsDictionary.Add("$custommessage$", + customMessage); + } + catch (Exception ex) + { + MessageBox.Show(ex.ToString()); + } + } + + // This method is only called for item templates, + // not for project templates. + public bool ShouldAddProjectItem(string filePath) + { + return true; + } + } +} \ No newline at end of file diff --git a/src/Stratis.VS.StratisEVM/SolidityProjectWizardUserInputForm.cs b/src/Stratis.VS.StratisEVM/SolidityProjectWizardUserInputForm.cs new file mode 100644 index 0000000..39b0d5d --- /dev/null +++ b/src/Stratis.VS.StratisEVM/SolidityProjectWizardUserInputForm.cs @@ -0,0 +1,44 @@ +using System.Windows.Forms; +using System; + +namespace Stratis.VS.StratisEVM +{ + public partial class SolidityProjectWizardUserInputForm : Form + { + private static string customMessage; + private TextBox textBox1; + private Button button1; + + public SolidityProjectWizardUserInputForm() + { + this.Size = new System.Drawing.Size(155, 265); + + button1 = new Button(); + button1.Location = new System.Drawing.Point(90, 25); + button1.Size = new System.Drawing.Size(50, 25); + button1.Click += button1_Click; + this.Controls.Add(button1); + + textBox1 = new TextBox(); + textBox1.Location = new System.Drawing.Point(10, 25); + textBox1.Size = new System.Drawing.Size(70, 20); + this.Controls.Add(textBox1); + } + public static string CustomMessage + { + get + { + return customMessage; + } + set + { + customMessage = value; + } + } + private void button1_Click(object sender, EventArgs e) + { + customMessage = textBox1.Text; + this.Close(); + } + } +} \ No newline at end of file diff --git a/src/Stratis.VS.StratisEVM/Stratis.VS.StratisEVM.csproj b/src/Stratis.VS.StratisEVM/Stratis.VS.StratisEVM.csproj index 0546b55..9c07437 100644 --- a/src/Stratis.VS.StratisEVM/Stratis.VS.StratisEVM.csproj +++ b/src/Stratis.VS.StratisEVM/Stratis.VS.StratisEVM.csproj @@ -47,7 +47,11 @@ 4 + + + Form + @@ -91,6 +95,8 @@ + + @@ -103,6 +109,9 @@ 17.9.380 + + 17.5.33428.366 + 17.1.11-preview-0002 @@ -165,17 +174,14 @@ These are the parts of the custom project system which will be deployed as part of the final implementation, and provide the basic processing for handling rules in CPS. --> - - - \ No newline at end of file diff --git a/src/Stratis.VS.StratisEVM/source.extension.vsixmanifest b/src/Stratis.VS.StratisEVM/source.extension.vsixmanifest index 76a1f8e..423510c 100644 --- a/src/Stratis.VS.StratisEVM/source.extension.vsixmanifest +++ b/src/Stratis.VS.StratisEVM/source.extension.vsixmanifest @@ -30,5 +30,6 @@ +