Skip to content

Commit

Permalink
Merge pull request #22 from sboulema/ImageMoniker
Browse files Browse the repository at this point in the history
Image moniker
  • Loading branch information
sboulema authored Mar 23, 2017
2 parents 8c3e05a + 05c7e7c commit 127e204
Show file tree
Hide file tree
Showing 77 changed files with 131 additions and 1,611 deletions.
20 changes: 0 additions & 20 deletions CodeNav.Tests/MapperTests/TestEmptyClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,25 +35,5 @@ public void ShouldBeVisible()
// Since it does not have members, it should not show the expander symbol
Assert.AreEqual(Visibility.Collapsed, innerClass.HasMembersVisibility);
}

[Test]
public void ShouldHaveCorrectDefaultAccess()
{
var document = SyntaxMapper.MapDocument(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..\\..\\Files\\TestEmptyClass.cs"));

Assert.IsTrue(document.Any());

// First item should be a namespace
Assert.AreEqual(CodeItemKindEnum.Namespace, document.First().Kind);

// Namespace item should have members
Assert.IsTrue((document.First() as IMembers).Members.Any());

// Inner item should be a class
var innerClass = (document.First() as IMembers).Members.First() as CodeClassItem;

Assert.AreEqual(CodeItemAccessEnum.Unknown, innerClass.Access);
Assert.IsFalse(innerClass.IconPath.Contains("Friend"));
}
}
}
1 change: 0 additions & 1 deletion CodeNav.Tests/MapperTests/TestInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ public void TestInterfaceShouldBeOk()
// First item should be an interface
var innerInterface = (document.First() as IMembers).Members.First() as CodeInterfaceItem;
Assert.AreEqual(3, innerInterface.Members.Count);
Assert.IsTrue(innerInterface.IconPath.Contains("Interface"));

