Skip to content

Commit b68c89e

Browse files
committed
Merge branch 'nameLength' of https://github.com/Hosch250/Rubberduck into nameLength
2 parents 8fd983c + a6d034f commit b68c89e

24 files changed

+608
-142
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
<img src="http://i.stack.imgur.com/jnBEp.jpg" width=100% />
22

3+
<!-- campaign is no longer accepting donations
34
### Donate!
45
56
If you like this project and would like to thank its contributors, you are welcome to support our GoFundMe campaign to finance Rubberduck swag and international shipping - contributors will be getting t-shirts, mugs, and other cool things.
67
78
[![GoFundMe campaign](https://user-images.githubusercontent.com/5751684/29191799-e3d20b72-7dec-11e7-8ec6-0c69da4a3135.png)](https://www.gofundme.com/rubberduckvba)
9+
-->
810

911
Branch | Description | Build Status |
1012
|------------|---|--------------|

RetailCoder.VBE/Navigation/CodeExplorer/CodeExplorerItemViewModel.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,17 @@ public bool IsExpanded
190190

191191
public bool IsSelected { get; set; }
192192

193+
private bool _isVisisble = true;
194+
public bool IsVisible
195+
{
196+
get { return _isVisisble; }
197+
set
198+
{
199+
_isVisisble = value;
200+
OnPropertyChanged();
201+
}
202+
}
203+
193204
public abstract string Name { get; }
194205
public abstract string NameWithSignature { get; }
195206
public abstract BitmapImage CollapsedIcon { get; }

RetailCoder.VBE/Navigation/CodeExplorer/CodeExplorerViewModel.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,23 @@ public Visibility EmptyUIRefreshMessageVisibility
577577
}
578578
}
579579

