Skip to content

Commit 5a743db

Browse files
authored
Merge pull request #3372 from ghost/Refresh_UI_Refactor
Apply Refresh Message to Code Inspections window
2 parents b269ca6 + eebaf88 commit 5a743db

File tree

9 files changed

+108
-46
lines changed

9 files changed

+108
-46
lines changed

RetailCoder.VBE/Navigation/CodeExplorer/CodeExplorerViewModel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ public bool IsBusy
214214
_isBusy = value;
215215
OnPropertyChanged();
216216
// If the window is "busy" then hide the Refresh message
217-
OnPropertyChanged("EmptyTreeMessageVisibility");
217+
OnPropertyChanged("EmptyUIRefreshMessageVisibility");
218218
}
219219
}
220220

@@ -566,7 +566,7 @@ public Visibility TreeViewVisibility
566566
}
567567
}
568568

569-
public Visibility EmptyTreeMessageVisibility
569+
public Visibility EmptyUIRefreshMessageVisibility
570570
{
571571
get
572572
{

RetailCoder.VBE/Rubberduck.csproj

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,9 @@
419419
<Compile Include="UI\Command\MenuItems\CommandBars\ContextDescriptionLabelMenuItem.cs" />
420420
<Compile Include="UI\Command\MenuItems\IndentCurrentProjectCommandMenuItem.cs" />
421421
<Compile Include="UI\Command\MenuItems\ExportAllCommandMenuItem.cs" />
422+
<Compile Include="UI\Controls\EmptyUIRefresh.xaml.cs">
423+
<DependentUpon>EmptyUIRefresh.xaml</DependentUpon>
424+
</Compile>
422425
<Compile Include="UI\EnvironmentProvider.cs" />
423426
<Compile Include="UI\Inspections\AggregateInspectionResult.cs" />
424427
<Compile Include="UI\ModernFolderBrowser.cs" />
@@ -1379,6 +1382,10 @@
13791382
<Generator>MSBuild:Compile</Generator>
13801383
<SubType>Designer</SubType>
13811384
</Page>
1385+
<Page Include="UI\Controls\EmptyUIRefresh.xaml">
1386+
<SubType>Designer</SubType>
1387+
<Generator>MSBuild:Compile</Generator>
1388+
</Page>
13821389
<Page Include="UI\Inspections\InspectionResultsControl.xaml">
13831390
<SubType>Designer</SubType>
13841391
<Generator>MSBuild:Compile</Generator>

RetailCoder.VBE/UI/CodeExplorer/CodeExplorerControl.xaml

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -288,22 +288,6 @@
288288
<RowDefinition Height="Auto" MinHeight="48"/>
289289
</Grid.RowDefinitions>
290290

291-
<Border Grid.Row="0" Grid.RowSpan="3" Background="#FFEEF5FD">
292-
<TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" TextWrapping="WrapWithOverflow" TextAlignment="Center"
293-
Visibility="{Binding EmptyTreeMessageVisibility}" MinWidth="200">
294-
<Run FontWeight="Bold" Text="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=CodeExplorer_EmptyViewMessage_Title}"/><LineBreak/><Run/>
295-
<LineBreak/>
296-
<Button Command="{Binding RefreshCommand}" BorderThickness="0" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}">
297-
<Image Height="16" Source="../../Resources/arrow-circle-double.png" ClipToBounds="True" />
298-
<Button.ToolTip>
299-
<TextBlock Text="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=Refresh}" />
300-
</Button.ToolTip>
301-
</Button>
302-
<Hyperlink Command="{Binding RefreshCommand}"><Run Text="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=Refresh}"/></Hyperlink>
303-
<Run Text="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=CodeExplorer_EmptyViewMessage}"/>
304-
</TextBlock>
305-
</Border>
306-
307291
<ToolBarTray Grid.Row="0" IsLocked="True">
308292
<ToolBar Style="{DynamicResource ToolBarWithOverflowOnlyShowingWhenNeededStyle}">
309293

@@ -440,6 +424,8 @@
440424
</ToolBar>
441425
</ToolBarTray>
442426

427+
<controls:EmptyUIRefresh Grid.Row="1" />
428+
443429
<TreeView x:Name="ProjectTree"
444430
Grid.Row="1"
445431
Background="White"
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<UserControl x:Class="Rubberduck.UI.Controls.EmptyUIRefresh"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
mc:Ignorable="d"
7+
d:DesignHeight="300" d:DesignWidth="300">
8+
9+
<Border Background="AliceBlue" DataContext="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=DataContext}">
10+
<TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" TextWrapping="WrapWithOverflow" TextAlignment="Center"
11+
MinWidth="200" Visibility="{Binding EmptyUIRefreshMessageVisibility}">
12+
<Run FontWeight="Bold" Text="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=EmptyUIRefreshMessage_Title}"/><LineBreak/>
13+
<LineBreak/>
14+
<Button Command="{Binding RefreshCommand}" BorderThickness="0" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}">
15+
<Image Height="16" Source="../../Resources/arrow-circle-double.png" ClipToBounds="True" />
16+
<Button.ToolTip>
17+
<TextBlock Text="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=Refresh}" />
18+
</Button.ToolTip>
19+
</Button>
20+
<Hyperlink Command="{Binding RefreshCommand}"><Run Text="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=Refresh}"/></Hyperlink>
21+
<Run Text="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=EmptyUIRefreshMessage}"/>
22+
</TextBlock>
23+
</Border>
24+
25+
</UserControl>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using System.Windows;
7+
using System.Windows.Controls;
8+
using System.Windows.Data;
9+
using System.Windows.Documents;
10+
using System.Windows.Input;
11+
using System.Windows.Media;
12+
using System.Windows.Media.Imaging;
13+
using System.Windows.Navigation;
14+
using System.Windows.Shapes;
15+
16+
namespace Rubberduck.UI.Controls
17+
{
18+
/// <summary>
19+
/// Interaction logic for Refresh.xaml
20+
/// </summary>
21+
public partial class EmptyUIRefresh : UserControl
22+
{
23+
public EmptyUIRefresh()
24+
{
25+
InitializeComponent();
26+
}
27+
}
28+
}