// Second item should be the implementing class
var implementingClass = (document.First() as IMembers).Members[1] as CodeClassItem;
Expand Down
234 changes: 9 additions & 225 deletions CodeNav/CodeNav.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,19 @@
<HintPath>..\packages\Microsoft.VisualStudio.Editor.14.3.25407\lib\net45\Microsoft.VisualStudio.Editor.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.ImageCatalog, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.VisualStudio.ImageCatalog.14.3.25407\lib\net45\Microsoft.VisualStudio.ImageCatalog.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.Imaging, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.VisualStudio.Imaging.14.3.25407\lib\net45\Microsoft.VisualStudio.Imaging.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.Imaging.Interop.14.0.DesignTime, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<EmbedInteropTypes>True</EmbedInteropTypes>
<HintPath>..\packages\Microsoft.VisualStudio.Imaging.Interop.14.0.DesignTime.14.3.25407\lib\Microsoft.VisualStudio.Imaging.Interop.14.0.DesignTime.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.VisualStudio.LanguageServices, Version=1.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.VisualStudio.LanguageServices.1.2.2\lib\net46\Microsoft.VisualStudio.LanguageServices.dll</HintPath>
</Reference>
Expand Down Expand Up @@ -382,241 +391,16 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Icons\Class\ClassFriend_16x.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Icons\Class\ClassPrivate_16x.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Icons\Class\ClassProtect_16x.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Icons\Class\ClassSealed_16x.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Icons\Class\Class_16x.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Icons\Constant\ConstantFriend_16x.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Icons\Constant\ConstantPrivate_16x.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Icons\Constant\ConstantProtect_16x.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Icons\Constant\Constant_16x.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Icons\Delegate\DelegateFriend_16x.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Icons\Delegate\DelegatePrivate_16x.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Icons\Delegate\DelegateProtect_16x.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Icons\Delegate\Delegate_16x.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Icons\Enum\EnumSealed_16x.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Icons\Enum\Enum_16x.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Icons\Enum\EnumItemFriend_16x.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Icons\Enum\EnumItemPrivate_16x.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Icons\Enum\EnumItemProtect_16x.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Icons\Enum\EnumItem_16x.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Icons\Enum\EnumPrivate_16x.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Icons\Enum\EnumProtect_16x.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Icons\Event\EventFriend_16x.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Icons\Event\EventPrivate_16x.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Icons\Event\EventProtect_16x.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Icons\Event\Event_16x.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Icons\Field\FieldFriend_16x.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Icons\Field\FieldPrivate_16x.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Icons\Field\FieldProtect_16x.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Icons\Field\Field_16x.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Icons\UI\DeleteFilter_16x.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Icons\UI\Filter_16x.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Icons\Interface\InterfaceFriend_16x.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Icons\Interface\InterfacePrivate_16x.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Icons\Interface\InterfaceProtect_16x.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Icons\Interface\Interface_16x.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Icons\Method\MethodAdded_16x.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Icons\Method\MethodSealed_16x.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Icons\Property\PropertyFriend_16x.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Icons\Property\PropertyPrivate_16x.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Icons\Property\PropertyProtect_16x.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Icons\Property\PropertySealed_16x.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Icons\Property\Property_16x.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Icons\UI\DocumentOutline_16x.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Icons\UI\Refresh_16x.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Icons\UI\Settings_16x.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Icons\Sort\SortAscending_16x.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Icons\Sort\SortingGrouping_16x.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Icons\Structure\StructureFriend_16x.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Icons\Structure\StructurePrivate_16x.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Icons\Structure\StructureProtect_16x.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Icons\Structure\Structure_16x.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Styles\PlusMinusExpanderStyles.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Resource Include="Icons\ExpanderHeader\Collapse_16xSM.png" />
<Resource Include="Icons\ExpanderHeader\Expand_16xSM.png" />
<Resource Include="Icons\Method\MethodFriend_16x.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Resource>
<Resource Include="Icons\Method\MethodPrivate_16x.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Resource>
<Resource Include="Icons\Method\MethodProtect_16x.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Resource>
<Resource Include="Icons\Method\Method_16x.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Resource>
</ItemGroup>
<ItemGroup>
<Resource Include="Icons\UI\CollapseGroup_16x.png" />
<Resource Include="Icons\UI\ExpandAll_16x.png" />
<Content Include="Resources\Preview-small.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<IncludeInVSIX>true</IncludeInVSIX>
</Content>
<Content Include="Resources\DocumentOutline_16x.png" />
<Content Include="Resources\DocumentOutline_256x.ico" />
<Content Include="Resources\DocumentOutline_256x.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
Expand Down
11 changes: 6 additions & 5 deletions CodeNav/CodeViewUserControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
using CodeNav.Mappers;
using CodeNav.Models;
using EnvDTE;
using Microsoft.VisualStudio.Imaging;
using Microsoft.VisualStudio.Imaging.Interop;
using Microsoft.VisualStudio.LanguageServices;
using Microsoft.VisualStudio.PlatformUI;
using Microsoft.VisualStudio.Text.Editor;
Expand Down Expand Up @@ -130,10 +132,10 @@ public void UpdateDocument(bool forceUpdate = false)

#region Custom Items

private static List<CodeItem> CreateLoadingItem() => CreateItem("Loading...", "Refresh");
private static List<CodeItem> CreateSelectDocumentItem() => CreateItem("Waiting for active code document...", "DocumentOutline");
private static List<CodeItem> CreateLoadingItem() => CreateItem("Loading...", KnownMonikers.Refresh);
private static List<CodeItem> CreateSelectDocumentItem() => CreateItem("Waiting for active code document...", KnownMonikers.DocumentOutline);

private static List<CodeItem> CreateItem(string name, string icon)
private static List<CodeItem> CreateItem(string name, ImageMoniker moniker)
{
return new List<CodeItem>
{
Expand All @@ -149,11 +151,10 @@ private static List<CodeItem> CreateItem(string name, string icon)
Id = name,
Foreground = new SolidColorBrush(Colors.Black),
BorderBrush = new SolidColorBrush(Colors.DarkGray),
IconPath = $"pack://application:,,,/CodeNav;component/Icons/UI/{icon}_16x.xaml"
Moniker = moniker
}
}
}

};
}

