Skip to content

Commit

Permalink
Add support for editing solution file
Browse files Browse the repository at this point in the history
  • Loading branch information
heku committed Feb 23, 2019
1 parent 39642c3 commit 6f3710f
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 2 deletions.
40 changes: 40 additions & 0 deletions Kool.EditProject/Commands/EditSolutionCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using System.IO;

namespace Kool.EditProject.Commands
{
internal sealed class EditSolutionCommand : BaseCommand
{
public static EditSolutionCommand Instance { get; private set; }

public static void Initialize(EditProjectPackage package)
{
Instance = new EditSolutionCommand(package);
package.CommandService.AddCommand(Instance);
}

private string _solutionFile;

private EditSolutionCommand(EditProjectPackage package)
: base(package, Ids.CMD_SET, Ids.EDIT_SOLUTION_MENU_COMMAND_ID)
{
}

protected override void OnBeforeQueryStatus()
{
_solutionFile = Package.DTE.Solution.FullName;
Text = string.Format(VSPackage.EditMenuPattern, Path.GetFileName(_solutionFile));
}

protected override void OnExecute()
{
if (IsEditing(_solutionFile))
{
ActiveDocument(_solutionFile);
}
else
{
OpenDocument(_solutionFile);
}
}
}
}
1 change: 1 addition & 0 deletions Kool.EditProject/EditProjectPackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ protected override async Tasks.Task InitializeAsync(CancellationToken cancellati

EditProjectCommand.Initialize(this);
EditProjectsCommand.Initialize(this);
EditSolutionCommand.Initialize(this);
}
}

Expand Down
12 changes: 11 additions & 1 deletion Kool.EditProject/EditProjectPackage.en.vsct
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<CommandFlag>IconAndText</CommandFlag>
<CommandFlag>IconIsMoniker</CommandFlag>
<Strings>
<ButtonText>Edit...</ButtonText>
<ButtonText>Edit (Project...)</ButtonText>
</Strings>
</Button>
<Button guid="guidCmdSet" id="EDIT_PROJECTS_CMD_ID" priority="0x0100" type="Button">
Expand All @@ -28,6 +28,16 @@
<ButtonText>Edit Selected Projects</ButtonText>
</Strings>
</Button>
<Button guid="guidCmdSet" id="EDIT_SOLUTION_CMD_ID" priority="0x0100" type="Button">
<Parent guid="guidCmdSet" id="EDIT_SOLUTION_GROUP_ID" />
<Icon guid="ImageCatalogGuid" id="Open" />
<CommandFlag>TextChanges</CommandFlag>
<CommandFlag>IconAndText</CommandFlag>
<CommandFlag>IconIsMoniker</CommandFlag>
<Strings>
<ButtonText>Edit (Solution...)</ButtonText>
</Strings>
</Button>
</Buttons>
</Commands>
</CommandTable>
6 changes: 6 additions & 0 deletions Kool.EditProject/EditProjectPackage.vsct
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
<Group guid="guidCmdSet" id="EDIT_PROJECTS_GROUP_ID" priority="0x017F">
<Parent guid="guidSHLMainMenu" id="IDM_VS_CTXT_XPROJ_MULTIPROJ" />
</Group>
<Group guid="guidCmdSet" id="EDIT_SOLUTION_GROUP_ID" priority="0x017F">
<Parent guid="guidSHLMainMenu" id="IDM_VS_CTXT_SOLNNODE" />
</Group>
</Groups>
</Commands>

Expand All @@ -26,8 +29,11 @@
<GuidSymbol name="guidCmdSet" value="{6c7e3ed8-7da3-456d-802f-e11c4f8f8438}">
<IDSymbol name="EDIT_PROJECT_CMD_ID" value="0x0100" />
<IDSymbol name="EDIT_PROJECTS_CMD_ID" value="0x0110" />
<IDSymbol name="EDIT_SOLUTION_CMD_ID" value="0x0120" />

<IDSymbol name="EDIT_PROJECT_GROUP_ID" value="0x1000" />
<IDSymbol name="EDIT_PROJECTS_GROUP_ID" value="0x1100" />
<IDSymbol name="EDIT_SOLUTION_GROUP_ID" value="0x1200" />
</GuidSymbol>
</Symbols>
</CommandTable>
12 changes: 11 additions & 1 deletion Kool.EditProject/EditProjectPackage.zh-Hans.vsct
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<CommandFlag>IconAndText</CommandFlag>
<CommandFlag>IconIsMoniker</CommandFlag>
<Strings>
<ButtonText>编辑...</ButtonText>
<ButtonText>编辑 (项目...)</ButtonText>
</Strings>
</Button>
<Button guid="guidCmdSet" id="EDIT_PROJECTS_CMD_ID" priority="0x0100" type="Button">
Expand All @@ -28,6 +28,16 @@
<ButtonText>编辑项目文件</ButtonText>
</Strings>
</Button>
<Button guid="guidCmdSet" id="EDIT_SOLUTION_CMD_ID" priority="0x0100" type="Button">
<Parent guid="guidCmdSet" id="EDIT_SOLUTION_GROUP_ID" />
<Icon guid="ImageCatalogGuid" id="Open" />
<CommandFlag>TextChanges</CommandFlag>
<CommandFlag>IconAndText</CommandFlag>
<CommandFlag>IconIsMoniker</CommandFlag>
<Strings>
<ButtonText>编辑 (解决方案...)</ButtonText>
</Strings>
</Button>
</Buttons>
</Commands>
</CommandTable>
1 change: 1 addition & 0 deletions Kool.EditProject/Ids.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ internal static class Ids

public const int EDIT_PROJECT_MENU_COMMAND_ID = 0x0100;
public const int EDIT_PROJECTS_MENU_COMMAND_ID = 0x0110;
public const int EDIT_SOLUTION_MENU_COMMAND_ID = 0x0120;
}
}
1 change: 1 addition & 0 deletions Kool.EditProject/Kool.EditProject.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
<Compile Include="Commands\BaseCommand.cs" />
<Compile Include="Commands\EditProjectCommand.cs" />
<Compile Include="Commands\EditProjectsCommand.cs" />
<Compile Include="Commands\EditSolutionCommand.cs" />
<Compile Include="EditProjectPackage.cs" />
<Compile Include="Ids.cs" />
<Compile Include="Models\ProjectHelper.cs" />
Expand Down

0 comments on commit 6f3710f

Please sign in to comment.