580+
public void FilterByName(IEnumerable<CodeExplorerItemViewModel> nodes, string searchString)
581+
{
582+
foreach (var item in nodes)
583+
{
584+
if (item == null) { continue; }
585+
586+
if (item.Items.Any())
587+
{
588+
FilterByName(item.Items, searchString);
589+
}
590+
591+
item.IsVisible = item.Items.Any(c => c.IsVisible) ||
592+
item.Name.ToLowerInvariant().Contains(searchString.ToLowerInvariant()) ||
593+
string.IsNullOrEmpty(searchString);
594+
}
595+
}
596+
580597
public void Dispose()
581598
{
582599
if (_state != null)
586 Bytes
Loading

RetailCoder.VBE/Root/RubberduckModule.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,8 @@ private IEnumerable<IMenuItem> GetFormDesignerContextMenuItems()
613613
{
614614
return new IMenuItem[]
615615
{
616-
KernelInstance.Get<FormDesignerRefactorRenameCommandMenuItem>()
616+
KernelInstance.Get<FormDesignerRefactorRenameCommandMenuItem>(),
617+
KernelInstance.Get<FormDesignerFindAllReferencesCommandMenuItem>()
617618
};
618619
}
619620

RetailCoder.VBE/Rubberduck.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,8 @@
405405
<Compile Include="UI\CodeExplorer\Commands\CommitCommand.cs" />
406406
<Compile Include="UI\CodeExplorer\Commands\AddUserFormCommand.cs" />
407407
<Compile Include="UI\CodeExplorer\Commands\CopyResultsCommand.cs" />
408+
<Compile Include="UI\CodeExplorer\Converters\StringHasNoValueToVisibilityConverter.cs" />
409+
<Compile Include="UI\CodeExplorer\Converters\StringHasValueToVisibilityConverter.cs" />
408410
<Compile Include="UI\Command\ExportAllCommand.cs" />
409411
<Compile Include="UI\CodeExplorer\Commands\OpenProjectPropertiesCommand.cs" />
410412
<Compile Include="UI\CodeExplorer\Commands\RenameCommand.cs" />
@@ -421,8 +423,10 @@
421423
<Compile Include="UI\CodeExplorer\Commands\AddStdModuleCommand.cs" />
422424
<Compile Include="UI\CodeExplorer\Commands\AddTestModuleCommand.cs" />
423425
<Compile Include="UI\CodeExplorer\Commands\AddComponentCommand.cs" />
426+
<Compile Include="UI\Command\FormDesignerFindAllReferencesCommand.cs" />
424427
<Compile Include="UI\Command\IndentCurrentProjectCommand.cs" />
425428
<Compile Include="UI\Command\MenuItems\CommandBars\ContextDescriptionLabelMenuItem.cs" />
429+
<Compile Include="UI\Command\MenuItems\FormDesignerFindAllReferencesCommandMenuItem.cs" />
426430
<Compile Include="UI\Command\MenuItems\IndentCurrentProjectCommandMenuItem.cs" />
427431
<Compile Include="UI\Command\MenuItems\ExportAllCommandMenuItem.cs" />
428432
<Compile Include="UI\Controls\EmptyUIRefresh.xaml.cs">
@@ -1289,6 +1293,7 @@
12891293
<Resource Include="Resources\folder-open.png" />
12901294
<Resource Include="Resources\folder.png" />
12911295
<None Include="Resources\RD-300x250-base.png" />
1296+
<Resource Include="Resources\magnifier-medium.png" />
12921297
<Content Include="Resources\Rubberduck\RD-AboutWindow.png" />
12931298
<Content Include="Resources\Rubberduck\RD-InstallBanner.bmp" />
12941299
<Content Include="Resources\Rubberduck\RD-InstallWindow.bmp" />

RetailCoder.VBE/UI/CodeExplorer/CodeExplorerControl.xaml

Lines changed: 68 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
xmlns:controls="clr-namespace:Rubberduck.UI.Controls"
99
xmlns:themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero"
1010
xmlns:converters="clr-namespace:Rubberduck.UI.Converters"
11+
xmlns:codeExplorerConverters="clr-namespace:Rubberduck.UI.CodeExplorer.Converters"
1112
ResxExtension.DefaultResxName="Rubberduck.UI.RubberduckUI"
1213
Language="{UICulture}"
1314
Name="CodeExplorer"
@@ -28,9 +29,12 @@
2829
<BitmapImage x:Key="AddStdModuleImage" UriSource="../../Resources/Custom/PNG/AddModule.png" />
2930
<BitmapImage x:Key="AddClassModuleImage" UriSource="../../Resources/Custom/PNG/AddClass.png" />
3031
<BitmapImage x:Key="AddUserFormImage" UriSource="../../Resources/Custom/PNG/AddForm.png" />
32+
<BitmapImage x:Key="SearchImage" UriSource="../../Resources/magnifier-medium.png" />
3133

3234
<BooleanToVisibilityConverter x:Key="BoolToVisibility"/>
3335
<converters:BoolToHiddenVisibilityConverter x:Key="BoolToHiddenVisibility" />
36+
<codeExplorerConverters:StringHasValueToVisibilityConverter x:Key="StringHasValueToVisibility" />
37+
<codeExplorerConverters:StringHasNoValueToVisibilityConverter x:Key="StringHasNoValueToVisibility" />
3438

3539
<LinearGradientBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" EndPoint="0,1" StartPoint="0,0">
3640
<GradientStop Color="#FFD9F4FF" Offset="0"/>
@@ -48,6 +52,7 @@
4852
<Setter Property="BorderThickness" Value="1.5"/>
4953
<Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}"/>
5054
<Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />
55+
<Setter Property="Visibility" Value="{Binding IsVisible, Mode=OneWay, Converter={StaticResource BoolToVisibility}}" />
5156
<Setter Property="HorizontalAlignment" Value="Left" />
5257
<EventSetter Event="MouseDoubleClick" Handler="TreeView_OnMouseDoubleClick" />
5358
<EventSetter Event="MouseRightButtonDown" Handler="TreeView_OnMouseRightButtonDown" />
@@ -284,12 +289,66 @@
284289
</Setter>
285290
</Style>
286291