Expand Down
5 changes: 3 additions & 2 deletions CodeNav/Controls/ClassDataTemplate.xaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:models="clr-namespace:CodeNav.Models"
xmlns:vsShell="clr-namespace:Microsoft.VisualStudio.PlatformUI;assembly=Microsoft.VisualStudio.Shell.14.0">
xmlns:vsShell="clr-namespace:Microsoft.VisualStudio.PlatformUI;assembly=Microsoft.VisualStudio.Shell.14.0"
xmlns:imaging="clr-namespace:Microsoft.VisualStudio.Imaging;assembly=Microsoft.VisualStudio.Imaging">

<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="../Styles/PlusMinusExpanderStyles.xaml" />
Expand All @@ -15,7 +16,7 @@
x:Name="Expander">
<Expander.Header>
<StackPanel Orientation="Horizontal">
<Frame Source="{Binding IconPath}" Margin="0,0,3,0" DockPanel.Dock="Left" />
<imaging:CrispImage Width="16" Height="16" Moniker="{Binding Moniker}" Margin="0,0,3,0" DockPanel.Dock="Left" />
<TextBlock>
<Run Text="{Binding Name}"
FontFamily="{Binding FontFamily}"
Expand Down
6 changes: 4 additions & 2 deletions CodeNav/Controls/FilterToolbar.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:vsShell="clr-namespace:Microsoft.VisualStudio.PlatformUI;assembly=Microsoft.VisualStudio.Shell.14.0"
xmlns:catalog="clr-namespace:Microsoft.VisualStudio.Imaging;assembly=Microsoft.VisualStudio.ImageCatalog"
xmlns:imaging="clr-namespace:Microsoft.VisualStudio.Imaging;assembly=Microsoft.VisualStudio.Imaging"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<Grid>
Expand Down Expand Up @@ -40,15 +42,15 @@
<Button Click="ButtonClear_OnClick" ToolTip="Click to clear text filter contents">
<Button.Template>
<ControlTemplate>
<Frame Source="../Icons/UI/DeleteFilter_16x.xaml" />
<imaging:CrispImage Width="16" Height="16" Moniker="{x:Static catalog:KnownMonikers.DeleteFilter}" />
</ControlTemplate>
</Button.Template>
</Button>

<Button Click="ButtonFilter_OnClick" ToolTip="Click to filter by item kind">
<Button.Template>
<ControlTemplate>
<Frame Source="../Icons/UI/Filter_16x.xaml" />
<imaging:CrispImage Width="16" Height="16" Moniker="{x:Static catalog:KnownMonikers.Filter}" />
</ControlTemplate>
</Button.Template>
</Button>
Expand Down
8 changes: 6 additions & 2 deletions CodeNav/Controls/ItemDataTemplate.xaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:models="clr-namespace:CodeNav.Models">
xmlns:models="clr-namespace:CodeNav.Models"
xmlns:imaging="clr-namespace:Microsoft.VisualStudio.Imaging;assembly=Microsoft.VisualStudio.Imaging">

<DataTemplate DataType="{x:Type models:CodeItem}">
<Button Command="{Binding Path=ClickItemCommand}" CommandParameter="{Binding StartLine}"
Expand All @@ -17,7 +18,10 @@
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>

<Frame Source="{Binding IconPath}" Margin="0,0,3,0" />
<Grid Margin="0,0,3,0" Width="16" Height="16">
<imaging:CrispImage Moniker="{Binding Moniker}" />
<imaging:CrispImage Width="8" Height="8" Moniker="{Binding OverlayMoniker}" HorizontalAlignment="Right" VerticalAlignment="Bottom" />
</Grid>

<TextBlock Grid.Column="1" FontFamily="{Binding FontFamily}" FontStyle="{Binding FontStyle}">
<Run Text="{Binding Name}"
Expand Down
Loading

0 comments on commit 127e204

Please sign in to comment.