Skip to content

Commit

Permalink
Fix filling in guid when adding a new component/command to an existin…
Browse files Browse the repository at this point in the history
…g project.

Also fix creating new GH commands so it doesn't always have the project name, but the new name you typed in.
  • Loading branch information
cwensley committed May 2, 2018
1 parent a334327 commit abc4487
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 14 deletions.
1 change: 1 addition & 0 deletions MonoDevelop.RhinoDebug.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
<Compile Include="Wizard\ProvideSampleControl.cs" />
<Compile Include="Helpers.cs" />
<Compile Include="RhinoGlobalProperties.cs" />
<Compile Include="RhinoFileTemplate.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Properties/AddinInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// the same stable release of Xamarin Studio.
[assembly:Addin(
"RhinoXamarinStudioAddIn",
Version = "7.4.3.0"
Version = "7.4.3.1"
)]

// This controls the displayed name in the Xamarin Studio Add-In Manager...
Expand Down
3 changes: 3 additions & 0 deletions Properties/Manifest.addin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,7 @@
<Image id="grasshopper-project" resource="MonoDevelop.RhinoDebug.Templates.Grasshopper.grasshopper-project.png" />
</Extension>

<Extension path = "/MonoDevelop/Ide/FileTemplateTypes">
<FileTemplateType name = "RhinoFile" class = "MonoDevelop.RhinoDebug.RhinoFileTemplate"/>
</Extension>
</ExtensionModel>
26 changes: 26 additions & 0 deletions RhinoFileTemplate.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using MonoDevelop.Ide.Templates;
using MonoDevelop.Projects;
using System.Text.RegularExpressions;

namespace MonoDevelop.RhinoDebug
{
public class RhinoFileTemplate : TextFileDescriptionTemplate
{
public override string CreateContent(Project project, Dictionary<string, string> tags, string language)
{
var content = base.CreateContent(project, tags, language);
var keys = new Dictionary<string, Guid>(StringComparer.OrdinalIgnoreCase);
return Regex.Replace(content, @"\$\{Guid\d+\}", match =>
{
if (!keys.TryGetValue(match.Value, out var key))
{
key = Guid.NewGuid();
keys.Add(match.Value, key);
}
return key.ToString();
});
}
}
}
10 changes: 5 additions & 5 deletions Templates/Grasshopper/EmptyComponent.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;

using Grasshopper;
Expand All @@ -7,7 +7,7 @@

namespace ${Namespace}
{
public class ${ProjectName}Component : GH_Component
public class ${EscapedIdentifier} : GH_Component
{
/// <summary>
/// Each implementation of GH_Component must provide a public
Expand All @@ -16,9 +16,9 @@ public class ${ProjectName}Component : GH_Component
/// Subcategory the panel. If you use non-existing tab or panel names,
/// new tabs/panels will automatically be created.
/// </summary>
public ${ProjectName}Component()
: base("${ProjectName}", "Nickname",
"${ProjectName} description",
public ${EscapedIdentifier}()
: base("${EscapedIdentifier}", "Nickname",
"${EscapedIdentifier} description",
"Category", "Subcategory")
{
}
Expand Down
2 changes: 1 addition & 1 deletion Templates/Grasshopper/EmptyComponent.xft.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
<DefaultFilename>MyComponent</DefaultFilename>
</TemplateConfiguration>
<TemplateFiles>
<File name="${Name}.cs" AddStandardHeader="true" src="EmptyComponent.cs" />
<RhinoFile name="${Name}.cs" AddStandardHeader="true" src="EmptyComponent.cs" />
</TemplateFiles>
</Template>
8 changes: 4 additions & 4 deletions Templates/Grasshopper/SimpleComponent.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;

using Grasshopper;
Expand All @@ -7,7 +7,7 @@

namespace ${Namespace}
{
public class ${ProjectName}Component : GH_Component
public class ${EscapedIdentifier} : GH_Component
{
/// <summary>
/// Each implementation of GH_Component must provide a public
Expand All @@ -16,8 +16,8 @@ public class ${ProjectName}Component : GH_Component
/// Subcategory the panel. If you use non-existing tab or panel names,
/// new tabs/panels will automatically be created.
/// </summary>
public ${ProjectName}Component()
: base("${ProjectName}", "ASpi",
public ${EscapedIdentifier}()
: base("${EscapedIdentifier}", "ASpi",
"Construct an Archimedean, or arithmetic, spiral given its radii and number of turns.",
"Curve", "Primitive")
{
Expand Down
2 changes: 1 addition & 1 deletion Templates/Rhino/EmptyCommand.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using Rhino;
using Rhino.Commands;
using Rhino.Geometry;
Expand Down
2 changes: 1 addition & 1 deletion Templates/Rhino/EmptyCommand.xft.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
<DefaultFilename>MyCommand</DefaultFilename>
</TemplateConfiguration>
<TemplateFiles>
<File name="${Name}.cs" AddStandardHeader="true" src="EmptyCommand.cs" />
<RhinoFile name="${Name}.cs" AddStandardHeader="true" src="EmptyCommand.cs" />
</TemplateFiles>
</Template>
2 changes: 1 addition & 1 deletion Templates/Rhino/SimpleCommand.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using Rhino;
using Rhino.Commands;
using Rhino.Geometry;
Expand Down

0 comments on commit abc4487

Please sign in to comment.