292+
<Style x:Key="XButtonStyle" TargetType="Button">
293+
<Setter Property="Background" Value="Transparent"/>
294+
<Setter Property="BorderThickness" Value="0"/>
295+
<Setter Property="HorizontalContentAlignment" Value="Center"/>
296+
<Setter Property="VerticalContentAlignment" Value="Center"/>
297+
<Setter Property="Template">
298+
<Setter.Value>
299+
<ControlTemplate TargetType="Button">
300+
<Grid>
301+
<VisualStateManager.VisualStateGroups>
302+
<VisualStateGroup x:Name="CommonStates">
303+
<VisualState x:Name="Normal"/>
304+
<VisualState x:Name="MouseOver">
305+
<Storyboard>
306+
<ColorAnimation Duration="0" Storyboard.TargetName="Background" Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)" To="PaleGoldenrod"/>
307+
<DoubleAnimation Duration="0" Storyboard.TargetName="BackgroundAnimation" Storyboard.TargetProperty="Opacity" To="1"/>
308+
</Storyboard>
309+
</VisualState>
310+
<VisualState x:Name="Pressed">
311+
<Storyboard>
312+
<ColorAnimation Duration="0" Storyboard.TargetName="Background" Storyboard.TargetProperty="(Border.Background).(SolidColorBrush.Color)" To="PaleGoldenrod"/>
313+
<DoubleAnimation Duration="0" Storyboard.TargetName="BackgroundAnimation" Storyboard.TargetProperty="Opacity" To="1"/>
314+
</Storyboard>
315+
</VisualState>
316+
</VisualStateGroup>
317+
<VisualStateGroup x:Name="FocusStates">
318+
<VisualState x:Name="Focused">
319+
<Storyboard>
320+
<DoubleAnimation Duration="0" Storyboard.TargetName="FocusVisualElement" Storyboard.TargetProperty="Opacity" To="1"/>
321+
</Storyboard>
322+
</VisualState>
323+
<VisualState x:Name="Unfocused" />
324+
</VisualStateGroup>
325+
</VisualStateManager.VisualStateGroups>
326+
<Border x:Name="Background" CornerRadius="3" Background="White" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}">
327+
<Grid Background="{TemplateBinding Background}" Margin="1">
328+
<Border Opacity="0" x:Name="BackgroundAnimation" Background="PaleGoldenrod" />
329+
</Grid>
330+
</Border>
331+
<ContentPresenter
332+
x:Name="contentPresenter"
333+
Content="{TemplateBinding Content}"
334+
ContentTemplate="{TemplateBinding ContentTemplate}"
335+
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
336+
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
337+
Margin="{TemplateBinding Padding}"/>
338+
<Rectangle x:Name="DisabledVisualElement" RadiusX="3" RadiusY="3" Fill="#FFFFFFFF" Opacity="0" IsHitTestVisible="false" />
339+
<Rectangle x:Name="FocusVisualElement" RadiusX="2" RadiusY="2" Margin="1" Stroke="PaleGoldenrod" StrokeThickness="1" Opacity="0" IsHitTestVisible="false" />
340+
</Grid>
341+
</ControlTemplate>
342+
</Setter.Value>
343+
</Setter>
344+
</Style>
287345
</ResourceDictionary>
288346
</UserControl.Resources>
289347

290348
<Grid UseLayoutRounding="True">
291349
<Grid.RowDefinitions>
292350
<RowDefinition Height="30"/>
351+
<RowDefinition Height="20"/>
293352
<RowDefinition Height="*" MinHeight="64" />
294353
<RowDefinition Height="5"/>
295354
<RowDefinition Height="Auto" MinHeight="48"/>
@@ -431,10 +490,14 @@
431490
</ToolBar>
432491
</ToolBarTray>
433492

434-
<controls:EmptyUIRefresh Grid.Row="1" />
493+
<TextBox Grid.Row="1" TextChanged="SearchBox_OnTextChanged" VerticalContentAlignment="Center" Name="SearchBox"></TextBox>
494+
<Image Grid.Row="1" Source="{StaticResource SearchImage}" HorizontalAlignment="Right" VerticalAlignment="Center" MaxHeight="16" Margin="0,0,1,0" MouseDown="SearchIcon_OnMouseDown" Visibility="{Binding ElementName=SearchBox, Path=Text.Length, Converter={StaticResource StringHasValueToVisibility}}" />
495+
<Button Grid.Row="1" Style="{StaticResource XButtonStyle}" HorizontalAlignment="Right" VerticalAlignment="Center" Height="18" Width="18" Margin="0,1,1,0" Visibility="{Binding ElementName=SearchBox, Path=Text.Length, Converter={StaticResource StringHasNoValueToVisibility}}" Click="ButtonBase_OnClick">✕</Button>
496+
497+
<controls:EmptyUIRefresh Grid.Row="2" />
435498