RetailCoder.VBE/UI/Inspections/InspectionResultsControl.xaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@
5959
<RowDefinition Height="Auto" MinHeight="48"/>
6060
</Grid.RowDefinitions>
6161

62-
<Border Grid.Row="0" Grid.RowSpan="3" Background="White" />
63-
6462
<ToolBarTray Grid.Row="0" IsLocked="True">
6563
<ToolBar Style="{StaticResource ToolBarWithOverflowOnlyShowingWhenNeededStyle}">
6664

@@ -127,14 +125,15 @@
127125
</ToolBar>
128126
</ToolBarTray>
129127

130-
<controls:GroupingGrid Grid.Row="1"
128+
<controls:GroupingGrid x:Name="InspectionResultsGrid"
129+
Grid.Row="1"
131130
ShowGroupingItemCount="True"
132131
SelectedItem="{Binding SelectedItem}"
133132
ItemsSource="{Binding Source={StaticResource ResultsByInspectionType}, IsAsync=True}"
134133
Visibility="{Binding IsChecked, ElementName=GroupByInspectionType, Converter={StaticResource BoolToVisibility}}"
135134
VirtualizingPanel.IsVirtualizingWhenGrouping="True">
136135
<DataGrid.Columns>
137-
<DataGridTemplateColumn Header="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=CodeInspectionResults_Type}" SortDirection="Descending">
136+
<DataGridTemplateColumn Header="{Resx ResxName=Rubberduck.UI.RubberduckUI, Key=CodeInspectionResults_Type}" SortDirection="{Binding}">
138137
<DataGridTemplateColumn.CellTemplate>
139138
<DataTemplate DataType="abstract1:IInspectionResult">
140139
<Image Source="{Binding Inspection, Converter={StaticResource InspectionIconConverter}}" Height="16" />
@@ -165,6 +164,8 @@
165164
</DataGrid.Columns>
166165
</controls:GroupingGrid>
167166

167+
<controls:EmptyUIRefresh Grid.Row="1" Visibility="{Binding EmptyUIRefreshVisibility}"/>
168+
168169
<controls:BusyIndicator Grid.Row="1" Width="120" Height="120" Visibility="{Binding IsBusy, Converter={StaticResource BoolToVisibility}}" />
169170

170171
<GridSplitter Grid.Row="2" Height="5" ShowsPreview="True" Cursor="SizeNS" HorizontalAlignment="Stretch"/>

RetailCoder.VBE/UI/Inspections/InspectionResultsViewModel.cs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ public bool CanQuickFix
255255
}
256256

257257
private bool _isBusy;
258-
public bool IsBusy { get { return _isBusy; } set { _isBusy = value; OnPropertyChanged(); } }
258+
public bool IsBusy { get { return _isBusy; } set { _isBusy = value; OnPropertyChanged(); OnPropertyChanged("EmptyUIRefreshMessageVisibility"); } }
259259

260260
private bool _runInspectionsOnReparse;
261261
private void HandleStateChanged(object sender, EventArgs e)
@@ -305,9 +305,8 @@ private async void RefreshInspections()
305305

306306
UiDispatcher.Invoke(() =>
307307
{
308-
//Results = new ObservableCollection<IInspectionResult>(results);
309-
310308
IsBusy = false;
309+
OnPropertyChanged("EmptyUIRefreshVisibility");
311310
IsRefreshing = false;
312311
SelectedItem = null;
313312
});
@@ -478,6 +477,22 @@ private bool CanExecuteCopyResultsCommand(object parameter)
478477
return !IsBusy && _results != null && _results.Any();
479478
}
480479

480+
public Visibility EmptyUIRefreshVisibility
481+
{
482+
get
483+
{
484+
return _state.Projects.Count > 0 ? Visibility.Hidden : Visibility.Visible;
485+
}
486+
}
487+
488+
public Visibility EmptyUIRefreshMessageVisibility
489+
{
490+
get
491+
{
492+
return _isBusy ? Visibility.Hidden : Visibility.Visible;
493+
}
494+
}
495+
481496
public void Dispose()
482497
{
483498
if (_state != null)

RetailCoder.VBE/UI/RubberduckUI.Designer.cs

Lines changed: 19 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

RetailCoder.VBE/UI/RubberduckUI.resx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2092,12 +2092,12 @@ Would you like to import them to Rubberduck?</value>
20922092
<data name="CodeExplorer_AddModule" xml:space="preserve">
20932093
<value>Add Module</value>
20942094
</data>
2095-
<data name="CodeExplorer_EmptyViewMessage" xml:space="preserve">
2095+
<data name="EmptyUIRefreshMessage" xml:space="preserve">
20962096
<value>to parse and process
20972097
the projects in the VBE.</value>
20982098
<comment>Follows the text for "Refresh"</comment>
20992099
</data>
2100-
<data name="CodeExplorer_EmptyViewMessage_Title" xml:space="preserve">
2100+
<data name="EmptyUIRefreshMessage_Title" xml:space="preserve">
21012101
<value>Rubberduck doesn't see anything yet.</value>
21022102
</data>
21032103
</root>

0 commit comments

Comments
 (0)