Skip to content

Commit 0844966

Browse files
committed
added ProjectCount to solution view
1 parent 44bb067 commit 0844966

3 files changed

Lines changed: 19 additions & 3 deletions

File tree

Solutionizer/ViewModels/SolutionFolder.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ public class SolutionFolder : SolutionItem {
1010
new SortedObservableCollection<SolutionItem>(new SolutionItemComparer());
1111

1212
public SolutionFolder(SolutionFolder parent) : base(parent) {
13+
_items.CollectionChanged += (sender, args) => NotifyOfPropertyChange(() => ProjectCount);
1314
}
1415

1516
public ObservableCollection<SolutionItem> Items {
@@ -20,6 +21,10 @@ public bool ContainsProject(Project project) {
2021
return _items.OfType<SolutionProject>().Any(p => p.Guid == project.Guid);
2122
}
2223

24+
public int ProjectCount {
25+
get { return _items.OfType<SolutionProject>().Count() + _items.OfType<SolutionFolder>().Select(_ => _.ProjectCount).Sum(); }
26+
}
27+
2328
public SolutionFolder GetOrCreateSubfolder(string folderName) {
2429
var folder = _items.OfType<SolutionFolder>().SingleOrDefault(p => p.Name == folderName);
2530
if (folder == null) {

Solutionizer/ViewModels/SolutionViewModel.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ public SolutionViewModel(ISettings settings, string rootPath, IDictionary<string
3636
if (args.PropertyName == "ShowLaunchElevatedButton") {
3737
NotifyOfPropertyChange(() => ShowLaunchElevatedButton);
3838
}
39+
if (args.PropertyName == "ShowProjectCount") {
40+
NotifyOfPropertyChange(() => ShowProjectCount);
41+
}
3942
};
4043
}
4144

@@ -131,6 +134,11 @@ public bool IsSccBound {
131134
}
132135
}
133136

137+
public bool ShowProjectCount {
138+
get { return _settings.ShowProjectCount; }
139+
}
140+
141+
134142
public void AddProject(Project project) {
135143
IsSccBound |= project.IsSccBound;
136144

Solutionizer/Views/SolutionView.xaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
1010
xmlns:cal="http://www.caliburnproject.org" mc:Ignorable="d"
1111
xmlns:Infrastructure="clr-namespace:Solutionizer.Infrastructure"
12-
xmlns:ViewModels="clr-namespace:Solutionizer.ViewModels"
12+
xmlns:ViewModels="clr-namespace:Solutionizer.ViewModels" xmlns:Views="clr-namespace:Solutionizer.Views"
1313
d:DataContext="{d:DesignInstance Type=ViewModels:SolutionViewModel}"
1414
d:DesignHeight="300" d:DesignWidth="300">
1515
<Grid>
1616
<Grid.Resources>
17-
<BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
17+
<BooleanToVisibilityConverter x:Key="BooleanToVisibility"/>
1818

1919
<Converters:FilePathToImageSourceConverter x:Key="FilePathToImageSource"/>
2020
<DataTemplate x:Key="NameWithImage" DataType="{x:Type Models:Project}">
@@ -28,6 +28,9 @@
2828
<StackPanel Orientation="Horizontal" Margin="1">
2929
<Image Height="16" Width="16" x:Name="nodeImg" Source="{Converters:Shell32Icon FileName='shell32.dll',IconIndex=3}" Margin="0 0 4 0" />
3030
<TextBlock Text="{Binding Name}" />
31+
<TextBlock Foreground="{DynamicResource AccentColorBrush}"
32+
Visibility="{Binding Path=DataContext.ShowProjectCount, RelativeSource={RelativeSource AncestorType=Views:SolutionView}, Converter={StaticResource BooleanToVisibility}}"
33+
Text="{Binding Path=ProjectCount, StringFormat=' ({0})'}"/>
3134
</StackPanel>
3235
<HierarchicalDataTemplate.Triggers>
3336
<DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=TreeViewItem}, Path=IsExpanded}" Value="True">
@@ -79,7 +82,7 @@
7982

8083
<StackPanel Grid.Column="1" Grid.Row="1" Margin="10 0 4 0">
8184
<Button x:Name="Launch" Content="Launch" Margin="0 0 0 4" MinWidth="80"/>
82-
<Button x:Name="LaunchElevated" Margin="0 0 0 4" MinWidth="80" Visibility="{Binding ShowLaunchElevatedButton, Converter={StaticResource BooleanToVisibilityConverter}}">
85+
<Button x:Name="LaunchElevated" Margin="0 0 0 4" MinWidth="80" Visibility="{Binding ShowLaunchElevatedButton, Converter={StaticResource BooleanToVisibility}}">
8386
<Grid HorizontalAlignment="Stretch">
8487
<Grid.ColumnDefinitions>
8588
<ColumnDefinition Width="auto"/>

0 commit comments

Comments
 (0)