436499
<TreeView x:Name="ProjectTree"
437-
Grid.Row="1"
500+
Grid.Row="2"
438501
Background="White"
439502
ItemContainerStyle="{StaticResource ShinyTreeView}"
440503
HorizontalContentAlignment="Stretch"
@@ -446,11 +509,11 @@
446509
</i:Interaction.Behaviors>
447510
</TreeView>
448511

449-
<controls:BusyIndicator Grid.Row="1" Width="120" Height="120" Visibility="{Binding IsBusy, Converter={StaticResource BoolToVisibility}}" />
512+
<controls:BusyIndicator Grid.Row="2" Width="120" Height="120" Visibility="{Binding IsBusy, Converter={StaticResource BoolToVisibility}}" />
450513

451-
<GridSplitter Grid.Row="2" Height="5" ShowsPreview="True" Cursor="SizeNS" HorizontalAlignment="Stretch"/>
514+
<GridSplitter Grid.Row="3" Height="5" ShowsPreview="True" Cursor="SizeNS" HorizontalAlignment="Stretch"/>
452515

453-
<Border Grid.Row="3" BorderThickness="0,1,0,0" BorderBrush="DimGray">
516+
<Border Grid.Row="4" BorderThickness="0,1,0,0" BorderBrush="DimGray">
454517

455518
<ScrollViewer Background="WhiteSmoke" VerticalScrollBarVisibility="Auto">
456519
<WrapPanel Orientation="Vertical" MinHeight="70" Background="WhiteSmoke">

RetailCoder.VBE/UI/CodeExplorer/CodeExplorerControl.xaml.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Windows.Controls;
1+
using System.Windows;
2+
using System.Windows.Controls;
23
using System.Windows.Input;
34
using Rubberduck.Navigation.CodeExplorer;
45

@@ -30,5 +31,21 @@ private void TreeView_OnMouseRightButtonDown(object sender, MouseButtonEventArgs
3031
((TreeViewItem)sender).IsSelected = true;
3132
e.Handled = true;
3233
}
34+
35+
private void SearchBox_OnTextChanged(object sender, TextChangedEventArgs e)
36+
{
37+
ViewModel.FilterByName(ViewModel.Projects, ((TextBox)sender).Text);
38+
}
39+
40+
private void SearchIcon_OnMouseDown(object sender, MouseButtonEventArgs e)
41+
{
42+
SearchBox.Focus();
43+
}
44+
45+
private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
46+
{
47+
SearchBox.Text = string.Empty;
48+
SearchBox.Focus();
49+
}
3350
}
3451
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using System;
2+
using System.Globalization;
3+
using System.Windows;
4+
using System.Windows.Data;
5+
6+
namespace Rubberduck.UI.CodeExplorer.Converters
7+
{
8+
public class StringHasNoValueToVisibilityConverter : IValueConverter
9+
{
10+
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
11+
{
12+
return (int)value == 0 ? Visibility.Collapsed : Visibility.Visible;
13+
}
14+
15+
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
16+
{
17+
throw new NotImplementedException();
18+
}
19+
}
20+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using System;
2+
using System.Globalization;
3+
using System.Windows;
4+
using System.Windows.Data;
5+
6+
namespace Rubberduck.UI.CodeExplorer.Converters
7+
{
8+
public class StringHasValueToVisibilityConverter : IValueConverter
9+
{
10+
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
11+
{
12+
return (int)value > 0 ? Visibility.Collapsed : Visibility.Visible;
13+
}
14+
15+
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
16+
{
17+
throw new NotImplementedException();
18+
}
19+
}
20+
}

0 commit comments

Comments
 (0)